xref: /llvm-project/llvm/test/LTO/Resolution/X86/not-prevailing-alias.ll (revision 15655915b38600c28f58721950ae75e6284763b6)
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: FUNC    GLOBAL DEFAULT    2 zed
25; SYMBOLS: NOTYPE  GLOBAL DEFAULT  UND barAlias
26; SYMBOLS: NOTYPE  GLOBAL DEFAULT  UND varAlias
27
28target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
29target triple = "x86_64-unknown-linux-gnu"
30
31@barAlias = alias void(), ptr @bar
32define void @bar() {
33  ret void
34}
35
36@var = global i32 99
37@varAlias = alias i32, ptr @var
38
39define i32 @zed() {
40  call void @barAlias()
41  %1 = load i32, ptr @varAlias, align 4
42  ret i32 %1
43}
44