From df7dd28dc81e23a3bac655cec89dc4ab543375b7 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Sun, 5 Jan 2014 01:47:20 +0000 Subject: 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 --- .../CodeGen/Generic/builtin-returnaddress-error.ll | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 llvm/test/CodeGen/Generic/builtin-returnaddress-error.ll (limited to 'llvm/test') diff --git a/llvm/test/CodeGen/Generic/builtin-returnaddress-error.ll b/llvm/test/CodeGen/Generic/builtin-returnaddress-error.ll new file mode 100644 index 00000000000..d3bd1571523 --- /dev/null +++ b/llvm/test/CodeGen/Generic/builtin-returnaddress-error.ll @@ -0,0 +1,27 @@ +; RUN: not llc < %s -O0 2> %t1 +; RUN: FileCheck %s < %t1 + +; CHECK: argument to '__builtin_return_address' must be a constant integer + +define i32* @foo() { +entry: + %t1 = call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 0, i32 0) + %t2 = extractvalue { i32, i1 } %t1, 0 + %t3 = extractvalue { i32, i1 } %t1, 1 + br i1 %t3, label %cont, label %trap + +trap: + call void @llvm.trap() + unreachable + +cont: + %t5 = call i8* @llvm.returnaddress(i32 %t2) + %t6 = bitcast i8* %t5 to i32* + ret i32* %t6 +} + +declare { i32, i1 } @llvm.sadd.with.overflow.i32(i32, i32) + +declare void @llvm.trap() + +declare i8* @llvm.returnaddress(i32) -- cgit v1.2.3