llvm.org GIT mirror llvm / e07c260
[ThinLTO] Rename index IsAnalysis flag to HaveGVs (NFC) With the upcoming patch to add summary parsing support, IsAnalysis would be true in contexts where we are not performing module summary analysis. Rename to the more specific and approprate HaveGVs, which is essentially what this flag is indicating. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334140 91177308-0d34-0410-b5e6-96231b3b80d8 Teresa Johnson 2 years ago
9 changed file(s) with 45 addition(s) and 44 deletion(s). Raw diff Collapse all Expand all
102102
103103 struct GlobalValueSummaryInfo {
104104 union NameOrGV {
105 NameOrGV(bool IsAnalysis) {
106 if (IsAnalysis)
105 NameOrGV(bool HaveGVs) {
106 if (HaveGVs)
107107 GV = nullptr;
108108 else
109109 Name = "";
110110 }
111111
112112 /// The GlobalValue corresponding to this summary. This is only used in
113 /// per-module summaries, when module analysis is being run.
113 /// per-module summaries and when the IR is available. E.g. when module
114 /// analysis is being run, or when parsing both the IR and the summary
115 /// from assembly.
114116 const GlobalValue *GV;
115117
116118 /// Summary string representation. This StringRef points to BC module
121123 StringRef Name;
122124 } U;
123125
124 GlobalValueSummaryInfo(bool IsAnalysis) : U(IsAnalysis) {}
126 GlobalValueSummaryInfo(bool HaveGVs) : U(HaveGVs) {}
125127
126128 /// List of global value summary structures for a particular value held
127129 /// in the GlobalValueMap. Requires a vector in the case of multiple
145147 RefAndFlag;
146148
147149 ValueInfo() = default;
148 ValueInfo(bool IsAnalysis, const GlobalValueSummaryMapTy::value_type *R) {
150 ValueInfo(bool HaveGVs, const GlobalValueSummaryMapTy::value_type *R) {
149151 RefAndFlag.setPointer(R);
150 RefAndFlag.setInt(IsAnalysis);
152 RefAndFlag.setInt(HaveGVs);
151153 }
152154
153155 operator bool() const { return getRef(); }
154156
155157 GlobalValue::GUID getGUID() const { return getRef()->first; }
156158 const GlobalValue *getValue() const {
157 assert(isFromAnalysis());
159 assert(haveGVs());
158160 return getRef()->second.U.GV;
159161 }
160162
163165 }
164166
165167 StringRef name() const {
166 return isFromAnalysis() ? getRef()->second.U.GV->getName()
167 : getRef()->second.U.Name;
168 }
169
170 bool isFromAnalysis() const { return RefAndFlag.getInt(); }
168 return haveGVs() ? getRef()->second.U.GV->getName()
169 : getRef()->second.U.Name;
170 }
171
172 bool haveGVs() const { return RefAndFlag.getInt(); }
171173
172174 const GlobalValueSummaryMapTy::value_type *getRef() const {
173175 return RefAndFlag.getPointer();
208210 }
209211
210212 static bool isEqual(ValueInfo L, ValueInfo R) {
211 // We are not supposed to mix ValueInfo(s) with different analysis flag
213 // We are not supposed to mix ValueInfo(s) with different HaveGVs flag
212214 // in a same container.
213 assert(isSpecialKey(L) || isSpecialKey(R) ||
214 (L.isFromAnalysis() == R.isFromAnalysis()));
215 assert(isSpecialKey(L) || isSpecialKey(R) || (L.haveGVs() == R.haveGVs()));
215216 return L.getRef() == R.getRef();
216217 }
217218 static unsigned getHashValue(ValueInfo I) { return (uintptr_t)I.getRef(); }
755756 /// valid object file.
756757 bool SkipModuleByDistributedBackend = false;
757758
758 /// If true then we're performing analysis of IR module, filling summary
759 /// accordingly. The value of 'false' means we're reading summary from
760 /// BC or YAML source. Affects the type of value stored in NameOrGV union
761 bool IsAnalysis;
759 /// If true then we're performing analysis of IR module, or parsing along with
760 /// the IR from assembly. The value of 'false' means we're reading summary
761 /// from BC or YAML source. Affects the type of value stored in NameOrGV
762 /// union.
763 bool HaveGVs;
762764
763765 std::set CfiFunctionDefs;
764766 std::set CfiFunctionDecls;
768770
769771 GlobalValueSummaryMapTy::value_type *
770772 getOrInsertValuePtr(GlobalValue::GUID GUID) {
771 return &*GlobalValueMap.emplace(GUID, GlobalValueSummaryInfo(IsAnalysis)).first;
773 return &*GlobalValueMap.emplace(GUID, GlobalValueSummaryInfo(HaveGVs))
774 .first;
772775 }
773776
774777 public:
775 // See IsAnalysis variable comment.
776 ModuleSummaryIndex(bool IsPerformingAnalysis)
777 : IsAnalysis(IsPerformingAnalysis) {}
778
779 bool isPerformingAnalysis() const { return IsAnalysis; }
778 // See HaveGVs variable comment.
779 ModuleSummaryIndex(bool HaveGVs) : HaveGVs(HaveGVs) {}
780
781 bool haveGVs() const { return HaveGVs; }
780782
781783 gvsummary_iterator begin() { return GlobalValueMap.begin(); }
782784 const_gvsummary_iterator begin() const { return GlobalValueMap.begin(); }
829831 if (!S.second.SummaryList.size() ||
830832 !isa(S.second.SummaryList.front().get()))
831833 continue;
832 discoverNodes(ValueInfo(IsAnalysis, &S), FunctionHasParent);
834 discoverNodes(ValueInfo(HaveGVs, &S), FunctionHasParent);
833835 }
834836
835837 std::vector Edges;
869871 /// Return a ValueInfo for the index value_type (convenient when iterating
870872 /// index).
871873 ValueInfo getValueInfo(const GlobalValueSummaryMapTy::value_type &R) const {
872 return ValueInfo(IsAnalysis, &R);
874 return ValueInfo(HaveGVs, &R);
873875 }
874876
875877 /// Return a ValueInfo for GUID if it exists, otherwise return ValueInfo().
876878 ValueInfo getValueInfo(GlobalValue::GUID GUID) const {
877879 auto I = GlobalValueMap.find(GUID);
878 return ValueInfo(IsAnalysis, I == GlobalValueMap.end() ? nullptr : &*I);
880 return ValueInfo(HaveGVs, I == GlobalValueMap.end() ? nullptr : &*I);
879881 }
880882
881883 /// Return a ValueInfo for \p GUID.
882884 ValueInfo getOrInsertValueInfo(GlobalValue::GUID GUID) {
883 return ValueInfo(IsAnalysis, getOrInsertValuePtr(GUID));
885 return ValueInfo(HaveGVs, getOrInsertValuePtr(GUID));
884886 }
885887
886888 /// Return a ValueInfo for \p GUID setting value \p Name.
887889 ValueInfo getOrInsertValueInfo(GlobalValue::GUID GUID, StringRef Name) {
888 assert(!IsAnalysis);
890 assert(!HaveGVs);
889891 auto VP = getOrInsertValuePtr(GUID);
890892 VP->second.U.Name = Name;
891 return ValueInfo(IsAnalysis, VP);
893 return ValueInfo(HaveGVs, VP);
892894 }
893895
894896 /// Return a ValueInfo for \p GV and mark it as belonging to GV.
895897 ValueInfo getOrInsertValueInfo(const GlobalValue *GV) {
896 assert(IsAnalysis);
898 assert(HaveGVs);
897899 auto VP = getOrInsertValuePtr(GV->getGUID());
898900 VP->second.U.GV = GV;
899 return ValueInfo(IsAnalysis, VP);
901 return ValueInfo(HaveGVs, VP);
900902 }
901903
902904 /// Return the GUID for \p OriginalId in the OidGuidMap.
11081110 static NodeRef getEntryNode(ModuleSummaryIndex *I) {
11091111 std::unique_ptr Root =
11101112 make_unique(I->calculateCallGraphRoot());
1111 GlobalValueSummaryInfo G(I->isPerformingAnalysis());
1113 GlobalValueSummaryInfo G(I->haveGVs());
11121114 G.SummaryList.push_back(std::move(Root));
11131115 static auto P =
11141116 GlobalValueSummaryMapTy::value_type(GlobalValue::GUID(0), std::move(G));
1115 return ValueInfo(I->isPerformingAnalysis(), &P);
1117 return ValueInfo(I->haveGVs(), &P);
11161118 }
11171119 };
11181120
407407 std::function GetBFICallback,
408408 ProfileSummaryInfo *PSI) {
409409 assert(PSI);
410 ModuleSummaryIndex Index(/*IsPerformingAnalysis=*/true);
410 ModuleSummaryIndex Index(/*HaveGVs=*/true);
411411
412412 // Identify the local values in the llvm.used and llvm.compiler.used sets,
413413 // which should not be exported as they would then require renaming and
57785778 BitstreamCursor Stream(Buffer);
57795779 Stream.JumpToBit(ModuleBit);
57805780
5781 auto Index =
5782 llvm::make_unique(/*IsPerformingAnalysis=*/false);
5781 auto Index = llvm::make_unique(/*HaveGVs=*/false);
57835782 ModuleSummaryIndexBitcodeReader R(std::move(Stream), Strtab, *Index,
57845783 ModuleIdentifier, 0);
57855784
400400 Mover(llvm::make_unique(*CombinedModule)) {}
401401
402402 LTO::ThinLTOState::ThinLTOState(ThinBackend Backend)
403 : Backend(Backend), CombinedIndex(/*IsPeformingAnalysis*/ false) {
403 : Backend(Backend), CombinedIndex(/*HaveGVs*/ false) {
404404 if (!Backend)
405405 this->Backend =
406406 createInProcessThinBackend(llvm::heavyweight_hardware_concurrency());
589589 */
590590 std::unique_ptr ThinLTOCodeGenerator::linkCombinedIndex() {
591591 std::unique_ptr CombinedIndex =
592 llvm::make_unique(/*IsPeformingAnalysis=*/false);
592 llvm::make_unique(/*HaveGVs=*/false);
593593 uint64_t NextModuleId = 0;
594594 for (auto &ModuleBuffer : Modules) {
595595 if (Error Err = readModuleSummaryIndex(ModuleBuffer.getMemBuffer(),
15901590 }
15911591
15921592 bool LowerTypeTestsModule::runForTesting(Module &M) {
1593 ModuleSummaryIndex Summary(/*IsPerformingAnalysis=*/false);
1593 ModuleSummaryIndex Summary(/*HaveGVs=*/false);
15941594
15951595 // Handle the command-line summary arguments. This code is for testing
15961596 // purposes only, so we handle errors directly.
618618 bool DevirtModule::runForTesting(
619619 Module &M, function_ref AARGetter,
620620 function_ref OREGetter) {
621 ModuleSummaryIndex Summary(/*IsPerformingAnalysis=*/false);
621 ModuleSummaryIndex Summary(/*HaveGVs=*/false);
622622
623623 // Handle the command-line summary arguments. This code is for testing
624624 // purposes only, so we handle errors directly.
926926 (NewModulePath + ".thinlto.bc").c_str(), EC.message().c_str());
927927
928928 if (SkipModule) {
929 ModuleSummaryIndex Index(false);
929 ModuleSummaryIndex Index(/*HaveGVs*/ false);
930930 Index.setSkipModuleByDistributedBackend();
931931 WriteIndexToFile(Index, OS, nullptr);
932932 }
373373 /// This is meant to enable testing of ThinLTO combined index generation,
374374 /// currently available via the gold plugin via -thinlto.
375375 static void createCombinedModuleSummaryIndex() {
376 ModuleSummaryIndex CombinedIndex(/*IsPerformingAnalysis=*/false);
376 ModuleSummaryIndex CombinedIndex(/*HaveGVs=*/false);
377377 uint64_t NextModuleId = 0;
378378 for (auto &Filename : InputFilenames) {
379379 ExitOnError ExitOnErr("llvm-lto: error loading file '" + Filename + "': ");