[ThinLTO] Prevent importing of "llvm.used" values

Summary:
This patch prevents importing from (and therefore exporting from) any
module with a "llvm.used" local value. Local values need to be promoted
and renamed when importing, and their presense on the llvm.used variable
indicates that there are opaque uses that won't see the rename. One such
example is a use in inline assembly.

See also the discussion at:
http://lists.llvm.org/pipermail/llvm-dev/2016-April/098047.html

As part of this, move collectUsedGlobalVariables out of Transforms/Utils
and into IR/Module so that it can be used more widely. There are several
other places in LLVM that used copies of this code that can be cleaned
up as a follow on NFC patch.

Reviewers: joker.eph

Subscribers: pcc, llvm-commits, joker.eph

Differential Revision: http://reviews.llvm.org/D18986

llvm-svn: 266877
This commit is contained in:
Teresa Johnson
2016-04-20 14:39:45 +00:00
parent 6eda85ac1f
commit b35cc691ea
12 changed files with 101 additions and 27 deletions

View File

@@ -2889,6 +2889,9 @@ static void WritePerModuleGlobalValueSummary(const Module *M,
if (M->empty())
return;
if (Index.begin() == Index.end())
return;
Stream.EnterSubblock(bitc::GLOBALVAL_SUMMARY_BLOCK_ID, 3);
// Abbrev for FS_PERMODULE.