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

Peter Collingbourne via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 13 17:34:42 PST 2015


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: llvm.diff
Type: text/x-diff
Size: 426 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151113/4c133333/attachment.diff>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fmtable.bc
Type: application/octet-stream
Size: 4096 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151113/4c133333/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: brkiter.bc
Type: application/octet-stream
Size: 5120 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151113/4c133333/attachment-0001.obj>


More information about the llvm-commits mailing list