Fix ThinLTO test: depends on the X86 backend
authorMehdi Amini <mehdi.amini@apple.com>
Wed, 9 Mar 2016 04:04:40 +0000 (04:04 +0000)
committerMehdi Amini <mehdi.amini@apple.com>
Wed, 9 Mar 2016 04:04:40 +0000 (04:04 +0000)
From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 262993

llvm/test/ThinLTO/Inputs/funcimport.ll [deleted file]
llvm/test/ThinLTO/X86/Inputs/funcimport.ll [new file with mode: 0644]
llvm/test/ThinLTO/X86/funcimport.ll [new file with mode: 0644]
llvm/test/ThinLTO/X86/lit.local.cfg [new file with mode: 0644]
llvm/test/ThinLTO/funcimport.ll [deleted file]

diff --git a/llvm/test/ThinLTO/Inputs/funcimport.ll b/llvm/test/ThinLTO/Inputs/funcimport.ll
deleted file mode 100644 (file)
index e0df9e0..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
-target triple = "x86_64-apple-macosx10.11.0"
-
-
-define i32 @main() #0 {
-entry:
-  call void (...) @weakalias()
-  call void (...) @analias()
-  %call = call i32 (...) @referencestatics()
-  %call1 = call i32 (...) @referenceglobals()
-  %call2 = call i32 (...) @referencecommon()
-  call void (...) @setfuncptr()
-  call void (...) @callfuncptr()
-  call void (...) @callweakfunc()
-  ret i32 0
-}
-
-declare void @weakalias(...) #1
-
-declare void @analias(...) #1
-
-declare i32 @referencestatics(...) #1
-
-declare i32 @referenceglobals(...) #1
-
-declare i32 @referencecommon(...) #1
-
-declare void @setfuncptr(...) #1
-
-declare void @callfuncptr(...) #1
-
-declare void @callweakfunc(...) #1
diff --git a/llvm/test/ThinLTO/X86/Inputs/funcimport.ll b/llvm/test/ThinLTO/X86/Inputs/funcimport.ll
new file mode 100644 (file)
index 0000000..e0df9e0
--- /dev/null
@@ -0,0 +1,32 @@
+target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-apple-macosx10.11.0"
+
+
+define i32 @main() #0 {
+entry:
+  call void (...) @weakalias()
+  call void (...) @analias()
+  %call = call i32 (...) @referencestatics()
+  %call1 = call i32 (...) @referenceglobals()
+  %call2 = call i32 (...) @referencecommon()
+  call void (...) @setfuncptr()
+  call void (...) @callfuncptr()
+  call void (...) @callweakfunc()
+  ret i32 0
+}
+
+declare void @weakalias(...) #1
+
+declare void @analias(...) #1
+
+declare i32 @referencestatics(...) #1
+
+declare i32 @referenceglobals(...) #1
+
+declare i32 @referencecommon(...) #1
+
+declare void @setfuncptr(...) #1
+
+declare void @callfuncptr(...) #1
+
+declare void @callweakfunc(...) #1
diff --git a/llvm/test/ThinLTO/X86/funcimport.ll b/llvm/test/ThinLTO/X86/funcimport.ll
new file mode 100644 (file)
index 0000000..98f7353
--- /dev/null
@@ -0,0 +1,139 @@
+; Do setup work for all below tests: generate bitcode and combined index
+; RUN: llvm-as -function-summary %s -o %t.bc
+; RUN: llvm-as -function-summary %p/Inputs/funcimport.ll -o %t2.bc
+; RUN: llvm-lto -thinlto-action=thinlink -o %t3.bc %t.bc %t2.bc
+
+; Ensure statics are promoted/renamed correctly from this file (all but
+; constant variable need promotion).
+; RUN: llvm-lto -thinlto-action=promote %t.bc -thinlto-index=%t3.bc -o - | llvm-dis -o - | FileCheck %s --check-prefix=EXPORTSTATIC
+; EXPORTSTATIC-DAG: @staticvar.llvm.0 = hidden global
+; EXPORTSTATIC-DAG: @staticconstvar = internal unnamed_addr constant
+; EXPORTSTATIC-DAG: @P.llvm.0 = hidden global void ()* null
+; 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.
+; 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
+; IMPORTGLOB1-NOT: declare void @globalfunc2
+
+; Verify that the optimizer run
+; RUN: llvm-lto -thinlto-action=optimize %t2.bc -o - | llvm-dis -o - | FileCheck %s --check-prefix=OPTIMIZED
+; OPTIMIZED: define i32 @main()
+
+; Verify that the codegen run
+; RUN: llvm-lto -thinlto-action=codegen %t2.bc -o - | llvm-nm -o - | FileCheck %s --check-prefix=CODEGEN
+; CODEGEN: T _main
+
+; Verify that all run together
+; RUN: llvm-lto -thinlto-action=run %t2.bc  %t.bc
+; RUN: llvm-nm -o - < %t.bc.thinlto.o | FileCheck %s --check-prefix=ALL
+; RUN: llvm-nm -o - < %t2.bc.thinlto.o | FileCheck %s --check-prefix=ALL2
+; ALL: T _callfuncptr
+; ALL2: T _main
+
+target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-apple-macosx10.11.0"
+
+@globalvar_in_section = global i32 1, align 4
+@globalvar = global i32 1, align 4
+@staticvar = internal global i32 1, align 4
+@staticvar2 = internal global i32 1, align 4
+@staticconstvar = internal unnamed_addr constant [2 x i32] [i32 10, i32 20], align 4
+@commonvar = common global i32 0, align 4
+@P = internal global void ()* null, align 8
+
+@weakalias = weak alias void (...), bitcast (void ()* @globalfunc1 to void (...)*)
+@analias = alias void (...), bitcast (void ()* @globalfunc2 to void (...)*)
+@linkoncealias = alias void (...), bitcast (void ()* @linkoncefunc to void (...)*)
+
+define void @globalfunc1() #0 {
+entry:
+  ret void
+}
+
+define void @globalfunc2() #0 {
+entry:
+  ret void
+}
+
+define linkonce_odr void @linkoncefunc() #0 {
+entry:
+  ret void
+}
+
+define i32 @referencestatics(i32 %i) #0 {
+entry:
+  %i.addr = alloca i32, align 4
+  store i32 %i, i32* %i.addr, align 4
+  %call = call i32 @staticfunc()
+  %0 = load i32, i32* @staticvar, align 4
+  %add = add nsw i32 %call, %0
+  %1 = load i32, i32* %i.addr, align 4
+  %idxprom = sext i32 %1 to i64
+  %arrayidx = getelementptr inbounds [2 x i32], [2 x i32]* @staticconstvar, i64 0, i64 %idxprom
+  %2 = load i32, i32* %arrayidx, align 4
+  %add1 = add nsw i32 %add, %2
+  ret i32 %add1
+}
+
+define i32 @referenceglobals(i32 %i) #0 {
+entry:
+  %i.addr = alloca i32, align 4
+  store i32 %i, i32* %i.addr, align 4
+  call void @globalfunc1()
+  %0 = load i32, i32* @globalvar, align 4
+  ret i32 %0
+}
+
+define i32 @referencecommon(i32 %i) #0 {
+entry:
+  %i.addr = alloca i32, align 4
+  store i32 %i, i32* %i.addr, align 4
+  %0 = load i32, i32* @commonvar, align 4
+  ret i32 %0
+}
+
+define void @setfuncptr() #0 {
+entry:
+  store void ()* @staticfunc2, void ()** @P, align 8
+  ret void
+}
+
+define void @callfuncptr() #0 {
+entry:
+  %0 = load void ()*, void ()** @P, align 8
+  call void %0()
+  ret void
+}
+
+@weakvar = weak global i32 1, align 4
+define weak void @weakfunc() #0 {
+entry:
+  ret void
+}
+
+define void @callweakfunc() #0 {
+entry:
+  call void @weakfunc()
+  ret void
+}
+
+define internal i32 @staticfunc() #0 {
+entry:
+  ret i32 1
+}
+
+define internal void @staticfunc2() #0 {
+entry:
+  %0 = load i32, i32* @staticvar2, align 4
+  ret void
+}
diff --git a/llvm/test/ThinLTO/X86/lit.local.cfg b/llvm/test/ThinLTO/X86/lit.local.cfg
new file mode 100644 (file)
index 0000000..b744761
--- /dev/null
@@ -0,0 +1,3 @@
+if not 'X86' in config.root.targets:
+  config.unsupported = True
+
diff --git a/llvm/test/ThinLTO/funcimport.ll b/llvm/test/ThinLTO/funcimport.ll
deleted file mode 100644 (file)
index 98f7353..0000000
+++ /dev/null
@@ -1,139 +0,0 @@
-; Do setup work for all below tests: generate bitcode and combined index
-; RUN: llvm-as -function-summary %s -o %t.bc
-; RUN: llvm-as -function-summary %p/Inputs/funcimport.ll -o %t2.bc
-; RUN: llvm-lto -thinlto-action=thinlink -o %t3.bc %t.bc %t2.bc
-
-; Ensure statics are promoted/renamed correctly from this file (all but
-; constant variable need promotion).
-; RUN: llvm-lto -thinlto-action=promote %t.bc -thinlto-index=%t3.bc -o - | llvm-dis -o - | FileCheck %s --check-prefix=EXPORTSTATIC
-; EXPORTSTATIC-DAG: @staticvar.llvm.0 = hidden global
-; EXPORTSTATIC-DAG: @staticconstvar = internal unnamed_addr constant
-; EXPORTSTATIC-DAG: @P.llvm.0 = hidden global void ()* null
-; 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.
-; 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
-; IMPORTGLOB1-NOT: declare void @globalfunc2
-
-; Verify that the optimizer run
-; RUN: llvm-lto -thinlto-action=optimize %t2.bc -o - | llvm-dis -o - | FileCheck %s --check-prefix=OPTIMIZED
-; OPTIMIZED: define i32 @main()
-
-; Verify that the codegen run
-; RUN: llvm-lto -thinlto-action=codegen %t2.bc -o - | llvm-nm -o - | FileCheck %s --check-prefix=CODEGEN
-; CODEGEN: T _main
-
-; Verify that all run together
-; RUN: llvm-lto -thinlto-action=run %t2.bc  %t.bc
-; RUN: llvm-nm -o - < %t.bc.thinlto.o | FileCheck %s --check-prefix=ALL
-; RUN: llvm-nm -o - < %t2.bc.thinlto.o | FileCheck %s --check-prefix=ALL2
-; ALL: T _callfuncptr
-; ALL2: T _main
-
-target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
-target triple = "x86_64-apple-macosx10.11.0"
-
-@globalvar_in_section = global i32 1, align 4
-@globalvar = global i32 1, align 4
-@staticvar = internal global i32 1, align 4
-@staticvar2 = internal global i32 1, align 4
-@staticconstvar = internal unnamed_addr constant [2 x i32] [i32 10, i32 20], align 4
-@commonvar = common global i32 0, align 4
-@P = internal global void ()* null, align 8
-
-@weakalias = weak alias void (...), bitcast (void ()* @globalfunc1 to void (...)*)
-@analias = alias void (...), bitcast (void ()* @globalfunc2 to void (...)*)
-@linkoncealias = alias void (...), bitcast (void ()* @linkoncefunc to void (...)*)
-
-define void @globalfunc1() #0 {
-entry:
-  ret void
-}
-
-define void @globalfunc2() #0 {
-entry:
-  ret void
-}
-
-define linkonce_odr void @linkoncefunc() #0 {
-entry:
-  ret void
-}
-
-define i32 @referencestatics(i32 %i) #0 {
-entry:
-  %i.addr = alloca i32, align 4
-  store i32 %i, i32* %i.addr, align 4
-  %call = call i32 @staticfunc()
-  %0 = load i32, i32* @staticvar, align 4
-  %add = add nsw i32 %call, %0
-  %1 = load i32, i32* %i.addr, align 4
-  %idxprom = sext i32 %1 to i64
-  %arrayidx = getelementptr inbounds [2 x i32], [2 x i32]* @staticconstvar, i64 0, i64 %idxprom
-  %2 = load i32, i32* %arrayidx, align 4
-  %add1 = add nsw i32 %add, %2
-  ret i32 %add1
-}
-
-define i32 @referenceglobals(i32 %i) #0 {
-entry:
-  %i.addr = alloca i32, align 4
-  store i32 %i, i32* %i.addr, align 4
-  call void @globalfunc1()
-  %0 = load i32, i32* @globalvar, align 4
-  ret i32 %0
-}
-
-define i32 @referencecommon(i32 %i) #0 {
-entry:
-  %i.addr = alloca i32, align 4
-  store i32 %i, i32* %i.addr, align 4
-  %0 = load i32, i32* @commonvar, align 4
-  ret i32 %0
-}
-
-define void @setfuncptr() #0 {
-entry:
-  store void ()* @staticfunc2, void ()** @P, align 8
-  ret void
-}
-
-define void @callfuncptr() #0 {
-entry:
-  %0 = load void ()*, void ()** @P, align 8
-  call void %0()
-  ret void
-}
-
-@weakvar = weak global i32 1, align 4
-define weak void @weakfunc() #0 {
-entry:
-  ret void
-}
-
-define void @callweakfunc() #0 {
-entry:
-  call void @weakfunc()
-  ret void
-}
-
-define internal i32 @staticfunc() #0 {
-entry:
-  ret i32 1
-}
-
-define internal void @staticfunc2() #0 {
-entry:
-  %0 = load i32, i32* @staticvar2, align 4
-  ret void
-}