diff options
author | Anton Korobeynikov <asl@math.spbu.ru> | 2009-12-27 14:27:22 +0000 |
---|---|---|
committer | Anton Korobeynikov <asl@math.spbu.ru> | 2009-12-27 14:27:22 +0000 |
commit | 83c2a98012a65b51be66fd76c3a1b13ed782c558 (patch) | |
tree | 1059fbf4fac977e3ee6e9fca6e5c18c5ed3a4849 /lib | |
parent | 8f5d7404da36f689b0005fc0fb5bba398c3919a9 (diff) |
Promote arguments of frameaddr / returnaddr builtins to i32 type, when needed.
This is needed for the platforms, where bitwidth of "int" is not 32 bits
(e.g. 16 on msp430).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92176 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/CodeGen/CGBuiltin.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/CodeGen/CGBuiltin.cpp b/lib/CodeGen/CGBuiltin.cpp index a2328e4a49..866c58780b 100644 --- a/lib/CodeGen/CGBuiltin.cpp +++ b/lib/CodeGen/CGBuiltin.cpp @@ -340,12 +340,20 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD, return RValue::get(Address); } case Builtin::BI__builtin_return_address: { + Value *Depth = EmitScalarExpr(E->getArg(0)); + Depth = Builder.CreateIntCast(Depth, + llvm::Type::getInt32Ty(VMContext), + false, "tmp"); Value *F = CGM.getIntrinsic(Intrinsic::returnaddress, 0, 0); - return RValue::get(Builder.CreateCall(F, EmitScalarExpr(E->getArg(0)))); + return RValue::get(Builder.CreateCall(F, Depth)); } case Builtin::BI__builtin_frame_address: { + Value *Depth = EmitScalarExpr(E->getArg(0)); + Depth = Builder.CreateIntCast(Depth, + llvm::Type::getInt32Ty(VMContext), + false, "tmp"); Value *F = CGM.getIntrinsic(Intrinsic::frameaddress, 0, 0); - return RValue::get(Builder.CreateCall(F, EmitScalarExpr(E->getArg(0)))); + return RValue::get(Builder.CreateCall(F, Depth)); } case Builtin::BI__builtin_extract_return_addr: { // FIXME: There should be a target hook for this |