[PATCH] D16421: FunctionImport: handle metadata importing in the main import loop (NFC)

Mehdi AMINI via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 21 10:59:41 PST 2016


joker.eph created this revision.
joker.eph added a reviewer: tejohnson.
joker.eph added a subscriber: llvm-commits.

It does not seem there is a good reason for not doing it, and it
should divide by 2 the number of bitcode parsing.

http://reviews.llvm.org/D16421

Files:
  lib/Transforms/IPO/FunctionImport.cpp

Index: lib/Transforms/IPO/FunctionImport.cpp
===================================================================
--- lib/Transforms/IPO/FunctionImport.cpp
+++ lib/Transforms/IPO/FunctionImport.cpp
@@ -295,9 +295,6 @@
                 ModuleToFunctionsToImportMap, Index, ModuleLoaderCache);
   assert(Worklist.empty() && "Worklist hasn't been flushed in GetImportList");
 
-  StringMap<std::unique_ptr<DenseMap<unsigned, MDNode *>>>
-      ModuleToTempMDValsMap;
-
   // Do the actual import of functions now, one Module at a time
   for (auto &FunctionsToImportPerModule : ModuleToFunctionsToImportMap) {
     // Get the module for the import
@@ -310,30 +307,24 @@
     // Save the mapping of value ids to temporary metadata created when
     // importing this function. If we have already imported from this module,
     // add new temporary metadata to the existing mapping.
-    auto &TempMDVals = ModuleToTempMDValsMap[SrcModule->getModuleIdentifier()];
-    if (!TempMDVals)
-      TempMDVals = llvm::make_unique<DenseMap<unsigned, MDNode *>>();
+    DenseMap<unsigned, MDNode *> TempMDVals;
 
     // Link in the specified functions.
     if (TheLinker.linkInModule(std::move(SrcModule), Linker::Flags::None,
-                               &Index, &FunctionsToImport, TempMDVals.get()))
+                               &Index, &FunctionsToImport, &TempMDVals))
       report_fatal_error("Function Import: link error");
 
     ImportedCount += FunctionsToImport.size();
-  }
 
-  // Now link in metadata for all modules from which we imported functions.
-  for (StringMapEntry<std::unique_ptr<DenseMap<unsigned, MDNode *>>> &SME :
-       ModuleToTempMDValsMap) {
-    // Load the specified source module.
-    auto &SrcModule = ModuleLoaderCache(SME.getKey());
+    // Now link in metadata
+
     // The modules were created with lazy metadata loading. Materialize it
     // now, before linking it.
-    SrcModule.materializeMetadata();
-    UpgradeDebugInfo(SrcModule);
+    SrcModule->materializeMetadata();
+    UpgradeDebugInfo(*SrcModule);
 
     // Link in all necessary metadata from this module.
-    if (TheLinker.linkInMetadata(SrcModule, SME.getValue().get()))
+    if (TheLinker.linkInMetadata(*SrcModule, &TempMDVals))
       return false;
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16421.45569.patch
Type: text/x-patch
Size: 2269 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160121/b51218e4/attachment.bin>


More information about the llvm-commits mailing list