Skip to content

CodeGen/NewPM: Initialize MMI in NewPM path #99754

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

Closed

Conversation

arsenm
Copy link
Contributor

@arsenm arsenm commented Jul 20, 2024

This should have been in c2019a3,
but it breaks with:

Assertion failed: (AnalysisPasses.count(PassT::ID()) && "This analysis pass was not registered prior to being queried"), function getResult, file PassManager.h, line 407.

This should have been in c2019a3,
but it breaks with:

Assertion failed: (AnalysisPasses.count(PassT::ID()) && "This analysis pass was not registered prior to being queried"), function getResult, file PassManager.h, line 407.
Copy link
Contributor Author

arsenm commented Jul 20, 2024

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

Join @arsenm and the rest of your teammates on Graphite Graphite

@arsenm arsenm requested review from aeubanks and paperchalice July 20, 2024 12:17
@arsenm arsenm marked this pull request as ready for review July 20, 2024 12:17
@llvmbot llvmbot added the llvm:SelectionDAG SelectionDAGISel as well label Jul 20, 2024
@llvmbot
Copy link
Member

llvmbot commented Jul 20, 2024

@llvm/pr-subscribers-llvm-selectiondag

Author: Matt Arsenault (arsenm)

Changes

This should have been in c2019a3,
but it breaks with:

Assertion failed: (AnalysisPasses.count(PassT::ID()) && "This analysis pass was not registered prior to being queried"), function getResult, file PassManager.h, line 407.


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

2 Files Affected:

  • (modified) llvm/include/llvm/Passes/MachinePassRegistry.def (+1)
  • (modified) llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (+2)
diff --git a/llvm/include/llvm/Passes/MachinePassRegistry.def b/llvm/include/llvm/Passes/MachinePassRegistry.def
index 03f0782de6fed..e702721c299a8 100644
--- a/llvm/include/llvm/Passes/MachinePassRegistry.def
+++ b/llvm/include/llvm/Passes/MachinePassRegistry.def
@@ -17,6 +17,7 @@
 #define MODULE_ANALYSIS(NAME, CREATE_PASS)
 #endif
 MODULE_ANALYSIS("collector-metadata", CollectorMetadataAnalysis())
+MODULE_ANALYSIS("machine-module-info", MachineModuleAnalysis())
 MODULE_ANALYSIS("pass-instrumentation", PassInstrumentationAnalysis(PIC))
 #undef MODULE_ANALYSIS
 
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
index 2670ff488fbed..478e544fd4bc0 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
@@ -509,6 +509,8 @@ void SelectionDAGISel::initializeAnalysisResults(
     FnVarLocs = &FAM.getResult<DebugAssignmentTrackingAnalysis>(Fn);
 
   auto *UA = FAM.getCachedResult<UniformityInfoAnalysis>(Fn);
+  MMI = &MFAM.getResult<MachineModuleAnalysis>(*MF).getMMI();
+
   CurDAG->init(*MF, *ORE, MFAM, LibInfo, UA, PSI, BFI, *MMI, FnVarLocs);
 
   // Now get the optional analyzes if we want to.

@@ -509,6 +509,8 @@ void SelectionDAGISel::initializeAnalysisResults(
FnVarLocs = &FAM.getResult<DebugAssignmentTrackingAnalysis>(Fn);

auto *UA = FAM.getCachedResult<UniformityInfoAnalysis>(Fn);
MMI = &MFAM.getResult<MachineModuleAnalysis>(*MF).getMMI();
Copy link
Contributor

Choose a reason for hiding this comment

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

IIUC it should be obtained from ModuleAnalysisManager or ModuleAnalysisManagerMachineFunctionProxy, but current ModuleAnalysisManagerMachineFunctionProxy is an OuterAnalysisManagerProxy.

off-topic: Ideally, it should be thread-safe to obtain module analysis results in machine function pass pipeline.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was expecting this to not compile if it wasn't going to work. I'm not sure how to get a ModuleAnalysisManager from the MachineFunctionAnalysisManager

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the registration is just not happening and I'm not sure why. I can't run the analysis standalone with -passes either

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ping. Is MachineModuleInfo just broken in new PM?

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
MMI = &MFAM.getResult<MachineModuleAnalysis>(*MF).getMMI();
MMI = MFAM.getResult<ModuleAnalysisManagerMachineFunctionProxy>(*MF)
.getCachedResult<MachineModuleAnalysis>(*MF->getFunction().getParent());

arsenm added a commit that referenced this pull request Jul 24, 2024
@arsenm
Copy link
Contributor Author

arsenm commented Jul 24, 2024

Thanks, folded into #99779

@arsenm arsenm closed this Jul 24, 2024
@arsenm arsenm deleted the users/arsenm/codegen-newpm-machinemoduleinfo-sdag branch April 25, 2025 11:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
llvm:codegen llvm:SelectionDAG SelectionDAGISel as well
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants