1 ; Test to ensure that uses and defs in module level asm are handled
2 ; appropriately. Specifically, we should conservatively block importing
3 ; of any references to these values, as they can't be renamed.
4 ; RUN: opt -module-summary %s -o %t1.bc
5 ; RUN: opt -module-summary %p/Inputs/module_asm2.ll -o %t2.bc
7 ; RUN: llvm-lto -thinlto-action=run -exported-symbol=main -exported-symbol=func1 -exported-symbol=func2 -exported-symbol=func3 -exported-symbol=callglobalfunc -exported-symbol=callweakfunc %t1.bc %t2.bc
8 ; RUN: llvm-nm %t1.bc.thinlto.o | FileCheck %s --check-prefix=NM0
9 ; RUN: llvm-nm %t2.bc.thinlto.o | FileCheck %s --check-prefix=NM1
11 ; RUN: llvm-lto2 run %t1.bc %t2.bc -o %t.o -save-temps \
12 ; RUN: -r=%t1.bc,foo,plx \
13 ; RUN: -r=%t1.bc,globalfunc,plx \
14 ; RUN: -r=%t1.bc,globalfunc,lx \
15 ; RUN: -r=%t1.bc,weakfunc,plx \
16 ; RUN: -r=%t1.bc,weakfunc,lx \
17 ; RUN: -r=%t1.bc,b,pl \
18 ; RUN: -r=%t1.bc,x,pl \
19 ; RUN: -r=%t1.bc,func1,pl \
20 ; RUN: -r=%t1.bc,func2,pl \
21 ; RUN: -r=%t1.bc,func3,pl \
22 ; RUN: -r=%t1.bc,callglobalfunc,plx \
23 ; RUN: -r=%t1.bc,callweakfunc,plx \
24 ; RUN: -r=%t2.bc,main,plx \
25 ; RUN: -r=%t2.bc,func1,l \
26 ; RUN: -r=%t2.bc,func2,l \
27 ; RUN: -r=%t2.bc,func3,l \
28 ; RUN: -r=%t2.bc,callglobalfunc,l \
29 ; RUN: -r=%t2.bc,callweakfunc,l
30 ; RUN: llvm-nm %t.o.1 | FileCheck %s --check-prefix=NM0
31 ; RUN: llvm-nm %t.o.2 | FileCheck %s --check-prefix=NM1
33 ; Check that local values b and x, which are referenced on
34 ; llvm.used and llvm.compiler.used, respectively, are not promoted.
35 ; Similarly, foo which is defined in module level asm should not be
43 ; NM0-DAG: T callglobalfunc
44 ; NM0-DAG: T callweakfunc
45 ; NM0-DAG: T globalfunc
48 ; Ensure that foo, b and x are likewise not exported (imported as refs
49 ; into the other module), since they can't be promoted. Additionally,
50 ; referencing functions func2 and func3 should not have been
51 ; imported. However, we should have been able to import callglobalfunc
52 ; and callweakfunc (leaving undefined symbols globalfunc and weakfunc)
53 ; since globalfunc and weakfunc were defined but not local in module asm.
60 ; NM1-DAG: U globalfunc
67 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
68 target triple = "x86_64-unknown-linux-gnu"
70 @b = internal global i32 1, align 4
71 @x = internal global i32 1, align 4
73 @llvm.compiler.used = appending global [1 x i8*] [i8* bitcast (i32* @b to i8*)], section "llvm.metadata"
74 @llvm.used = appending global [1 x i8*] [i8* bitcast (i32* @x to i8*)], section "llvm.metadata"
77 module asm "\09.type\09foo,@function"
79 module asm "\09movl b, %eax"
80 module asm "\09movl x, %edx"
82 module asm "\09.size\09foo, .-foo"
84 module asm "\09.globl\09globalfunc"
85 module asm "\09.type\09globalfunc,@function"
86 module asm "globalfunc:"
87 module asm "\09movl b, %eax"
88 module asm "\09movl x, %edx"
90 module asm "\09.size\09globalfunc, .-globalfunc"
92 module asm "\09.weak\09weakfunc"
93 module asm "\09.type\09weakfunc,@function"
94 module asm "weakfunc:"
95 module asm "\09movl b, %eax"
96 module asm "\09movl x, %edx"
98 module asm "\09.size\09weakfunc, .-weakfunc"
101 declare i16 @foo() #0
102 declare i16 @globalfunc() #0
103 declare i16 @weakfunc() #0
105 define i32 @func1() #1 {
110 define i32 @func2() #1 {
111 %1 = load i32, i32* @b, align 4
115 define i32 @func3() #1 {
116 %1 = load i32, i32* @x, align 4
120 define i32 @callglobalfunc() #1 {
121 call i16 @globalfunc()
125 define i32 @callweakfunc() #1 {