summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorEugene Leviant <eleviant@accesssoftek.com>2018-02-16 08:11:04 +0000
committerEugene Leviant <eleviant@accesssoftek.com>2018-02-16 08:11:04 +0000
commit7331a0bf1c96a99bb47ecbdf9081e53f822eca66 (patch)
treed2f2927d5381f9c37e2039a8c86e56370fdfdf09 /llvm/test
parent3e2ae49a25f80a24e6cb5efdcb9c4caf42ba95ae (diff)
downloadbcm5719-llvm-7331a0bf1c96a99bb47ecbdf9081e53f822eca66.tar.gz
bcm5719-llvm-7331a0bf1c96a99bb47ecbdf9081e53f822eca66.zip
[ThinLTO] Import global variables
Differential revision: https://reviews.llvm.org/D43077 llvm-svn: 325320
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/ThinLTO/X86/Inputs/globals-import-cf-baz.ll4
-rw-r--r--llvm/test/ThinLTO/X86/globals-import-const-fold.ll23
-rw-r--r--llvm/test/Transforms/FunctionImport/funcimport.ll13
3 files changed, 38 insertions, 2 deletions
diff --git a/llvm/test/ThinLTO/X86/Inputs/globals-import-cf-baz.ll b/llvm/test/ThinLTO/X86/Inputs/globals-import-cf-baz.ll
new file mode 100644
index 00000000000..e41163063b4
--- /dev/null
+++ b/llvm/test/ThinLTO/X86/Inputs/globals-import-cf-baz.ll
@@ -0,0 +1,4 @@
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-pc-linux-gnu"
+
+@baz = local_unnamed_addr constant i32 10, align 4
diff --git a/llvm/test/ThinLTO/X86/globals-import-const-fold.ll b/llvm/test/ThinLTO/X86/globals-import-const-fold.ll
new file mode 100644
index 00000000000..49e31b79a47
--- /dev/null
+++ b/llvm/test/ThinLTO/X86/globals-import-const-fold.ll
@@ -0,0 +1,23 @@
+; RUN: opt -module-summary %s -o %t1.bc
+; RUN: opt -module-summary %p/Inputs/globals-import-cf-baz.ll -o %t2.bc
+; RUN: llvm-lto -thinlto-action=thinlink %t1.bc %t2.bc -o %t3.index.bc
+
+; RUN: llvm-lto -thinlto-action=import %t1.bc %t2.bc -thinlto-index=%t3.index.bc
+; RUN: llvm-dis %t1.bc.thinlto.imported.bc -o - | FileCheck --check-prefix=IMPORT %s
+; RUN: llvm-lto -thinlto-action=optimize %t1.bc.thinlto.imported.bc -o %t1.bc.thinlto.opt.bc
+; RUN: llvm-dis %t1.bc.thinlto.opt.bc -o - | FileCheck --check-prefix=OPTIMIZE %s
+
+; IMPORT: @baz = available_externally local_unnamed_addr constant i32 10
+
+; OPTIMIZE: define i32 @main()
+; OPTIMIZE-NEXT: ret i32 10
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-pc-linux-gnu"
+
+@baz = external local_unnamed_addr constant i32, align 4
+
+define i32 @main() local_unnamed_addr {
+ %1 = load i32, i32* @baz, align 4
+ ret i32 %1
+}
diff --git a/llvm/test/Transforms/FunctionImport/funcimport.ll b/llvm/test/Transforms/FunctionImport/funcimport.ll
index 4ff51a33b5e..bb974b587e3 100644
--- a/llvm/test/Transforms/FunctionImport/funcimport.ll
+++ b/llvm/test/Transforms/FunctionImport/funcimport.ll
@@ -7,7 +7,8 @@
; RUN: opt -function-import -stats -print-imports -enable-import-metadata -summary-file %t3.thinlto.bc %t.bc -S 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=INSTLIMDEF
; Try again with new pass manager
; RUN: opt -passes='function-import' -stats -print-imports -enable-import-metadata -summary-file %t3.thinlto.bc %t.bc -S 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=INSTLIMDEF
-; "-stats" requires +Asserts.
+; RUN: opt -passes='function-import' -debug-only=function-import -enable-import-metadata -summary-file %t3.thinlto.bc %t.bc -S 2>&1 | FileCheck %s --check-prefix=DUMP
+; "-stats" and "-debug-only" require +Asserts.
; REQUIRES: asserts
; Test import with smaller instruction limit
@@ -80,7 +81,7 @@ 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.{{.*}} = external hidden global void ()*
+; CHECK-DAG: @P.llvm.{{.*}} = available_externally hidden global void ()* null
; CHECK-DAG: %0 = load void ()*, void ()** @P.llvm.
; CHECK-DAG: store void ()* @staticfunc2.llvm.{{.*}}, void ()** @P.llvm.
@@ -107,6 +108,8 @@ declare void @variadic(...)
; INSTLIMDEF-DAG: Import globalfunc2
; INSTLIMDEF-DAG: 13 function-import - Number of functions imported
+; INSTLIMDEF-DAG: 4 function-import - Number of global variables imported
+
; CHECK-DAG: !0 = !{!"{{.*}}/Inputs/funcimport.ll"}
; The actual GUID values will depend on path to test.
@@ -142,3 +145,9 @@ declare void @variadic(...)
; GUID-DAG: GUID {{.*}} is linkoncealias
; GUID-DAG: GUID {{.*}} is callfuncptr
; GUID-DAG: GUID {{.*}} is linkoncefunc
+
+; DUMP: Module [[M1:.*]] imports from 1 module
+; DUMP-NEXT: 13 functions imported from [[M2:.*]]
+; DUMP-NEXT: 4 vars imported from [[M2]]
+; DUMP: Imported 13 functions for Module [[M1]]
+; DUMP-NEXT: Imported 4 global variables for Module [[M1]]
OpenPOWER on IntegriCloud