File tree 3 files changed +45
-5
lines changed 3 files changed +45
-5
lines changed Original file line number Diff line number Diff line change 15
15
#include " bolt/Core/ParallelUtilities.h"
16
16
#include " bolt/Passes/ReorderAlgorithm.h"
17
17
#include " bolt/Passes/ReorderFunctions.h"
18
+ #include " bolt/Utils/CommandLineOpts.h"
18
19
#include " llvm/Support/CommandLine.h"
19
20
#include < atomic>
20
21
#include < mutex>
@@ -1923,7 +1924,7 @@ Error RemoveNops::runOnFunctions(BinaryContext &BC) {
1923
1924
};
1924
1925
1925
1926
ParallelUtilities::PredicateTy SkipFunc = [&](const BinaryFunction &BF) {
1926
- return BF.shouldPreserveNops ();
1927
+ return BF.shouldPreserveNops () || (!opts::StrictMode && !BF. isSimple ()) ;
1927
1928
};
1928
1929
1929
1930
ParallelUtilities::runOnEachFunction (
Original file line number Diff line number Diff line change
1
+ # This test checks th at the nop instruction is preserved before the
2
+ # ADRRelaxation pass. Otherwise the ADRRelaxation pass would
3
+ # fail to replace nop + adr to adrp + add for non - simple function.
4
+
5
+ # RUN: llvm - mc - filetype=obj - triple aarch64 - unknown - unknown \
6
+ # RUN: %s - o %t.o
7
+ # RUN: %clang %cflags %t.o - o %t.exe - Wl ,- q
8
+ # RUN: llvm - bolt %t.exe - o %t.bolt -- adr - relaxation=true \
9
+ # RUN: -- print - cfg -- print - only=_start | FileCheck %s
10
+ # RUN: llvm - objdump - d - j .text %t.bolt | \
11
+ # RUN: FileCheck -- check - prefix=DISASMCHECK %s
12
+
13
+ # CHECK: Binary Function "_start" after building cfg
14
+ # CHECK: IsSimple : 0
15
+
16
+ # DISASMCHECK: {{. * }}<_start>:
17
+ # DISASMCHECK - NEXT: adrp
18
+ # DISASMCHECK - NEXT: add
19
+ # DISASMCHECK - NEXT: adr
20
+
21
+ .text
22
+ . align 4
23
+ . global test
24
+ .type test , %function
25
+ test :
26
+ ret
27
+ .size test , . - test
28
+
29
+ . global _start
30
+ .type _start , %function
31
+ _start:
32
+ nop
33
+ adr x0 , test
34
+ adr x1 , 1f
35
+ 1 :
36
+ mov x1 , x0
37
+ br x0
38
+ .size _start , . - _start
Original file line number Diff line number Diff line change 1
1
// RUN: %clang %cflags -o %t %s
2
- // RUN: llvm-bolt -o %t.bolt %t
2
+ // RUN: llvm-bolt --strict - o %t.bolt %t
3
3
// RUN: llvm-readelf -x .data %t.bolt | FileCheck %s
4
4
5
5
.text
9
9
_start:
10
10
// Force BOLT into relocation mode
11
11
.reloc 0 , R_RISCV_NONE
12
- // BOLT removes this nop so the label difference is initially 8 but should be
13
- // 4 after BOLT processes it.
12
+ // BOLT removes this nop so the label difference is initially 12 but should be
13
+ // 8 after BOLT processes it.
14
14
nop
15
15
beq x0, x0, _test_end
16
+ addi x1, x1, 1
16
17
_test_end:
17
18
ret
18
19
.size _start, .-_start
19
20
20
21
.data
21
22
// CHECK: Hex dump of section '.data':
22
- // CHECK: 0x{{.*}} 04000000
23
+ // CHECK: 0x{{.*}} 08000000
23
24
.word _test_end - _start
You can’t perform that action at this time.
0 commit comments