xref: /llvm-project/bolt/test/X86/debug-fission-single.s (revision 79dcd93b70e1e36fea43b1bb297b98299bbbf612)
1## Checks debug fission support in BOLT
2
3# REQUIRES: system-linux
4
5# RUN: llvm-mc -g \
6# RUN:   --filetype=obj \
7# RUN:   --triple x86_64-unknown-unknown \
8# RUN:   --split-dwarf-file=debug-fission-simple.dwo \
9# RUN:   %p/Inputs/debug-fission-simple.s \
10# RUN:   -o %t.o
11# RUN: %clangxx %cxxflags -no-pie -g \
12# RUN:   -Wl,--gc-sections,-q,-nostdlib \
13# RUN:   -Wl,--undefined=_Z6_startv \
14# RUN:   -nostartfiles \
15# RUN:   -Wl,--script=%p/Inputs/debug-fission-script.txt \
16# RUN:   %t.o -o %t.exe
17# RUN: llvm-bolt %t.exe \
18# RUN:   --reorder-blocks=reverse \
19# RUN:   --update-debug-sections \
20# RUN:   --dwarf-output-path=%T \
21# RUN:   -o %t.bolt.1.exe 2>&1 | FileCheck %s
22# RUN: llvm-dwarfdump --show-form --verbose --debug-ranges %t.bolt.1.exe &> %tAddrIndexTest
23# RUN: llvm-dwarfdump --show-form --verbose --debug-info %T/debug-fission-simple.dwo0.dwo >> %tAddrIndexTest
24# RUN: cat %tAddrIndexTest | FileCheck %s --check-prefix=CHECK-DWO-DWO
25# RUN: llvm-dwarfdump --show-form --verbose   --debug-addr  %t.bolt.1.exe | FileCheck %s --check-prefix=CHECK-ADDR-SEC
26
27# CHECK-NOT: warning: DWARF unit from offset {{.*}} incl. to offset {{.*}} excl. tries to read DIEs at offset {{.*}}
28
29# CHECK-DWO-DWO: 00000010
30# CHECK-DWO-DWO: 00000010
31# CHECK-DWO-DWO: DW_TAG_subprogram
32# CHECK-DWO-DWO-NEXT: DW_AT_low_pc [DW_FORM_GNU_addr_index]	(indexed (00000001)
33# CHECK-DWO-DWO-NEXT: DW_AT_high_pc [DW_FORM_data4]	(0x00000031)
34# CHECK-DWO-DWO: DW_TAG_subprogram
35# CHECK-DWO-DWO-NEXT: DW_AT_low_pc [DW_FORM_GNU_addr_index]	(indexed (00000002)
36# CHECK-DWO-DWO-NEXT: DW_AT_high_pc [DW_FORM_data4]	(0x00000012)
37# CHECK-DWO-DWO: DW_TAG_subprogram
38# CHECK-DWO-DWO-NEXT: DW_AT_low_pc [DW_FORM_GNU_addr_index]	(indexed (00000003)
39# CHECK-DWO-DWO-NEXT: DW_AT_high_pc [DW_FORM_data4]	(0x0000001d)
40
41# CHECK-ADDR-SEC: .debug_addr contents:
42# CHECK-ADDR-SEC: 0x00000000: Addrs: [
43# CHECK-ADDR-SEC: 0x0000000000601000
44
45//clang++ -ffunction-sections -fno-exceptions -g -gsplit-dwarf=split -S debug-fission-simple.cpp -o debug-fission-simple.s
46static int foo = 2;
47int doStuff(int val) {
48  if (val == 5)
49    val += 1 + foo;
50  else
51    val -= 1;
52  return val;
53}
54
55int doStuff2(int val) {
56  return val += 3;
57}
58
59int main(int argc, const char** argv) {
60  return doStuff(argc);
61}
62