<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Oct 16, 2014 at 6:20 PM, Duncan P. N. Exon Smith <span dir="ltr"><<a href="mailto:dexonsmith@apple.com" target="_blank">dexonsmith@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
> On Oct 16, 2014, at 6:08 PM, Eric Christopher <<a href="mailto:echristo@gmail.com">echristo@gmail.com</a>> wrote:<br>
><br>
> On Thu, Oct 16, 2014 at 6:06 PM, Duncan P. N. Exon Smith<br>
> <<a href="mailto:dexonsmith@apple.com">dexonsmith@apple.com</a>> wrote:<br>
>><br>
>>> On Oct 16, 2014, at 3:54 PM, Frederic Riss <<a href="mailto:friss@apple.com">friss@apple.com</a>> wrote:<br>
>>><br>
>>> If you look at the added testcase, it cast a void (*func)() to a int (*func)(). The int typed result is referenced in a debug info metadata node (an argument to the dbg.value intrinsic). Then instcombine would remove the bitcast and turn the int returning function into a void returning function that gets RAUWd over the value in the MDNode. And at this point in the current code you have invalid IR.<br>
>>><br>
>>> The code in the testcase is reduced from a huge LTO link that encountered this situation in a much more complicated setup.<br>
>>><br>
>>> <a href="http://reviews.llvm.org/D5828" target="_blank">http://reviews.llvm.org/D5828</a><br>
>><br>
>> Weird.  This LGTM (after fixing a few super minor whitespace changes);<br>
>> not sure if Eric is still looking.<br>
><br>
> Enh, I was trying to figure out if there was some way to avoid the<br>
> void metadata node being create rather than avoiding RAUW'ing it. It's<br>
> probably not a huge distinction at the moment.<br>
<br>
</span>I don't think it is a void metadata node; it's a void `CallInst`.<br>
<br>
We have:<br>
<br>
    call void @llvm.dbg.declare(metadata !{i32* %deadvar}, ...)<br>
    %call = ...<br>
<span class="">    store i32 %call, i32* %deadvar, align 4, !dbg !21<br>
<br>
</span>Which converts to:<br>
<br>
    call void @llvm.dbg.value(metadata !{i32* %call}, ...)<br>
    %call = ...<br>
<br>
Then, when %call gets RAUW'ed, `metadata !{i32* %call}` gets updated<br>
to `void`.<br></blockquote><div><br></div><div>My only thought is that this code has UB, right? I don't know whether we should do something else with it, which might involve killing the dbg.value metadata along with all the other instructions that are fruit of the UB tree. (the whole basic block, anything else reachable from it, etc).<br></div><div> </div></div><br></div></div>