llvm.org GIT mirror llvm / 031332e
Recommit "Enable MachineOutliner by default under -Oz for AArch64" Fixed the ASAN failure from before in r338148, so recommiting. This patch enables the MachineOutliner by default in AArch64 under -Oz. The MachineOutliner offers around a 4.5% improvement on the current -Oz code size improvements. We have done work into improving the debuggability of outlined code, so that users of -Oz won't be surprised by the optimization. We have also been executing the LLVM test suite and common external tests such as the SPEC suites continuously with no issue. The outliner has a low compile-time overhead of roughly 1%. At this point, the outliner would be a really good addition to the -Oz pass pipeline! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@338160 91177308-0d34-0410-b5e6-96231b3b80d8 Jessica Paquette 1 year, 3 months ago
10 changed file(s) with 97 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
54815481
54825482 return CallPt;
54835483 }
5484
5485 bool AArch64InstrInfo::shouldOutlineFromFunctionByDefault(
5486 MachineFunction &MF) const {
5487 return MF.getFunction().optForMinSize();
5488 }
248248 insertOutlinedCall(Module &M, MachineBasicBlock &MBB,
249249 MachineBasicBlock::iterator &It, MachineFunction &MF,
250250 const outliner::Candidate &C) const override;
251 bool shouldOutlineFromFunctionByDefault(MachineFunction &MF) const override;
251252 /// Returns true if the instruction sets to an immediate value that can be
252253 /// executed more efficiently.
253254 bool isExynosResetFast(const MachineInstr &MI) const;
254254
255255 // AArch64 supports the MachineOutliner.
256256 setMachineOutliner(true);
257
258 // AArch64 supports default outlining behaviour.
259 setSupportsDefaultOutlining(true);
257260 }
258261
259262 AArch64TargetMachine::~AArch64TargetMachine() = default;
153153 ; CHECK-NEXT: Insert fentry calls
154154 ; CHECK-NEXT: Insert XRay ops
155155 ; CHECK-NEXT: Implement the 'patchable-function' attribute
156 ; CHECK-NEXT: Machine Outliner
157 ; CHECK-NEXT: FunctionPass Manager
156158 ; CHECK-NEXT: Lazy Machine Block Frequency Analysis
157159 ; CHECK-NEXT: Machine Optimization Remark Emitter
158160 ; CHECK-NEXT: AArch64 Assembly Printer
None ; RUN: llc %s -mtriple=arm64-apple-darwin -o - | \
1 ; RUN: FileCheck --check-prefixes=CHECK,CHECK-DARWIN %s
2 ; RUN: llc %s -mtriple=arm64-linux-gnu -o - | \
0 ; RUN: llc %s -enable-machine-outliner=never -mtriple=arm64-apple-darwin -o - \
1 ; RUN: | FileCheck --check-prefixes=CHECK,CHECK-DARWIN %s
2 ; RUN: llc %s -enable-machine-outliner=never -mtriple=arm64-linux-gnu -o - | \
33 ; RUN: FileCheck --check-prefixes=CHECK,CHECK-LINUX %s
44 ; ARM64: Calls to bzero() replaced with calls to memset()
55
2525 ; requested. (This hard-codes the previous pass to the Assembly Printer,
2626 ; please adjust accordingly.)
2727
28 ; HOTNESS: Executing Pass 'Implement the 'patchable-function' attribute'
29 ; HOTNESS-NEXT: Freeing Pass 'Implement the 'patchable-function' attribute'
28 ; HOTNESS: Freeing Pass 'Machine Outliner'
29 ; HOTNESS-NEXT: Executing Pass 'Function Pass Manager'
3030 ; HOTNESS-NEXT: Executing Pass 'Lazy Machine Block Frequency Analysis'
3131 ; HOTNESS-NEXT: Executing Pass 'Machine Optimization Remark Emitter'
3232 ; HOTNESS-NEXT: Building MachineBlockFrequencyInfo on the fly
4040 ; HOTNESS: arm64-summary-remarks.ll:5:0: 1 instructions in function (hotness: 33)
4141
4242
43 ; NO_HOTNESS: Executing Pass 'Implement the 'patchable-function' attribute'
44 ; NO_HOTNESS-NEXT: Freeing Pass 'Implement the 'patchable-function' attribute'
43 ; NO_HOTNESS: Freeing Pass 'Machine Outliner'
44 ; NO_HOTNESS-NEXT: Executing Pass 'Function Pass Manager'
4545 ; NO_HOTNESS-NEXT: Executing Pass 'Lazy Machine Block Frequency Analysis'
4646 ; NO_HOTNESS-NEXT: Executing Pass 'Machine Optimization Remark Emitter'
4747 ; NO_HOTNESS-NEXT: Executing Pass 'AArch64 Assembly Printer'
None ; RUN: llc -verify-machineinstrs < %s -mtriple=aarch64-none-linux-gnu -mcpu=cyclone | FileCheck %s
1 ; RUN: llc -verify-machineinstrs < %s -mtriple=aarch64-none-linux-gnu -mattr=-fp-armv8 | FileCheck --check-prefix=CHECK-NOFP %s
0 ; RUN: llc -enable-machine-outliner=never -verify-machineinstrs < %s -mtriple=aarch64-none-linux-gnu -mcpu=cyclone | FileCheck %s
1 ; RUN: llc -enable-machine-outliner=never -verify-machineinstrs < %s -mtriple=aarch64-none-linux-gnu -mattr=-fp-armv8 | FileCheck --check-prefix=CHECK-NOFP %s
22
33 @var32 = global i32 0
44 @var64 = global i64 0
0 # RUN: llc -mtriple=aarch64--- -run-pass=machine-outliner \
1 # RUN: -verify-machineinstrs %s -o - | FileCheck %s
2
3 --- |
4 define void @outline_1() #0 { ret void }
5 define void @outline_2() #0 { ret void }
6 define void @outline_3() #0 { ret void }
7 define void @dont_outline() #1 { ret void }
8
9 attributes #0 = { noredzone minsize optsize }
10 attributes #1 = { noredzone }
11 ...
12 ---
13
14 name: outline_1
15 tracksRegLiveness: true
16 body: |
17 bb.0:
18 ; CHECK-LABEL: bb.0:
19 ; CHECK: OUTLINED
20 liveins: $w8, $wzr
21 $w8 = ORRWri $wzr, 1
22 $w8 = ORRWri $wzr, 2
23 $w8 = ORRWri $wzr, 3
24 $w8 = ORRWri $wzr, 4
25 RET undef $lr
26 ...
27 ---
28
29 name: outline_2
30 tracksRegLiveness: true
31 body: |
32 bb.0:
33 ; CHECK-LABEL: bb.0:
34 ; CHECK: OUTLINED
35 liveins: $w8, $wzr
36 $w8 = ORRWri $wzr, 1
37 $w8 = ORRWri $wzr, 2
38 $w8 = ORRWri $wzr, 3
39 $w8 = ORRWri $wzr, 4
40 RET undef $lr
41 ...
42 ---
43
44 name: outline_3
45 tracksRegLiveness: true
46 body: |
47 bb.0:
48 ; CHECK-LABEL: bb.0:
49 ; CHECK: OUTLINED
50 liveins: $w8, $wzr
51 $w8 = ORRWri $wzr, 1
52 $w8 = ORRWri $wzr, 2
53 $w8 = ORRWri $wzr, 3
54 $w8 = ORRWri $wzr, 4
55 RET undef $lr
56 ...
57 ---
58
59 name: dont_outline
60 tracksRegLiveness: true
61 body: |
62 bb.0:
63 ; CHECK-LABEL: bb.0:
64 ; CHECK-NOT: BL
65 liveins: $w8, $wzr
66 $w8 = ORRWri $wzr, 1
67 $w8 = ORRWri $wzr, 2
68 $w8 = ORRWri $wzr, 3
69 $w8 = ORRWri $wzr, 4
70 RET undef $lr
1313 ; RUN: | FileCheck %s -check-prefix=NEVER
1414
1515 ; RUN: llc %s -debug-pass=Structure -verify-machineinstrs \
16 ; RUN: -mtriple arm64---- -o /dev/null 2>&1 \
16 ; RUN: --debug-only=machine-outliner -mtriple arm64---- -o /dev/null 2>&1 \
1717 ; RUN: | FileCheck %s -check-prefix=NOT-ADDED
1818
1919 ; RUN: llc %s -O=0 -debug-pass=Structure -verify-machineinstrs \
2626 ; Cases where it should be added:
2727 ; * -enable-machine-outliner
2828 ; * -enable-machine-outliner=always
29 ; * -enable-machine-outliner is not passed (AArch64 supports
30 ; target-default outlining)
2931 ;
3032 ; Cases where it should not be added:
3133 ; * -O0 or equivalent
32 ; * -enable-machine-outliner is not passed
3334 ; * -enable-machine-outliner=never is passed
3435
3536 ; ALWAYS: Machine Outliner
3738 ; ENABLE: Machine Outliner
3839 ; ENABLE: Machine Outliner: Running on all functions
3940 ; NEVER-NOT: Machine Outliner
40 ; NOT-ADDED-NOT: Machine Outliner
41 ; NOT-ADDED: Machine Outliner
42 ; NOT-ADDED: Machine Outliner: Running on target-default functions
4143 ; OPTNONE-NOT: Machine Outliner
4244
4345 define void @foo() {
8888 ; CHECKM1-NOT: %jump-table.1
8989 ; CHECKM3-NEXT: %jump-table.0: %bb.1 %bb.2 %bb.3 %bb.4 %bb.7 %bb.7 %bb.7 %bb.7 %bb.7 %bb.7 %bb.7 %bb.7 %bb.7 %bb.5 %bb.6{{$}}
9090 ; CHECKM3-NOT: %jump-table.1
91 ; CHECK-DAG: End machine code for function jt2.
9192
9293 bb1: tail call void @ext(i32 1) br label %return
9394 bb2: tail call void @ext(i32 2) br label %return