xref: /llvm-project/bolt/test/X86/dwarf-debug-line-stmt-list-offset-change.test (revision bb6a4850553dd4140a5bd63187ec1b14d0b731f9)
1# REQUIRES: system-linux
2
3## Check that BOLT updates DW_AT_stmt_list correctly for TUs when both objects are built with DWARF5.
4
5# RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-debug-line-offset-change-after-bolt-main.s -o %tmain.o
6# RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf4-types-dwarf5-types-helper.s -o %thelper.o
7# RUN: %clang %cflags %tmain.o %thelper.o -o %t.exe -Wl,-q
8# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections --lite=0 --reorder-blocks=reverse
9# RUN: llvm-dwarfdump --debug-info -r 0 %t.exe > %tlogOffsetNotEqual.txt
10# RUN: llvm-dwarfdump --debug-info -r 0 %t.bolt >> %tlogOffsetNotEqual.txt
11# RUN: llvm-dwarfdump --debug-info -r 0 --debug-line %t.bolt > %tlogCheckLineTable.txt
12# RUN: cat %tlogOffsetNotEqual.txt | FileCheck --check-prefix=CHECK1 %s
13# RUN: cat %tlogCheckLineTable.txt | FileCheck --check-prefix=CHECK2 %s
14
15## Check offset gets modified.
16# CHECK1: DW_TAG_compile_unit
17# CHECK1: DW_AT_stmt_list
18# CHECK1: DW_TAG_type_unit
19# CHECK1: DW_AT_stmt_list	([[OFFSET:0x[0-9a-f]*]])
20# CHECK1: DW_TAG_type_unit
21# CHECK1: DW_AT_stmt_list	([[OFFSET]])
22# CHECK1: DW_TAG_compile_unit
23# CHECK1: DW_AT_stmt_list	([[OFFSET]])
24# CHECK1: DW_TAG_type_unit
25# CHECK1-NOT: DW_AT_stmt_list	([[OFFSET]])
26# CHECK1: DW_TAG_type_unit
27# CHECK1-NOT: DW_AT_stmt_list	([[OFFSET]])
28# CHECK1: DW_TAG_compile_unit
29# CHECK1: DW_TAG_compile_unit
30# CHECK1-NOT: DW_AT_stmt_list	([[OFFSET]])
31
32## Check that offset is correct.
33# CHECK2: DW_TAG_type_unit
34# CHECK2: DW_AT_stmt_list	([[OFFSET1:0x[0-9a-f]*]])
35# CHECK2: DW_TAG_type_unit
36# CHECK2: DW_AT_stmt_list	([[OFFSET1]])
37# CHECK2: DW_TAG_compile_unit
38# CHECK2: DW_AT_stmt_list
39# CHECK2: DW_TAG_compile_unit
40# CHECK2: DW_AT_stmt_list	([[OFFSET1]])
41# CHECK2: debug_line
42# CHECK2: debug_line[[[OFFSET1]]]
43# CHECK2-NOT: debug_line
44
45## Check that BOLT updates DW_AT_stmt_list correctly for TUs when both objects are built with DWARF4.
46
47# RUN: llvm-mc -dwarf-version=4 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf4-debug-line-offset-change-after-bolt-main.s -o %tmain.o
48# RUN: llvm-mc -dwarf-version=4 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf4-debug-line-offset-change-after-bolt-helper.s -o %thelper.o
49# RUN: %clang %cflags %tmain.o %thelper.o -o %t.exe -Wl,-q
50# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections --lite=0 --reorder-blocks=reverse
51# RUN: llvm-dwarfdump --debug-info --debug-types -r 0 %t.exe > %tlogOffsetNotEqual.txt
52# RUN: llvm-dwarfdump --debug-info --debug-types -r 0 %t.bolt >> %tlogOffsetNotEqual.txt
53# RUN: llvm-dwarfdump --debug-info --debug-types -r 0 --debug-line %t.bolt > %tlogCheckLineTable.txt
54# RUN: cat %tlogOffsetNotEqual.txt | FileCheck --check-prefix=CHECK3 %s
55# RUN: cat %tlogCheckLineTable.txt | FileCheck --check-prefix=CHECK4 %s
56## Check offset gets modified.
57# CHECK3: DW_TAG_compile_unit
58# CHECK3: DW_TAG_compile_unit
59# CHECK3: DW_AT_stmt_list ([[OFFSET2:0x[0-9a-f]*]])
60# CHECK3: DW_TAG_type_unit
61# CHECK3: DW_AT_stmt_list ([[OFFSET2]])
62# CHECK3: DW_TAG_compile_unit
63# CHECK3-NOT: DW_AT_stmt_list ([[OFFSET2]])
64# CHECK3: DW_TAG_type_unit
65# CHECK3-NOT: DW_AT_stmt_list ([[OFFSET2]])
66
67## Check that offset is correct.
68# CHECK4: DW_TAG_compile_unit
69# CHECK4: DW_TAG_compile_unit
70# CHECK4: DW_TAG_type_unit
71# CHECK4: DW_AT_stmt_list ([[OFFSET3:0x[0-9a-f]*]])
72# CHECK4: debug_line
73# CHECK4: debug_line[[[OFFSET3]]]
74# CHECK4-NOT: debug_line
75
76## Check that BOLT updates DW_AT_stmt_list correctly for TUs when objects are built with DWARF4/DWARF5.
77
78# RUN: llvm-mc -dwarf-version=4 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf4-debug-line-offset-change-after-bolt-main.s -o %tmain.o
79# RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf4-types-dwarf5-types-helper.s -o %thelper.o
80# RUN: %clang %cflags %tmain.o %thelper.o -o %t.exe -Wl,-q
81# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections --lite=0 --reorder-blocks=reverse
82# RUN: llvm-dwarfdump --debug-info --debug-types -r 0 %t.exe > %tlogOffsetNotEqual.txt
83# RUN: llvm-dwarfdump --debug-info --debug-types -r 0 %t.bolt >> %tlogOffsetNotEqual.txt
84# RUN: llvm-dwarfdump --debug-info --debug-types -r 0 --debug-line %t.bolt > %tlogCheckLineTable.txt
85# RUN: cat %tlogOffsetNotEqual.txt | FileCheck --check-prefix=CHECK5 %s
86# RUN: cat %tlogCheckLineTable.txt | FileCheck --check-prefix=CHECK6 %s
87
88## Check offset gets modified.
89# CHECK5: DW_TAG_compile_unit
90# CHECK5: DW_TAG_type_unit
91# CHECK5: DW_AT_stmt_list ([[OFFSET4:0x[0-9a-f]*]])
92# CHECK5: DW_TAG_type_unit
93# CHECK5: DW_AT_stmt_list ([[OFFSET4]])
94# CHECK5: DW_TAG_compile_unit
95# CHECK5: DW_AT_stmt_list ([[OFFSET4]])
96# CHECK5: DW_TAG_type_unit
97# CHECK5-NOT: DW_AT_stmt_list ([[OFFSET4]])
98# CHECK5: DW_TAG_type_unit
99# CHECK5-NOT: DW_AT_stmt_list ([[OFFSET4]])
100# CHECK5: DW_TAG_compile_unit
101# CHECK5: DW_TAG_compile_unit
102# CHECK5-NOT: DW_AT_stmt_list ([[OFFSET4]])
103
104# CHECK6: DW_TAG_type_unit
105# CHECK6: DW_AT_stmt_list ([[OFFSET5:0x[0-9a-f]*]])
106# CHECK6: DW_TAG_type_unit
107# CHECK6: DW_AT_stmt_list ([[OFFSET5]])
108# CHECK6: DW_TAG_compile_unit
109# CHECK6: DW_TAG_compile_unit
110# CHECK6: DW_AT_stmt_list ([[OFFSET5]])
111# CHECK6: debug_line
112# CHECK6: debug_line[[[OFFSET5]]]
113# CHECK6-NOT: debug_line
114