[PATCH] Linker: Replace overridden subprograms

Rafael EspĂ­ndola rafael.espindola at gmail.com
Tue Dec 16 07:23:40 PST 2014


On 16 December 2014 at 01:20, Duncan P. N. Exon Smith
<dexonsmith at apple.com> wrote:
> When a function gets replaced by `ModuleLinker`, ensure that the "first"
> subprogram pointing to it is updated to be the *same* subprogram pointed
> to by the `!dbg` references in that function.  That means it should come
> from the "first" subprogram in a linked-in compile unit.
>
> This is a stop-gap "fix" for PR21910.  Ideally we wouldn't have two
> different subprograms around, but it's not easy to fix that.  In the
> meantime, this fixes bootstraps that hit assertions in
> `LexicalScopes::initialize()` due to the explicit instantiations in
> `lib/IR/Dominators.cpp` eventually getting replaced by -argpromotion.

The final objective is to delete the subprogram that was in the
destination, correct? If I understand correctly, that is what regular
linkers do. They will keep the dwarf corresponding to the symbol they
kept.

Can't you do just that? Before doing the rest of ModuleLinker::linkNamedMDNodes:

* Record in a set the source functions that replaced some destination function.
* Get llvm.dbg.cu of the destination module.
* For each CU, get the list of subprograms.
* Remove from the list any subprogram that points to one of the
functions in the set.

Also, should drop subprograms from the source that point to functions
that were not copied over? Once module owns metadata we should not
even copy those.

With both of those done, the existing linkNamedMDNodes should finish
up the work correctly, no?

Is there a corresponding problem for global variables?

Cheers,
Rafael



More information about the llvm-commits mailing list