Skip to content

Commit ad2f029

Browse files
committed
[BOLT] Remove unnecessary script, and rewrite unit test using it
- the checks that match_dwarf.py helped with can also be done using BOLT logs. - rewrote the negate-ra-state.s test to only rely on logs to verify correct OpNegateRAState CFI generation.
1 parent c75645f commit ad2f029

File tree

3 files changed

+67
-177
lines changed

3 files changed

+67
-177
lines changed
Lines changed: 67 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,76 @@
1+
# Checking that .cfi-negate_ra_state directives are emitted in the same location as in the input in the case of no optimizations.
2+
13
# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %s -o %t.o
24
# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q
5+
# RUN: llvm-bolt %t.exe -o %t.exe.bolt --no-threads --print-all | FileCheck %s --check-prefix=CHECK-BOLT
6+
7+
# Check that the negate-ra-state at the start of bar is not discarded.
8+
# If it was discarded, MarkRAState would report bar as having inconsistent RAStates.
9+
# CHECK-BOLT-NOT: BOLT-INFO: inconsistent RAStates in function foo
10+
# CHECK-BOLT-NOT: BOLT-INFO: inconsistent RAStates in function bar
11+
12+
# Check that OpNegateRAState CFIs are generated correctly.
13+
# CHECK-BOLT: Binary Function "foo" after insert-negate-ra-state-pass {
14+
# CHECK-BOLT: paciasp
15+
# CHECK-BOLT-NEXT: OpNegateRAState
16+
17+
# CHECK-BOLT: DWARF CFI Instructions:
18+
# CHECK-BOLT-NEXT: 0: OpNegateRAState
19+
# CHECK-BOLT-NEXT: End of Function "foo"
20+
21+
# CHECK-BOLT: Binary Function "bar" after insert-negate-ra-state-pass {
22+
# CHECK-BOLT: OpNegateRAState
23+
# CHECK-BOLT-NEXT: mov x1, #0x0
24+
# CHECK-BOLT-NEXT: mov x1, #0x1
25+
# CHECK-BOLT-NEXT: autiasp
26+
# CHECK-BOLT-NEXT: OpNegateRAState
27+
# CHECK-BOLT-NEXT: ret
328

4-
# RUN: llvm-objdump %t.exe -d > %t.exe.dump
5-
# RUN: llvm-objdump --dwarf=frames %t.exe > %t.exe.dump-dwarf
6-
# RUN: match-dwarf %t.exe.dump %t.exe.dump-dwarf foo > %t.match-dwarf.txt
29+
# CHECK-BOLT: DWARF CFI Instructions:
30+
# CHECK-BOLT-NEXT: 0: OpNegateRAState
31+
# CHECK-BOLT-NEXT: 1: OpNegateRAState
32+
# CHECK-BOLT-NEXT: End of Function "bar"
733

8-
# RUN: llvm-bolt %t.exe -o %t.exe.bolt
34+
# End of negate-ra-state insertion logs for foo and bar.
35+
# CHECK: Binary Function "_start" after insert-negate-ra-state-pass {
936

10-
# RUN: llvm-objdump %t.exe.bolt -d > %t.exe.bolt.dump
11-
# RUN: llvm-objdump --dwarf=frames %t.exe.bolt > %t.exe.bolt.dump-dwarf
12-
# RUN: match-dwarf %t.exe.bolt.dump %t.exe.bolt.dump-dwarf foo > %t.bolt.match-dwarf.txt
37+
# Check that the functions are in the new .text section
38+
# RUN: llvm-objdump %t.exe.bolt -d -j .text | FileCheck %s --check-prefix=CHECK-OBJDUMP
39+
# CHECK-OBJDUMP: <foo>:
40+
# CHECK-OBJDUMP: <bar>:
1341

14-
# RUN: diff %t.match-dwarf.txt %t.bolt.match-dwarf.txt
1542

16-
.text
17-
.globl foo
18-
.p2align 2
19-
.type foo,@function
43+
.text
44+
.globl foo
45+
.p2align 2
46+
.type foo,@function
2047
foo:
21-
.cfi_startproc
22-
hint #25
23-
.cfi_negate_ra_state
24-
sub sp, sp, #16
25-
stp x29, x30, [sp, #16] // 16-byte Folded Spill
26-
.cfi_def_cfa_offset 16
27-
str w0, [sp, #12]
28-
ldr w8, [sp, #12]
29-
add w0, w8, #1
30-
ldp x29, x30, [sp, #16] // 16-byte Folded Reload
31-
add sp, sp, #16
32-
hint #29
33-
.cfi_negate_ra_state
34-
ret
35-
.Lfunc_end1:
36-
.size foo, .Lfunc_end1-foo
37-
.cfi_endproc
38-
39-
.global _start
40-
.type _start, %function
48+
.cfi_startproc
49+
paciasp
50+
.cfi_negate_ra_state
51+
mov x1, #0
52+
b bar
53+
.cfi_endproc
54+
.size foo, .-foo
55+
56+
57+
58+
.text
59+
.globl bar
60+
.p2align 2
61+
.type bar,@function
62+
bar:
63+
.cfi_startproc
64+
.cfi_negate_ra_state // Indicating that RA is signed from the start of bar.
65+
mov x1, #0
66+
mov x1, #1
67+
autiasp
68+
.cfi_negate_ra_state
69+
ret
70+
.cfi_endproc
71+
.size bar, .-bar
72+
73+
.global _start
74+
.type _start, %function
4175
_start:
42-
b foo
76+
b foo

bolt/test/lit.cfg.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@
100100
config.substitutions.append(("%cxxflags", ""))
101101

102102
link_fdata_cmd = os.path.join(config.test_source_root, "link_fdata.py")
103-
match_dwarf_cmd = os.path.join(config.test_source_root, "match_dwarf.py")
104103

105104
tool_dirs = [config.llvm_tools_dir, config.test_source_root]
106105

@@ -144,12 +143,6 @@
144143
ToolSubst("llvm-readobj", unresolved="fatal"),
145144
ToolSubst("llvm-dwp", unresolved="fatal"),
146145
ToolSubst("split-file", unresolved="fatal"),
147-
ToolSubst(
148-
"match-dwarf",
149-
command=sys.executable,
150-
unresolved="fatal",
151-
extra_args=[match_dwarf_cmd],
152-
),
153146
]
154147
llvm_config.add_tool_substitutions(tools, tool_dirs)
155148

bolt/test/match_dwarf.py

Lines changed: 0 additions & 137 deletions
This file was deleted.

0 commit comments

Comments
 (0)