aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGBuiltin.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2010-03-03 10:30:05 +0000
committerJohn McCall <rjmccall@apple.com>2010-03-03 10:30:05 +0000
commitfb17a562135dd7597121da9245d0c1bdcda4146f (patch)
treed128ef262b6f0f93a7a70b0e29f428a00d3db4c6 /lib/CodeGen/CGBuiltin.cpp
parent3bed527b10502c6a5916ebb6e6abc49687ce1444 (diff)
Sketch out an implementation for __builtin_dwarf_cfa. I have no idea
why the front-end is calculating the argument to llvm.eh.dwarf.cfa(). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97653 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGBuiltin.cpp')
-rw-r--r--lib/CodeGen/CGBuiltin.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/CodeGen/CGBuiltin.cpp b/lib/CodeGen/CGBuiltin.cpp
index faea4fe9d4..0f5e90fb15 100644
--- a/lib/CodeGen/CGBuiltin.cpp
+++ b/lib/CodeGen/CGBuiltin.cpp
@@ -59,6 +59,10 @@ static RValue EmitBinaryAtomicPost(CodeGenFunction& CGF,
return RValue::get(CGF.Builder.CreateBinOp(Op, Result, Operand));
}
+static llvm::ConstantInt *getInt32(llvm::LLVMContext &Context, int32_t Value) {
+ return llvm::ConstantInt::get(llvm::Type::getInt32Ty(Context), Value);
+}
+
RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
unsigned BuiltinID, const CallExpr *E) {
// See if we can constant fold this builtin. If so, don't emit it at all.
@@ -343,6 +347,20 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
llvm::ConstantInt::get(llvm::Type::getInt32Ty(VMContext), 1));
return RValue::get(Address);
}
+ case Builtin::BI__builtin_dwarf_cfa: {
+ // The offset in bytes from the first argument to the CFA.
+ //
+ // Why on earth is this in the frontend? Is there any reason at
+ // all that the backend can't reasonably determine this while
+ // lowering llvm.eh.dwarf.cfa()?
+ //
+ // TODO: If there's a satisfactory reason, add a target hook for
+ // this instead of hard-coding 0, which is correct for most targets.
+ int32_t Offset = 0;
+
+ Value *F = CGM.getIntrinsic(Intrinsic::eh_dwarf_cfa, 0, 0);
+ return RValue::get(Builder.CreateCall(F, getInt32(VMContext, Offset)));
+ }
case Builtin::BI__builtin_return_address: {
Value *Depth = EmitScalarExpr(E->getArg(0));
Depth = Builder.CreateIntCast(Depth,