3 ; RUN: llvm-lto2 run -o %t.o %t.bc -save-temps \
8 ; RUN: llvm-readelf --symbols %t.o.0 | grep \.cfi_jt | FileCheck --check-prefix=CHECK-FULL-RE %s
9 ; RUN: llvm-objdump -dr %t.o.0 | FileCheck --check-prefix=CHECK-FULL-OD %s
10 ; RUN: llvm-dis %t.o.0.4.opt.bc -o - | FileCheck --check-prefix=CHECK-USED %s
12 ; RUN: opt -thinlto-bc -thinlto-split-lto-unit %s -o %t.bc
13 ; RUN: llvm-lto2 run -o %t.o %t.bc \
14 ; RUN: -r=%t.bc,a,px \
15 ; RUN: -r=%t.bc,b,px \
16 ; RUN: -r=%t.bc,c,px \
18 ; RUN: llvm-readelf --symbols %t.o.0 | grep \.cfi_jt | FileCheck --check-prefix=CHECK-THIN-RE %s
19 ; RUN: llvm-objdump -dr %t.o.0 | FileCheck --check-prefix=CHECK-THIN-OD %s
21 ; CHECK-FULL-RE: FUNC LOCAL DEFAULT {{[0-9]+}} a.cfi_jt
22 ; CHECK-FULL-RE-NEXT: FUNC LOCAL DEFAULT {{[0-9]+}} b.cfi_jt
23 ; CHECK-FULL-RE-NEXT: FUNC LOCAL DEFAULT {{[0-9]+}} c.cfi_jt
25 ; CHECK-THIN-RE: FUNC GLOBAL HIDDEN {{[0-9]+}} b.cfi_jt
26 ; CHECK-THIN-RE-NEXT: FUNC GLOBAL HIDDEN {{[0-9]+}} c.cfi_jt
27 ; CHECK-THIN-RE-NEXT: FUNC GLOBAL HIDDEN {{[0-9]+}} a.cfi_jt
29 ; CHECK-FULL-OD: a.cfi_jt>:
30 ; CHECK-FULL-OD: jmp {{.*}} <a.cfi_jt
31 ; CHECK-FULL-OD-NEXT: R_X86_64_PLT32 .La$local
32 ; CHECK-FULL-OD: b.cfi_jt>:
33 ; CHECK-FULL-OD: jmp {{.*}} <b.cfi_jt
34 ; CHECK-FULL-OD-NEXT: R_X86_64_PLT32 .Lb$local
35 ; CHECK-FULL-OD: c.cfi_jt>:
36 ; CHECK-FULL-OD: jmp {{.*}} <c.cfi_jt
37 ; CHECK-FULL-OD-NEXT: R_X86_64_PLT32 .Lc$local
39 ; CHECK-THIN-OD: b.cfi_jt>:
40 ; CHECK-THIN-OD: jmp {{.*}} <b.cfi_jt
41 ; CHECK-THIN-OD-NEXT: R_X86_64_PLT32 b
42 ; CHECK-THIN-OD: c.cfi_jt>:
43 ; CHECK-THIN-OD: jmp {{.*}} <c.cfi_jt
44 ; CHECK-THIN-OD-NEXT: R_X86_64_PLT32 c
45 ; CHECK-THIN-OD: a.cfi_jt>:
46 ; CHECK-THIN-OD: jmp {{.*}} <a.cfi_jt
47 ; CHECK-THIN-OD-NEXT: R_X86_64_PLT32 a
49 ; CHECK-USED: @llvm.used = appending global [3 x ptr] [ptr @a.cfi_jt, ptr @b.cfi_jt, ptr @c.cfi_jt], section "llvm.metadata"
51 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
52 target triple = "x86_64-unknown-linux-gnu"
54 @f = internal global [4 x ptr] [ptr @a, ptr @b, ptr @c, ptr null], align 16
56 define dso_local void @a() !type !5 !type !6 { ret void }
57 define dso_local void @b() !type !5 !type !6 { ret void }
58 define dso_local void @c() !type !5 !type !6 { ret void }
60 define dso_local void @d() !type !5 !type !6 {
62 %i = alloca i32, align 4
63 store i32 0, ptr %i, align 4
66 for.cond: ; preds = %for.inc, %entry
67 %0 = load i32, ptr %i, align 4
68 %idxprom = sext i32 %0 to i64
69 %arrayidx = getelementptr inbounds [4 x ptr], ptr @f, i64 0, i64 %idxprom
70 %1 = load ptr, ptr %arrayidx, align 8
71 %tobool = icmp ne ptr %1, null
72 br i1 %tobool, label %for.body, label %for.end
74 for.body: ; preds = %for.cond
75 %2 = load i32, ptr %i, align 4
76 %idxprom1 = sext i32 %2 to i64
77 %arrayidx2 = getelementptr inbounds [4 x ptr], ptr @f, i64 0, i64 %idxprom1
78 %3 = load ptr, ptr %arrayidx2, align 8
79 %4 = call i1 @llvm.type.test(ptr %3, metadata !"_ZTSFvvE"), !nosanitize !7
80 br i1 %4, label %cont, label %trap, !nosanitize !7
82 trap: ; preds = %for.body
83 call void @llvm.ubsantrap(i8 2), !nosanitize !7
84 unreachable, !nosanitize !7
86 cont: ; preds = %for.body
90 for.inc: ; preds = %cont
91 %5 = load i32, ptr %i, align 4
92 %inc = add nsw i32 %5, 1
93 store i32 %inc, ptr %i, align 4
96 for.end: ; preds = %for.cond
100 declare i1 @llvm.type.test(ptr, metadata)
101 declare void @llvm.ubsantrap(i8 immarg)
103 !llvm.module.flags = !{!0, !1, !2, !3}
105 !0 = !{i32 1, !"wchar_size", i32 4}
106 !1 = !{i32 4, !"CFI Canonical Jump Tables", i32 0}
107 !2 = !{i32 7, !"uwtable", i32 1}
108 !3 = !{i32 7, !"frame-pointer", i32 2}
109 !5 = !{i64 0, !"_ZTSFvvE"}
110 !6 = !{i64 0, !"_ZTSFvvE.generalized"}