Skip to content

Commit 1396809

Browse files
committed
[ThinLTO] Record all global variable defs in the summary
Record all variable defs with a summary record to aid in building a complete reference graph and locating constant variable defs to import. llvm-svn: 263576
1 parent 9b4bbea commit 1396809

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

llvm/lib/Bitcode/Writer/BitcodeWriter.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2900,20 +2900,20 @@ static void WriteModuleLevelReferences(const GlobalVariable &V,
29002900
SmallVector<uint64_t, 64> &NameVals,
29012901
unsigned FSModRefsAbbrev,
29022902
BitstreamWriter &Stream) {
2903+
// Only interested in recording variable defs in the summary.
2904+
if (V.isDeclaration())
2905+
return;
29032906
DenseSet<unsigned> RefEdges;
29042907
SmallPtrSet<const User *, 8> Visited;
29052908
findRefEdges(&V, VE, RefEdges, Visited);
2906-
unsigned RefCount = RefEdges.size();
2907-
if (RefCount) {
2908-
NameVals.push_back(VE.getValueID(&V));
2909-
NameVals.push_back(getEncodedLinkage(V.getLinkage()));
2910-
for (auto RefId : RefEdges) {
2911-
NameVals.push_back(RefId);
2912-
}
2913-
Stream.EmitRecord(bitc::FS_PERMODULE_GLOBALVAR_INIT_REFS, NameVals,
2914-
FSModRefsAbbrev);
2915-
NameVals.clear();
2909+
NameVals.push_back(VE.getValueID(&V));
2910+
NameVals.push_back(getEncodedLinkage(V.getLinkage()));
2911+
for (auto RefId : RefEdges) {
2912+
NameVals.push_back(RefId);
29162913
}
2914+
Stream.EmitRecord(bitc::FS_PERMODULE_GLOBALVAR_INIT_REFS, NameVals,
2915+
FSModRefsAbbrev);
2916+
NameVals.clear();
29172917
}
29182918

29192919
/// Emit the per-module summary section alongside the rest of
@@ -3054,7 +3054,6 @@ static void WriteCombinedGlobalValueSummary(
30543054
assert(S);
30553055

30563056
if (auto *VS = dyn_cast<GlobalVarSummary>(S)) {
3057-
assert(!VS->refs().empty() && "Expected at least one ref edge");
30583057
NameVals.push_back(I.getModuleId(VS->modulePath()));
30593058
NameVals.push_back(getEncodedLinkage(VS->linkage()));
30603059
for (auto &RI : VS->refs()) {

0 commit comments

Comments
 (0)