Skip to content

Commit 18415c8

Browse files
authored
[DebugInfo] Add debug info test for jump table (#71018)
Test whether jump table BB has debug info after ISel.
1 parent a533b76 commit 18415c8

File tree

1 file changed

+176
-0
lines changed

1 file changed

+176
-0
lines changed
Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
; RUN: llc -debug-only=isel %s -o /dev/null 2>&1 | FileCheck --match-full-lines %s
2+
3+
source_filename = "jump_table.c"
4+
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
5+
target triple = "x86_64-unknown-linux-gnu"
6+
7+
@str = private unnamed_addr constant [2 x i8] c"1\00", align 1
8+
@str.12 = private unnamed_addr constant [2 x i8] c"2\00", align 1
9+
@str.13 = private unnamed_addr constant [2 x i8] c"3\00", align 1
10+
@str.14 = private unnamed_addr constant [2 x i8] c"4\00", align 1
11+
@str.15 = private unnamed_addr constant [2 x i8] c"5\00", align 1
12+
@str.16 = private unnamed_addr constant [2 x i8] c"6\00", align 1
13+
@str.17 = private unnamed_addr constant [2 x i8] c"7\00", align 1
14+
@str.18 = private unnamed_addr constant [2 x i8] c"8\00", align 1
15+
@str.19 = private unnamed_addr constant [2 x i8] c"9\00", align 1
16+
@str.20 = private unnamed_addr constant [3 x i8] c"10\00", align 1
17+
@str.21 = private unnamed_addr constant [3 x i8] c"11\00", align 1
18+
@str.22 = private unnamed_addr constant [3 x i8] c"12\00", align 1
19+
20+
21+
22+
; Function Attrs: nofree nounwind uwtable
23+
define dso_local void @foo(i32 noundef %cond) local_unnamed_addr #0 !dbg !42 {
24+
;CHECK: Initial selection DAG: %bb.{{[0-9]+}} 'foo:entry'
25+
;CHECK: SelectionDAG has 5 nodes:
26+
;CHECK: [[TMP1:t.*]]: ch,glue = EntryToken
27+
;CHECK: [[TMP2:t.*]]: i64,ch = CopyFromReg [[TMP1]], Register:i64 %{{[0-9]+}}
28+
;CHECK: t{{[0-9]+}}: ch = br_jt [[TMP2]]:1, JumpTable:i64<0>, [[TMP2]]
29+
30+
entry:
31+
call void @llvm.dbg.value(metadata i32 %cond, metadata !47, metadata !DIExpression()), !dbg !48
32+
switch i32 %cond, label %sw.epilog [
33+
i32 1, label %sw.bb
34+
i32 2, label %sw.bb1
35+
i32 3, label %sw.bb3
36+
i32 4, label %sw.bb5
37+
i32 5, label %sw.bb7
38+
i32 6, label %sw.bb9
39+
i32 7, label %sw.bb11
40+
i32 8, label %sw.bb13
41+
i32 9, label %sw.bb15
42+
i32 10, label %sw.bb17
43+
i32 11, label %sw.bb19
44+
i32 12, label %sw.bb21
45+
], !dbg !49
46+
47+
sw.bb: ; preds = %entry
48+
%puts = tail call i32 @puts(ptr nonnull dereferenceable(1) @str), !dbg !50
49+
br label %sw.bb1, !dbg !50
50+
51+
sw.bb1: ; preds = %entry, %sw.bb
52+
%puts23 = tail call i32 @puts(ptr nonnull dereferenceable(1) @str.12), !dbg !52
53+
br label %sw.bb3, !dbg !52
54+
55+
sw.bb3: ; preds = %entry, %sw.bb1
56+
%puts24 = tail call i32 @puts(ptr nonnull dereferenceable(1) @str.13), !dbg !53
57+
br label %sw.bb5, !dbg !53
58+
59+
sw.bb5: ; preds = %entry, %sw.bb3
60+
%puts25 = tail call i32 @puts(ptr nonnull dereferenceable(1) @str.14), !dbg !54
61+
br label %sw.bb7, !dbg !54
62+
63+
sw.bb7: ; preds = %entry, %sw.bb5
64+
%puts26 = tail call i32 @puts(ptr nonnull dereferenceable(1) @str.15), !dbg !55
65+
br label %sw.bb9, !dbg !55
66+
67+
sw.bb9: ; preds = %entry, %sw.bb7
68+
%puts27 = tail call i32 @puts(ptr nonnull dereferenceable(1) @str.16), !dbg !56
69+
br label %sw.bb11, !dbg !56
70+
71+
sw.bb11: ; preds = %entry, %sw.bb9
72+
%puts28 = tail call i32 @puts(ptr nonnull dereferenceable(1) @str.17), !dbg !57
73+
br label %sw.bb13, !dbg !57
74+
75+
sw.bb13: ; preds = %entry, %sw.bb11
76+
%puts29 = tail call i32 @puts(ptr nonnull dereferenceable(1) @str.18), !dbg !58
77+
br label %sw.bb15, !dbg !58
78+
79+
sw.bb15: ; preds = %entry, %sw.bb13
80+
%puts30 = tail call i32 @puts(ptr nonnull dereferenceable(1) @str.19), !dbg !59
81+
br label %sw.bb17, !dbg !59
82+
83+
sw.bb17: ; preds = %entry, %sw.bb15
84+
%puts31 = tail call i32 @puts(ptr nonnull dereferenceable(1) @str.20), !dbg !60
85+
br label %sw.bb19, !dbg !60
86+
87+
sw.bb19: ; preds = %entry, %sw.bb17
88+
%puts32 = tail call i32 @puts(ptr nonnull dereferenceable(1) @str.21), !dbg !61
89+
br label %sw.bb21, !dbg !61
90+
91+
sw.bb21: ; preds = %entry, %sw.bb19
92+
%puts33 = tail call i32 @puts(ptr nonnull dereferenceable(1) @str.22), !dbg !62
93+
ret void, !dbg !63
94+
95+
sw.epilog: ; preds = %entry
96+
ret void, !dbg !63
97+
}
98+
99+
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
100+
declare void @llvm.dbg.value(metadata, metadata, metadata) #1
101+
102+
; Function Attrs: nofree nounwind
103+
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #2
104+
105+
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
106+
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
107+
attributes #2 = { nofree nounwind }
108+
109+
!llvm.dbg.cu = !{!0}
110+
!llvm.module.flags = !{!34, !35, !36, !37, !38, !39, !40}
111+
!llvm.ident = !{!41}
112+
113+
!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: "clang version 18.0.0 (https://github.com/llvm/llvm-project.git 24cf476bd6d144b9fa28325b4d16e3c9dbfc4d4f)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, globals: !2, splitDebugInlining: false, nameTableKind: None)
114+
!1 = !DIFile(filename: "jump_table.c", directory: "/export/compilers/llvm-project", checksumkind: CSK_MD5, checksum: "0847b70de02e07499cd0177d1bdc6dae")
115+
!2 = !{!3, !9, !11, !13, !15, !17, !19, !21, !23, !25, !30, !32}
116+
!3 = !DIGlobalVariableExpression(var: !4, expr: !DIExpression())
117+
!4 = distinct !DIGlobalVariable(scope: null, file: !1, line: 6, type: !5, isLocal: true, isDefinition: true)
118+
!5 = !DICompositeType(tag: DW_TAG_array_type, baseType: !6, size: 24, elements: !7)
119+
!6 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
120+
!7 = !{!8}
121+
!8 = !DISubrange(count: 3)
122+
!9 = !DIGlobalVariableExpression(var: !10, expr: !DIExpression())
123+
!10 = distinct !DIGlobalVariable(scope: null, file: !1, line: 8, type: !5, isLocal: true, isDefinition: true)
124+
!11 = !DIGlobalVariableExpression(var: !12, expr: !DIExpression())
125+
!12 = distinct !DIGlobalVariable(scope: null, file: !1, line: 10, type: !5, isLocal: true, isDefinition: true)
126+
!13 = !DIGlobalVariableExpression(var: !14, expr: !DIExpression())
127+
!14 = distinct !DIGlobalVariable(scope: null, file: !1, line: 12, type: !5, isLocal: true, isDefinition: true)
128+
!15 = !DIGlobalVariableExpression(var: !16, expr: !DIExpression())
129+
!16 = distinct !DIGlobalVariable(scope: null, file: !1, line: 14, type: !5, isLocal: true, isDefinition: true)
130+
!17 = !DIGlobalVariableExpression(var: !18, expr: !DIExpression())
131+
!18 = distinct !DIGlobalVariable(scope: null, file: !1, line: 16, type: !5, isLocal: true, isDefinition: true)
132+
!19 = !DIGlobalVariableExpression(var: !20, expr: !DIExpression())
133+
!20 = distinct !DIGlobalVariable(scope: null, file: !1, line: 18, type: !5, isLocal: true, isDefinition: true)
134+
!21 = !DIGlobalVariableExpression(var: !22, expr: !DIExpression())
135+
!22 = distinct !DIGlobalVariable(scope: null, file: !1, line: 20, type: !5, isLocal: true, isDefinition: true)
136+
!23 = !DIGlobalVariableExpression(var: !24, expr: !DIExpression())
137+
!24 = distinct !DIGlobalVariable(scope: null, file: !1, line: 22, type: !5, isLocal: true, isDefinition: true)
138+
!25 = !DIGlobalVariableExpression(var: !26, expr: !DIExpression())
139+
!26 = distinct !DIGlobalVariable(scope: null, file: !1, line: 24, type: !27, isLocal: true, isDefinition: true)
140+
!27 = !DICompositeType(tag: DW_TAG_array_type, baseType: !6, size: 32, elements: !28)
141+
!28 = !{!29}
142+
!29 = !DISubrange(count: 4)
143+
!30 = !DIGlobalVariableExpression(var: !31, expr: !DIExpression())
144+
!31 = distinct !DIGlobalVariable(scope: null, file: !1, line: 26, type: !27, isLocal: true, isDefinition: true)
145+
!32 = !DIGlobalVariableExpression(var: !33, expr: !DIExpression())
146+
!33 = distinct !DIGlobalVariable(scope: null, file: !1, line: 28, type: !27, isLocal: true, isDefinition: true)
147+
!34 = !{i32 7, !"Dwarf Version", i32 5}
148+
!35 = !{i32 2, !"Debug Info Version", i32 3}
149+
!36 = !{i32 1, !"wchar_size", i32 4}
150+
!37 = !{i32 8, !"PIC Level", i32 2}
151+
!38 = !{i32 7, !"PIE Level", i32 2}
152+
!39 = !{i32 7, !"uwtable", i32 2}
153+
!40 = !{i32 7, !"debug-info-assignment-tracking", i1 true}
154+
!41 = !{!"clang version 18.0.0 (https://github.com/llvm/llvm-project.git 24cf476bd6d144b9fa28325b4d16e3c9dbfc4d4f)"}
155+
!42 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 3, type: !43, scopeLine: 3, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !46)
156+
!43 = !DISubroutineType(types: !44)
157+
!44 = !{null, !45}
158+
!45 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
159+
!46 = !{!47}
160+
!47 = !DILocalVariable(name: "cond", arg: 1, scope: !42, file: !1, line: 3, type: !45)
161+
!48 = !DILocation(line: 0, scope: !42)
162+
!49 = !DILocation(line: 4, column: 3, scope: !42)
163+
!50 = !DILocation(line: 6, column: 5, scope: !51)
164+
!51 = distinct !DILexicalBlock(scope: !42, file: !1, line: 4, column: 17)
165+
!52 = !DILocation(line: 8, column: 5, scope: !51)
166+
!53 = !DILocation(line: 10, column: 5, scope: !51)
167+
!54 = !DILocation(line: 12, column: 5, scope: !51)
168+
!55 = !DILocation(line: 14, column: 5, scope: !51)
169+
!56 = !DILocation(line: 16, column: 5, scope: !51)
170+
!57 = !DILocation(line: 18, column: 5, scope: !51)
171+
!58 = !DILocation(line: 20, column: 5, scope: !51)
172+
!59 = !DILocation(line: 22, column: 5, scope: !51)
173+
!60 = !DILocation(line: 24, column: 5, scope: !51)
174+
!61 = !DILocation(line: 26, column: 5, scope: !51)
175+
!62 = !DILocation(line: 28, column: 5, scope: !51)
176+
!63 = !DILocation(line: 30, column: 1, scope: !42)

0 commit comments

Comments
 (0)