[ThinLTO] Augment FunctionImport dump with value name to GUID map
authorTeresa Johnson <tejohnson@google.com>
Mon, 4 Apr 2016 18:52:23 +0000 (18:52 +0000)
committerTeresa Johnson <tejohnson@google.com>
Mon, 4 Apr 2016 18:52:23 +0000 (18:52 +0000)
Summary:
To aid in debugging, dump out the correlation between value names and
GUID for each source module when it is materialized. This will make it
easier to comprehend the earlier summary-based function importing debug
trace which only has access to and prints the GUIDs.

Reviewers: joker.eph

Subscribers: llvm-commits, joker.eph

Differential Revision: http://reviews.llvm.org/D18556

llvm-svn: 265326

llvm/lib/Transforms/IPO/FunctionImport.cpp

index f69bc1d..a1d36de 100644 (file)
@@ -320,7 +320,14 @@ bool FunctionImporter::importFunctions(
     // Find the globals to import
     DenseSet<const GlobalValue *> GlobalsToImport;
     for (auto &GV : *SrcModule) {
-      if (GV.hasName() && ImportGUIDs.count(GV.getGUID())) {
+      if (!GV.hasName())
+        continue;
+      auto GUID = GV.getGUID();
+      auto Import = ImportGUIDs.count(GUID);
+      DEBUG(dbgs() << (Import ? "Is" : "Not") << " importing " << GUID << " "
+                   << GV.getName() << " from " << SrcModule->getSourceFileName()
+                   << "\n");
+      if (Import) {
         GV.materialize();
         GlobalsToImport.insert(&GV);
       }
@@ -329,7 +336,11 @@ bool FunctionImporter::importFunctions(
       if (!GV.hasName())
         continue;
       auto GUID = GV.getGUID();
-      if (ImportGUIDs.count(GUID)) {
+      auto Import = ImportGUIDs.count(GUID);
+      DEBUG(dbgs() << (Import ? "Is" : "Not") << " importing " << GUID << " "
+                   << GV.getName() << " from " << SrcModule->getSourceFileName()
+                   << "\n");
+      if (Import) {
         // Alias can't point to "available_externally". However when we import
         // linkOnceODR the linkage does not change. So we import the alias
         // and aliasee only in this case.
@@ -345,7 +356,11 @@ bool FunctionImporter::importFunctions(
       if (!GV.hasName())
         continue;
       auto GUID = GV.getGUID();
-      if (ImportGUIDs.count(GUID)) {
+      auto Import = ImportGUIDs.count(GUID);
+      DEBUG(dbgs() << (Import ? "Is" : "Not") << " importing " << GUID << " "
+                   << GV.getName() << " from " << SrcModule->getSourceFileName()
+                   << "\n");
+      if (Import) {
         GV.materialize();
         GlobalsToImport.insert(&GV);
       }