diff options
author | Bill Wendling <isanbard@gmail.com> | 2014-01-05 01:47:20 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2014-01-05 01:47:20 +0000 |
commit | df7dd28dc81e23a3bac655cec89dc4ab543375b7 (patch) | |
tree | dbe9dd627c73cf6eb458de43f13f969239b91fc0 /llvm/lib/Target/MSP430/MSP430ISelLowering.cpp | |
parent | 5999d475386ee68df51e50bf888bbd62d5b3b90b (diff) | |
download | bcm5719-llvm-df7dd28dc81e23a3bac655cec89dc4ab543375b7.tar.gz bcm5719-llvm-df7dd28dc81e23a3bac655cec89dc4ab543375b7.zip |
Emit an error message if the value passed to __builtin_returnaddress isn't a constant
__builtin_returnaddress requires that the value passed into is be a constant.
However, at -O0 even a constant expression may not be converted to a constant.
Emit an error message intead of crashing.
llvm-svn: 198531
Diffstat (limited to 'llvm/lib/Target/MSP430/MSP430ISelLowering.cpp')
-rw-r--r-- | llvm/lib/Target/MSP430/MSP430ISelLowering.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/Target/MSP430/MSP430ISelLowering.cpp b/llvm/lib/Target/MSP430/MSP430ISelLowering.cpp index 745cdf5bc79..a1a7c5e08ef 100644 --- a/llvm/lib/Target/MSP430/MSP430ISelLowering.cpp +++ b/llvm/lib/Target/MSP430/MSP430ISelLowering.cpp @@ -32,6 +32,7 @@ #include "llvm/IR/GlobalAlias.h" #include "llvm/IR/GlobalVariable.h" #include "llvm/IR/Intrinsics.h" +#include "llvm/IR/LLVMContext.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" #include "llvm/Support/ErrorHandling.h" @@ -1047,6 +1048,12 @@ SDValue MSP430TargetLowering::LowerRETURNADDR(SDValue Op, MachineFrameInfo *MFI = DAG.getMachineFunction().getFrameInfo(); MFI->setReturnAddressIsTaken(true); + if (!isa<ConstantSDNode>(Op.getOperand(0))) { + DAG.getContext()->emitError("argument to '__builtin_return_address' must " + "be a constant integer"); + return SDValue(); + } + unsigned Depth = cast<ConstantSDNode>(Op.getOperand(0))->getZExtValue(); SDLoc dl(Op); |