xref: /llvm-project/bolt/test/X86/debug-fission-single-convert.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-convert.dwo \
9# RUN:   %p/Inputs/debug-fission-simple-convert.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:   --always-convert-to-ranges=true \
22# RUN:   -o %t.bolt.1.exe 2>&1 | FileCheck %s
23# RUN: llvm-dwarfdump --show-form --verbose --debug-ranges %t.bolt.1.exe &> %tAddrIndexTest
24# RUN: not llvm-dwarfdump --show-form --verbose --debug-info %T/debug-fission-simple-convert.dwo0.dwo >> %tAddrIndexTest
25# RUN: cat %tAddrIndexTest | FileCheck %s --check-prefix=CHECK-DWO-DWO
26# RUN: llvm-dwarfdump --show-form --verbose   --debug-addr  %t.bolt.1.exe | FileCheck %s --check-prefix=CHECK-ADDR-SEC
27
28# CHECK-NOT: warning: DWARF unit from offset {{.*}} incl. to offset {{.*}} excl. tries to read DIEs at offset {{.*}}
29
30# CHECK-DWO-DWO: 00000000
31# CHECK-DWO-DWO: 00000010
32# CHECK-DWO-DWO: 00000010
33# CHECK-DWO-DWO: DW_TAG_subprogram
34# CHECK-DWO-DWO-NEXT: DW_AT_ranges [DW_FORM_sec_offset] (0x00000000
35# CHECK-DWO-DWO: DW_TAG_subprogram
36# CHECK-DWO-DWO-NEXT: DW_AT_ranges [DW_FORM_sec_offset] (0x00000020
37# CHECK-DWO-DWO: DW_TAG_subprogram
38# CHECK-DWO-DWO-NEXT: DW_AT_ranges [DW_FORM_sec_offset] (0x00000040
39
40# CHECK-ADDR-SEC: .debug_addr contents:
41# CHECK-ADDR-SEC: 0x00000000: Addrs: [
42# CHECK-ADDR-SEC: 0x0000000000601000
43
44//clang++ -ffunction-sections -fno-exceptions -g -gsplit-dwarf=split -S debug-fission-simple.cpp -o debug-fission-simple.s
45static int foo = 2;
46int doStuff(int val) {
47  if (val == 5)
48    val += 1 + foo;
49  else
50    val -= 1;
51  return val;
52}
53
54int doStuff2(int val) {
55  return val += 3;
56}
57
58int main(int argc, const char** argv) {
59  return doStuff(argc);
60}
61