From b6a11a78794b196cf8cda59d584cbe0d3243c06b Mon Sep 17 00:00:00 2001 From: Mehdi Amini Date: Wed, 9 Nov 2016 01:45:13 +0000 Subject: Revert "[ThinLTO] Prevent exporting of locals used/defined in module level asm" This reverts commit r286297. Introduces a dependency from libAnalysis to libObject, which I missed during the review. llvm-svn: 286329 --- llvm/lib/Analysis/ModuleSummaryAnalysis.cpp | 61 ++--------------------------- 1 file changed, 4 insertions(+), 57 deletions(-) (limited to 'llvm/lib/Analysis/ModuleSummaryAnalysis.cpp') diff --git a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp index 5cf4a895c91..09d18eb3da1 100644 --- a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp +++ b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp @@ -13,7 +13,6 @@ //===----------------------------------------------------------------------===// #include "llvm/Analysis/ModuleSummaryAnalysis.h" -#include "llvm/ADT/Triple.h" #include "llvm/Analysis/BlockFrequencyInfo.h" #include "llvm/Analysis/BlockFrequencyInfoImpl.h" #include "llvm/Analysis/BranchProbabilityInfo.h" @@ -25,7 +24,6 @@ #include "llvm/IR/InstIterator.h" #include "llvm/IR/IntrinsicInst.h" #include "llvm/IR/ValueSymbolTable.h" -#include "llvm/Object/IRObjectFile.h" #include "llvm/Pass.h" using namespace llvm; @@ -196,22 +194,12 @@ ModuleSummaryIndex llvm::buildModuleSummaryIndex( ProfileSummaryInfo *PSI) { ModuleSummaryIndex Index; - // Identify the local values in the llvm.used and llvm.compiler.used sets, - // which should not be exported as they would then require renaming and - // promotion, but we may have opaque uses e.g. in inline asm. We collect them - // here because we use this information to mark functions containing inline - // assembly calls as not importable. - SmallPtrSet LocalsUsed; + // Identify the local values in the llvm.used set, which should not be + // exported as they would then require renaming and promotion, but we + // may have opaque uses e.g. in inline asm. SmallPtrSet Used; - // First collect those in the llvm.used set. collectUsedGlobalVariables(M, Used, /*CompilerUsed*/ false); - for (auto *V : Used) { - if (V->hasLocalLinkage()) - LocalsUsed.insert(V); - } - Used.clear(); - // Next collect those in the llvm.compiler.used set. - collectUsedGlobalVariables(M, Used, /*CompilerUsed*/ true); + SmallPtrSet LocalsUsed; for (auto *V : Used) { if (V->hasLocalLinkage()) LocalsUsed.insert(V); @@ -256,47 +244,6 @@ ModuleSummaryIndex llvm::buildModuleSummaryIndex( Summary->setNoRename(); } - if (!M.getModuleInlineAsm().empty()) { - // Collect the local values defined by module level asm, and set up - // summaries for these symbols so that they can be marked as NoRename, - // to prevent export of any use of them in regular IR that would require - // renaming within the module level asm. Note we don't need to create a - // summary for weak or global defs, as they don't need to be flagged as - // NoRename, and defs in module level asm can't be imported anyway. - // Also, any values used but not defined within module level asm should - // be listed on the llvm.used or llvm.compiler.used global and marked as - // referenced from there. - // FIXME: Rename CollectAsmUndefinedRefs to something more general, as we - // are also using it to find the file-scope locals defined in module asm. - object::IRObjectFile::CollectAsmUndefinedRefs( - Triple(M.getTargetTriple()), M.getModuleInlineAsm(), - [&M, &Index](StringRef Name, object::BasicSymbolRef::Flags Flags) { - // Symbols not marked as Weak or Global are local definitions. - if (Flags & (object::BasicSymbolRef::SF_Weak || - object::BasicSymbolRef::SF_Global)) - return; - GlobalValue *GV = M.getNamedValue(Name); - if (!GV) - return; - assert(GV->isDeclaration() && "Def in module asm already has definition"); - GlobalValueSummary::GVFlags GVFlags(GlobalValue::InternalLinkage, - /* NoRename */ true, - /*IsNotViableToInline */ true); - // Create the appropriate summary type. - if (isa(GV)) { - std::unique_ptr Summary = - llvm::make_unique(GVFlags, 0); - Summary->setNoRename(); - Index.addGlobalValueSummary(Name, std::move(Summary)); - } else { - std::unique_ptr Summary = - llvm::make_unique(GVFlags); - Summary->setNoRename(); - Index.addGlobalValueSummary(Name, std::move(Summary)); - } - }); - } - return Index; } -- cgit v1.2.3