<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Dec 16, 2014 at 7:23 AM, Rafael Espíndola <span dir="ltr"><<a href="mailto:rafael.espindola@gmail.com" target="_blank">rafael.espindola@gmail.com</a>></span> wrote:<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">On 16 December 2014 at 01:20, Duncan P. N. Exon Smith<br>
<div><div class="h5"><<a href="mailto:dexonsmith@apple.com">dexonsmith@apple.com</a>> wrote:<br>
> When a function gets replaced by `ModuleLinker`, ensure that the "first"<br>
> subprogram pointing to it is updated to be the *same* subprogram pointed<br>
> to by the `!dbg` references in that function.  That means it should come<br>
> from the "first" subprogram in a linked-in compile unit.<br>
><br>
> This is a stop-gap "fix" for PR21910.  Ideally we wouldn't have two<br>
> different subprograms around, but it's not easy to fix that.  In the<br>
> meantime, this fixes bootstraps that hit assertions in<br>
> `LexicalScopes::initialize()` due to the explicit instantiations in<br>
> `lib/IR/Dominators.cpp` eventually getting replaced by -argpromotion.<br>
<br>
</div></div>The final objective is to delete the subprogram that was in the<br>
destination, correct? If I understand correctly, that is what regular</blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
linkers do. They will keep the dwarf corresponding to the symbol they<br>
kept.<br></blockquote><div><br>It's possible to put DWARF subprogram definitions for linkonce_odr functions into comdat groups so they are dropped along with the linkonce_odr function, but Clang (& I don't think GCC by default) does that (there's some overhead to that representational choice, etc). But yes, it can be done. I think today, for both GCC and Clang, you'd end up with two subprogram definitions (one in each DWARF compile unit) each pointing to the same high_pc/low_pc to describe the function.<br><br>(but yeah, vaguely sounds like what you're suggesting would make sense - I haven't looked at the initial proposed patch yet, though)<br> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Can't you do just that? Before doing the rest of ModuleLinker::linkNamedMDNodes:<br>
<br>
* Record in a set the source functions that replaced some destination function.<br>
* Get <a href="http://llvm.dbg.cu" target="_blank">llvm.dbg.cu</a> of the destination module.<br>
* For each CU, get the list of subprograms.<br>
* Remove from the list any subprogram that points to one of the<br>
functions in the set.<br>
<br>
Also, should drop subprograms from the source that point to functions<br>
that were not copied over? Once module owns metadata we should not<br>
even copy those.<br>
<br>
With both of those done, the existing linkNamedMDNodes should finish<br>
up the work correctly, no?<br>
<br>
Is there a corresponding problem for global variables?<br>
<br>
Cheers,<br>
Rafael<br>
</blockquote></div></div></div>