1 ; RUN: llc -mtriple=riscv32 --code-model=small \
2 ; RUN: -stop-after riscv-prera-expand-pseudo %s -o %t.mir
3 ; RUN: llc -mtriple=riscv32 -run-pass riscv-expand-pseudo %t.mir -o - | \
4 ; RUN: FileCheck %s -check-prefix=RV32-SMALL
6 ; RUN: llc -mtriple=riscv32 --code-model=medium --relocation-model=pic \
7 ; RUN: -stop-after riscv-prera-expand-pseudo %s -o %t.mir
8 ; RUN: llc -mtriple=riscv32 -run-pass riscv-expand-pseudo %t.mir -o - | \
9 ; RUN: FileCheck %s -check-prefix=RV32-MED
11 ; This tests the RISC-V-specific serialization and deserialization of
14 @g_e = external global i32
15 @g_i = internal global i32 0
16 @t_un = external thread_local global i32
17 @t_ld = external thread_local(localdynamic) global i32
18 @t_ie = external thread_local(initialexec) global i32
19 @t_le = external thread_local(localexec) global i32
21 declare i32 @callee(i32) nounwind
23 define i32 @caller(i32 %a) nounwind {
24 ; RV32-SMALL-LABEL: name: caller
25 ; RV32-SMALL: target-flags(riscv-hi) @g_e
26 ; RV32-SMALL-NEXT: target-flags(riscv-lo) @g_e
27 ; RV32-SMALL: target-flags(riscv-hi) @g_i
28 ; RV32-SMALL-NEXT: target-flags(riscv-lo) @g_i
29 ; RV32-SMALL: target-flags(riscv-tls-got-hi) @t_un
30 ; RV32-SMALL-NEXT: target-flags(riscv-pcrel-lo) <mcsymbol .Lpcrel_hi0>
31 ; RV32-SMALL: target-flags(riscv-tls-got-hi) @t_ld
32 ; RV32-SMALL-NEXT: target-flags(riscv-pcrel-lo) <mcsymbol .Lpcrel_hi1>
33 ; RV32-SMALL: target-flags(riscv-tls-got-hi) @t_ie
34 ; RV32-SMALL-NEXT: target-flags(riscv-pcrel-lo) <mcsymbol .Lpcrel_hi2>
35 ; RV32-SMALL: target-flags(riscv-tprel-hi) @t_le
36 ; RV32-SMALL-NEXT: target-flags(riscv-tprel-add) @t_le
37 ; RV32-SMALL-NEXT: target-flags(riscv-tprel-lo) @t_le
38 ; RV32-SMALL: target-flags(riscv-call) @callee
40 ; RV32-MED-LABEL: name: caller
41 ; RV32-MED: target-flags(riscv-got-hi) @g_e
42 ; RV32-MED-NEXT: target-flags(riscv-pcrel-lo) <mcsymbol .Lpcrel_hi0>
43 ; RV32-MED: target-flags(riscv-pcrel-hi) @g_i
44 ; RV32-MED-NEXT: target-flags(riscv-pcrel-lo) <mcsymbol .Lpcrel_hi1>
45 ; RV32-MED: target-flags(riscv-tls-gd-hi) @t_un
46 ; RV32-MED-NEXT: target-flags(riscv-pcrel-lo) <mcsymbol .Lpcrel_hi2>
47 ; RV32-MED: target-flags(riscv-call) &__tls_get_addr
48 ; RV32-MED: target-flags(riscv-tls-gd-hi) @t_ld
49 ; RV32-MED-NEXT: target-flags(riscv-pcrel-lo) <mcsymbol .Lpcrel_hi3>
50 ; RV32-MED: target-flags(riscv-call) &__tls_get_addr
51 ; RV32-MED: target-flags(riscv-tls-got-hi) @t_ie
52 ; RV32-MED-NEXT: target-flags(riscv-pcrel-lo) <mcsymbol .Lpcrel_hi4>
53 ; RV32-MED: target-flags(riscv-tprel-hi) @t_le
54 ; RV32-MED-NEXT: target-flags(riscv-tprel-add) @t_le
55 ; RV32-MED-NEXT: target-flags(riscv-tprel-lo) @t_le
56 ; RV32-MED: target-flags(riscv-call) @callee
58 %b = load i32, ptr @g_e
59 %c = load i32, ptr @g_i
60 %d = load i32, ptr @t_un
61 %e = load i32, ptr @t_ld
62 %f = load i32, ptr @t_ie
63 %g = load i32, ptr @t_le
64 %sum = bitcast i32 0 to i32
65 %sum.a = add i32 %sum, %a
66 %sum.b = add i32 %sum.a, %b
67 %sum.c = add i32 %sum.b, %c
68 %sum.d = add i32 %sum.c, %d
69 %sum.e = add i32 %sum.d, %e
70 %sum.f = add i32 %sum.e, %f
71 %sum.g = add i32 %sum.f, %g
72 %retval = call i32 @callee(i32 %sum.g)