Teresa Johnson | a081145 | 2016-11-10 16:57:32 +0000 | [diff] [blame^] | 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 %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 %t1.bc %t2.bc -o %t.o -save-temps \ |
| 12 | ; RUN: -r=%t1.bc,foo,plx \ |
| 13 | ; RUN: -r=%t1.bc,b,pl \ |
| 14 | ; RUN: -r=%t1.bc,x,pl \ |
| 15 | ; RUN: -r=%t1.bc,func1,pl \ |
| 16 | ; RUN: -r=%t1.bc,func2,pl \ |
| 17 | ; RUN: -r=%t1.bc,func3,pl \ |
| 18 | ; RUN: -r=%t2.bc,main,plx \ |
| 19 | ; RUN: -r=%t2.bc,func1,l \ |
| 20 | ; RUN: -r=%t2.bc,func2,l \ |
| 21 | ; RUN: -r=%t2.bc,func3,l |
| 22 | ; RUN: llvm-nm %t.o.0 | FileCheck %s --check-prefix=NM0 |
| 23 | ; RUN: llvm-nm %t.o.1 | FileCheck %s --check-prefix=NM1 |
| 24 | |
| 25 | ; Check that local values b and x, which are referenced on |
| 26 | ; llvm.used and llvm.compiler.used, respectively, are not promoted. |
| 27 | ; Similarly, foo which is defined in module level asm should not be |
| 28 | ; promoted. We have to check in the importing module, however, as we |
| 29 | ; don't currently generate a summary for values defined in module asm, |
| 30 | ; so they couldn't get promoted even if we exported a reference. |
| 31 | ; NM0-DAG: d b |
| 32 | ; NM0-DAG: d x |
| 33 | ; NM0-DAG: t foo |
| 34 | ; NM0-DAG: T func1 |
| 35 | ; NM0-DAG: T func2 |
| 36 | ; NM0-DAG: T func3 |
| 37 | |
| 38 | ; Ensure that b and x are likewise not exported (imported as refs |
| 39 | ; into the other module), since they can't be promoted. Additionally, |
| 40 | ; referencing functions func2 and func3 should not have been |
| 41 | ; imported. |
| 42 | ; FIXME: Likewise, foo should not be exported, along with referencing function |
| 43 | ; func1. However, this relies on being able to add a dependence from |
| 44 | ; libAnalysis to libObject, which is currently blocked (see revert of |
| 45 | ; r286297). |
| 46 | ; NM1-NOT: b |
| 47 | ; NM1-NOT: x |
| 48 | ; NM1-DAG: U func2 |
| 49 | ; NM1-DAG: U func3 |
| 50 | ; NM1-DAG: T main |
| 51 | ; NM1-NOT: b |
| 52 | ; NM1-NOT: x |
| 53 | |
| 54 | target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" |
| 55 | target triple = "x86_64-unknown-linux-gnu" |
| 56 | |
| 57 | @b = internal global i32 1, align 4 |
| 58 | @x = internal global i32 1, align 4 |
| 59 | |
| 60 | @llvm.compiler.used = appending global [1 x i8*] [i8* bitcast (i32* @b to i8*)], section "llvm.metadata" |
| 61 | @llvm.used = appending global [1 x i8*] [i8* bitcast (i32* @x to i8*)], section "llvm.metadata" |
| 62 | |
| 63 | module asm "\09.text" |
| 64 | module asm "\09.type\09foo,@function" |
| 65 | module asm "foo:" |
| 66 | module asm "\09movl b, %eax" |
| 67 | module asm "\09movl x, %edx" |
| 68 | module asm "\09ret " |
| 69 | module asm "\09.size\09foo, .-foo" |
| 70 | module asm "" |
| 71 | |
| 72 | declare i16 @foo() #0 |
| 73 | |
| 74 | define i32 @func1() #1 { |
| 75 | call i16 @foo() |
| 76 | ret i32 1 |
| 77 | } |
| 78 | |
| 79 | define i32 @func2() #1 { |
| 80 | %1 = load i32, i32* @b, align 4 |
| 81 | ret i32 %1 |
| 82 | } |
| 83 | |
| 84 | define i32 @func3() #1 { |
| 85 | %1 = load i32, i32* @x, align 4 |
| 86 | ret i32 %1 |
| 87 | } |