Sure. Richard, what say you? On Tue, Jul 28, 2015 at 3:54 PM, Pieb, Wolfgang wrote: > Hi, would it be possible to put this fix into the 3.7 branch? > > Thanks > >> -----Original Message----- >> From: cfe-commits-bounces@cs.uiuc.edu [mailto:cfe-commits- >> bounces@cs.uiuc.edu] On Behalf Of David Majnemer >> Sent: Friday, July 24, 2015 10:57 PM >> To: cfe-commits@cs.uiuc.edu >> Subject: r243206 - [CodeGen] Don't UBSan-ize the argument to >> __builtin_frame_address >> >> Author: majnemer >> Date: Sat Jul 25 00:57:24 2015 >> New Revision: 243206 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=243206&view=rev >> Log: >> [CodeGen] Don't UBSan-ize the argument to __builtin_frame_address >> >> __builtin_frame_address requires its argument to be a constant >> expression which already implies that it cannot have undefined >> behavior. >> However, we used EmitScalarExpr to emit the argument causing UBSan to >> try to check for overflow. >> >> Instead, use the constant expression emission system. >> >> This fixes PR24256. >> >> Modified: >> cfe/trunk/lib/CodeGen/CGBuiltin.cpp >> cfe/trunk/test/CodeGen/integer-overflow.c >> >> Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp >> URL: http://llvm.org/viewvc/llvm- >> project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=243206&r1=243205&r2=243 >> 206&view=diff >> ======================================================================= >> ======= >> --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original) >> +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Sat Jul 25 00:57:24 2015 >> @@ -866,14 +866,14 @@ RValue CodeGenFunction::EmitBuiltinExpr( >> 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)); >> } >> >> Modified: cfe/trunk/test/CodeGen/integer-overflow.c >> URL: http://llvm.org/viewvc/llvm- >> project/cfe/trunk/test/CodeGen/integer- >> overflow.c?rev=243206&r1=243205&r2=243206&view=diff >> ======================================================================= >> ======= >> --- cfe/trunk/test/CodeGen/integer-overflow.c (original) >> +++ cfe/trunk/test/CodeGen/integer-overflow.c Sat Jul 25 00:57:24 2015 >> @@ -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) >> } >> >> >> _______________________________________________ >> cfe-commits mailing list >> cfe-commits@cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits _______________________________________________ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits