From 9222ed4485a59903606aa995bbfe157dae6ca69b Mon Sep 17 00:00:00 2001 From: Anton Korobeynikov Date: Wed, 9 Jan 2019 12:52:15 +0000 Subject: [PATCH] [MSP430] Fix crash while lowering llvm.stacksave/stackrestore Perform the usual expansion of stacksave / restore intrinsics. Patch by Kristina Bessonova! Differential Revision: https://reviews.llvm.org/D54890 llvm-svn: 350710 --- llvm/lib/Target/MSP430/MSP430ISelLowering.cpp | 2 ++ llvm/test/CodeGen/MSP430/stacksave_restore.ll | 13 +++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 llvm/test/CodeGen/MSP430/stacksave_restore.ll diff --git a/llvm/lib/Target/MSP430/MSP430ISelLowering.cpp b/llvm/lib/Target/MSP430/MSP430ISelLowering.cpp index 73c8793aa01c..3df1f7b9a783 100644 --- a/llvm/lib/Target/MSP430/MSP430ISelLowering.cpp +++ b/llvm/lib/Target/MSP430/MSP430ISelLowering.cpp @@ -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/llvm/test/CodeGen/MSP430/stacksave_restore.ll b/llvm/test/CodeGen/MSP430/stacksave_restore.ll new file mode 100644 index 000000000000..47c4553929d4 --- /dev/null +++ b/llvm/test/CodeGen/MSP430/stacksave_restore.ll @@ -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*)