diff options
author | Teresa Johnson <tejohnson@google.com> | 2016-04-27 14:19:38 +0000 |
---|---|---|
committer | Teresa Johnson <tejohnson@google.com> | 2016-04-27 14:19:38 +0000 |
commit | df5ef8711f5b5b374144b32eecb9f2bacdecfb8a (patch) | |
tree | 1c90654b021ce91545ec9d67f45c7d3afb6e2b69 /llvm/lib/Transforms/Utils/FunctionImportUtils.cpp | |
parent | 221e2c61ec3b83add0d54b41eaee650b9ca6b386 (diff) | |
download | bcm5719-llvm-df5ef8711f5b5b374144b32eecb9f2bacdecfb8a.tar.gz bcm5719-llvm-df5ef8711f5b5b374144b32eecb9f2bacdecfb8a.zip |
[ThinLTO] Refine fix to avoid renaming of uses in inline assembly.
Summary:
Refine the workaround from r266877 that attempts to prevent
renaming of locals in inline assembly, so that in addition to looking
for a llvm.used local value, that there is at least one inline assembly
call in the module. Otherwise, debug functions added to the llvm.used
can block importing/exporting unnecessarily.
Reviewers: joker.eph
Subscribers: llvm-commits, joker.eph
Differential Revision: http://reviews.llvm.org/D19573
llvm-svn: 267717
Diffstat (limited to 'llvm/lib/Transforms/Utils/FunctionImportUtils.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/FunctionImportUtils.cpp | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/llvm/lib/Transforms/Utils/FunctionImportUtils.cpp b/llvm/lib/Transforms/Utils/FunctionImportUtils.cpp index 4280e96841e..33ce5ccefda 100644 --- a/llvm/lib/Transforms/Utils/FunctionImportUtils.cpp +++ b/llvm/lib/Transforms/Utils/FunctionImportUtils.cpp @@ -13,6 +13,8 @@ //===----------------------------------------------------------------------===// #include "llvm/Transforms/Utils/FunctionImportUtils.h" +#include "llvm/IR/InstIterator.h" +#include "llvm/IR/Instructions.h" using namespace llvm; /// Checks if we should import SGV as a definition, otherwise import as a @@ -211,25 +213,31 @@ void FunctionImportGlobalProcessing::processGlobalForThinLTO(GlobalValue &GV) { } void FunctionImportGlobalProcessing::processGlobalsForThinLTO() { - // We cannot currently promote or rename anything that is in llvm.used, - // since any such value may have a use that won't see the new name. - // Specifically, any uses within inline assembly are not visible to the - // compiler. Prevent changing any such values on the exporting side, + // We cannot currently promote or rename anything used in inline assembly, + // which are not visible to the compiler. Detect a possible case by looking + // for a llvm.used local value, in conjunction with an inline assembly call + // in the module. Prevent changing any such values on the exporting side, // since we would already have guarded against an import from this module by // suppressing its index generation. See comments on what is required // in order to implement a finer grained solution in // ModuleSummaryIndexBuilder::ModuleSummaryIndexBuilder(). SmallPtrSet<GlobalValue *, 8> Used; collectUsedGlobalVariables(M, Used, /*CompilerUsed*/ false); + bool LocalIsUsed = false; for (GlobalValue *V : Used) { - if (!V->hasLocalLinkage()) - continue; // We would have blocked importing from this module by suppressing index // generation. - assert(!isPerformingImport() && + assert((!V->hasLocalLinkage() || !isPerformingImport()) && "Should have blocked importing from module with local used"); - return; + if ((LocalIsUsed |= V->hasLocalLinkage())) + break; } + if (LocalIsUsed) + for (auto &F : M) + for (auto &I : instructions(F)) + if (const CallInst *CallI = dyn_cast<CallInst>(&I)) + if (CallI->isInlineAsm()) + return; for (GlobalVariable &GV : M.globals()) processGlobalForThinLTO(GV); |