brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.9 KiB · 7ab7847 Raw
129 lines · plain
1; Test to ensure that uses and defs in module level asm are handled2; appropriately. Specifically, we should conservatively block importing3; of any references to these values, as they can't be renamed.4; RUN: opt -module-summary %s -o %t1.bc5; RUN: opt -module-summary %p/Inputs/module_asm2.ll -o %t2.bc6 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.bc8; RUN:  llvm-nm %t1.bc.thinlto.o | FileCheck  %s --check-prefix=NM09; RUN:  llvm-nm %t2.bc.thinlto.o | FileCheck  %s --check-prefix=NM110 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,l30; RUN: llvm-nm %t.o.1 | FileCheck  %s --check-prefix=NM031; RUN: llvm-nm %t.o.2 | FileCheck  %s --check-prefix=NM132 33; Check that local values b and x, which are referenced on34; llvm.used and llvm.compiler.used, respectively, are not promoted.35; Similarly, foo which is defined in module level asm should not be36; promoted.37; NM0-DAG: d b38; NM0-DAG: d x39; NM0-DAG: t foo40; NM0-DAG: T func141; NM0-DAG: T func242; NM0-DAG: T func343; NM0-DAG: T callglobalfunc44; NM0-DAG: T callweakfunc45; NM0-DAG: T globalfunc46; NM0-DAG: W weakfunc47 48; Ensure that foo, b and x are likewise not exported (imported as refs49; into the other module), since they can't be promoted. Additionally,50; referencing functions func2 and func3 should not have been51; imported. However, we should have been able to import callglobalfunc52; and callweakfunc (leaving undefined symbols globalfunc and weakfunc)53; since globalfunc and weakfunc were defined but not local in module asm.54; NM1-NOT: foo55; NM1-NOT: b56; NM1-NOT: x57; NM1-DAG: U func158; NM1-DAG: U func259; NM1-DAG: U func360; NM1-DAG: U globalfunc61; NM1-DAG: U weakfunc62; NM1-DAG: T main63; NM1-NOT: foo64; NM1-NOT: b65; NM1-NOT: x66 67target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"68target triple = "x86_64-unknown-linux-gnu"69 70@b = internal global i32 1, align 471@x = internal global i32 1, align 472 73@llvm.compiler.used = appending global [1 x ptr] [ptr @b], section "llvm.metadata"74@llvm.used = appending global [1 x ptr] [ptr @x], 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() #0102declare i16 @globalfunc() #0103declare i16 @weakfunc() #0104 105define i32 @func1() #1 {106  call i16 @foo()107  ret i32 1108}109 110define i32 @func2() #1 {111  %1 = load i32, ptr @b, align 4112  ret i32 %1113}114 115define i32 @func3() #1 {116  %1 = load i32, ptr @x, align 4117  ret i32 %1118}119 120define i32 @callglobalfunc() #1 {121  call i16 @globalfunc()122  ret i32 1123}124 125define i32 @callweakfunc() #1 {126  call i16 @weakfunc()127  ret i32 1128}129