[llvm] r252320 - Restore "Move metadata linking after lazy global materialization/linking."

Teresa Johnson via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 13 19:15:33 PST 2015


Hi Peter,

Sorry about that. Thanks for the detailed root cause analysis!

I see the problem, which I didn't notice before due to the llvm-link
behavior you note that was causing null to eventually get into the
expected metadata fields. Looking at the code, I will need to fix this
by changing the handshaking between the ValueMapper and the
ModuleLinker. Working on it, but might not get a fix out tonight,
although it looks like you have a workaround.

Teresa

On Fri, Nov 13, 2015 at 5:34 PM, Peter Collingbourne <peter at pcc.me.uk> wrote:
> Hi Teresa,
>
> I tracked down an issue LTO-linking Chrome for Windows to this commit.
> You can reproduce by applying the attached diff to LLVM and running
> "llvm-link -o /dev/null fmtable.bc brkiter.bc" on the attached files.
>
> On Fri, Nov 06, 2015 at 05:50:53PM -0000, Teresa Johnson via llvm-commits wrote:
>> +  // If we are done linking global value bodies (i.e. we are performing
>> +  // metadata linking), don't link in the global value due to this
>> +  // reference, simply map it to null.
>> +  if (ModLinker->doneLinkingBodies())
>> +    return nullptr;
>
> This won't map the global value to null, it will in fact map it to itself
> (see ValueMapper.cpp around line 43 after the call to materializeValueFor).
> This will end up creating a cross-module reference in the combined module's
> metadata, which confuses many parts of the compiler including the bitcode
> writer.
>
> It is possible for LTO clients to work around this by destroying the module.
> This will cause any metadata uses to be replaced with null, which satisfied
> the original intent. In fact, this is what most other module linker clients do
> (including llvm-link and llvm-lto), which made this somewhat hard to track
> down. I'll probably do the same thing in LLD if for no other reason than to
> save a little memory.
>
> At the same time, can you please see if there is some way to fix this in the
> module linker?
>
> Thanks,
> --
> Peter



-- 
Teresa Johnson | Software Engineer | tejohnson at google.com | 408-460-2413


More information about the llvm-commits mailing list