Skip to content

Commit ab07e40

Browse files
author
Alex B
committed
More comprehensive test
1 parent 662dcec commit ab07e40

File tree

1 file changed

+102
-61
lines changed

1 file changed

+102
-61
lines changed
Lines changed: 102 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,123 @@
1-
; RUN: llc -mtriple=i686-w64-mingw32 -o %t -filetype=obj %s
2-
; RUN: llvm-dwarfdump -v -all %t | FileCheck %s -check-prefix=NO_STMT_SEQ
1+
; RUN: llc -O3 -mtriple=i686-w64-mingw32 -o %t_no -filetype=obj %s
2+
; RUN: llvm-dwarfdump -v -all %t_no | FileCheck %s -check-prefix=NO_STMT_SEQ
33

4-
; RUN: llc -mtriple=i686-w64-mingw32 -o %t -filetype=obj %s -emit-func-debug-line-table-offsets
5-
; RUN: llvm-dwarfdump -v -all %t | FileCheck %s -check-prefix=STMT_SEQ
4+
; RUN: llc -O3 -mtriple=i686-w64-mingw32 -o %t_yes -filetype=obj %s -emit-func-debug-line-table-offsets
5+
; RUN: llvm-dwarfdump -v -all %t_yes | FileCheck %s -check-prefix=STMT_SEQ
66

77
; NO_STMT_SEQ-NOT: DW_AT_LLVM_stmt_sequence
88

9-
; STMT_SEQ: [[[ABBREV_CODE:[0-9]+]]] DW_TAG_subprogram
9+
; STMT_SEQ: [[[ABBREV_CODE1:[0-9]+]]] DW_TAG_subprogram
1010
; STMT_SEQ: DW_AT_LLVM_stmt_sequence DW_FORM_sec_offset
11-
; STMT_SEQ: DW_TAG_subprogram [[[ABBREV_CODE]]]
12-
; STMT_SEQ: DW_AT_LLVM_stmt_sequence [DW_FORM_sec_offset] (0x00000028)
11+
; STMT_SEQ: [[[ABBREV_CODE2:[0-9]+]]] DW_TAG_subprogram
12+
; STMT_SEQ: DW_AT_LLVM_stmt_sequence DW_FORM_sec_offset
13+
; STMT_SEQ: DW_TAG_subprogram [[[ABBREV_CODE1]]]
14+
; STMT_SEQ: DW_AT_LLVM_stmt_sequence [DW_FORM_sec_offset] (0x00000043)
1315
; STMT_SEQ: DW_AT_name {{.*}}func01
14-
; STMT_SEQ: DW_TAG_subprogram [[[ABBREV_CODE]]]
15-
; STMT_SEQ: DW_AT_LLVM_stmt_sequence [DW_FORM_sec_offset] (0x00000036)
16+
; STMT_SEQ: DW_TAG_subprogram [[[ABBREV_CODE2]]]
17+
; STMT_SEQ: DW_AT_LLVM_stmt_sequence [DW_FORM_sec_offset] (0x00000056)
1618
; STMT_SEQ: DW_AT_name {{.*}}main
1719

18-
;; Check that the line table starts at 0x00000028 (first function)
19-
; STMT_SEQ: Address Line Column File ISA Discriminator OpIndex Flags
20-
; STMT_SEQ-NEXT: ------------------ ------ ------ ------ --- ------------- ------- -------------
21-
; STMT_SEQ-NEXT: 0x00000028: 05 DW_LNS_set_column (3)
22-
23-
;; Check that we have an 'end_sequence' just before the next function (0x00000036)
24-
; STMT_SEQ: 0x0000000000000000 2 3 1 0 0 0 is_stmt end_sequence
25-
; STMT_SEQ-NEXT: 0x00000036: 00 DW_LNE_set_address (0x00000010)
26-
27-
;; Check that the end of the line table still has an 'end_sequence'
28-
; STMT_SEQ 0x00000047: 00 DW_LNE_end_sequence
29-
; STMT_SEQ-NEXT 0x0000000000000027 6 3 1 0 0 0 end_sequence
30-
20+
;; Check the entire line sequence to see that it's correct
21+
; STMT_SEQ: Address Line Column File ISA Discriminator OpIndex Flags
22+
; STMT_SEQ-NEXT: ------------------ ------ ------ ------ --- ------------- ------- -------------
23+
; STMT_SEQ-NEXT: 0x00000043: 04 DW_LNS_set_file (0)
24+
; STMT_SEQ-NEXT: 0x00000045: 05 DW_LNS_set_column (9)
25+
; STMT_SEQ-NEXT: 0x00000047: 0a DW_LNS_set_prologue_end
26+
; STMT_SEQ-NEXT: 0x00000048: 00 DW_LNE_set_address (0x00000000)
27+
; STMT_SEQ-NEXT: 0x0000004f: 16 address += 0, line += 4, op-index += 0
28+
; STMT_SEQ-NEXT: 0x0000000000000000 5 9 0 0 0 0 is_stmt prologue_end
29+
; STMT_SEQ-NEXT: 0x00000050: 05 DW_LNS_set_column (3)
30+
; STMT_SEQ-NEXT: 0x00000052: 67 address += 6, line += 1, op-index += 0
31+
; STMT_SEQ-NEXT: 0x0000000000000006 6 3 0 0 0 0 is_stmt
32+
; STMT_SEQ-NEXT: 0x00000053: 00 DW_LNE_end_sequence
33+
; STMT_SEQ-NEXT: 0x0000000000000006 6 3 0 0 0 0 is_stmt end_sequence
34+
; STMT_SEQ-NEXT: 0x00000056: 04 DW_LNS_set_file (0)
35+
; STMT_SEQ-NEXT: 0x00000058: 00 DW_LNE_set_address (0x00000008)
36+
; STMT_SEQ-NEXT: 0x0000005f: 03 DW_LNS_advance_line (10)
37+
; STMT_SEQ-NEXT: 0x00000061: 01 DW_LNS_copy
38+
; STMT_SEQ-NEXT: 0x0000000000000008 10 0 0 0 0 0 is_stmt
39+
; STMT_SEQ-NEXT: 0x00000062: 05 DW_LNS_set_column (10)
40+
; STMT_SEQ-NEXT: 0x00000064: 0a DW_LNS_set_prologue_end
41+
; STMT_SEQ-NEXT: 0x00000065: 83 address += 8, line += 1, op-index += 0
42+
; STMT_SEQ-NEXT: 0x0000000000000010 11 10 0 0 0 0 is_stmt prologue_end
43+
; STMT_SEQ-NEXT: 0x00000066: 05 DW_LNS_set_column (3)
44+
; STMT_SEQ-NEXT: 0x00000068: 9f address += 10, line += 1, op-index += 0
45+
; STMT_SEQ-NEXT: 0x000000000000001a 12 3 0 0 0 0 is_stmt
46+
; STMT_SEQ-NEXT: 0x00000069: 02 DW_LNS_advance_pc (addr += 5, op-index += 0)
47+
; STMT_SEQ-NEXT: 0x0000006b: 00 DW_LNE_end_sequence
48+
; STMT_SEQ-NEXT: 0x000000000000001f 12 3 0 0 0 0 is_stmt end_sequence
3149

3250
; generated from:
33-
; clang -g -S -emit-llvm test.c -o test.ll
51+
; clang -Oz -g -S -emit-llvm test.c -o test.ll
3452
; ======= test.c ======
35-
; int func01() {
53+
; volatile int g_var1 = 1;
54+
; #define ATTR __attribute__((noinline))
55+
; ATTR int func01() {
56+
; g_var1++;
57+
; func01();
3658
; return 1;
3759
; }
38-
; int main() {
39-
; return 0;
60+
; ATTR int main() {
61+
; g_var1 = 100;
62+
; func01();
63+
; g_var1--;
64+
; return g_var1;
4065
; }
4166
; =====================
4267

4368

4469
; ModuleID = 'test.c'
4570
source_filename = "test.c"
46-
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
47-
target triple = "arm64-apple-macosx14.0.0"
48-
49-
; Function Attrs: noinline nounwind optnone ssp uwtable(sync)
50-
define i32 @func01() #0 !dbg !9 {
51-
ret i32 1, !dbg !13
71+
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"
72+
target triple = "x86_64-unknown-linux-gnu"
73+
@g_var1 = dso_local global i32 1, align 4, !dbg !0
74+
; Function Attrs: minsize nofree noinline norecurse noreturn nounwind optsize memory(readwrite, argmem: none) uwtable
75+
define dso_local noundef i32 @func01() local_unnamed_addr #0 !dbg !14 {
76+
entry:
77+
br label %tailrecurse
78+
tailrecurse: ; preds = %tailrecurse, %entry
79+
%0 = load volatile i32, ptr @g_var1, align 4, !dbg !17, !tbaa !18
80+
%inc = add nsw i32 %0, 1, !dbg !17
81+
store volatile i32 %inc, ptr @g_var1, align 4, !dbg !17, !tbaa !18
82+
br label %tailrecurse, !dbg !22
5283
}
53-
54-
; Function Attrs: noinline nounwind optnone ssp uwtable(sync)
55-
define i32 @main() #0 !dbg !14 {
56-
%1 = alloca i32, align 4
57-
store i32 0, ptr %1, align 4
58-
ret i32 0, !dbg !15
84+
; Function Attrs: minsize nofree noinline norecurse noreturn nounwind optsize uwtable
85+
define dso_local noundef i32 @main() local_unnamed_addr #1 !dbg !23 {
86+
entry:
87+
store volatile i32 100, ptr @g_var1, align 4, !dbg !24, !tbaa !18
88+
%call = tail call i32 @func01() #2, !dbg !25
89+
unreachable, !dbg !26
5990
}
60-
61-
attributes #0 = { noinline nounwind optnone ssp uwtable(sync) "frame-pointer"="non-leaf" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="apple-m1" "target-features"="+aes,+crc,+dotprod,+fp-armv8,+fp16fml,+fullfp16,+lse,+neon,+ras,+rcpc,+rdm,+sha2,+sha3,+v8.1a,+v8.2a,+v8.3a,+v8.4a,+v8.5a,+v8a,+zcm,+zcz" }
62-
63-
!llvm.dbg.cu = !{!0}
64-
!llvm.module.flags = !{!2, !3, !4, !5, !6, !7}
65-
!llvm.ident = !{!8}
66-
67-
!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: "Homebrew clang version 17.0.6", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: Apple, sysroot: "/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk", sdk: "MacOSX14.sdk")
68-
!1 = !DIFile(filename: "test.c", directory: "/tmp/clang_test")
69-
!2 = !{i32 7, !"Dwarf Version", i32 4}
70-
!3 = !{i32 2, !"Debug Info Version", i32 3}
71-
!4 = !{i32 1, !"wchar_size", i32 4}
72-
!5 = !{i32 8, !"PIC Level", i32 2}
73-
!6 = !{i32 7, !"uwtable", i32 1}
74-
!7 = !{i32 7, !"frame-pointer", i32 1}
75-
!8 = !{!"Homebrew clang version 17.0.6"}
76-
!9 = distinct !DISubprogram(name: "func01", scope: !1, file: !1, line: 1, type: !10, scopeLine: 1, spFlags: DISPFlagDefinition, unit: !0)
77-
!10 = !DISubroutineType(types: !11)
78-
!11 = !{!12}
79-
!12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
80-
!13 = !DILocation(line: 2, column: 3, scope: !9)
81-
!14 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 5, type: !10, scopeLine: 5, spFlags: DISPFlagDefinition, unit: !0)
82-
!15 = !DILocation(line: 6, column: 3, scope: !14)
91+
attributes #0 = { minsize nofree noinline norecurse noreturn nounwind optsize memory(readwrite, argmem: none) 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" }
92+
attributes #1 = { minsize nofree noinline norecurse noreturn nounwind optsize 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" }
93+
attributes #2 = { minsize optsize }
94+
!llvm.dbg.cu = !{!2}
95+
!llvm.module.flags = !{!7, !8, !9, !10, !11, !12}
96+
!llvm.ident = !{!13}
97+
!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
98+
!1 = distinct !DIGlobalVariable(name: "g_var1", scope: !2, file: !3, line: 1, type: !5, isLocal: false, isDefinition: true)
99+
!2 = distinct !DICompileUnit(language: DW_LANG_C11, file: !3, producer: "clang version 20.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, globals: !4, splitDebugInlining: false, nameTableKind: None)
100+
!3 = !DIFile(filename: "test.c", directory: "/tmp/tst", checksumkind: CSK_MD5, checksum: "eee003eb3c4fd0a1ff078d3148679e06")
101+
!4 = !{!0}
102+
!5 = !DIDerivedType(tag: DW_TAG_volatile_type, baseType: !6)
103+
!6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
104+
!7 = !{i32 7, !"Dwarf Version", i32 5}
105+
!8 = !{i32 2, !"Debug Info Version", i32 3}
106+
!9 = !{i32 1, !"wchar_size", i32 4}
107+
!10 = !{i32 8, !"PIC Level", i32 2}
108+
!11 = !{i32 7, !"PIE Level", i32 2}
109+
!12 = !{i32 7, !"uwtable", i32 2}
110+
!13 = !{!"clang version 20.0.0"}
111+
!14 = distinct !DISubprogram(name: "func01", scope: !3, file: !3, line: 4, type: !15, scopeLine: 4, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2)
112+
!15 = !DISubroutineType(types: !16)
113+
!16 = !{!6}
114+
!17 = !DILocation(line: 5, column: 9, scope: !14)
115+
!18 = !{!19, !19, i64 0}
116+
!19 = !{!"int", !20, i64 0}
117+
!20 = !{!"omnipotent char", !21, i64 0}
118+
!21 = !{!"Simple C/C++ TBAA"}
119+
!22 = !DILocation(line: 6, column: 3, scope: !14)
120+
!23 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 10, type: !15, scopeLine: 10, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2)
121+
!24 = !DILocation(line: 11, column: 10, scope: !23)
122+
!25 = !DILocation(line: 12, column: 3, scope: !23)
123+
!26 = !DILocation(line: 13, column: 9, scope: !23)

0 commit comments

Comments
 (0)