summaryrefslogtreecommitdiff
path: root/lib/Target/Mips
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2014-01-05 01:47:20 +0000
committerBill Wendling <isanbard@gmail.com>2014-01-05 01:47:20 +0000
commit4a816471f527b90464806892feeecc242491a459 (patch)
tree9ca957843b95ddfcd4da7de54fedaddbcbdaad75 /lib/Target/Mips
parente43a0f801506cbc2f5a4e5ac020d23d9038aff4d (diff)
downloadllvm-4a816471f527b90464806892feeecc242491a459.tar.gz
llvm-4a816471f527b90464806892feeecc242491a459.tar.bz2
llvm-4a816471f527b90464806892feeecc242491a459.tar.xz
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198531 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/Mips')
-rw-r--r--lib/Target/Mips/MipsISelLowering.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/Target/Mips/MipsISelLowering.cpp b/lib/Target/Mips/MipsISelLowering.cpp
index 9c74ae4ce2..220b1c4a35 100644
--- a/lib/Target/Mips/MipsISelLowering.cpp
+++ b/lib/Target/Mips/MipsISelLowering.cpp
@@ -31,6 +31,7 @@
#include "llvm/IR/CallingConv.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/GlobalVariable.h"
+#include "llvm/IR/LLVMContext.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
@@ -1844,6 +1845,12 @@ lowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const {
SDValue MipsTargetLowering::lowerRETURNADDR(SDValue Op,
SelectionDAG &DAG) const {
+ if (!isa<ConstantSDNode>(Op.getOperand(0))) {
+ DAG.getContext()->emitError("argument to '__builtin_return_address' must "
+ "be a constant integer");
+ return SDValue();
+ }
+
// check the depth
assert((cast<ConstantSDNode>(Op.getOperand(0))->getZExtValue() == 0) &&
"Return address can be determined only for current frame.");