r231245 - Adjust the changes from r230255 to bail out if the backend can't lower
Joerg Sonnenberger
joerg at bec.de
Wed Mar 4 06:25:35 PST 2015
Author: joerg
Date: Wed Mar 4 08:25:35 2015
New Revision: 231245
URL: http://llvm.org/viewvc/llvm-project?rev=231245&view=rev
Log:
Adjust the changes from r230255 to bail out if the backend can't lower
__builtin_setjmp/__builtin_longjmp and don't fall back to the libc
functions.
Modified:
cfe/trunk/include/clang/Basic/Builtins.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/CodeGen/TargetInfo.h
cfe/trunk/test/CodeGen/builtin-longjmp.c
Modified: cfe/trunk/include/clang/Basic/Builtins.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=231245&r1=231244&r2=231245&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Builtins.def (original)
+++ cfe/trunk/include/clang/Basic/Builtins.def Wed Mar 4 08:25:35 2015
@@ -448,8 +448,8 @@ BUILTIN(__builtin_extract_return_addr, "
BUILTIN(__builtin_frame_address, "v*IUi", "n")
BUILTIN(__builtin___clear_cache, "vc*c*", "n")
BUILTIN(__builtin_flt_rounds, "i", "nc")
-BUILTIN(__builtin_setjmp, "iv**", "Fj")
-BUILTIN(__builtin_longjmp, "vv**i", "Fr")
+BUILTIN(__builtin_setjmp, "iv**", "j")
+BUILTIN(__builtin_longjmp, "vv**i", "r")
BUILTIN(__builtin_unwind_init, "v", "")
BUILTIN(__builtin_eh_return_data_regno, "iIi", "nc")
BUILTIN(__builtin_snprintf, "ic*zcC*.", "nFp:2:")
Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=231245&r1=231244&r2=231245&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Wed Mar 4 08:25:35 2015
@@ -859,8 +859,11 @@ RValue CodeGenFunction::EmitBuiltinExpr(
return RValue::get(Builder.CreateZExt(Result, Int64Ty, "extend.zext"));
}
case Builtin::BI__builtin_setjmp: {
- if (!getTargetHooks().hasSjLjLowering(*this))
- break;
+ if (!getTargetHooks().hasSjLjLowering(*this)) {
+ CGM.ErrorUnsupported(E, "__builtin_setjmp");
+ return RValue::get(nullptr);
+ }
+
// Buffer is a void**.
Value *Buf = EmitScalarExpr(E->getArg(0));
@@ -883,8 +886,10 @@ RValue CodeGenFunction::EmitBuiltinExpr(
return RValue::get(Builder.CreateCall(F, Buf));
}
case Builtin::BI__builtin_longjmp: {
- if (!getTargetHooks().hasSjLjLowering(*this))
- break;
+ if (!getTargetHooks().hasSjLjLowering(*this)) {
+ CGM.ErrorUnsupported(E, "__builtin_longjmp");
+ return RValue::get(nullptr);
+ }
Value *Buf = EmitScalarExpr(E->getArg(0));
Buf = Builder.CreateBitCast(Buf, Int8PtrTy);
Modified: cfe/trunk/lib/CodeGen/TargetInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.h?rev=231245&r1=231244&r2=231245&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/TargetInfo.h (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.h Wed Mar 4 08:25:35 2015
@@ -226,9 +226,8 @@ public:
return 0;
}
- /// Control whether __builtin_longjmp / __builtin_setjmp are lowered to
- /// llvm.eh.sjlj.longjmp / llvm.eh.sjlj.setjmp or the normal library
- /// function.
+ /// Control if __builtin_longjmp / __builtin_setjmp can be lowered to
+ /// llvm.eh.sjlj.longjmp / llvm.eh.sjlj.setjmp.
virtual bool hasSjLjLowering(CodeGen::CodeGenFunction &CGF) const {
return false;
}
Modified: cfe/trunk/test/CodeGen/builtin-longjmp.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtin-longjmp.c?rev=231245&r1=231244&r2=231245&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/builtin-longjmp.c (original)
+++ cfe/trunk/test/CodeGen/builtin-longjmp.c Wed Mar 4 08:25:35 2015
@@ -1,11 +1,12 @@
-// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm < %s| FileCheck %s -check-prefix=SUPPORTED
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm < %s| FileCheck %s -check-prefix=SUPPORTED
-// RUN: %clang_cc1 -triple powerpc-unknown-unknown -emit-llvm < %s| FileCheck %s -check-prefix=SUPPORTED
-// RUN: %clang_cc1 -triple powerpc64-unknown-unknown -emit-llvm < %s| FileCheck %s -check-prefix=SUPPORTED
-// RUN: %clang_cc1 -triple arm-unknown-unknown -emit-llvm < %s| FileCheck %s -check-prefix=UNSUPPORTED
-// RUN: %clang_cc1 -triple aarch64-unknown-unknown -emit-llvm < %s| FileCheck %s -check-prefix=UNSUPPORTED
-// RUN: %clang_cc1 -triple mips-unknown-unknown -emit-llvm < %s| FileCheck %s -check-prefix=UNSUPPORTED
-// RUN: %clang_cc1 -triple mips64-unknown-unknown -emit-llvm < %s| FileCheck %s -check-prefix=UNSUPPORTED
+// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm < %s| FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm < %s| FileCheck %s
+// RUN: %clang_cc1 -triple powerpc-unknown-unknown -emit-llvm < %s| FileCheck %s
+// RUN: %clang_cc1 -triple powerpc64-unknown-unknown -emit-llvm < %s| FileCheck %s
+
+// RUN: %clang_cc1 -triple arm-unknown-unknown -emit-llvm -verify %s
+// RUN: %clang_cc1 -triple aarch64-unknown-unknown -emit-llvm -verify %s
+// RUN: %clang_cc1 -triple mips-unknown-unknown -emit-llvm -verify %s
+// RUN: %clang_cc1 -triple mips64-unknown-unknown -emit-llvm -verify %s
// Check that __builtin_longjmp and __builtin_setjmp are lowerd into
// IR intrinsics on those architectures that can handle them.
@@ -14,18 +15,14 @@
typedef void *jmp_buf;
jmp_buf buf;
-// SUPPORTED: define{{.*}} void @do_jump()
-// SUPPORTED: call{{.*}} void @llvm.eh.sjlj.longjmp
-// UNSUPPORTED: define{{.*}} void @do_jump()
-// UNSUPPORTED: call{{.*}} void @longjmp
-
-// SUPPORTED: define{{.*}} void @do_setjmp()
-// SUPPORTED: call{{.*}} i32 @llvm.eh.sjlj.setjmp
-// UNSUPPORTED: define{{.*}} void @do_setjmp()
-// UNSUPPORTED: call{{.*}} i32 @setjmp
+// CHECK: define{{.*}} void @do_jump()
+// CHECK: call{{.*}} void @llvm.eh.sjlj.longjmp
+
+// CHECK: define{{.*}} void @do_setjmp()
+// CHECK: call{{.*}} i32 @llvm.eh.sjlj.setjmp
void do_jump(void) {
- __builtin_longjmp(buf, 1);
+ __builtin_longjmp(buf, 1); // expected-error {{cannot compile this __builtin_longjmp yet}}
}
void f(void);
More information about the cfe-commits
mailing list