[llvm] r266018 - ThinLTO renaming: use module hash instead of position in the summary

Mehdi Amini via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 11 16:26:46 PDT 2016


Author: mehdi_amini
Date: Mon Apr 11 18:26:46 2016
New Revision: 266018

URL: http://llvm.org/viewvc/llvm-project?rev=266018&view=rev
Log:
ThinLTO renaming: use module hash instead of position in the summary

This is more robust to changes in the link ordering.

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

From: Mehdi Amini <mehdi.amini at apple.com>

Modified:
    llvm/trunk/include/llvm/IR/ModuleSummaryIndex.h
    llvm/trunk/lib/Transforms/Utils/FunctionImportUtils.cpp
    llvm/trunk/test/Linker/funcimport.ll
    llvm/trunk/test/Transforms/FunctionImport/adjustable_threshold.ll
    llvm/trunk/test/Transforms/FunctionImport/funcimport.ll

Modified: llvm/trunk/include/llvm/IR/ModuleSummaryIndex.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/ModuleSummaryIndex.h?rev=266018&r1=266017&r2=266018&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/ModuleSummaryIndex.h (original)
+++ llvm/trunk/include/llvm/IR/ModuleSummaryIndex.h Mon Apr 11 18:26:46 2016
@@ -20,6 +20,7 @@
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/IR/Function.h"
 #include "llvm/IR/Module.h"
@@ -403,10 +404,10 @@ public:
 
   /// Convenience method for creating a promoted global name
   /// for the given value name of a local, and its original module's ID.
-  static std::string getGlobalNameForLocal(StringRef Name, uint64_t ModId) {
+  static std::string getGlobalNameForLocal(StringRef Name, ModuleHash ModHash) {
     SmallString<256> NewName(Name);
     NewName += ".llvm.";
-    raw_svector_ostream(NewName) << ModId;
+    NewName += utohexstr(ModHash[0]); // Take the first 32 bits
     return NewName.str();
   }
 

Modified: llvm/trunk/lib/Transforms/Utils/FunctionImportUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/FunctionImportUtils.cpp?rev=266018&r1=266017&r2=266018&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/FunctionImportUtils.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/FunctionImportUtils.cpp Mon Apr 11 18:26:46 2016
@@ -80,7 +80,7 @@ std::string FunctionImportGlobalProcessi
       (doPromoteLocalToGlobal(SGV) || isPerformingImport()))
     return ModuleSummaryIndex::getGlobalNameForLocal(
         SGV->getName(),
-        ImportIndex.getModuleId(SGV->getParent()->getModuleIdentifier()));
+        ImportIndex.getModuleHash(SGV->getParent()->getModuleIdentifier()));
   return SGV->getName();
 }
 

Modified: llvm/trunk/test/Linker/funcimport.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Linker/funcimport.ll?rev=266018&r1=266017&r2=266018&view=diff
==============================================================================
--- llvm/trunk/test/Linker/funcimport.ll (original)
+++ llvm/trunk/test/Linker/funcimport.ll Mon Apr 11 18:26:46 2016
@@ -13,11 +13,11 @@
 ; Ensure statics are promoted/renamed correctly from this file (all but
 ; constant variable need promotion).
 ; RUN: llvm-link %t.bc -summary-index=%t3.thinlto.bc -S | FileCheck %s --check-prefix=EXPORTSTATIC
-; EXPORTSTATIC-DAG: @staticvar.llvm.1 = hidden global
+; EXPORTSTATIC-DAG: @staticvar.llvm.{{.*}} = hidden global
 ; EXPORTSTATIC-DAG: @staticconstvar = internal unnamed_addr constant
-; EXPORTSTATIC-DAG: @P.llvm.1 = hidden global void ()* null
-; EXPORTSTATIC-DAG: define hidden i32 @staticfunc.llvm.1
-; EXPORTSTATIC-DAG: define hidden void @staticfunc2.llvm.1
+; EXPORTSTATIC-DAG: @P.llvm.{{.*}} = hidden global void ()* null
+; EXPORTSTATIC-DAG: define hidden i32 @staticfunc.llvm.
+; EXPORTSTATIC-DAG: define hidden void @staticfunc2.llvm.
 
 ; Ensure that both weak alias to an imported function and strong alias to a
 ; non-imported function are correctly turned into declarations.
@@ -67,12 +67,12 @@
 ; Ensure that imported static variable and function references are correctly
 ; promoted and renamed (including static constant variable).
 ; RUN: llvm-link %t2.bc -summary-index=%t3.thinlto.bc -import=referencestatics:%t.bc -S | FileCheck %s --check-prefix=IMPORTSTATIC
-; IMPORTSTATIC-DAG: @staticvar.llvm.1 = external hidden global
-; IMPORTSTATIC-DAG: @staticconstvar.llvm.1 = internal unnamed_addr constant
+; IMPORTSTATIC-DAG: @staticvar.llvm.{{.*}} = external hidden global
+; IMPORTSTATIC-DAG: @staticconstvar.llvm.{{.*}} = internal unnamed_addr constant
 ; IMPORTSTATIC-DAG: define available_externally i32 @referencestatics
-; IMPORTSTATIC-DAG: %call = call i32 @staticfunc.llvm.1
-; IMPORTSTATIC-DAG: %0 = load i32, i32* @staticvar.llvm.1
-; IMPORTSTATIC-DAG: declare hidden i32 @staticfunc.llvm.1
+; IMPORTSTATIC-DAG: %call = call i32 @staticfunc.llvm.
+; IMPORTSTATIC-DAG: %0 = load i32, i32* @staticvar.llvm.
+; IMPORTSTATIC-DAG: declare hidden i32 @staticfunc.llvm.
 
 ; Ensure that imported global (external) function and variable references
 ; are handled correctly (including referenced variable imported as
@@ -89,9 +89,9 @@
 
 ; Ensure that imported static function pointer correctly promoted and renamed.
 ; RUN: llvm-link %t2.bc -summary-index=%t3.thinlto.bc -import=callfuncptr:%t.bc -S | FileCheck %s --check-prefix=IMPORTFUNCPTR
-; IMPORTFUNCPTR-DAG: @P.llvm.1 = external hidden global void ()*
+; IMPORTFUNCPTR-DAG: @P.llvm.{{.*}} = external hidden global void ()*
 ; IMPORTFUNCPTR-DAG: define available_externally void @callfuncptr
-; IMPORTFUNCPTR-DAG: %0 = load void ()*, void ()** @P.llvm.1
+; IMPORTFUNCPTR-DAG: %0 = load void ()*, void ()** @P.llvm.
 
 ; Ensure that imported weak function reference/definition handled properly.
 ; Imported weak_any definition should be skipped with warning, and imported

Modified: llvm/trunk/test/Transforms/FunctionImport/adjustable_threshold.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/FunctionImport/adjustable_threshold.ll?rev=266018&r1=266017&r2=266018&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/FunctionImport/adjustable_threshold.ll (original)
+++ llvm/trunk/test/Transforms/FunctionImport/adjustable_threshold.ll Mon Apr 11 18:26:46 2016
@@ -5,7 +5,7 @@
 
 ; Test import with default progressive instruction factor
 ; RUN: opt -function-import -summary-file %t3.thinlto.bc %t.bc -import-instr-limit=10 -S | FileCheck %s --check-prefix=CHECK --check-prefix=INSTLIM-DEFAULT
-; INSTLIM-DEFAULT: call void @staticfunc2.llvm.2()
+; INSTLIM-DEFAULT: call void @staticfunc2.llvm.
 
 ; Test import with a reduced progressive instruction factor
 ; RUN: opt -function-import -summary-file %t3.thinlto.bc %t.bc -import-instr-limit=10 -import-instr-evolution-factor=0.5 -S | FileCheck %s --check-prefix=CHECK --check-prefix=INSTLIM-PROGRESSIVE

Modified: llvm/trunk/test/Transforms/FunctionImport/funcimport.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/FunctionImport/funcimport.ll?rev=266018&r1=266017&r2=266018&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/FunctionImport/funcimport.ll (original)
+++ llvm/trunk/test/Transforms/FunctionImport/funcimport.ll Mon Apr 11 18:26:46 2016
@@ -10,7 +10,7 @@
 
 ; Test import with smaller instruction limit
 ; RUN: opt -function-import -summary-file %t3.thinlto.bc %t.bc -import-instr-limit=5 -S | FileCheck %s --check-prefix=CHECK --check-prefix=INSTLIM5
-; INSTLIM5-NOT: @staticfunc.llvm.2
+; INSTLIM5-NOT: @staticfunc.llvm.
 
 define i32 @main() #0 {
 entry:
@@ -48,8 +48,8 @@ declare i32 @referencestatics(...) #1
 ; should in turn be imported as a promoted/renamed and hidden function.
 ; Ensure that the call is to the properly-renamed function.
 ; INSTLIMDEF-DAG: Import staticfunc
-; INSTLIMDEF-DAG: %call = call i32 @staticfunc.llvm.2()
-; INSTLIMDEF-DAG: define available_externally hidden i32 @staticfunc.llvm.2()
+; INSTLIMDEF-DAG: %call = call i32 @staticfunc.llvm.
+; INSTLIMDEF-DAG: define available_externally hidden i32 @staticfunc.llvm.
 
 ; INSTLIMDEF-DAG: Import referenceglobals
 ; CHECK-DAG: define available_externally i32 @referenceglobals(i32 %i)
@@ -74,17 +74,17 @@ declare void @callfuncptr(...) #1
 
 ; Ensure that all uses of local variable @P which has used in setfuncptr
 ; and callfuncptr are to the same promoted/renamed global.
-; CHECK-DAG: @P.llvm.2 = external hidden global void ()*
-; CHECK-DAG: %0 = load void ()*, void ()** @P.llvm.2,
-; CHECK-DAG: store void ()* @staticfunc2.llvm.2, void ()** @P.llvm.2,
+; CHECK-DAG: @P.llvm.{{.*}} = external hidden global void ()*
+; CHECK-DAG: %0 = load void ()*, void ()** @P.llvm.
+; CHECK-DAG: store void ()* @staticfunc2.llvm.{{.*}}, void ()** @P.llvm.
 
 ; Won't import weak func
 ; CHECK-DAG: declare void @weakfunc(...)
 declare void @weakfunc(...) #1
 
 ; INSTLIMDEF-DAG: Import funcwithpersonality
-; INSTLIMDEF-DAG: define available_externally hidden void @funcwithpersonality.llvm.2() personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
-; INSTLIM5-DAG: declare hidden void @funcwithpersonality.llvm.2()
+; INSTLIMDEF-DAG: define available_externally hidden void @funcwithpersonality.llvm.{{.*}}() personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
+; INSTLIM5-DAG: declare hidden void @funcwithpersonality.llvm.{{.*}}()
 
 ; INSTLIMDEF-DAG: Import globalfunc2
 ; INSTLIMDEF-DAG: 9 function-import - Number of functions imported




More information about the llvm-commits mailing list