[PATCH] D21915: ThinLTO: Add -thinlto-action=promote-internalize.

Peter Collingbourne via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 1 13:37:40 PDT 2016


pcc added inline comments.

================
Comment at: test/ThinLTO/X86/alias_import.ll:91
@@ +90,3 @@
+; Promotion + internalization should internalize all of these (except for aliases of
+; linkonce_odr functions for some reason).
+; PROMOTE-INTERNALIZE-DAG: @globalfuncAlias = internal alias void (...), bitcast (void ()* @globalfunc to void (...)*)
----------------
tejohnson wrote:
> Probably because alias to linkonce odr are the only aliases we will import. So they will be exported and therefore not internalizable. See selectCallee() in FunctionImport.cpp
Okay, I'll update the comment here

================
Comment at: tools/llvm-lto/llvm-lto.cpp:100
@@ +99,3 @@
+        clEnumValN(
+            THINPROMOTEINTERNALIZE, "promote-internalize",
+            "Perform promotion and internalization (requires -thinlto-index)."),
----------------
tejohnson wrote:
> Rather than add a new type here, can the test just do two invocations of llvm-lto - one invoking promotion and then feeding the resulting bitcode into another invoking internalization?
That's what I tried first of all, but I got assertion failures like this:

```llvm-lto: ../lib/Transforms/IPO/FunctionImport.cpp:536: auto llvm::thinLTOInternalizeModule(llvm::Module &, const GVSummaryMapTy &)::(anonymous class)::operator()(const llvm::GlobalValue &) const: Assertion `GS != DefinedGlobals.end()' failed.```

I think this is caused by the internalization code looking up symbol names by GUID, which will be different as a result of the module identifier being different if the input bitcode is piped in. (I thought the whole point of the source_filename thing was to try to protect against that sort of problem, but evidently it doesn't help here -- even if I apply a diff like this:
```
diff --git a/test/ThinLTO/X86/Inputs/alias_import.ll b/test/ThinLTO/X86/Inputs/alias_import.ll
index 36e5ad1..5f1324b 100644
--- a/test/ThinLTO/X86/Inputs/alias_import.ll
+++ b/test/ThinLTO/X86/Inputs/alias_import.ll
@@ -1,6 +1,4 @@
-
-
-
+source_filename = "2.c"
 
 @globalfuncAlias = alias void (...), bitcast (void ()* @globalfunc to void (...)*)
 @globalfuncWeakAlias = weak alias void (...), bitcast (void ()* @globalfunc to void (...)*)
diff --git a/test/ThinLTO/X86/alias_import.ll b/test/ThinLTO/X86/alias_import.ll
index d4cc996..c7ffc12 100644
--- a/test/ThinLTO/X86/alias_import.ll
+++ b/test/ThinLTO/X86/alias_import.ll
@@ -2,7 +2,7 @@
 ; RUN: opt -module-summary %p/Inputs/alias_import.ll -o %t2.bc
 ; RUN: llvm-lto -thinlto-action=thinlink -o %t.index.bc %t1.bc %t2.bc
 ; RUN: llvm-lto -thinlto-action=promote -thinlto-index %t.index.bc %t2.bc -o - | llvm-dis -o - | FileCheck %s --check-prefix=PROMOTE
-; RUN: llvm-lto -thinlto-action=promote-internalize -thinlto-index %t.index.bc %t2.bc -o - | llvm-dis -o - | FileCheck %s --check-prefix=PROMOTE-INTERNALIZE
+; RUN: llvm-lto -thinlto-action=promote -thinlto-index %t.index.bc %t2.bc -o - | llvm-lto -thinlto-action=internalize -thinlto-index %t.index.bc -exported-symbol=dummy - -o - | llvm-dis -o - | FileCheck %s --check-prefix=PROMOTE-INTERNALIZE
 ; RUN: llvm-lto -thinlto-action=import -thinlto-index %t.index.bc %t1.bc -o - | llvm-dis -o - | FileCheck %s --check-prefix=IMPORT
 
 ;
@@ -126,6 +126,8 @@
 ; PROMOTE-INTERNALIZE-DAG: define internal void @linkoncefunc()
 ; PROMOTE-INTERNALIZE-DAG: define internal void @weakfunc()
 
+source_filename = "1.c"
+
 define i32 @main() #0 {
 entry:
   call void @globalfuncAlias()
```

 the combined summary still looks like this here:

```
  <ENTRY [...] /> record string = '[...]/Output/alias_import.ll.tmp1.bc'
  <ENTRY [...] /> record string = '[...]/Output/alias_import.ll.tmp2.bc
```
)


http://reviews.llvm.org/D21915





More information about the llvm-commits mailing list