1 ; Check that non-prevailing symbols in module inline assembly are discarded
2 ; during regular LTO otherwise the final symbol binding could be wrong.
4 ; RUN: split-file %s %t
5 ; RUN: opt %t/t1.ll -o %t1
6 ; RUN: opt %t/t2.ll -o %t2
7 ; RUN: opt %t/t3.ll -o %t3
8 ; RUN: opt %t/t4.ll -o %t4
10 ; RUN: llvm-lto2 run -o %to1 -save-temps %t1 %t2 \
11 ; RUN: -r %t1,foo,px \
14 ; RUN: llvm-dis < %to1.0.0.preopt.bc | FileCheck %s --check-prefix=ASM1
15 ; RUN: llvm-nm %to1.0 | FileCheck %s --check-prefix=SYM
16 ; RUN: llvm-objdump --no-print-imm-hex -d --disassemble-symbols=foo %to1.0 \
17 ; RUN: | FileCheck %s --check-prefix=DEF
19 ; RUN: llvm-lto2 run -o %to2 -save-temps %t2 %t3 \
21 ; RUN: -r %t2,bar,pl \
23 ; RUN: llvm-dis < %to2.0.0.preopt.bc | FileCheck %s --check-prefix=ASM2
24 ; RUN: llvm-nm %to2.0 | FileCheck %s --check-prefix=SYM
25 ; RUN: llvm-objdump --no-print-imm-hex -d --disassemble-symbols=foo %to2.0 \
26 ; RUN: | FileCheck %s --check-prefix=DEF
28 ; Check that ".symver" is properly handled.
29 ; RUN: llvm-lto2 run -o %to3 -save-temps %t4 \
32 ; RUN: -r %t4,foo@@VER1,px
33 ; RUN: llvm-dis < %to3.0.0.preopt.bc | FileCheck %s --check-prefix=ASM3
35 ; ASM1: module asm ".lto_discard foo"
36 ; ASM1-NEXT: module asm ".weak foo"
37 ; ASM1-NEXT: module asm ".equ foo,bar"
39 ; ASM2: module asm ".lto_discard foo"
40 ; ASM2-NEXT: module asm ".weak foo"
41 ; ASM2-NEXT: module asm ".equ foo,bar"
42 ; ASM2-NEXT: module asm ".lto_discard"
43 ; ASM2-NEXT: module asm " .global foo ; foo: leal 2(%rdi), %eax"
45 ; ASM3-NOT: module asm ".lto_discard foo"
49 ; DEF: leal 2(%rdi), %eax
52 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
53 target triple = "x86_64-unknown-linux-gnu"
55 define dso_local i32 @foo(i32 %0) {
56 %2 = add nsw i32 %0, 2
61 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
62 target triple = "x86_64-unknown-linux-gnu"
64 module asm ".weak foo"
65 module asm ".equ foo,bar"
67 @llvm.compiler.used = appending global [1 x ptr] [ptr @bar], section "llvm.metadata"
69 define internal i32 @bar(i32 %0) {
70 %2 = add nsw i32 %0, 1
75 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
76 target triple = "x86_64-unknown-linux-gnu"
78 module asm " .global foo ; foo: leal 2(%rdi), %eax"
81 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
82 target triple = "x86_64-unknown-linux-gnu"
84 module asm ".global foo"
85 module asm "foo: call bar"
86 module asm ".symver foo,foo@@@VER1"
87 module asm ".symver bar,bar@@@VER1"