diff options
-rw-r--r-- | llvm/include/llvm/IR/ModuleSummaryIndex.h | 66 | ||||
-rw-r--r-- | llvm/lib/Analysis/ModuleSummaryAnalysis.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 3 | ||||
-rw-r--r-- | llvm/lib/LTO/LTO.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/LTO/ThinLTOCodeGenerator.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/Transforms/IPO/LowerTypeTests.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp | 2 | ||||
-rw-r--r-- | llvm/tools/gold/gold-plugin.cpp | 2 | ||||
-rw-r--r-- | llvm/tools/llvm-lto/llvm-lto.cpp | 2 |
9 files changed, 42 insertions, 41 deletions
diff --git a/llvm/include/llvm/IR/ModuleSummaryIndex.h b/llvm/include/llvm/IR/ModuleSummaryIndex.h index 3ea22561987..064ca653611 100644 --- a/llvm/include/llvm/IR/ModuleSummaryIndex.h +++ b/llvm/include/llvm/IR/ModuleSummaryIndex.h @@ -103,15 +103,17 @@ using GlobalValueSummaryList = std::vector<std::unique_ptr<GlobalValueSummary>>; struct GlobalValueSummaryInfo { union NameOrGV { - NameOrGV(bool IsAnalysis) { - if (IsAnalysis) + NameOrGV(bool HaveGVs) { + if (HaveGVs) GV = nullptr; else Name = ""; } /// The GlobalValue corresponding to this summary. This is only used in - /// per-module summaries, when module analysis is being run. + /// per-module summaries and when the IR is available. E.g. when module + /// analysis is being run, or when parsing both the IR and the summary + /// from assembly. const GlobalValue *GV; /// Summary string representation. This StringRef points to BC module @@ -122,7 +124,7 @@ struct GlobalValueSummaryInfo { StringRef Name; } U; - GlobalValueSummaryInfo(bool IsAnalysis) : U(IsAnalysis) {} + GlobalValueSummaryInfo(bool HaveGVs) : U(HaveGVs) {} /// List of global value summary structures for a particular value held /// in the GlobalValueMap. Requires a vector in the case of multiple @@ -146,16 +148,16 @@ struct ValueInfo { RefAndFlag; ValueInfo() = default; - ValueInfo(bool IsAnalysis, const GlobalValueSummaryMapTy::value_type *R) { + ValueInfo(bool HaveGVs, const GlobalValueSummaryMapTy::value_type *R) { RefAndFlag.setPointer(R); - RefAndFlag.setInt(IsAnalysis); + RefAndFlag.setInt(HaveGVs); } operator bool() const { return getRef(); } GlobalValue::GUID getGUID() const { return getRef()->first; } const GlobalValue *getValue() const { - assert(isFromAnalysis()); + assert(haveGVs()); return getRef()->second.U.GV; } @@ -164,11 +166,11 @@ struct ValueInfo { } StringRef name() const { - return isFromAnalysis() ? getRef()->second.U.GV->getName() - : getRef()->second.U.Name; + return haveGVs() ? getRef()->second.U.GV->getName() + : getRef()->second.U.Name; } - bool isFromAnalysis() const { return RefAndFlag.getInt(); } + bool haveGVs() const { return RefAndFlag.getInt(); } const GlobalValueSummaryMapTy::value_type *getRef() const { return RefAndFlag.getPointer(); @@ -209,10 +211,9 @@ template <> struct DenseMapInfo<ValueInfo> { } static bool isEqual(ValueInfo L, ValueInfo R) { - // We are not supposed to mix ValueInfo(s) with different analysis flag + // We are not supposed to mix ValueInfo(s) with different HaveGVs flag // in a same container. - assert(isSpecialKey(L) || isSpecialKey(R) || - (L.isFromAnalysis() == R.isFromAnalysis())); + assert(isSpecialKey(L) || isSpecialKey(R) || (L.haveGVs() == R.haveGVs())); return L.getRef() == R.getRef(); } static unsigned getHashValue(ValueInfo I) { return (uintptr_t)I.getRef(); } @@ -756,10 +757,11 @@ private: /// valid object file. bool SkipModuleByDistributedBackend = false; - /// If true then we're performing analysis of IR module, filling summary - /// accordingly. The value of 'false' means we're reading summary from - /// BC or YAML source. Affects the type of value stored in NameOrGV union - bool IsAnalysis; + /// If true then we're performing analysis of IR module, or parsing along with + /// the IR from assembly. The value of 'false' means we're reading summary + /// from BC or YAML source. Affects the type of value stored in NameOrGV + /// union. + bool HaveGVs; std::set<std::string> CfiFunctionDefs; std::set<std::string> CfiFunctionDecls; @@ -769,15 +771,15 @@ private: GlobalValueSummaryMapTy::value_type * getOrInsertValuePtr(GlobalValue::GUID GUID) { - return &*GlobalValueMap.emplace(GUID, GlobalValueSummaryInfo(IsAnalysis)).first; + return &*GlobalValueMap.emplace(GUID, GlobalValueSummaryInfo(HaveGVs)) + .first; } public: - // See IsAnalysis variable comment. - ModuleSummaryIndex(bool IsPerformingAnalysis) - : IsAnalysis(IsPerformingAnalysis) {} + // See HaveGVs variable comment. + ModuleSummaryIndex(bool HaveGVs) : HaveGVs(HaveGVs) {} - bool isPerformingAnalysis() const { return IsAnalysis; } + bool haveGVs() const { return HaveGVs; } gvsummary_iterator begin() { return GlobalValueMap.begin(); } const_gvsummary_iterator begin() const { return GlobalValueMap.begin(); } @@ -830,7 +832,7 @@ public: if (!S.second.SummaryList.size() || !isa<FunctionSummary>(S.second.SummaryList.front().get())) continue; - discoverNodes(ValueInfo(IsAnalysis, &S), FunctionHasParent); + discoverNodes(ValueInfo(HaveGVs, &S), FunctionHasParent); } std::vector<FunctionSummary::EdgeTy> Edges; @@ -870,34 +872,34 @@ public: /// Return a ValueInfo for the index value_type (convenient when iterating /// index). ValueInfo getValueInfo(const GlobalValueSummaryMapTy::value_type &R) const { - return ValueInfo(IsAnalysis, &R); + return ValueInfo(HaveGVs, &R); } /// Return a ValueInfo for GUID if it exists, otherwise return ValueInfo(). ValueInfo getValueInfo(GlobalValue::GUID GUID) const { auto I = GlobalValueMap.find(GUID); - return ValueInfo(IsAnalysis, I == GlobalValueMap.end() ? nullptr : &*I); + return ValueInfo(HaveGVs, I == GlobalValueMap.end() ? nullptr : &*I); } /// Return a ValueInfo for \p GUID. ValueInfo getOrInsertValueInfo(GlobalValue::GUID GUID) { - return ValueInfo(IsAnalysis, getOrInsertValuePtr(GUID)); + return ValueInfo(HaveGVs, getOrInsertValuePtr(GUID)); } /// Return a ValueInfo for \p GUID setting value \p Name. ValueInfo getOrInsertValueInfo(GlobalValue::GUID GUID, StringRef Name) { - assert(!IsAnalysis); + assert(!HaveGVs); auto VP = getOrInsertValuePtr(GUID); VP->second.U.Name = Name; - return ValueInfo(IsAnalysis, VP); + return ValueInfo(HaveGVs, VP); } /// Return a ValueInfo for \p GV and mark it as belonging to GV. ValueInfo getOrInsertValueInfo(const GlobalValue *GV) { - assert(IsAnalysis); + assert(HaveGVs); auto VP = getOrInsertValuePtr(GV->getGUID()); VP->second.U.GV = GV; - return ValueInfo(IsAnalysis, VP); + return ValueInfo(HaveGVs, VP); } /// Return the GUID for \p OriginalId in the OidGuidMap. @@ -1109,11 +1111,11 @@ struct GraphTraits<ModuleSummaryIndex *> : public GraphTraits<ValueInfo> { static NodeRef getEntryNode(ModuleSummaryIndex *I) { std::unique_ptr<GlobalValueSummary> Root = make_unique<FunctionSummary>(I->calculateCallGraphRoot()); - GlobalValueSummaryInfo G(I->isPerformingAnalysis()); + GlobalValueSummaryInfo G(I->haveGVs()); G.SummaryList.push_back(std::move(Root)); static auto P = GlobalValueSummaryMapTy::value_type(GlobalValue::GUID(0), std::move(G)); - return ValueInfo(I->isPerformingAnalysis(), &P); + return ValueInfo(I->haveGVs(), &P); } }; diff --git a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp index e6516c199ea..ca0a315bf39 100644 --- a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp +++ b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp @@ -408,7 +408,7 @@ ModuleSummaryIndex llvm::buildModuleSummaryIndex( std::function<BlockFrequencyInfo *(const Function &F)> GetBFICallback, ProfileSummaryInfo *PSI) { assert(PSI); - ModuleSummaryIndex Index(/*IsPerformingAnalysis=*/true); + ModuleSummaryIndex Index(/*HaveGVs=*/true); // 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 diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index 5f044f41dfd..a0347a154e8 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -5779,8 +5779,7 @@ Expected<std::unique_ptr<ModuleSummaryIndex>> BitcodeModule::getSummary() { BitstreamCursor Stream(Buffer); Stream.JumpToBit(ModuleBit); - auto Index = - llvm::make_unique<ModuleSummaryIndex>(/*IsPerformingAnalysis=*/false); + auto Index = llvm::make_unique<ModuleSummaryIndex>(/*HaveGVs=*/false); ModuleSummaryIndexBitcodeReader R(std::move(Stream), Strtab, *Index, ModuleIdentifier, 0); diff --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp index c74a7b39466..6077b3b1ba4 100644 --- a/llvm/lib/LTO/LTO.cpp +++ b/llvm/lib/LTO/LTO.cpp @@ -401,7 +401,7 @@ LTO::RegularLTOState::RegularLTOState(unsigned ParallelCodeGenParallelismLevel, Mover(llvm::make_unique<IRMover>(*CombinedModule)) {} LTO::ThinLTOState::ThinLTOState(ThinBackend Backend) - : Backend(Backend), CombinedIndex(/*IsPeformingAnalysis*/ false) { + : Backend(Backend), CombinedIndex(/*HaveGVs*/ false) { if (!Backend) this->Backend = createInProcessThinBackend(llvm::heavyweight_hardware_concurrency()); diff --git a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp index 872b9232e34..8c65a868580 100644 --- a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp +++ b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp @@ -590,7 +590,7 @@ std::unique_ptr<TargetMachine> TargetMachineBuilder::create() const { */ std::unique_ptr<ModuleSummaryIndex> ThinLTOCodeGenerator::linkCombinedIndex() { std::unique_ptr<ModuleSummaryIndex> CombinedIndex = - llvm::make_unique<ModuleSummaryIndex>(/*IsPeformingAnalysis=*/false); + llvm::make_unique<ModuleSummaryIndex>(/*HaveGVs=*/false); uint64_t NextModuleId = 0; for (auto &ModuleBuffer : Modules) { if (Error Err = readModuleSummaryIndex(ModuleBuffer.getMemBuffer(), diff --git a/llvm/lib/Transforms/IPO/LowerTypeTests.cpp b/llvm/lib/Transforms/IPO/LowerTypeTests.cpp index 7dbc6ad2555..b6033908204 100644 --- a/llvm/lib/Transforms/IPO/LowerTypeTests.cpp +++ b/llvm/lib/Transforms/IPO/LowerTypeTests.cpp @@ -1591,7 +1591,7 @@ LowerTypeTestsModule::LowerTypeTestsModule( } bool LowerTypeTestsModule::runForTesting(Module &M) { - ModuleSummaryIndex Summary(/*IsPerformingAnalysis=*/false); + ModuleSummaryIndex Summary(/*HaveGVs=*/false); // Handle the command-line summary arguments. This code is for testing // purposes only, so we handle errors directly. diff --git a/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp b/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp index cf6cb562f32..6a99ca17dfd 100644 --- a/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp +++ b/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp @@ -619,7 +619,7 @@ PreservedAnalyses WholeProgramDevirtPass::run(Module &M, bool DevirtModule::runForTesting( Module &M, function_ref<AAResults &(Function &)> AARGetter, function_ref<OptimizationRemarkEmitter &(Function *)> OREGetter) { - ModuleSummaryIndex Summary(/*IsPerformingAnalysis=*/false); + ModuleSummaryIndex Summary(/*HaveGVs=*/false); // Handle the command-line summary arguments. This code is for testing // purposes only, so we handle errors directly. diff --git a/llvm/tools/gold/gold-plugin.cpp b/llvm/tools/gold/gold-plugin.cpp index 76511f60243..08cef6f9310 100644 --- a/llvm/tools/gold/gold-plugin.cpp +++ b/llvm/tools/gold/gold-plugin.cpp @@ -927,7 +927,7 @@ static void writeEmptyDistributedBuildOutputs(const std::string &ModulePath, (NewModulePath + ".thinlto.bc").c_str(), EC.message().c_str()); if (SkipModule) { - ModuleSummaryIndex Index(false); + ModuleSummaryIndex Index(/*HaveGVs*/ false); Index.setSkipModuleByDistributedBackend(); WriteIndexToFile(Index, OS, nullptr); } diff --git a/llvm/tools/llvm-lto/llvm-lto.cpp b/llvm/tools/llvm-lto/llvm-lto.cpp index eb8aa27b033..75668a9dd8b 100644 --- a/llvm/tools/llvm-lto/llvm-lto.cpp +++ b/llvm/tools/llvm-lto/llvm-lto.cpp @@ -374,7 +374,7 @@ static void listSymbols(const TargetOptions &Options) { /// This is meant to enable testing of ThinLTO combined index generation, /// currently available via the gold plugin via -thinlto. static void createCombinedModuleSummaryIndex() { - ModuleSummaryIndex CombinedIndex(/*IsPerformingAnalysis=*/false); + ModuleSummaryIndex CombinedIndex(/*HaveGVs=*/false); uint64_t NextModuleId = 0; for (auto &Filename : InputFilenames) { ExitOnError ExitOnErr("llvm-lto: error loading file '" + Filename + "': "); |