Skip to content

Commit

Permalink
[AArch64] Move machine bundle unpacking to PreEmit2 phase.
Browse files Browse the repository at this point in the history
This patch adjusts the placement of the bundle unpacking to just before
code emission. In particular, this means bundle unpacking happens AFTER
the machine outliner. With the previous position, the machine outliner
may outline parts of a bundle, which breaks them up.

This is an issue for BLR_RVMARKER handling, as illustrated by the
rvmarker-pseudo-expansion-and-outlining.mir test case. The machine
outliner should not break up the bundles created during pseudo
expansion.

This should fix PR49082.

Reviewed By: SjoerdMeijer

Differential Revision: https://reviews.llvm.org/D96294
  • Loading branch information
fhahn committed Feb 15, 2021
1 parent 99dbc0f commit ca23b2c
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 6 deletions.
6 changes: 5 additions & 1 deletion llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
Expand Up @@ -431,6 +431,7 @@ class AArch64PassConfig : public TargetPassConfig {
void addPostRegAlloc() override;
void addPreSched2() override;
void addPreEmitPass() override;
void addPreEmitPass2() override;

std::unique_ptr<CSEConfigBase> getCSEConfig() const override;
};
Expand Down Expand Up @@ -695,8 +696,11 @@ void AArch64PassConfig::addPreEmitPass() {
if (TM->getOptLevel() != CodeGenOpt::None && EnableCollectLOH &&
TM->getTargetTriple().isOSBinFormatMachO())
addPass(createAArch64CollectLOHPass());
}

// SVE bundles move prefixes with destructive operations.
void AArch64PassConfig::addPreEmitPass2() {
// SVE bundles move prefixes with destructive operations. BLR_RVMARKER pseudo
// instructions are lowered to bundles as well.
addPass(createUnpackMachineBundles(nullptr));
}

Expand Down
2 changes: 1 addition & 1 deletion llvm/test/CodeGen/AArch64/O0-pipeline.ll
Expand Up @@ -64,10 +64,10 @@
; CHECK-NEXT: Implement the 'patchable-function' attribute
; CHECK-NEXT: AArch64 Branch Targets
; CHECK-NEXT: Branch relaxation pass
; CHECK-NEXT: Unpack machine instruction bundles
; CHECK-NEXT: Contiguously Lay Out Funclets
; CHECK-NEXT: StackMap Liveness Analysis
; CHECK-NEXT: Live DEBUG_VALUE analysis
; CHECK-NEXT: Unpack machine instruction bundles
; CHECK-NEXT: Lazy Machine Block Frequency Analysis
; CHECK-NEXT: Machine Optimization Remark Emitter
; CHECK-NEXT: AArch64 Assembly Printer
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/CodeGen/AArch64/O3-pipeline.ll
Expand Up @@ -196,12 +196,12 @@
; CHECK-NEXT: AArch64 Branch Targets
; CHECK-NEXT: Branch relaxation pass
; CHECK-NEXT: AArch64 Compress Jump Tables
; CHECK-NEXT: Unpack machine instruction bundles
; CHECK-NEXT: Contiguously Lay Out Funclets
; CHECK-NEXT: StackMap Liveness Analysis
; CHECK-NEXT: Live DEBUG_VALUE analysis
; CHECK-NEXT: Machine Outliner
; CHECK-NEXT: FunctionPass Manager
; CHECK-NEXT: Unpack machine instruction bundles
; CHECK-NEXT: Lazy Machine Block Frequency Analysis
; CHECK-NEXT: Machine Optimization Remark Emitter
; CHECK-NEXT: AArch64 Assembly Printer
Expand Down
8 changes: 8 additions & 0 deletions llvm/test/CodeGen/AArch64/arm64-opt-remarks-lazy-bfi.ll
Expand Up @@ -34,6 +34,10 @@
; HOTNESS-NEXT: Executing Pass 'Function Pass Manager'
; HOTNESS-NEXT: Executing Pass 'Verify generated machine code'
; HOTNESS-NEXT: Freeing Pass 'Verify generated machine code'
; HOTNESS-NEXT: Executing Pass 'Unpack machine instruction bundles'
; HOTNESS-NEXT: Freeing Pass 'Unpack machine instruction bundles'
; HOTNESS-NEXT: Executing Pass 'Verify generated machine code'
; HOTNESS-NEXT: Freeing Pass 'Verify generated machine code'
; HOTNESS-NEXT: Executing Pass 'Lazy Machine Block Frequency Analysis'
; HOTNESS-NEXT: Executing Pass 'Machine Optimization Remark Emitter'
; HOTNESS-NEXT: Building MachineBlockFrequencyInfo on the fly
Expand All @@ -51,6 +55,10 @@
; NO_HOTNESS-NEXT: Executing Pass 'Function Pass Manager'
; NO_HOTNESS-NEXT: Executing Pass 'Verify generated machine code'
; NO_HOTNESS-NEXT: Freeing Pass 'Verify generated machine code'
; NO_HOTNESS-NEXT: Executing Pass 'Unpack machine instruction bundles'
; NO_HOTNESS-NEXT: Freeing Pass 'Unpack machine instruction bundles'
; NO_HOTNESS-NEXT: Executing Pass 'Verify generated machine code'
; NO_HOTNESS-NEXT: Freeing Pass 'Verify generated machine code'
; NO_HOTNESS-NEXT: Executing Pass 'Lazy Machine Block Frequency Analysis'
; NO_HOTNESS-NEXT: Executing Pass 'Machine Optimization Remark Emitter'
; NO_HOTNESS-NEXT: Executing Pass 'AArch64 Assembly Printer'
Expand Down
@@ -1,21 +1,22 @@
# RUN: llc -enable-machine-outliner -start-before=aarch64-expand-pseudo -mtriple=arm64-apple-ios -o - %s | FileCheck %s
#
# FIXME: The calls to _cb1 & _cb2 should be followed by the marker instruction
# 'mov x29, x29'. The marker should not get outlined.
# The calls to _cb1 & _cb2 should be followed by the marker instruction
# 'mov x29, x29'. The marker should not get outlined.
#
# CHECK-LABEL: _fn1:
# CHECK: bb.0:
# CHECK: bl _cb1
# CHECK-NEXT: mov x29, x29
# CHECK-NEXT: bl _OUTLINED_FUNCTION_0
#
# CHECK-LABEL: _fn2:
# CHECK: bb.0:
# CHECK: bl _cb2
# CHECK-NEXT: mov x29, x29
# CHECK-NEXT: bl _OUTLINED_FUNCTION_0
#
# CHECK-LABEL: _OUTLINED_FUNCTION_0:
# CHECK: bb.0:
# CHECK-NEXT: mov x29, x29
# CHECK-NEXT: orr w12, wzr, #0x3
# CHECK-NEXT: orr w12, wzr, #0x3
# CHECK-NEXT: orr w12, wzr, #0x3
Expand Down

0 comments on commit ca23b2c

Please sign in to comment.