[cfe-commits] r72727 - in /cfe/trunk: lib/CodeGen/CGBuiltin.cpp test/CodeGen/builtin-unwind-init.c
Eli Friedman
eli.friedman at gmail.com
Tue Jun 2 02:37:59 PDT 2009
Author: efriedma
Date: Tue Jun 2 04:37:50 2009
New Revision: 72727
URL: http://llvm.org/viewvc/llvm-project?rev=72727&view=rev
Log:
Add support for __builtin_unwind_init.
Also, committing an #if 0'ed __builtin_setjmp and __builtin_longjmp
implementation I've had sitting in my tree for a while. I haven't
enabled it because the LLVM backend support isn't complete yet.
Added:
cfe/trunk/test/CodeGen/builtin-unwind-init.c
Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=72727&r1=72726&r2=72727&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Tue Jun 2 04:37:50 2009
@@ -320,6 +320,36 @@
// FIXME: There should be a target hook for this
return RValue::get(EmitScalarExpr(E->getArg(0)));
}
+ case Builtin::BI__builtin_unwind_init: {
+ Value *F = CGM.getIntrinsic(Intrinsic::eh_unwind_init, 0, 0);
+ return RValue::get(Builder.CreateCall(F));
+ }
+#if 0
+ // FIXME: Finish/enable when LLVM backend support stabilizes
+ case Builtin::BI__builtin_setjmp: {
+ Value *Buf = EmitScalarExpr(E->getArg(0));
+ // Store the frame pointer to the buffer
+ Value *FrameAddrF = CGM.getIntrinsic(Intrinsic::frameaddress, 0, 0);
+ Value *FrameAddr =
+ Builder.CreateCall(FrameAddrF,
+ Constant::getNullValue(llvm::Type::Int32Ty));
+ Builder.CreateStore(FrameAddr, Buf);
+ // Call the setjmp intrinsic
+ Value *F = CGM.getIntrinsic(Intrinsic::eh_sjlj_setjmp, 0, 0);
+ const llvm::Type *DestType =
+ llvm::PointerType::getUnqual(llvm::Type::Int8Ty);
+ Buf = Builder.CreateBitCast(Buf, DestType);
+ return RValue::get(Builder.CreateCall(F, Buf));
+ }
+ case Builtin::BI__builtin_longjmp: {
+ Value *F = CGM.getIntrinsic(Intrinsic::eh_sjlj_longjmp, 0, 0);
+ Value *Buf = EmitScalarExpr(E->getArg(0));
+ const llvm::Type *DestType =
+ llvm::PointerType::getUnqual(llvm::Type::Int8Ty);
+ Buf = Builder.CreateBitCast(Buf, DestType);
+ return RValue::get(Builder.CreateCall(F, Buf));
+ }
+#endif
case Builtin::BI__sync_fetch_and_add:
case Builtin::BI__sync_fetch_and_sub:
case Builtin::BI__sync_fetch_and_or:
Added: cfe/trunk/test/CodeGen/builtin-unwind-init.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtin-unwind-init.c?rev=72727&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/builtin-unwind-init.c (added)
+++ cfe/trunk/test/CodeGen/builtin-unwind-init.c Tue Jun 2 04:37:50 2009
@@ -0,0 +1,4 @@
+// RUN: clang-cc -emit-llvm < %s -o - | grep -F "llvm.eh.unwind.init"
+
+int a() { __builtin_unwind_init(); }
+
More information about the cfe-commits
mailing list