]> granicus.if.org Git - llvm/commitdiff
[MSP430] Fix crash while lowering llvm.stacksave/stackrestore
authorAnton Korobeynikov <anton@korobeynikov.info>
Wed, 9 Jan 2019 12:52:15 +0000 (12:52 +0000)
committerAnton Korobeynikov <anton@korobeynikov.info>
Wed, 9 Jan 2019 12:52:15 +0000 (12:52 +0000)
Perform the usual expansion of stacksave / restore intrinsics.
Patch by Kristina Bessonova!

Differential Revision: https://reviews.llvm.org/D54890

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@350710 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/MSP430/MSP430ISelLowering.cpp
test/CodeGen/MSP430/stacksave_restore.ll [new file with mode: 0644]

index 73c8793aa01c08d337e8b4e7219aecc5fac403a1..3df1f7b9a7830519df89f06bcc9edf023f75ff56 100644 (file)
@@ -95,6 +95,8 @@ MSP430TargetLowering::MSP430TargetLowering(const TargetMachine &TM,
   setOperationAction(ISD::SIGN_EXTEND,      MVT::i16,   Custom);
   setOperationAction(ISD::DYNAMIC_STACKALLOC, MVT::i8, Expand);
   setOperationAction(ISD::DYNAMIC_STACKALLOC, MVT::i16, Expand);
+  setOperationAction(ISD::STACKSAVE,        MVT::Other, Expand);
+  setOperationAction(ISD::STACKRESTORE,     MVT::Other, Expand);
 
   setOperationAction(ISD::CTTZ,             MVT::i8,    Expand);
   setOperationAction(ISD::CTTZ,             MVT::i16,   Expand);
diff --git a/test/CodeGen/MSP430/stacksave_restore.ll b/test/CodeGen/MSP430/stacksave_restore.ll
new file mode 100644 (file)
index 0000000..47c4553
--- /dev/null
@@ -0,0 +1,13 @@
+; RUN: llc < %s -march=msp430
+
+target triple = "msp430"
+
+define void @foo() {
+entry:
+  %0 = tail call i8* @llvm.stacksave()
+  tail call void @llvm.stackrestore(i8* %0)
+  ret void
+}
+
+declare i8* @llvm.stacksave()
+declare void @llvm.stackrestore(i8*)