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 | 73d50b91413d2770f0ee767b86bae861229273ef (patch) | |
| tree | 12d501cbd9e16348a801a5b2c296423a817dbf19 /clang/lib/CodeGen/CGBuiltin.cpp | |
| parent | 1e26278b3b5198f37343fedc85fdb1f808d41624 (diff) | |
| download | bcm5719-llvm-73d50b91413d2770f0ee767b86bae861229273ef.tar.gz bcm5719-llvm-73d50b91413d2770f0ee767b86bae861229273ef.zip | |
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).
llvm-svn: 92176
Diffstat (limited to 'clang/lib/CodeGen/CGBuiltin.cpp')
| -rw-r--r-- | clang/lib/CodeGen/CGBuiltin.cpp | 12 | 
1 files changed, 10 insertions, 2 deletions
| diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index a2328e4a498..866c58780b9 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/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 | 

