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 6 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 10 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 32 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 36; promoted. 37; NM0-DAG: d b 38; NM0-DAG: d x 39; NM0-DAG: t foo 40; NM0-DAG: T func1 41; NM0-DAG: T func2 42; NM0-DAG: T func3 43; NM0-DAG: T callglobalfunc 44; NM0-DAG: T callweakfunc 45; NM0-DAG: T globalfunc 46; NM0-DAG: W weakfunc 47 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. 54; NM1-NOT: foo 55; NM1-NOT: b 56; NM1-NOT: x 57; NM1-DAG: U func1 58; NM1-DAG: U func2 59; NM1-DAG: U func3 60; NM1-DAG: U globalfunc 61; NM1-DAG: U weakfunc 62; NM1-DAG: T main 63; NM1-NOT: foo 64; NM1-NOT: b 65; NM1-NOT: x 66 67target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" 68target triple = "x86_64-unknown-linux-gnu" 69 70@b = internal global i32 1, align 4 71@x = internal global i32 1, align 4 72 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" 75 76module asm "\09.text" 77module asm "\09.type\09foo,@function" 78module asm "foo:" 79module asm "\09movl b, %eax" 80module asm "\09movl x, %edx" 81module asm "\09ret " 82module asm "\09.size\09foo, .-foo" 83module asm "" 84module asm "\09.globl\09globalfunc" 85module asm "\09.type\09globalfunc,@function" 86module asm "globalfunc:" 87module asm "\09movl b, %eax" 88module asm "\09movl x, %edx" 89module asm "\09ret " 90module asm "\09.size\09globalfunc, .-globalfunc" 91module asm "" 92module asm "\09.weak\09weakfunc" 93module asm "\09.type\09weakfunc,@function" 94module asm "weakfunc:" 95module asm "\09movl b, %eax" 96module asm "\09movl x, %edx" 97module asm "\09ret " 98module asm "\09.size\09weakfunc, .-weakfunc" 99module asm "" 100 101declare i16 @foo() #0 102declare i16 @globalfunc() #0 103declare i16 @weakfunc() #0 104 105define i32 @func1() #1 { 106 call i16 @foo() 107 ret i32 1 108} 109 110define i32 @func2() #1 { 111 %1 = load i32, i32* @b, align 4 112 ret i32 %1 113} 114 115define i32 @func3() #1 { 116 %1 = load i32, i32* @x, align 4 117 ret i32 %1 118} 119 120define i32 @callglobalfunc() #1 { 121 call i16 @globalfunc() 122 ret i32 1 123} 124 125define i32 @callweakfunc() #1 { 126 call i16 @weakfunc() 127 ret i32 1 128} 129