diff options
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/CodeGen/CGBuiltin.cpp | 8 | ||||
-rw-r--r-- | clang/test/CodeGen/integer-overflow.c | 7 |
2 files changed, 11 insertions, 4 deletions
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index 463b3eee3d3..9b8694f9c5f 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -866,14 +866,14 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD, llvm::ConstantInt::get(Int32Ty, Offset))); } case Builtin::BI__builtin_return_address: { - Value *Depth = EmitScalarExpr(E->getArg(0)); - Depth = Builder.CreateIntCast(Depth, Int32Ty, false); + Value *Depth = + CGM.EmitConstantExpr(E->getArg(0), getContext().UnsignedIntTy, this); Value *F = CGM.getIntrinsic(Intrinsic::returnaddress); return RValue::get(Builder.CreateCall(F, Depth)); } case Builtin::BI__builtin_frame_address: { - Value *Depth = EmitScalarExpr(E->getArg(0)); - Depth = Builder.CreateIntCast(Depth, Int32Ty, false); + Value *Depth = + CGM.EmitConstantExpr(E->getArg(0), getContext().UnsignedIntTy, this); Value *F = CGM.getIntrinsic(Intrinsic::frameaddress); return RValue::get(Builder.CreateCall(F, Depth)); } diff --git a/clang/test/CodeGen/integer-overflow.c b/clang/test/CodeGen/integer-overflow.c index de3b53f4b5b..6a7c3e51ee1 100644 --- a/clang/test/CodeGen/integer-overflow.c +++ b/clang/test/CodeGen/integer-overflow.c @@ -72,4 +72,11 @@ void test1() { // TRAPV: add i8 {{.*}}, 1 // CATCH_UB: add i8 {{.*}}, 1 ++PR9350; + + // PR24256: don't instrument __builtin_frame_address. + __builtin_frame_address(0 + 0); + // DEFAULT: call i8* @llvm.frameaddress(i32 0) + // WRAPV: call i8* @llvm.frameaddress(i32 0) + // TRAPV: call i8* @llvm.frameaddress(i32 0) + // CATCH_UB: call i8* @llvm.frameaddress(i32 0) } |