summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorMehdi Amini <mehdi.amini@apple.com>2016-04-20 04:17:36 +0000
committerMehdi Amini <mehdi.amini@apple.com>2016-04-20 04:17:36 +0000
commit2c719cc11781bba190687b3a68fea88d88e2fef8 (patch)
tree8a738579ecb02f262d0f6533b686d49307fab5f3 /llvm/test
parent48591dd98cd840e7add4615211691bf4bbb5640d (diff)
downloadbcm5719-llvm-2c719cc11781bba190687b3a68fea88d88e2fef8.tar.gz
bcm5719-llvm-2c719cc11781bba190687b3a68fea88d88e2fef8.zip
FunctionImport: make sure we always select the right callee in presence of alias
From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 266854
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/ThinLTO/X86/Inputs/select_right_alias_definition1.ll6
-rw-r--r--llvm/test/ThinLTO/X86/Inputs/select_right_alias_definition2.ll7
-rw-r--r--llvm/test/ThinLTO/X86/select_right_alias_definition.ll27
3 files changed, 40 insertions, 0 deletions
diff --git a/llvm/test/ThinLTO/X86/Inputs/select_right_alias_definition1.ll b/llvm/test/ThinLTO/X86/Inputs/select_right_alias_definition1.ll
new file mode 100644
index 00000000000..cc19b038b06
--- /dev/null
+++ b/llvm/test/ThinLTO/X86/Inputs/select_right_alias_definition1.ll
@@ -0,0 +1,6 @@
+
+@foo = weak alias i32 (...), bitcast (i32 ()* @foo1 to i32 (...)*)
+
+define i32 @foo1() {
+ ret i32 42
+} \ No newline at end of file
diff --git a/llvm/test/ThinLTO/X86/Inputs/select_right_alias_definition2.ll b/llvm/test/ThinLTO/X86/Inputs/select_right_alias_definition2.ll
new file mode 100644
index 00000000000..9c5c0386e0f
--- /dev/null
+++ b/llvm/test/ThinLTO/X86/Inputs/select_right_alias_definition2.ll
@@ -0,0 +1,7 @@
+
+@foo = alias i32 (...), bitcast (i32 ()* @foo2 to i32 (...)*)
+
+define linkonce_odr i32 @foo2() {
+ %ret = add i32 42, 42
+ ret i32 %ret
+} \ No newline at end of file
diff --git a/llvm/test/ThinLTO/X86/select_right_alias_definition.ll b/llvm/test/ThinLTO/X86/select_right_alias_definition.ll
new file mode 100644
index 00000000000..48ae4cfa394
--- /dev/null
+++ b/llvm/test/ThinLTO/X86/select_right_alias_definition.ll
@@ -0,0 +1,27 @@
+; RUN: opt -module-summary %s -o %t_main.bc
+; RUN: opt -module-summary %p/Inputs/select_right_alias_definition1.ll -o %t1.bc
+; RUN: opt -module-summary %p/Inputs/select_right_alias_definition2.ll -o %t2.bc
+
+; Make sure that we always select the right definition for alia foo, whatever
+; order the files are linked in.
+
+; Try with one order
+; RUN: llvm-lto -thinlto-action=thinlink -o %t.index1.bc %t_main.bc %t1.bc %t2.bc
+; RUN: llvm-lto -thinlto-action=import -thinlto-index %t.index1.bc %t_main.bc -o - | llvm-dis -o - | FileCheck %s --check-prefix=IMPORT
+
+; Try with the other order (reversing %t1.bc and %t2.bc)
+; RUN: llvm-lto -thinlto-action=thinlink -o %t.index2.bc %t_main.bc %t2.bc %t1.bc
+; RUN: llvm-lto -thinlto-action=import -thinlto-index %t.index2.bc %t_main.bc -o - | llvm-dis -o - | FileCheck %s --check-prefix=IMPORT
+
+; IMPORT: @foo = alias i32 (...), bitcast (i32 ()* @foo2 to i32 (...)*)
+; IMPORT: define linkonce_odr i32 @foo2() {
+; IMPORT-NEXT: %ret = add i32 42, 42
+; IMPORT-NEXT: ret i32 %ret
+; IMPORT-NEXT: }
+
+declare i32 @foo()
+
+define i32 @main() {
+ %ret = call i32 @foo()
+ ret i32 %ret
+} \ No newline at end of file
OpenPOWER on IntegriCloud