Skip to content

[CodeGen][NewPM] Make MFProperties methods const NFC #113304

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 1 commit into from
Oct 24, 2024

Conversation

optimisan
Copy link
Contributor

Makes them congruent with the legacy PM methods.

Unless it was made non-const on purpose: was it?

@optimisan optimisan changed the title [CodeGen][NewPM] Make MFProperty methods const [CodeGen][NewPM] Make MFProperties methods const Oct 22, 2024
@optimisan optimisan marked this pull request as ready for review October 22, 2024 12:18
@llvmbot
Copy link
Member

llvmbot commented Oct 22, 2024

@llvm/pr-subscribers-backend-amdgpu

Author: Akshat Oke (optimisan)

Changes

Makes them congruent with the legacy PM methods.

Unless it was made non-const on purpose: was it?


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

4 Files Affected:

  • (modified) llvm/include/llvm/CodeGen/MachinePassManager.h (+2-2)
  • (modified) llvm/include/llvm/CodeGen/RegAllocFast.h (+3-3)
  • (modified) llvm/include/llvm/CodeGen/TwoAddressInstructionPass.h (+1-1)
  • (modified) llvm/lib/Target/AMDGPU/SILowerSGPRSpills.h (+1-1)
diff --git a/llvm/include/llvm/CodeGen/MachinePassManager.h b/llvm/include/llvm/CodeGen/MachinePassManager.h
index 253fabdac0019d..69b5f6e92940c4 100644
--- a/llvm/include/llvm/CodeGen/MachinePassManager.h
+++ b/llvm/include/llvm/CodeGen/MachinePassManager.h
@@ -41,7 +41,7 @@ using MachineFunctionAnalysisManager = AnalysisManager<MachineFunction>;
 /// MachineFunctionProperties properly.
 template <typename PassT> class MFPropsModifier {
 public:
-  MFPropsModifier(PassT &P_, MachineFunction &MF_) : P(P_), MF(MF_) {
+  MFPropsModifier(const PassT &P_, MachineFunction &MF_) : P(P_), MF(MF_) {
     auto &MFProps = MF.getProperties();
 #ifndef NDEBUG
     if constexpr (has_get_required_properties_v<PassT>) {
@@ -71,7 +71,7 @@ template <typename PassT> class MFPropsModifier {
   }
 
 private:
-  PassT &P;
+  const PassT &P;
   MachineFunction &MF;
 
   template <typename T>
diff --git a/llvm/include/llvm/CodeGen/RegAllocFast.h b/llvm/include/llvm/CodeGen/RegAllocFast.h
index c99c715daacf96..440264a06ae89e 100644
--- a/llvm/include/llvm/CodeGen/RegAllocFast.h
+++ b/llvm/include/llvm/CodeGen/RegAllocFast.h
@@ -27,12 +27,12 @@ class RegAllocFastPass : public PassInfoMixin<RegAllocFastPass> {
   RegAllocFastPass(RegAllocFastPassOptions Opts = RegAllocFastPassOptions())
       : Opts(Opts) {}
 
-  MachineFunctionProperties getRequiredProperties() {
+  MachineFunctionProperties getRequiredProperties() const {
     return MachineFunctionProperties().set(
         MachineFunctionProperties::Property::NoPHIs);
   }
 
-  MachineFunctionProperties getSetProperties() {
+  MachineFunctionProperties getSetProperties() const {
     if (Opts.ClearVRegs) {
       return MachineFunctionProperties().set(
           MachineFunctionProperties::Property::NoVRegs);
@@ -41,7 +41,7 @@ class RegAllocFastPass : public PassInfoMixin<RegAllocFastPass> {
     return MachineFunctionProperties();
   }
 
-  MachineFunctionProperties getClearedProperties() {
+  MachineFunctionProperties getClearedProperties() const {
     return MachineFunctionProperties().set(
         MachineFunctionProperties::Property::IsSSA);
   }
diff --git a/llvm/include/llvm/CodeGen/TwoAddressInstructionPass.h b/llvm/include/llvm/CodeGen/TwoAddressInstructionPass.h
index 7f2a070c584347..d4d47f29cc8446 100644
--- a/llvm/include/llvm/CodeGen/TwoAddressInstructionPass.h
+++ b/llvm/include/llvm/CodeGen/TwoAddressInstructionPass.h
@@ -18,7 +18,7 @@ class TwoAddressInstructionPass
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
-  MachineFunctionProperties getSetProperties() {
+  MachineFunctionProperties getSetProperties() const {
     return MachineFunctionProperties().set(
         MachineFunctionProperties::Property::TiedOpsRewritten);
   }
diff --git a/llvm/lib/Target/AMDGPU/SILowerSGPRSpills.h b/llvm/lib/Target/AMDGPU/SILowerSGPRSpills.h
index 730b3f8c617bd3..a9ffb5705d094a 100644
--- a/llvm/lib/Target/AMDGPU/SILowerSGPRSpills.h
+++ b/llvm/lib/Target/AMDGPU/SILowerSGPRSpills.h
@@ -17,7 +17,7 @@ class SILowerSGPRSpillsPass : public PassInfoMixin<SILowerSGPRSpillsPass> {
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
 
-  MachineFunctionProperties getClearedProperties() {
+  MachineFunctionProperties getClearedProperties() const {
     // SILowerSGPRSpills introduces new Virtual VGPRs for spilling SGPRs.
     return MachineFunctionProperties()
         .set(MachineFunctionProperties::Property::IsSSA)

@optimisan optimisan requested review from aeubanks and cdevadas and removed request for aeubanks October 22, 2024 12:19
@optimisan optimisan marked this pull request as draft October 22, 2024 12:29
@optimisan optimisan changed the title [CodeGen][NewPM] Make MFProperties methods const [CodeGen][NewPM] Make MFProperties methods const NFC Oct 22, 2024
Makes them congruent with the legacy PM methods.
@optimisan optimisan marked this pull request as ready for review October 23, 2024 10:06
@optimisan optimisan merged commit 789fdd5 into llvm:main Oct 24, 2024
8 checks passed
@frobtech frobtech mentioned this pull request Oct 25, 2024
NoumanAmir657 pushed a commit to NoumanAmir657/llvm-project that referenced this pull request Nov 4, 2024
Makes them congruent with the legacy PM methods.
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.

3 participants