summaryrefslogtreecommitdiffstats
path: root/llvm/test/ThinLTO
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/test/ThinLTO')
-rw-r--r--llvm/test/ThinLTO/X86/Inputs/distributed_import.ll6
-rw-r--r--llvm/test/ThinLTO/X86/Inputs/distributed_indexes.ll6
-rw-r--r--llvm/test/ThinLTO/X86/alias_import.ll58
-rw-r--r--llvm/test/ThinLTO/X86/distributed_import.ll29
-rw-r--r--llvm/test/ThinLTO/X86/distributed_indexes.ll22
-rw-r--r--llvm/test/ThinLTO/X86/funcimport.ll8
6 files changed, 83 insertions, 46 deletions
diff --git a/llvm/test/ThinLTO/X86/Inputs/distributed_import.ll b/llvm/test/ThinLTO/X86/Inputs/distributed_import.ll
index 818c1ff3f8e..328603d20c4 100644
--- a/llvm/test/ThinLTO/X86/Inputs/distributed_import.ll
+++ b/llvm/test/ThinLTO/X86/Inputs/distributed_import.ll
@@ -6,3 +6,9 @@ entry:
%0 = load i32, i32* @G
ret i32 %0
}
+
+@analias = alias void (...), bitcast (void ()* @aliasee to void (...)*)
+define void @aliasee() {
+entry:
+ ret void
+}
diff --git a/llvm/test/ThinLTO/X86/Inputs/distributed_indexes.ll b/llvm/test/ThinLTO/X86/Inputs/distributed_indexes.ll
index 4e0840f3691..2755d264b3e 100644
--- a/llvm/test/ThinLTO/X86/Inputs/distributed_indexes.ll
+++ b/llvm/test/ThinLTO/X86/Inputs/distributed_indexes.ll
@@ -2,3 +2,9 @@ define void @g() {
entry:
ret void
}
+
+@analias = alias void (...), bitcast (void ()* @aliasee to void (...)*)
+define void @aliasee() {
+entry:
+ ret void
+}
diff --git a/llvm/test/ThinLTO/X86/alias_import.ll b/llvm/test/ThinLTO/X86/alias_import.ll
index fdfd90d03ad..ee4d533d0be 100644
--- a/llvm/test/ThinLTO/X86/alias_import.ll
+++ b/llvm/test/ThinLTO/X86/alias_import.ll
@@ -4,9 +4,9 @@
; 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=import -thinlto-index %t.index.bc %t1.bc -o - | llvm-dis -o - | FileCheck %s --check-prefix=IMPORT
-; Alias can't point to "available_externally", so they cannot be imported for
-; now. This could be implemented by importing the alias as an
-; available_externally definition copied from the aliasee's body.
+; Alias can't point to "available_externally", so they are implemented by
+; importing the alias as an available_externally definition copied from the
+; aliasee's body.
; PROMOTE-DAG: @globalfuncAlias = alias void (...), bitcast (void ()* @globalfunc to void (...)*)
; PROMOTE-DAG: @globalfuncWeakAlias = weak alias void (...), bitcast (void ()* @globalfunc to void (...)*)
; PROMOTE-DAG: @globalfuncLinkonceAlias = weak alias void (...), bitcast (void ()* @globalfunc to void (...)*)
@@ -45,45 +45,43 @@
; PROMOTE-DAG: define weak void @linkoncefunc()
; PROMOTE-DAG: define weak void @weakfunc()
-; On the import side now, verify that aliases are not imported
-; IMPORT-DAG: declare void @linkonceODRfuncWeakAlias
-; IMPORT-DAG: declare void @linkonceODRfuncLinkonceAlias
-; IMPORT-DAG: declare void @linkonceODRfuncAlias
-; IMPORT-DAG: declare void @linkonceODRfuncWeakODRAlias
-; IMPORT-DAG: declare void @linkonceODRfuncLinkonceODRAlias
-
-
-; On the import side, these aliases are not imported (they don't point to a linkonce_odr)
-; IMPORT-DAG: declare void @globalfuncAlias()
+; On the import side now, verify that aliases are imported unless they
+; are preemptible (non-ODR weak/linkonce).
+; IMPORT-DAG: declare void @linkonceODRfuncWeakAlias
+; IMPORT-DAG: declare void @linkonceODRfuncLinkonceAlias
+; IMPORT-DAG: define available_externally void @linkonceODRfuncAlias
+; IMPORT-DAG: define available_externally void @linkonceODRfuncWeakODRAlias
+; IMPORT-DAG: define available_externally void @linkonceODRfuncLinkonceODRAlias
+; IMPORT-DAG: define available_externally void @globalfuncAlias()
; IMPORT-DAG: declare void @globalfuncWeakAlias()
; IMPORT-DAG: declare void @globalfuncLinkonceAlias()
-; IMPORT-DAG: declare void @globalfuncWeakODRAlias()
-; IMPORT-DAG: declare void @globalfuncLinkonceODRAlias()
-; IMPORT-DAG: declare void @internalfuncAlias()
+; IMPORT-DAG: define available_externally void @globalfuncWeakODRAlias()
+; IMPORT-DAG: define available_externally void @globalfuncLinkonceODRAlias()
+; IMPORT-DAG: define available_externally void @internalfuncAlias()
; IMPORT-DAG: declare void @internalfuncWeakAlias()
; IMPORT-DAG: declare void @internalfuncLinkonceAlias()
-; IMPORT-DAG: declare void @internalfuncWeakODRAlias()
-; IMPORT-DAG: declare void @internalfuncLinkonceODRAlias()
-; IMPORT-DAG: declare void @weakODRfuncAlias()
+; IMPORT-DAG: define available_externally void @internalfuncWeakODRAlias()
+; IMPORT-DAG: define available_externally void @internalfuncLinkonceODRAlias()
+; IMPORT-DAG: define available_externally void @weakODRfuncAlias()
; IMPORT-DAG: declare void @weakODRfuncWeakAlias()
; IMPORT-DAG: declare void @weakODRfuncLinkonceAlias()
-; IMPORT-DAG: declare void @weakODRfuncWeakODRAlias()
-; IMPORT-DAG: declare void @weakODRfuncLinkonceODRAlias()
-; IMPORT-DAG: declare void @linkoncefuncAlias()
+; IMPORT-DAG: define available_externally void @weakODRfuncWeakODRAlias()
+; IMPORT-DAG: define available_externally void @weakODRfuncLinkonceODRAlias()
+; IMPORT-DAG: define available_externally void @linkoncefuncAlias()
; IMPORT-DAG: declare void @linkoncefuncWeakAlias()
; IMPORT-DAG: declare void @linkoncefuncLinkonceAlias()
-; IMPORT-DAG: declare void @linkoncefuncWeakODRAlias()
-; IMPORT-DAG: declare void @linkoncefuncLinkonceODRAlias()
-; IMPORT-DAG: declare void @weakfuncAlias()
+; IMPORT-DAG: define available_externally void @linkoncefuncWeakODRAlias()
+; IMPORT-DAG: define available_externally void @linkoncefuncLinkonceODRAlias()
+; IMPORT-DAG: define available_externally void @weakfuncAlias()
; IMPORT-DAG: declare void @weakfuncWeakAlias()
; IMPORT-DAG: declare void @weakfuncLinkonceAlias()
-; IMPORT-DAG: declare void @weakfuncWeakODRAlias()
-; IMPORT-DAG: declare void @weakfuncLinkonceODRAlias()
-; IMPORT-DAG: declare void @linkonceODRfuncAlias()
+; IMPORT-DAG: define available_externally void @weakfuncWeakODRAlias()
+; IMPORT-DAG: define available_externally void @weakfuncLinkonceODRAlias()
+; IMPORT-DAG: define available_externally void @linkonceODRfuncAlias()
; IMPORT-DAG: declare void @linkonceODRfuncWeakAlias()
-; IMPORT-DAG: declare void @linkonceODRfuncWeakODRAlias()
+; IMPORT-DAG: define available_externally void @linkonceODRfuncWeakODRAlias()
; IMPORT-DAG: declare void @linkonceODRfuncLinkonceAlias()
-; IMPORT-DAG: declare void @linkonceODRfuncLinkonceODRAlias()
+; IMPORT-DAG: define available_externally void @linkonceODRfuncLinkonceODRAlias()
define i32 @main() #0 {
entry:
diff --git a/llvm/test/ThinLTO/X86/distributed_import.ll b/llvm/test/ThinLTO/X86/distributed_import.ll
index e7e4904d52b..365fbd9b0f7 100644
--- a/llvm/test/ThinLTO/X86/distributed_import.ll
+++ b/llvm/test/ThinLTO/X86/distributed_import.ll
@@ -10,11 +10,15 @@
; RUN: llvm-lto2 run %t1.bc %t2.bc -o %t.o -save-temps \
; RUN: -thinlto-distributed-indexes \
; RUN: -r=%t1.bc,g, \
+; RUN: -r=%t1.bc,analias, \
; RUN: -r=%t1.bc,f,px \
-; RUN: -r=%t2.bc,g,px
-; RUN: opt -function-import -summary-file %t1.bc.thinlto.bc %t1.bc -o %t1.out
-; RUN: opt -function-import -summary-file %t2.bc.thinlto.bc %t2.bc -o %t2.out
-; RUN: llvm-dis -o - %t2.out | FileCheck %s
+; RUN: -r=%t2.bc,g,px \
+; RUN: -r=%t2.bc,analias,px \
+; RUN: -r=%t2.bc,aliasee,px
+; RUN: opt -function-import -import-all-index -summary-file %t1.bc.thinlto.bc %t1.bc -o %t1.out
+; RUN: opt -function-import -import-all-index -summary-file %t2.bc.thinlto.bc %t2.bc -o %t2.out
+; RUN: llvm-dis -o - %t1.out | FileCheck %s --check-prefix=IMPORT
+; RUN: llvm-dis -o - %t2.out | FileCheck %s --check-prefix=EXPORT
; Save the generated index files.
; RUN: cp %t1.bc.thinlto.bc %t1.bc.thinlto.bc.orig
@@ -34,26 +38,35 @@
; RUN: llvm-lto2 run %t1.bc %t2.bc -o %t.o -save-temps \
; RUN: -thinlto-distributed-indexes \
; RUN: -r=%t1.bc,g, \
+; RUN: -r=%t1.bc,analias, \
; RUN: -r=%t1.bc,f,px \
-; RUN: -r=%t2.bc,g,px
+; RUN: -r=%t2.bc,g,px \
+; RUN: -r=%t2.bc,analias,px \
+; RUN: -r=%t2.bc,aliasee,px
; RUN: diff %t1.bc.thinlto.bc.orig %t1.bc.thinlto.bc
; RUN: diff %t2.bc.thinlto.bc.orig %t2.bc.thinlto.bc
; Make sure importing occurs as expected
; RUN: cp %t1.bc.sv %t1.bc
; RUN: cp %t2.bc.sv %t2.bc
-; RUN: opt -function-import -summary-file %t2.bc.thinlto.bc %t2.bc -o %t2.out
-; RUN: llvm-dis -o - %t2.out | FileCheck %s
+; RUN: opt -function-import -import-all-index -summary-file %t1.bc.thinlto.bc %t1.bc -o %t1.out
+; RUN: opt -function-import -import-all-index -summary-file %t2.bc.thinlto.bc %t2.bc -o %t2.out
+; RUN: llvm-dis -o - %t1.out | FileCheck %s --check-prefix=IMPORT
+; RUN: llvm-dis -o - %t2.out | FileCheck %s --check-prefix=EXPORT
-; CHECK: @G.llvm.
+; IMPORT: define available_externally i32 @g() !thinlto_src_module
+; IMPORT: define available_externally void @analias() !thinlto_src_module
+; EXPORT: @G.llvm.
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
declare i32 @g(...)
+declare void @analias(...)
define void @f() {
entry:
call i32 (...) @g()
+ call void (...) @analias()
ret void
}
diff --git a/llvm/test/ThinLTO/X86/distributed_indexes.ll b/llvm/test/ThinLTO/X86/distributed_indexes.ll
index b81c94c2df8..d7e68ed5ecb 100644
--- a/llvm/test/ThinLTO/X86/distributed_indexes.ll
+++ b/llvm/test/ThinLTO/X86/distributed_indexes.ll
@@ -7,16 +7,22 @@
; The backend index for this module contains summaries from itself and
; Inputs/distributed_indexes.ll, as it imports from the latter.
+; We should import @g and alias @analias. While we don't import the aliasee
+; directly (and therefore don't have a third COMBINED record from module
+; id 1), we will have a VALUE_GUID for it (hence the 4 VALUE_GUID entries).
; BACKEND1: <MODULE_STRTAB_BLOCK
; BACKEND1-NEXT: <ENTRY {{.*}} record string = '{{.*}}distributed_indexes.ll.tmp{{.*}}.bc'
; BACKEND1-NEXT: <ENTRY {{.*}} record string = '{{.*}}distributed_indexes.ll.tmp{{.*}}.bc'
; BACKEND1-NEXT: </MODULE_STRTAB_BLOCK
; BACKEND1-NEXT: <GLOBALVAL_SUMMARY_BLOCK
; BACKEND1-NEXT: <VERSION
-; BACKEND1-NEXT: <VALUE_GUID op0={{1|2}} op1={{-3706093650706652785|-5300342847281564238}}
-; BACKEND1-NEXT: <VALUE_GUID op0={{1|2}} op1={{-3706093650706652785|-5300342847281564238}}
-; BACKEND1-NEXT: <COMBINED
-; BACKEND1-NEXT: <COMBINED
+; BACKEND1-DAG: <VALUE_GUID op0=2 op1=-5751648690987223394
+; BACKEND1-DAG: <VALUE_GUID op0=4 op1=-5300342847281564238
+; BACKEND1-DAG: <VALUE_GUID op0=1 op1=-3706093650706652785
+; BACKEND1-DAG: <VALUE_GUID op0=3 op1=-1039159065113703048
+; BACKEND1-DAG: <COMBINED {{.*}} op1=0
+; BACKEND1-DAG: <COMBINED {{.*}} op1=1
+; BACKEND1-DAG: <COMBINED_ALIAS {{.*}} op1=1
; BACKEND1-NEXT: </GLOBALVAL_SUMMARY_BLOCK
; The backend index for Input/distributed_indexes.ll contains summaries from
@@ -26,14 +32,20 @@
; BACKEND2-NEXT: </MODULE_STRTAB_BLOCK
; BACKEND2-NEXT: <GLOBALVAL_SUMMARY_BLOCK
; BACKEND2-NEXT: <VERSION
-; BACKEND2-NEXT: <VALUE_GUID op0=1 op1=-5300342847281564238
+; BACKEND2-DAG: <VALUE_GUID op0=1 op1=-5751648690987223394/>
+; BACKEND2-DAG: <VALUE_GUID op0=4 op1=-5300342847281564238/>
+; BACKEND2-DAG: <VALUE_GUID op0=3 op1=-1039159065113703048/>
; BACKEND2-NEXT: <COMBINED
+; BACKEND2-NEXT: <COMBINED
+; BACKEND2-NEXT: <COMBINED_ALIAS
; BACKEND2-NEXT: </GLOBALVAL_SUMMARY_BLOCK
declare void @g(...)
+declare void @analias(...)
define void @f() {
entry:
call void (...) @g()
+ call void (...) @analias()
ret void
}
diff --git a/llvm/test/ThinLTO/X86/funcimport.ll b/llvm/test/ThinLTO/X86/funcimport.ll
index f4c038f03e0..1e8784d7cac 100644
--- a/llvm/test/ThinLTO/X86/funcimport.ll
+++ b/llvm/test/ThinLTO/X86/funcimport.ll
@@ -16,17 +16,19 @@
; EXPORTSTATIC-DAG: define hidden i32 @staticfunc.llvm.0
; EXPORTSTATIC-DAG: define hidden void @staticfunc2.llvm.0
-; Ensure that both weak alias to an imported function and strong alias to a
-; non-imported function are correctly turned into declarations.
+; Ensure that weak alias to an imported function is correctly turned into
+; a declaration.
; Also ensures that alias to a linkonce function is turned into a declaration
; and that the associated linkonce function is not in the output, as it is
; lazily linked and never referenced/materialized.
; RUN: llvm-lto -thinlto-action=import %t2.bc -thinlto-index=%t3.bc -o - | llvm-dis -o - | FileCheck %s --check-prefix=IMPORTGLOB1
; IMPORTGLOB1-DAG: define available_externally void @globalfunc1
; IMPORTGLOB1-DAG: declare void @weakalias
-; IMPORTGLOB1-DAG: declare void @analias
; IMPORTGLOB1-NOT: @linkoncealias
; IMPORTGLOB1-NOT: @linkoncefunc
+
+; A strong alias is imported as an available_externally copy of its aliasee.
+; IMPORTGLOB1-DAG: define available_externally void @analias
; IMPORTGLOB1-NOT: declare void @globalfunc2
; Verify that the optimizer run
OpenPOWER on IntegriCloud