[PATCH] D14387: Move comdat setup after global value body linking in ModuleLinker

Teresa Johnson via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 5 10:03:29 PST 2015


tejohnson created this revision.
tejohnson added reviewers: dexonsmith, joker.eph.
tejohnson added a subscriber: llvm-commits.

The verifier complains if a declaration is in a comdat. However,
the module linker speculatively adds linked global values that are
in comdats in the source module into comdats in the destination module,
which assumes their bodies will also be linked.

For ThinLTO we may not link the body if it isn't an imported function.
Also, with currently reverted patch r251926 (D14195: Move metadata
linking after lazy global materialization/linking), during an LTO build
a function referenced only from metadata will not have its definition
linked and will become a declaration. If it was in a comdat it will also
hit the verifier error.

To handle this, delay setting up comdats on the Dest module until after
all global value bodies have been linked, so that we know which are
definitions vs declarations in Dest.

This change is an enabler for resubmitting r251926, and also for some
follow-on fixes for ThinLTO comdat handling I discovered in the process
of working on these changes.

http://reviews.llvm.org/D14387

Files:
  lib/Linker/LinkModules.cpp
  test/Linker/funcimport.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14387.39379.patch
Type: text/x-patch
Size: 8260 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151105/f129e5f8/attachment.bin>


More information about the llvm-commits mailing list