summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGBuiltin.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2010-03-03 05:38:58 +0000
committerJohn McCall <rjmccall@apple.com>2010-03-03 05:38:58 +0000
commit66769f85445d5bcc99b5bd6d9fb9d9f0b343dacc (patch)
tree860cb1b150e36516d5b126287a902204a45b3eb8 /clang/lib/CodeGen/CGBuiltin.cpp
parent29707de4fe40d6d7f07c74042e2cf31328b19d61 (diff)
downloadbcm5719-llvm-66769f85445d5bcc99b5bd6d9fb9d9f0b343dacc.tar.gz
bcm5719-llvm-66769f85445d5bcc99b5bd6d9fb9d9f0b343dacc.zip
Implement __builtin_eh_return.
llvm-svn: 97643
Diffstat (limited to 'clang/lib/CodeGen/CGBuiltin.cpp')
-rw-r--r--clang/lib/CodeGen/CGBuiltin.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 7dd9f6eb077..faea4fe9d43 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -369,6 +369,22 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
Value *Result = getTargetHooks().encodeReturnAddress(*this, Address);
return RValue::get(Result);
}
+ case Builtin::BI__builtin_eh_return: {
+ Value *Int = EmitScalarExpr(E->getArg(0));
+ Value *Ptr = EmitScalarExpr(E->getArg(1));
+
+ const llvm::IntegerType *IntTy = cast<llvm::IntegerType>(Int->getType());
+ assert((IntTy->getBitWidth() == 32 || IntTy->getBitWidth() == 64) &&
+ "LLVM's __builtin_eh_return only supports 32- and 64-bit variants");
+ Value *F = CGM.getIntrinsic(IntTy->getBitWidth() == 32
+ ? Intrinsic::eh_return_i32
+ : Intrinsic::eh_return_i64,
+ 0, 0);
+ Builder.CreateCall2(F, Int, Ptr);
+ Value *V = Builder.CreateUnreachable();
+ Builder.ClearInsertionPoint();
+ return RValue::get(V);
+ }
case Builtin::BI__builtin_unwind_init: {
Value *F = CGM.getIntrinsic(Intrinsic::eh_unwind_init, 0, 0);
return RValue::get(Builder.CreateCall(F));
OpenPOWER on IntegriCloud