Skip to content

Commit c109081

Browse files
committed
add mir test
1 parent 09aeee9 commit c109081

File tree

2 files changed

+52
-7
lines changed

2 files changed

+52
-7
lines changed

llvm/lib/CodeGen/MachineOutliner.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,22 +1076,17 @@ bool MachineOutliner::outline(
10761076
<< " B) > threshold (" << OutlinerBenefitThreshold
10771077
<< " B)\n");
10781078

1079-
// Remove all Linker Optimization Hints from the candidates since we did not
1080-
// check if the set of hints are the same for each of them.
1079+
// Remove all Linker Optimization Hints from the candidates.
10811080
// TODO: The intersection of the LOHs from all candidates should be legal in
10821081
// the outlined function.
10831082
SmallPtrSet<MachineInstr *, 2> MIs;
1084-
std::optional<size_t> MinRemovedLOHs;
10851083
for (Candidate &C : OF->Candidates) {
10861084
const TargetInstrInfo &TII = *C.getMF()->getSubtarget().getInstrInfo();
10871085
for (MachineInstr &MI : C)
10881086
MIs.insert(&MI);
1089-
size_t NumRemoved = TII.clearLinkerOptimizationHints(MIs);
1087+
NumRemovedLOHs += TII.clearLinkerOptimizationHints(MIs);
10901088
MIs.clear();
1091-
MinRemovedLOHs =
1092-
std::min(MinRemovedLOHs.value_or(NumRemoved), NumRemoved);
10931089
}
1094-
NumRemovedLOHs += MinRemovedLOHs.value_or(0);
10951090

10961091
// It's beneficial. Create the function and outline its sequence's
10971092
// occurrences.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# RUN: llc %s -mtriple=aarch64-apple-ios -run-pass=aarch64-collect-loh -run-pass=machine-outliner -stats -o - 2>%t | FileCheck %s
2+
# RUN: FileCheck %s --input-file=%t --check-prefix=STATS
3+
# REQUIRES: asserts
4+
5+
--- |
6+
define void @func0() noredzone minsize { ret void }
7+
8+
@g0 = external global i32
9+
...
10+
---
11+
# CHECK-LABEL: name: func0
12+
name: func0
13+
tracksRegLiveness: true
14+
body: |
15+
; CHECK-LABEL: bb.0:
16+
bb.0:
17+
; CHECK: BL @OUTLINED_FUNCTION_0
18+
$x10 = ADRP target-flags(aarch64-page) @g0
19+
$x11 = ADDXri $x10, target-flags(aarch64-pageoff) @g0, 0
20+
$w0 = ORRWri $wzr, 1
21+
$w0 = ORRWri $wzr, 1
22+
$w0 = ORRWri $wzr, 1
23+
$w0 = ORRWri $wzr, 1
24+
25+
; CHECK-LABEL: bb.1:
26+
bb.1:
27+
; CHECK: BL @OUTLINED_FUNCTION_0
28+
; MCLOH_AdrpAdd is not generated because $x11 is still live. If we want to
29+
; outline these instructions, we must remove the MCLOH_AdrpAdd from bb.0.
30+
$x10 = ADRP target-flags(aarch64-page) @g0
31+
$x11 = ADDXri $x10, target-flags(aarch64-pageoff) @g0, 0
32+
$w0 = ORRWri $wzr, 1
33+
$w0 = ORRWri $wzr, 1
34+
$w0 = ORRWri $wzr, 1
35+
$w0 = ORRWri $wzr, 1
36+
; CHECK: $x12 = ADDXri $x11, target-flags(aarch64-pageoff) @g0, 0
37+
$x12 = ADDXri $x11, target-flags(aarch64-pageoff) @g0, 0
38+
39+
...
40+
41+
# CHECK-LABEL: name: OUTLINED_FUNCTION_0
42+
# CHECK: $x10 = ADRP target-flags(aarch64-page) @g0
43+
# CHECK: $x11 = ADDXri $x10, target-flags(aarch64-pageoff) @g0, 0
44+
# CHECK: $w0 = ORRWri $wzr, 1
45+
# CHECK: $w0 = ORRWri $wzr, 1
46+
# CHECK: $w0 = ORRWri $wzr, 1
47+
# CHECK: $w0 = ORRWri $wzr, 1
48+
49+
# STATS: 1 aarch64-collect-loh - Number of simplifiable ADRP + ADD
50+
# STATS: 1 machine-outliner - Total number of Linker Optimization Hints removed

0 commit comments

Comments
 (0)