Teresa Johnson | 5a95c47 | 2018-02-05 15:44:27 +0000 | [diff] [blame] | 1 | ; Test to ensure that dead alias are dropped by converting to a declaration |
| 2 | ; RUN: opt -module-summary %s -o %t1.bc |
| 3 | ; RUN: llvm-lto2 run %t1.bc -r %t1.bc,barAlias,x \ |
| 4 | ; RUN: -r %t1.bc,bar,x -r %t1.bc,zed,px \ |
| 5 | ; RUN: -r %t1.bc,var,x -r %t1.bc,varAlias,x \ |
| 6 | ; RUN: -o %t2.o -save-temps |
| 7 | |
| 8 | ; Check that bar and barAlias were dropped to declarations |
| 9 | ; RUN: llvm-dis %t2.o.1.1.promote.bc -o - | FileCheck %s --check-prefix=DROP |
| 10 | ; DROP-DAG: declare void @bar() |
| 11 | ; DROP-DAG: declare void @barAlias() |
| 12 | ; DROP-DAG: @var = external global i32 |
| 13 | ; DROP-DAG: @varAlias = external global i32 |
| 14 | |
| 15 | ; Check that 'barAlias' and 'varAlias' were not inlined. |
| 16 | ; RUN: llvm-objdump -d %t2.o.1 | FileCheck %s |
| 17 | ; CHECK: zed: |
| 18 | ; CHECK-NEXT: {{.*}} pushq |
| 19 | ; CHECK-NEXT: {{.*}} callq 0 |
| 20 | ; CHECK-NEXT: movq (%rip), %rax |
| 21 | |
| 22 | ; Check that 'barAlias' and 'varAlias' produced as undefined. |
| 23 | ; RUN: llvm-readelf --symbols %t2.o.1 | FileCheck %s --check-prefix=SYMBOLS |
| 24 | ; SYMBOLS: NOTYPE GLOBAL DEFAULT UND barAlias |
| 25 | ; SYMBOLS: NOTYPE GLOBAL DEFAULT UND varAlias |
| 26 | ; SYMBOLS: FUNC GLOBAL DEFAULT 2 zed |
| 27 | |
| 28 | target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" |
| 29 | target triple = "x86_64-unknown-linux-gnu" |
| 30 | |
| 31 | @barAlias = alias void(), void()* @bar |
| 32 | define void @bar() { |
| 33 | ret void |
| 34 | } |
| 35 | |
| 36 | @var = global i32 99 |
| 37 | @varAlias = alias i32, i32* @var |
| 38 | |
| 39 | define i32 @zed() { |
| 40 | call void @barAlias() |
| 41 | %1 = load i32, i32* @varAlias, align 4 |
| 42 | ret i32 %1 |
| 43 | } |