diff options
author | John McCall <rjmccall@apple.com> | 2010-03-03 05:38:58 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2010-03-03 05:38:58 +0000 |
commit | 7ada111fd5e81aff355e67bad0e4083f552b34bd (patch) | |
tree | 7ed610abf932ad5563162101b228db95a945a8d2 /lib/CodeGen/CGBuiltin.cpp | |
parent | ce57dd5f9ff5bd6cebe3c94ae48eaf166ea50a23 (diff) |
Implement __builtin_eh_return.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97643 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGBuiltin.cpp')
-rw-r--r-- | lib/CodeGen/CGBuiltin.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/CodeGen/CGBuiltin.cpp b/lib/CodeGen/CGBuiltin.cpp index 7dd9f6eb07..faea4fe9d4 100644 --- a/lib/CodeGen/CGBuiltin.cpp +++ b/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)); |