--===============3712239228529818314== Content-Type: multipart/alternative; boundary=089e0118377a5fad43051c0fbbb4 --089e0118377a5fad43051c0fbbb4 Content-Type: text/plain; charset=UTF-8 Aye. On Tue, Jul 28, 2015 at 5:57 PM, Hans Wennborg wrote: > 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 > --089e0118377a5fad43051c0fbbb4 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: Quoted-printable
Aye.

On Tue, Jul 28, 2015 at 5:57 PM, Hans Wennborg &l= t;hans@chromium.org<= /a>> wrote:
Sure. Richard, what= say you?

On Tue, Jul 28, 2015 at 3:54 PM, Pieb, Wolfgang
<
Wolfgang_Pieb@pla= ystation.sony.com> wrote:
> Hi, would it be possible to put this fix into the 3.7 branch?
>
> Thanks
>
>> -----Original Message-----
>> From: cfe-commi= ts-bounces@cs.uiuc.edu [mailto:cfe-comm= its-
>> 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=3D243206&view=3Drev
>> Log:
>> [CodeGen] Don't UBSan-ize the argument to __builtin_frame_addr= ess
>>
>> __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:
>>=C2=A0 =C2=A0 =C2=A0cfe/trunk/lib/CodeGen/CGBuiltin.cpp
>>=C2=A0 =C2=A0 =C2=A0cfe/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=3D243206&r1=3D= 243205&r2=3D243
>> 206&view=3Ddiff
>> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>> =3D=3D=3D=3D=3D=3D=3D
>> --- 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(
>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 l= lvm::ConstantInt::get(Int32Ty,
>> Offset)));
>>=C2=A0 =C2=A0 }
>>=C2=A0 =C2=A0 case Builtin::BI__builtin_return_address: {
>> -=C2=A0 =C2=A0 Value *Depth =3D EmitScalarExpr(E->getArg(0)); >> -=C2=A0 =C2=A0 Depth =3D Builder.CreateIntCast(Depth, Int32Ty, fal= se);
>> +=C2=A0 =C2=A0 Value *Depth =3D
>> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 CGM.EmitConstantExpr(E->getArg(0),= getContext().UnsignedIntTy,
>> + this);
>>=C2=A0 =C2=A0 =C2=A0 Value *F =3D CGM.getIntrinsic(Intrinsic::retur= naddress);
>>=C2=A0 =C2=A0 =C2=A0 return RValue::get(Builder.CreateCall(F, Depth= ));
>>=C2=A0 =C2=A0 }
>>=C2=A0 =C2=A0 case Builtin::BI__builtin_frame_address: {
>> -=C2=A0 =C2=A0 Value *Depth =3D EmitScalarExpr(E->getArg(0)); >> -=C2=A0 =C2=A0 Depth =3D Builder.CreateIntCast(Depth, Int32Ty, fal= se);
>> +=C2=A0 =C2=A0 Value *Depth =3D
>> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 CGM.EmitConstantExpr(E->getArg(0),= getContext().UnsignedIntTy,
>> + this);
>>=C2=A0 =C2=A0 =C2=A0 Value *F =3D CGM.getIntrinsic(Intrinsic::frame= address);
>>=C2=A0 =C2=A0 =C2=A0 return RValue::get(Builder.CreateCall(F, Depth= ));
>>=C2=A0 =C2=A0 }
>>
>> Modified: cfe/trunk/test/CodeGen/integer-overflow.c
>> URL: http://llvm.org/viewvc/llvm-
>> project/cfe/trunk/test/CodeGen/integer-
>> overflow.c?rev=3D243206&r1=3D243205&r2=3D243206&view= =3Ddiff
>> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>> =3D=3D=3D=3D=3D=3D=3D
>> --- 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() {
>>=C2=A0 =C2=A0 // TRAPV: add i8 {{.*}}, 1
>>=C2=A0 =C2=A0 // CATCH_UB: add i8 {{.*}}, 1
>>=C2=A0 =C2=A0 ++PR9350;
>> +
>> +=C2=A0 // PR24256: don't instrument __builtin_frame_address.<= br> >> +=C2=A0 __builtin_frame_address(0 + 0);
>> +=C2=A0 // DEFAULT:=C2=A0 call i8* @llvm.frameaddress(i32 0)
>> +=C2=A0 // WRAPV:=C2=A0 =C2=A0 call i8* @llvm.frameaddress(i32 0)<= br> >> +=C2=A0 // TRAPV:=C2=A0 =C2=A0 call i8* @llvm.frameaddress(i32 0)<= br> >> +=C2=A0 // CATCH_UB: call i8* @llvm.frameaddress(i32 0)
>>=C2=A0 }
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits@cs.uiuc.edu=
>> http://lists.cs.uiuc.edu/mailman/listi= nfo/cfe-commits

--089e0118377a5fad43051c0fbbb4-- --===============3712239228529818314== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits --===============3712239228529818314==--