Skip to content

AMDGPU: Use MFPropsModifier modifier in SIFoldOperands #127752

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 17, 2025

Conversation

arsenm
Copy link
Contributor

@arsenm arsenm commented Feb 19, 2025

This doesn't appear to work. I do not get an error in the new PM.

Copy link
Contributor Author

arsenm commented Feb 19, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@arsenm arsenm marked this pull request as ready for review February 19, 2025 06:26
@llvmbot
Copy link
Member

llvmbot commented Feb 19, 2025

@llvm/pr-subscribers-backend-amdgpu

Author: Matt Arsenault (arsenm)

Changes

This doesn't appear to work. I do not get an error in the new PM.


Full diff: https://github.com/llvm/llvm-project/pull/127752.diff

2 Files Affected:

  • (modified) llvm/lib/Target/AMDGPU/SIFoldOperands.cpp (+2)
  • (added) llvm/test/CodeGen/AMDGPU/si-fold-operands-requires-ssa.mir (+15)
diff --git a/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp b/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp
index ab396929162d0..54baf90d95a12 100644
--- a/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp
+++ b/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp
@@ -2311,6 +2311,8 @@ bool SIFoldOperandsImpl::tryOptimizeAGPRPhis(MachineBasicBlock &MBB) {
 }
 
 bool SIFoldOperandsImpl::run(MachineFunction &MF) {
+  MFPropsModifier _(*this, MF);
+
   MRI = &MF.getRegInfo();
   ST = &MF.getSubtarget<GCNSubtarget>();
   TII = ST->getInstrInfo();
diff --git a/llvm/test/CodeGen/AMDGPU/si-fold-operands-requires-ssa.mir b/llvm/test/CodeGen/AMDGPU/si-fold-operands-requires-ssa.mir
new file mode 100644
index 0000000000000..9cad4eeab76c8
--- /dev/null
+++ b/llvm/test/CodeGen/AMDGPU/si-fold-operands-requires-ssa.mir
@@ -0,0 +1,15 @@
+# RUN: not --crash llc -mtriple=amdgcn -mcpu=gfx900 -run-pass=si-fold-operands -filetype=null %s 2>&1 | FileCheck -check-prefix=ERR %s
+# RUN: not --crash llc -mtriple=amdgcn -mcpu=gfx900 -passes=si-fold-operands -filetype=null %s 2>&1 | FileCheck -check-prefix=ERR %s
+
+# ERR: MachineFunctionProperties required by SI Fold Operands pass are not met by function not_ssa.
+# ERR-NEXT: Required properties: IsSSA
+# ERR-NEXT: Current properties: NoPHIs
+---
+name:            not_ssa
+body:             |
+  bb.0:
+    liveins: $vgpr0, $vgpr1
+    %0:vgpr_32 = COPY $vgpr0
+    %0:vgpr_32 = COPY $vgpr1
+
+...

@optimisan
Copy link
Contributor

Taking a look.

@optimisan
Copy link
Contributor

optimisan commented Feb 20, 2025

Turned out the error printing is finicky.

@arsenm arsenm marked this pull request as ready for review February 20, 2025 12:58
arsenm and others added 2 commits March 4, 2025 10:30
This doesn't appear to work. I do not get an error in the new PM.
@arsenm
Copy link
Contributor Author

arsenm commented Mar 4, 2025

Turned out the error printing is finicky.

There is still no error with the new PM

@arsenm arsenm force-pushed the users/arsenm/newpm/amdgpu-si-fold-operands-requires-ssa branch from 3c9e817 to a0fe5a0 Compare March 4, 2025 04:45
Copy link
Contributor Author

arsenm commented Mar 12, 2025

ping

Comment on lines +4 to +7
# ERR-LEGACY: MachineFunctionProperties required by SI Fold Operands pass are not met by function not_ssa.
# ERR-NPM: MachineFunctionProperties required by SIFoldOperandsPass pass are not met by function not_ssa.
# ERR-NEXT: Required properties: IsSSA
# ERR-NEXT: Current properties: NoPHIs
Copy link
Contributor

@optimisan optimisan Mar 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is still no error with the new PM

This is the error right? The test passes now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, the test is failing on the bot. And fails for me locally. There is no error produced

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, checked again. Will take a look

@optimisan
Copy link
Contributor

Moved MFPropsModifier to NPM's run method.

@arsenm
Copy link
Contributor Author

arsenm commented Mar 17, 2025

Moved MFPropsModifier to NPM's run method.

I think this is a decent example of why this is a terrible API. There's no enforcement that every pass uses it

@arsenm arsenm changed the title WIP: AMDGPU: Use MFPropsModifier modifier in SIFoldOperands AMDGPU: Use MFPropsModifier modifier in SIFoldOperands Mar 17, 2025
@arsenm arsenm merged commit f75d75b into main Mar 17, 2025
11 checks passed
@arsenm arsenm deleted the users/arsenm/newpm/amdgpu-si-fold-operands-requires-ssa branch March 17, 2025 06:37
@dyung
Copy link
Collaborator

dyung commented Mar 17, 2025

Hi @arsenm, the test added in this change seems to be failing on a build bot (https://lab.llvm.org/buildbot/#/builders/202/builds/100), can you take a look?

@arsenm
Copy link
Contributor Author

arsenm commented Mar 18, 2025

Apparently this error is only produced with asserts, but we should promote this to an unconditional report_fatal_error

@arsenm
Copy link
Contributor Author

arsenm commented Mar 18, 2025

Fixed in 092e255

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants