llvm.org GIT mirror llvm / 65562d6
Reorganize GlobalValueSummary with a "Flags" bitfield. Right now it only contains the LinkageType, but will be extended with "hasSection", "isOptSize", "hasInlineAssembly", etc. Differential Revision: http://reviews.llvm.org/D19404 From: Mehdi Amini <mehdi.amini@apple.com> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267319 91177308-0d34-0410-b5e6-96231b3b80d8 Mehdi Amini 4 years ago
8 changed file(s) with 136 addition(s) and 103 deletion(s). Raw diff Collapse all Expand all
194194 // The summary section uses different codes in the per-module
195195 // and combined index cases.
196196 enum GlobalValueSummarySymtabCodes {
197 // PERMODULE: [valueid, linkage, instcount, numrefs, numrefs x valueid,
197 // PERMODULE: [valueid, flags, instcount, numrefs, numrefs x valueid,
198198 // n x (valueid, callsitecount)]
199199 FS_PERMODULE = 1,
200 // PERMODULE_PROFILE: [valueid, linkage, instcount, numrefs,
200 // PERMODULE_PROFILE: [valueid, flags, instcount, numrefs,
201201 // numrefs x valueid,
202202 // n x (valueid, callsitecount, profilecount)]
203203 FS_PERMODULE_PROFILE = 2,
204 // PERMODULE_GLOBALVAR_INIT_REFS: [valueid, linkage, n x valueid]
204 // PERMODULE_GLOBALVAR_INIT_REFS: [valueid, flags, n x valueid]
205205 FS_PERMODULE_GLOBALVAR_INIT_REFS = 3,
206 // COMBINED: [modid, linkage, instcount, numrefs, numrefs x valueid,
206 // COMBINED: [modid, flags, instcount, numrefs, numrefs x valueid,
207207 // n x (valueid, callsitecount)]
208208 FS_COMBINED = 4,
209 // COMBINED_PROFILE: [modid, linkage, instcount, numrefs,
209 // COMBINED_PROFILE: [modid, flags, instcount, numrefs,
210210 // numrefs x valueid,
211211 // n x (valueid, callsitecount, profilecount)]
212212 FS_COMBINED_PROFILE = 5,
213 // COMBINED_GLOBALVAR_INIT_REFS: [modid, linkage, n x valueid]
213 // COMBINED_GLOBALVAR_INIT_REFS: [modid, flags, n x valueid]
214214 FS_COMBINED_GLOBALVAR_INIT_REFS = 6,
215 // ALIAS: [valueid, linkage, valueid]
215 // ALIAS: [valueid, flags, valueid]
216216 FS_ALIAS = 7,
217 // COMBINED_ALIAS: [modid, linkage, offset]
217 // COMBINED_ALIAS: [modid, flags, offset]
218218 FS_COMBINED_ALIAS = 8,
219219 // COMBINED_ORIGINAL_NAME: [original_name_hash]
220220 FS_COMBINED_ORIGINAL_NAME = 9,
9191 /// \brief Sububclass discriminator (for dyn_cast<> et al.)
9292 enum SummaryKind { AliasKind, FunctionKind, GlobalVarKind };
9393
94 /// Group flags (Linkage, hasSection, isOptSize, etc.) as a bitfield.
95 struct GVFlags {
96 /// \brief The linkage type of the associated global value.
97 ///
98 /// One use is to flag values that have local linkage types and need to
99 /// have module identifier appended before placing into the combined
100 /// index, to disambiguate from other values with the same name.
101 /// In the future this will be used to update and optimize linkage
102 /// types based on global summary-based analysis.
103 GlobalValue::LinkageTypes Linkage : 4;
104
105 /// Convenience Constructors
106 explicit GVFlags(GlobalValue::LinkageTypes Linkage) : Linkage(Linkage) {}
107 GVFlags(const GlobalValue &GV) : Linkage(GV.getLinkage()) {}
108 };
109
94110 private:
95111 /// Kind of summary for use in dyn_cast<> et al.
96112 SummaryKind Kind;
109125 /// module path string table.
110126 StringRef ModulePath;
111127
112 /// \brief The linkage type of the associated global value.
113 ///
114 /// One use is to flag values that have local linkage types and need to
115 /// have module identifier appended before placing into the combined
116 /// index, to disambiguate from other values with the same name.
117 /// In the future this will be used to update and optimize linkage
118 /// types based on global summary-based analysis.
119 GlobalValue::LinkageTypes Linkage;
128 GVFlags Flags;
120129
121130 /// List of values referenced by this global value's definition
122131 /// (either by the initializer of a global variable, or referenced
126135
127136 protected:
128137 /// GlobalValueSummary constructor.
129 GlobalValueSummary(SummaryKind K, GlobalValue::LinkageTypes Linkage)
130 : Kind(K), Linkage(Linkage) {}
138 GlobalValueSummary(SummaryKind K, GVFlags Flags) : Kind(K), Flags(Flags) {}
131139
132140 public:
133141 virtual ~GlobalValueSummary() = default;
149157 /// Get the path to the module containing this function.
150158 StringRef modulePath() const { return ModulePath; }
151159
160 /// Get the flags for this GlobalValue (see \p struct GVFlags).
161 GVFlags flags() { return Flags; }
162
152163 /// Return linkage type recorded for this global value.
153 GlobalValue::LinkageTypes linkage() const { return Linkage; }
164 GlobalValue::LinkageTypes linkage() const { return Flags.Linkage; }
154165
155166 /// Record a reference from this global value to the global value identified
156167 /// by \p RefGUID.
178189
179190 public:
180191 /// Summary constructors.
181 AliasSummary(GlobalValue::LinkageTypes Linkage)
182 : GlobalValueSummary(AliasKind, Linkage) {}
192 AliasSummary(GVFlags Flags) : GlobalValueSummary(AliasKind, Flags) {}
183193
184194 /// Check if this is an alias summary.
185195 static bool classof(const GlobalValueSummary *GVS) {
215225
216226 public:
217227 /// Summary constructors.
218 FunctionSummary(GlobalValue::LinkageTypes Linkage, unsigned NumInsts)
219 : GlobalValueSummary(FunctionKind, Linkage), InstCount(NumInsts) {}
228 FunctionSummary(GVFlags Flags, unsigned NumInsts)
229 : GlobalValueSummary(FunctionKind, Flags), InstCount(NumInsts) {}
220230
221231 /// Check if this is a function summary.
222232 static bool classof(const GlobalValueSummary *GVS) {
262272
263273 public:
264274 /// Summary constructors.
265 GlobalVarSummary(GlobalValue::LinkageTypes Linkage)
266 : GlobalValueSummary(GlobalVarKind, Linkage) {}
275 GlobalVarSummary(GVFlags Flags) : GlobalValueSummary(GlobalVarKind, Flags) {}
267276
268277 /// Check if this is a global variable summary.
269278 static bool classof(const GlobalValueSummary *GVS) {
9494 findRefEdges(&*I, RefEdges, Visited);
9595 }
9696
97 GlobalValueSummary::GVFlags Flags(F);
9798 std::unique_ptr FuncSummary =
98 llvm::make_unique(F.getLinkage(), NumInsts);
99 llvm::make_unique(Flags, NumInsts);
99100 FuncSummary->addCallGraphEdges(CallGraphEdges);
100101 FuncSummary->addRefEdges(RefEdges);
101102 std::unique_ptr GVInfo =
107108 DenseSet RefEdges;
108109 SmallPtrSet Visited;
109110 findRefEdges(&V, RefEdges, Visited);
111 GlobalValueSummary::GVFlags Flags(V);
110112 std::unique_ptr GVarSummary =
111 llvm::make_unique(V.getLinkage());
113 llvm::make_unique(Flags);
112114 GVarSummary->addRefEdges(RefEdges);
113115 std::unique_ptr GVInfo =
114116 llvm::make_unique(0, std::move(GVarSummary));
735735 case 19:
736736 return GlobalValue::LinkOnceODRLinkage;
737737 }
738 }
739
740 // Decode the flags for GlobalValue in the summary
741 static GlobalValueSummary::GVFlags getDecodedGVSummaryFlags(uint64_t RawFlags,
742 uint64_t Version) {
743 // Summary were not emitted before LLVM 3.9, we don't need to upgrade Linkage
744 // like getDecodedLinkage() above. Any future change to the linkage enum and
745 // to getDecodedLinkage() will need to be taken into account here as above.
746 auto Linkage = GlobalValue::LinkageTypes(RawFlags & 0xF); // 4 bits
747 return GlobalValueSummary::GVFlags(Linkage);
738748 }
739749
740750 static GlobalValue::VisibilityTypes getDecodedVisibility(unsigned Val) {
60506060 switch (BitCode) {
60516061 default: // Default behavior: ignore.
60526062 break;
6053 // FS_PERMODULE: [valueid, linkage, instcount, numrefs, numrefs x valueid,
6063 // FS_PERMODULE: [valueid, flags, instcount, numrefs, numrefs x valueid,
60546064 // n x (valueid, callsitecount)]
6055 // FS_PERMODULE_PROFILE: [valueid, linkage, instcount, numrefs,
6065 // FS_PERMODULE_PROFILE: [valueid, flags, instcount, numrefs,
60566066 // numrefs x valueid,
60576067 // n x (valueid, callsitecount, profilecount)]
60586068 case bitc::FS_PERMODULE:
60596069 case bitc::FS_PERMODULE_PROFILE: {
60606070 unsigned ValueID = Record[0];
6061 uint64_t RawLinkage = Record[1];
6071 uint64_t RawFlags = Record[1];
60626072 unsigned InstCount = Record[2];
60636073 unsigned NumRefs = Record[3];
6064 std::unique_ptr FS = llvm::make_unique(
6065 getDecodedLinkage(RawLinkage), InstCount);
6074 auto Flags = getDecodedGVSummaryFlags(RawFlags, Version);
6075 std::unique_ptr FS =
6076 llvm::make_unique(Flags, InstCount);
60666077 // The module path string ref set in the summary must be owned by the
60676078 // index's module string table. Since we don't have a module path
60686079 // string table section in the per-module index, we create a single
60966107 Info->setSummary(std::move(FS));
60976108 break;
60986109 }
6099 // FS_ALIAS: [valueid, linkage, valueid]
6110 // FS_ALIAS: [valueid, flags, valueid]
61006111 // Aliases must be emitted (and parsed) after all FS_PERMODULE entries, as
61016112 // they expect all aliasee summaries to be available.
61026113 case bitc::FS_ALIAS: {
61036114 unsigned ValueID = Record[0];
6104 uint64_t RawLinkage = Record[1];
6115 uint64_t RawFlags = Record[1];
61056116 unsigned AliaseeID = Record[2];
6106 std::unique_ptr AS =
6107 llvm::make_unique(getDecodedLinkage(RawLinkage));
6117 auto Flags = getDecodedGVSummaryFlags(RawFlags, Version);
6118 std::unique_ptr AS = llvm::make_unique(Flags);
61086119 // The module path string ref set in the summary must be owned by the
61096120 // index's module string table. Since we don't have a module path
61106121 // string table section in the per-module index, we create a single
61266137 Info->setSummary(std::move(AS));
61276138 break;
61286139 }
6129 // FS_PERMODULE_GLOBALVAR_INIT_REFS: [valueid, linkage, n x valueid]
6140 // FS_PERMODULE_GLOBALVAR_INIT_REFS: [valueid, flags, n x valueid]
61306141 case bitc::FS_PERMODULE_GLOBALVAR_INIT_REFS: {
61316142 unsigned ValueID = Record[0];
6132 uint64_t RawLinkage = Record[1];
6143 uint64_t RawFlags = Record[1];
6144 auto Flags = getDecodedGVSummaryFlags(RawFlags, Version);
61336145 std::unique_ptr FS =
6134 llvm::make_unique(getDecodedLinkage(RawLinkage));
6146 llvm::make_unique(Flags);
61356147 FS->setModulePath(
61366148 TheIndex->addModulePath(Buffer->getBufferIdentifier(), 0)->first());
61376149 for (unsigned I = 2, E = Record.size(); I != E; ++I) {
61466158 Info->setSummary(std::move(FS));
61476159 break;
61486160 }
6149 // FS_COMBINED: [modid, linkage, instcount, numrefs, numrefs x valueid,
6161 // FS_COMBINED: [modid, flags, instcount, numrefs, numrefs x valueid,
61506162 // n x (valueid, callsitecount)]
6151 // FS_COMBINED_PROFILE: [modid, linkage, instcount, numrefs,
6163 // FS_COMBINED_PROFILE: [modid, flags, instcount, numrefs,
61526164 // numrefs x valueid,
61536165 // n x (valueid, callsitecount, profilecount)]
61546166 case bitc::FS_COMBINED:
61556167 case bitc::FS_COMBINED_PROFILE: {
61566168 uint64_t ModuleId = Record[0];
6157 uint64_t RawLinkage = Record[1];
6169 uint64_t RawFlags = Record[1];
61586170 unsigned InstCount = Record[2];
61596171 unsigned NumRefs = Record[3];
6160 std::unique_ptr FS = llvm::make_unique(
6161 getDecodedLinkage(RawLinkage), InstCount);
6172 auto Flags = getDecodedGVSummaryFlags(RawFlags, Version);
6173 std::unique_ptr FS =
6174 llvm::make_unique(Flags, InstCount);
61626175 LastSeenSummary = FS.get();
61636176 FS->setModulePath(ModuleIdMap[ModuleId]);
61646177 static int RefListStartIndex = 4;
61866199 Combined = true;
61876200 break;
61886201 }
6189 // FS_COMBINED_ALIAS: [modid, linkage, offset]
6202 // FS_COMBINED_ALIAS: [modid, flags, offset]
61906203 // Aliases must be emitted (and parsed) after all FS_COMBINED entries, as
61916204 // they expect all aliasee summaries to be available.
61926205 case bitc::FS_COMBINED_ALIAS: {
61936206 uint64_t ModuleId = Record[0];
6194 uint64_t RawLinkage = Record[1];
6207 uint64_t RawFlags = Record[1];
61956208 uint64_t AliaseeSummaryOffset = Record[2];
6196 std::unique_ptr AS =
6197 llvm::make_unique(getDecodedLinkage(RawLinkage));
6209 auto Flags = getDecodedGVSummaryFlags(RawFlags, Version);
6210 std::unique_ptr AS = llvm::make_unique(Flags);
61986211 LastSeenSummary = AS.get();
61996212 AS->setModulePath(ModuleIdMap[ModuleId]);
62006213
62096222 Combined = true;
62106223 break;
62116224 }
6212 // FS_COMBINED_GLOBALVAR_INIT_REFS: [modid, linkage, n x valueid]
6225 // FS_COMBINED_GLOBALVAR_INIT_REFS: [modid, flags, n x valueid]
62136226 case bitc::FS_COMBINED_GLOBALVAR_INIT_REFS: {
62146227 uint64_t ModuleId = Record[0];
6215 uint64_t RawLinkage = Record[1];
6228 uint64_t RawFlags = Record[1];
6229 auto Flags = getDecodedGVSummaryFlags(RawFlags, Version);
62166230 std::unique_ptr FS =
6217 llvm::make_unique(getDecodedLinkage(RawLinkage));
6231 llvm::make_unique(Flags);
62186232 LastSeenSummary = FS.get();
62196233 FS->setModulePath(ModuleIdMap[ModuleId]);
62206234 for (unsigned I = 2, E = Record.size(); I != E; ++I) {
785785 return getEncodedLinkage(GV.getLinkage());
786786 }
787787
788 // Decode the flags for GlobalValue in the summary
789 static uint64_t getEncodedGVSummaryFlags(GlobalValueSummary::GVFlags Flags) {
790 uint64_t RawFlags = 0;
791 // Emit Linkage enum.
792 RawFlags |= Flags.Linkage; // 4 bits
793 return RawFlags;
794 }
795
788796 static unsigned getEncodedVisibility(const GlobalValue &GV) {
789797 switch (GV.getVisibility()) {
790798 case GlobalValue::DefaultVisibility: return 0;
30223030 NameVals.push_back(ValueID);
30233031
30243032 FunctionSummary *FS = cast(Info->summary());
3025 NameVals.push_back(getEncodedLinkage(FS->linkage()));
3033 NameVals.push_back(getEncodedGVSummaryFlags(FS->flags()));
30263034 NameVals.push_back(FS->instCount());
30273035 NameVals.push_back(FS->refs().size());
30283036
30563064 if (V.isDeclaration())
30573065 return;
30583066 NameVals.push_back(VE.getValueID(&V));
3059 NameVals.push_back(getEncodedLinkage(V.getLinkage()));
3067 NameVals.push_back(getEncodedGVSummaryFlags(V));
30603068 auto *Info = Index->getGlobalValueInfo(V);
30613069 GlobalVarSummary *VS = cast(Info->summary());
30623070 for (auto Ref : VS->refs())
30803088 if (Index->begin() == Index->end())
30813089 return;
30823090
3083 Stream.EnterSubblock(bitc::GLOBALVAL_SUMMARY_BLOCK_ID, 3);
3091 Stream.EnterSubblock(bitc::GLOBALVAL_SUMMARY_BLOCK_ID, 4);
30843092
30853093 Stream.EmitRecord(bitc::FS_VERSION, ArrayRef{INDEX_VERSION});
30863094
30883096 BitCodeAbbrev *Abbv = new BitCodeAbbrev();
30893097 Abbv->Add(BitCodeAbbrevOp(bitc::FS_PERMODULE));
30903098 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // valueid
3091 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 5)); // linkage
3099 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // flags
30923100 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // instcount
30933101 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 4)); // numrefs
30943102 // numrefs x valueid, n x (valueid, callsitecount)
31003108 Abbv = new BitCodeAbbrev();
31013109 Abbv->Add(BitCodeAbbrevOp(bitc::FS_PERMODULE_PROFILE));
31023110 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // valueid
3103 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 5)); // linkage
3111 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // flags
31043112 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // instcount
31053113 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 4)); // numrefs
31063114 // numrefs x valueid, n x (valueid, callsitecount, profilecount)
31123120 Abbv = new BitCodeAbbrev();
31133121 Abbv->Add(BitCodeAbbrevOp(bitc::FS_PERMODULE_GLOBALVAR_INIT_REFS));
31143122 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // valueid
3115 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 5)); // linkage
3123 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // flags
31163124 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array)); // valueids
31173125 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
31183126 unsigned FSModRefsAbbrev = Stream.EmitAbbrev(Abbv);
31213129 Abbv = new BitCodeAbbrev();
31223130 Abbv->Add(BitCodeAbbrevOp(bitc::FS_ALIAS));
31233131 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // valueid
3124 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 5)); // linkage
3132 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // flags
31253133 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // valueid
31263134 unsigned FSAliasAbbrev = Stream.EmitAbbrev(Abbv);
31273135
31563164 auto AliasId = VE.getValueID(&A);
31573165 auto AliaseeId = VE.getValueID(Aliasee);
31583166 NameVals.push_back(AliasId);
3159 NameVals.push_back(getEncodedLinkage(A.getLinkage()));
3167 NameVals.push_back(getEncodedGVSummaryFlags(A));
31603168 NameVals.push_back(AliaseeId);
31613169 Stream.EmitRecord(bitc::FS_ALIAS, NameVals, FSAliasAbbrev);
31623170 NameVals.clear();
31743182 BitCodeAbbrev *Abbv = new BitCodeAbbrev();
31753183 Abbv->Add(BitCodeAbbrevOp(bitc::FS_COMBINED));
31763184 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // modid
3177 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 5)); // linkage
3185 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // flags
31783186 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // instcount
31793187 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 4)); // numrefs
31803188 // numrefs x valueid, n x (valueid, callsitecount)
31863194 Abbv = new BitCodeAbbrev();
31873195 Abbv->Add(BitCodeAbbrevOp(bitc::FS_COMBINED_PROFILE));
31883196 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // modid
3189 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 5)); // linkage
3197 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // flags
31903198 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // instcount
31913199 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 4)); // numrefs
31923200 // numrefs x valueid, n x (valueid, callsitecount, profilecount)
31983206 Abbv = new BitCodeAbbrev();
31993207 Abbv->Add(BitCodeAbbrevOp(bitc::FS_COMBINED_GLOBALVAR_INIT_REFS));
32003208 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // modid
3201 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 5)); // linkage
3209 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // flags
32023210 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array)); // valueids
32033211 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
32043212 unsigned FSModRefsAbbrev = Stream.EmitAbbrev(Abbv);
32073215 Abbv = new BitCodeAbbrev();
32083216 Abbv->Add(BitCodeAbbrevOp(bitc::FS_COMBINED_ALIAS));
32093217 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // modid
3210 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 5)); // linkage
3218 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // flags
32113219 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // offset
32123220 unsigned FSAliasAbbrev = Stream.EmitAbbrev(Abbv);
32133221
32423250
32433251 if (auto *VS = dyn_cast(S)) {
32443252 NameVals.push_back(Index.getModuleId(VS->modulePath()));
3245 NameVals.push_back(getEncodedLinkage(VS->linkage()));
3253 NameVals.push_back(getEncodedGVSummaryFlags(VS->flags()));
32463254 for (auto &RI : VS->refs()) {
32473255 NameVals.push_back(getValueId(RI.getGUID()));
32483256 }
32653273
32663274 auto *FS = cast(S);
32673275 NameVals.push_back(Index.getModuleId(FS->modulePath()));
3268 NameVals.push_back(getEncodedLinkage(FS->linkage()));
3276 NameVals.push_back(getEncodedGVSummaryFlags(FS->flags()));
32693277 NameVals.push_back(FS->instCount());
32703278 NameVals.push_back(FS->refs().size());
32713279
33143322 for (auto GVI : Aliases) {
33153323 AliasSummary *AS = cast(GVI->summary());
33163324 NameVals.push_back(Index.getModuleId(AS->modulePath()));
3317 NameVals.push_back(getEncodedLinkage(AS->linkage()));
3325 NameVals.push_back(getEncodedGVSummaryFlags(AS->flags()));
33183326 auto AliaseeOffset = SummaryToOffsetMap[&AS->getAliasee()];
33193327 assert(AliaseeOffset);
33203328 NameVals.push_back(AliaseeOffset);
1212 ; Function main contains call to func, as well as address reference to func:
1313 ; CHECK-DAG:
1414 ; Function W contains a call to func3 as well as a reference to globalvar:
15 ; CHECK-DAG: 17 {{.*}} op3=1 op4=[[GLOBALVARID:[0-9]+]] op5=[[FUNC3ID:[0-9]+]] op6=1/>
15 ; CHECK-DAG: 5 {{.*}} op3=1 op4=[[GLOBALVARID:[0-9]+]] op5=[[FUNC3ID:[0-9]+]] op6=1/>
1616 ; Function X contains call to foo, as well as address reference to foo
1717 ; which is in the same instruction as the call:
18 ; CHECK-DAG: 2 {{.*}} op3=1 op4=[[FOOID:[0-9]+]] op5=[[FOOID]] op6=1/>
18 ; CHECK-DAG: {{.*}} op3=1 op4=[[FOOID:[0-9]+]] op5=[[FOOID]] op6=1/>
1919 ; Function Y contains call to func2, and ensures we don't incorrectly add
2020 ; a reference to it when reached while earlier analyzing the phi using its
2121 ; return value:
22 ; CHECK-DAG: 9 {{.*}} op3=0 op4=[[FUNC2ID:[0-9]+]] op5=1/>
22 ; CHECK-DAG: 8 {{.*}} op3=0 op4=[[FUNC2ID:[0-9]+]] op5=1/>
2323 ; Function Z contains call to func2, and ensures we don't incorrectly add
2424 ; a reference to it when reached while analyzing subsequent use of its return
2525 ; value:
26 ; CHECK-DAG: 19 {{.*}} op3=0 op4=[[FUNC2ID:[0-9]+]] op5=1/>
26 ; CHECK-DAG: 3 {{.*}} op3=0 op4=[[FUNC2ID:[0-9]+]] op5=1/>
2727 ; Variable bar initialization contains address reference to func:
2828 ; CHECK-DAG:
2929 ; CHECK:
77 ; BC-NEXT:
88 ; BC-NEXT:
99 ; BC-NEXT:
10 ; BC-NEXT: 3
10 ; BC-NEXT: 7
1111 ; BC-NEXT:
1212 ; BC-NEXT:
1313 ; BC-NEXT:
44 ; RUN: llvm-bcanalyzer -dump %t2.thinlto.bc | FileCheck %s --check-prefix=COMBINED
55
66 define private void @private()
7 ; CHECK:
8 ; COMBINED-DAG:
7 ; CHECK:
8 ; COMBINED-DAG:
99 {
1010 ret void
1111 }
1212
1313 define internal void @internal()
14 ; CHECK:
15 ; COMBINED-DAG:
16 {
17 ret void
18 }
19
20 define available_externally void @available_externally()
21 ; CHECK:
22 ; COMBINED-DAG:
23 {
24 ret void
25 }
26
27 define linkonce void @linkonce()
28 ; CHECK:
29 ; COMBINED-DAG:
30 {
31 ret void
32 }
33
34 define weak void @weak()
35 ; CHECK:
36 ; COMBINED-DAG:
37 {
38 ret void
39 }
40
41 define linkonce_odr void @linkonce_odr()
1442 ; CHECK:
1543 ; COMBINED-DAG:
1644 {
1745 ret void
1846 }
1947
20 define available_externally void @available_externally()
21 ; CHECK:
22 ; COMBINED-DAG:
23 {
24 ret void
25 }
26
27 define linkonce void @linkonce()
28 ; CHECK:
29 ; COMBINED-DAG:
30 {
31 ret void
32 }
33
34 define weak void @weak()
35 ; CHECK:
36 ; COMBINED-DAG:
37 {
38 ret void
39 }
40
41 define linkonce_odr void @linkonce_odr()
42 ; CHECK:
43 ; COMBINED-DAG:
44 {
45 ret void
46 }
47
4848 define weak_odr void @weak_odr()
49 ; CHECK:
50 ; COMBINED-DAG:
49 ; CHECK:
50 ; COMBINED-DAG:
5151 {
5252 ret void
5353 }