[PATCH] D55047: [ThinLTO] Import local variables from the same module as caller

Teresa Johnson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 28 22:19:43 PST 2018


tejohnson created this revision.
tejohnson added a reviewer: evgeny777.
Herald added subscribers: dang, dexonsmith, steven_wu, eraman, inglorion, mehdi_amini.

We can sometimes end up with multiple copies of a local variable that
have the same GUID in the index. This happens when there are local
variables with the same name that are in different source files having the
same name/path at compile time (but compiled into different bitcode objects).

In this case make sure we import the copy in the caller's module.
This enables importing both of the variables having the same GUID
(but which will have different promoted names since the module paths,
and therefore the module hashes, will be distinct).

Importing the wrong copy is particularly problematic for read only
variables, since we must import them as a local copy whenever
referenced. Otherwise we get undefs at link time.

Note that the llvm-lto.cpp and ThinLTOCodeGenerator changes are needed
for testing the distributed index case via clang, which will be sent as
a separate clang-side patch shortly. We were previously not doing the
dead code/read only computation before computing imports when testing
distributed index generation (like it was for testing importing and
other ThinLTO mechanisms alone).


Repository:
  rL LLVM

https://reviews.llvm.org/D55047

Files:
  include/llvm/LTO/legacy/ThinLTOCodeGenerator.h
  lib/LTO/ThinLTOCodeGenerator.cpp
  lib/Transforms/IPO/FunctionImport.cpp
  test/ThinLTO/X86/Inputs/local_name_conflict1.ll
  test/ThinLTO/X86/Inputs/local_name_conflict2.ll
  test/ThinLTO/X86/Inputs/local_name_conflict_var1.ll
  test/ThinLTO/X86/Inputs/local_name_conflict_var2.ll
  test/ThinLTO/X86/local_name_conflict.ll
  test/ThinLTO/X86/local_name_conflict_var.ll
  tools/llvm-lto/llvm-lto.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55047.175813.patch
Type: text/x-patch
Size: 13796 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181129/fcfec043/attachment.bin>


More information about the llvm-commits mailing list