Skip to content

Commit a0c3189

Browse files
authored
[CodeGen][NFC] Properly split MachineLICM and EarlyMachineLICM (#113573)
Both are based on MachineLICMBase, and the functionality there is "switched" based on a PreRegAlloc flag. This commit is simply about trusting the original value of that flag, defined by the `MachineLICM` and `EarlyMachineLICM` classes. The `PreRegAlloc` flag used to be overwritten it based on MRI.isSSA(), which is un-reliable due to how it is inferred by the MIRParser. I see that we can now define isSSA in MIR (thanks @gargaroff ), meaning the fix isn’t really needed anymore, but redefining that flag still feels wrong. Note that I'm looking into upstreaming more changes to MachineLICM, see [the discourse thread](https://discourse.llvm.org/t/extending-post-regalloc-machinelicm/82725).
1 parent f4db221 commit a0c3189

File tree

6 files changed

+8
-21
lines changed

6 files changed

+8
-21
lines changed

llvm/lib/CodeGen/MachineLICM.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -391,12 +391,6 @@ bool MachineLICMImpl::run(MachineFunction &MF) {
391391
MRI = &MF.getRegInfo();
392392
SchedModel.init(&ST);
393393

394-
// FIXME: Remove this assignment or convert to an assert? (dead variable PreRegAlloc)
395-
// MachineLICM and PostRAMachineLICM were distinguished by introducing
396-
// EarlyMachineLICM and MachineLICM respectively to avoid "using an unreliable
397-
// MRI::isSSA() check to determine whether register allocation has happened"
398-
// (See 4a7c8e7).
399-
PreRegAlloc = MRI->isSSA();
400394
HasProfileData = MF.getFunction().hasProfileData();
401395

402396
if (PreRegAlloc)

llvm/test/CodeGen/AArch64/mlicm-stack-write-check.mir

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
---
44
name: test
55
tracksRegLiveness: true
6-
isSSA: false
7-
registers:
8-
- { id: 0, class: gpr64 }
96
stack:
107
- { id: 0, size: 8, type: spill-slot }
118
body: |
@@ -30,14 +27,11 @@ body: |
3027
3128
bb.2:
3229
liveins: $x0
33-
%0 = COPY $x0
3430
...
31+
3532
---
3633
name: test2
3734
tracksRegLiveness: true
38-
isSSA: false
39-
registers:
40-
- { id: 0, class: gpr64 }
4135
stack:
4236
- { id: 0, size: 8, type: spill-slot }
4337
body: |
@@ -62,5 +56,4 @@ body: |
6256
6357
bb.2:
6458
liveins: $x0
65-
%0 = COPY $x0
6659
...

llvm/test/CodeGen/AMDGPU/licm-regpressure.mir

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2-
# RUN: llc -mtriple=amdgcn -mcpu=gfx900 -verify-machineinstrs -run-pass machinelicm -o - %s | FileCheck -check-prefix=GCN %s
3-
# RUN: llc -mtriple=amdgcn -mcpu=gfx900 -passes machinelicm -o - %s | FileCheck -check-prefix=GCN %s
2+
# RUN: llc -mtriple=amdgcn -mcpu=gfx900 -verify-machineinstrs -run-pass early-machinelicm -o - %s | FileCheck -check-prefix=GCN %s
3+
# RUN: llc -mtriple=amdgcn -mcpu=gfx900 -passes early-machinelicm -o - %s | FileCheck -check-prefix=GCN %s
44

55
# MachineLICM shall limit hoisting of V_CVT instructions out of the loop keeping
66
# register pressure within the budget. VGPR budget at occupancy 10 is 24 vgprs.

llvm/test/CodeGen/AMDGPU/licm-valu.mir

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2-
# RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -run-pass=machinelicm -verify-machineinstrs -o - %s | FileCheck -check-prefix=GCN %s
3-
# RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -passes=machinelicm -o - %s | FileCheck -check-prefix=GCN %s
2+
# RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -run-pass=early-machinelicm -verify-machineinstrs -o - %s | FileCheck -check-prefix=GCN %s
3+
# RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -passes=early-machinelicm -o - %s | FileCheck -check-prefix=GCN %s
44

55
---
66
name: hoist_move

llvm/test/CodeGen/X86/unfoldMemoryOperand.mir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
22
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
3-
# RUN: llc -mtriple=x86_64-- -passes machinelicm -mcpu=skx -verify-machineinstrs -o - %s | FileCheck %s
3+
# RUN: llc -mtriple=x86_64-- -passes early-machinelicm -mcpu=skx -verify-machineinstrs -o - %s | FileCheck %s
44
--- |
55
@x = dso_local global i32 0, align 4
66
@z = dso_local local_unnamed_addr global [1024 x i32] zeroinitializer, align 16

llvm/test/DebugInfo/MIR/X86/mlicm-hoist-pre-regalloc.mir

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
--- |
2-
; RUN: llc -run-pass=machinelicm -o - %s | FileCheck %s
3-
; RUN: llc -passes=machinelicm -o - %s | FileCheck %s
2+
; RUN: llc -run-pass=early-machinelicm -o - %s | FileCheck %s
3+
; RUN: llc -passes=early-machinelicm -o - %s | FileCheck %s
44
; Line numbers should not be retained when loop invariant instructions are hoisted.
55
; Doing so causes poor stepping bevavior.
66
;

0 commit comments

Comments
 (0)