[llvm] r263576 - [ThinLTO] Record all global variable defs in the summary

Teresa Johnson via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 15 12:35:45 PDT 2016


Author: tejohnson
Date: Tue Mar 15 14:35:45 2016
New Revision: 263576

URL: http://llvm.org/viewvc/llvm-project?rev=263576&view=rev
Log:
[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.

Modified:
    llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp

Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp?rev=263576&r1=263575&r2=263576&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp (original)
+++ llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Tue Mar 15 14:35:45 2016
@@ -2900,20 +2900,20 @@ static void WriteModuleLevelReferences(c
                                        SmallVector<uint64_t, 64> &NameVals,
                                        unsigned FSModRefsAbbrev,
                                        BitstreamWriter &Stream) {
+  // Only interested in recording variable defs in the summary.
+  if (V.isDeclaration())
+    return;
   DenseSet<unsigned> RefEdges;
   SmallPtrSet<const User *, 8> Visited;
   findRefEdges(&V, VE, RefEdges, Visited);
-  unsigned RefCount = RefEdges.size();
-  if (RefCount) {
-    NameVals.push_back(VE.getValueID(&V));
-    NameVals.push_back(getEncodedLinkage(V.getLinkage()));
-    for (auto RefId : RefEdges) {
-      NameVals.push_back(RefId);
-    }
-    Stream.EmitRecord(bitc::FS_PERMODULE_GLOBALVAR_INIT_REFS, NameVals,
-                      FSModRefsAbbrev);
-    NameVals.clear();
+  NameVals.push_back(VE.getValueID(&V));
+  NameVals.push_back(getEncodedLinkage(V.getLinkage()));
+  for (auto RefId : RefEdges) {
+    NameVals.push_back(RefId);
   }
+  Stream.EmitRecord(bitc::FS_PERMODULE_GLOBALVAR_INIT_REFS, NameVals,
+                    FSModRefsAbbrev);
+  NameVals.clear();
 }
 
 /// Emit the per-module summary section alongside the rest of
@@ -3054,7 +3054,6 @@ static void WriteCombinedGlobalValueSumm
       assert(S);
 
       if (auto *VS = dyn_cast<GlobalVarSummary>(S)) {
-        assert(!VS->refs().empty() && "Expected at least one ref edge");
         NameVals.push_back(I.getModuleId(VS->modulePath()));
         NameVals.push_back(getEncodedLinkage(VS->linkage()));
         for (auto &RI : VS->refs()) {




More information about the llvm-commits mailing list