<div dir="ltr">Aye.<br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jul 28, 2015 at 5:57 PM, Hans Wennborg <span dir="ltr"><<a href="mailto:hans@chromium.org" target="_blank">hans@chromium.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Sure. Richard, what say you?<br>
<div class="HOEnZb"><div class="h5"><br>
On Tue, Jul 28, 2015 at 3:54 PM, Pieb, Wolfgang<br>
<<a href="mailto:Wolfgang_Pieb@playstation.sony.com">Wolfgang_Pieb@playstation.sony.com</a>> wrote:<br>
> Hi, would it be possible to put this fix into the 3.7 branch?<br>
><br>
> Thanks<br>
><br>
>> -----Original Message-----<br>
>> From: <a href="mailto:cfe-commits-bounces@cs.uiuc.edu">cfe-commits-bounces@cs.uiuc.edu</a> [mailto:<a href="mailto:cfe-commits-">cfe-commits-</a><br>
>> <a href="mailto:bounces@cs.uiuc.edu">bounces@cs.uiuc.edu</a>] On Behalf Of David Majnemer<br>
>> Sent: Friday, July 24, 2015 10:57 PM<br>
>> To: <a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
>> Subject: r243206 - [CodeGen] Don't UBSan-ize the argument to<br>
>> __builtin_frame_address<br>
>><br>
>> Author: majnemer<br>
>> Date: Sat Jul 25 00:57:24 2015<br>
>> New Revision: 243206<br>
>><br>
>> URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D243206-26view-3Drev&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=BSqEv9KvKMW_Ob8SyngJ70KdZISM_ASROnREeq0cCxk&m=T3cS7qAdzRCR3x5NDzrVDkThGnXc3_quGPnwVKo29NA&s=3r0A6AZoojgR1NoIdocn8dwpiZidM2rSV1r0TWSolHk&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=243206&view=rev</a><br>
>> Log:<br>
>> [CodeGen] Don't UBSan-ize the argument to __builtin_frame_address<br>
>><br>
>> __builtin_frame_address requires its argument to be a constant<br>
>> expression which already implies that it cannot have undefined<br>
>> behavior.<br>
>> However, we used EmitScalarExpr to emit the argument causing UBSan to<br>
>> try to check for overflow.<br>
>><br>
>> Instead, use the constant expression emission system.<br>
>><br>
>> This fixes PR24256.<br>
>><br>
>> Modified:<br>
>>     cfe/trunk/lib/CodeGen/CGBuiltin.cpp<br>
>>     cfe/trunk/test/CodeGen/integer-overflow.c<br>
>><br>
>> Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp<br>
>> URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2D&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=BSqEv9KvKMW_Ob8SyngJ70KdZISM_ASROnREeq0cCxk&m=T3cS7qAdzRCR3x5NDzrVDkThGnXc3_quGPnwVKo29NA&s=kW3XTHF0UroSUExH3uYUYb13AdVvbzHcy3rw9GsgpWU&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-</a><br>
>> project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=243206&r1=243205&r2=243<br>
>> 206&view=diff<br>
>> =======================================================================<br>
>> =======<br>
>> --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)<br>
>> +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Sat Jul 25 00:57:24 2015<br>
>> @@ -866,14 +866,14 @@ RValue CodeGenFunction::EmitBuiltinExpr(<br>
>>                                        llvm::ConstantInt::get(Int32Ty,<br>
>> Offset)));<br>
>>    }<br>
>>    case Builtin::BI__builtin_return_address: {<br>
>> -    Value *Depth = EmitScalarExpr(E->getArg(0));<br>
>> -    Depth = Builder.CreateIntCast(Depth, Int32Ty, false);<br>
>> +    Value *Depth =<br>
>> +        CGM.EmitConstantExpr(E->getArg(0), getContext().UnsignedIntTy,<br>
>> + this);<br>
>>      Value *F = CGM.getIntrinsic(Intrinsic::returnaddress);<br>
>>      return RValue::get(Builder.CreateCall(F, Depth));<br>
>>    }<br>
>>    case Builtin::BI__builtin_frame_address: {<br>
>> -    Value *Depth = EmitScalarExpr(E->getArg(0));<br>
>> -    Depth = Builder.CreateIntCast(Depth, Int32Ty, false);<br>
>> +    Value *Depth =<br>
>> +        CGM.EmitConstantExpr(E->getArg(0), getContext().UnsignedIntTy,<br>
>> + this);<br>
>>      Value *F = CGM.getIntrinsic(Intrinsic::frameaddress);<br>
>>      return RValue::get(Builder.CreateCall(F, Depth));<br>
>>    }<br>
>><br>
>> Modified: cfe/trunk/test/CodeGen/integer-overflow.c<br>
>> URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2D&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=BSqEv9KvKMW_Ob8SyngJ70KdZISM_ASROnREeq0cCxk&m=T3cS7qAdzRCR3x5NDzrVDkThGnXc3_quGPnwVKo29NA&s=kW3XTHF0UroSUExH3uYUYb13AdVvbzHcy3rw9GsgpWU&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-</a><br>
>> project/cfe/trunk/test/CodeGen/integer-<br>
>> overflow.c?rev=243206&r1=243205&r2=243206&view=diff<br>
>> =======================================================================<br>
>> =======<br>
>> --- cfe/trunk/test/CodeGen/integer-overflow.c (original)<br>
>> +++ cfe/trunk/test/CodeGen/integer-overflow.c Sat Jul 25 00:57:24 2015<br>
>> @@ -72,4 +72,11 @@ void test1() {<br>
>>    // TRAPV: add i8 {{.*}}, 1<br>
>>    // CATCH_UB: add i8 {{.*}}, 1<br>
>>    ++PR9350;<br>
>> +<br>
>> +  // PR24256: don't instrument __builtin_frame_address.<br>
>> +  __builtin_frame_address(0 + 0);<br>
>> +  // DEFAULT:  call i8* @llvm.frameaddress(i32 0)<br>
>> +  // WRAPV:    call i8* @llvm.frameaddress(i32 0)<br>
>> +  // TRAPV:    call i8* @llvm.frameaddress(i32 0)<br>
>> +  // CATCH_UB: call i8* @llvm.frameaddress(i32 0)<br>
>>  }<br>
>><br>
>><br>
>> _______________________________________________<br>
>> cfe-commits mailing list<br>
>> <a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
>> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</div></div></blockquote></div><br></div></div>