Skip to content

[NewPM] Introduce MFAnalysisGetter for a common analysis getter #116166

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

Conversation

optimisan
Copy link
Contributor

@optimisan optimisan commented Nov 14, 2024

With this, there is no need to both getAnalysis<AnaT>() and MFAM.getResult<AnaT>(MF) to pass in analysis from legacy/new pass managers.

Instead just pass the MFAnalysisGetter into the pass implementation and use AG.getAnalysis<AnaT>(MF) once. It also detects outer analyses and routes it through the proxies itself.

@optimisan
Copy link
Contributor Author

optimisan commented Nov 14, 2024

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

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

@optimisan optimisan marked this pull request as ready for review November 14, 2024 06:04
@optimisan optimisan force-pushed the users/Akshat-Oke/11-14-_newpm_introduce_mfanalysisgetter_for_a_common_analysis_getter branch from 197b28c to 7e31c7d Compare November 14, 2024 06:17
Copy link
Collaborator

@cdevadas cdevadas left a comment

Choose a reason for hiding this comment

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

I liked the general direction. Do you have at least one analysis pass ported using this Getter?

MFAnalysisGetter(Pass *LegacyPass) : LegacyPass(LegacyPass) {}
MFAnalysisGetter(MachineFunctionAnalysisManager *MFAM) : MFAM(MFAM) {}

/// Outer analyses requested from NPM will be cached results and can be null
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ditto.

@@ -236,6 +238,82 @@ using MachineFunctionPassManager = PassManager<MachineFunction>;
/// preserve.
PreservedAnalyses getMachineFunctionPassPreservedAnalyses();

/// For migrating to new pass manager
Copy link
Collaborator

Choose a reason for hiding this comment

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

Full stop at the end of the comment.

template <typename AnalysisT>
typename AnalysisT::Result *getAnalysis(MachineFunction &MF) {
if (MFAM) {
// need a proxy to get the result for outer analyses
Copy link
Collaborator

Choose a reason for hiding this comment

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

Capitalize the first character.

@optimisan optimisan force-pushed the users/Akshat-Oke/10-30-_codegen_newpm_port_machinecycleinfo_to_npm branch from 68bcb36 to be67756 Compare November 14, 2024 11:54
@optimisan optimisan force-pushed the users/Akshat-Oke/11-14-_newpm_introduce_mfanalysisgetter_for_a_common_analysis_getter branch from 125b82d to fa301f7 Compare November 14, 2024 11:54
@optimisan
Copy link
Contributor Author

Updated MachineSink to use this #115434

@optimisan optimisan force-pushed the users/Akshat-Oke/10-30-_codegen_newpm_port_machinecycleinfo_to_npm branch from be67756 to 751c8bf Compare November 14, 2024 13:20
@optimisan optimisan force-pushed the users/Akshat-Oke/11-14-_newpm_introduce_mfanalysisgetter_for_a_common_analysis_getter branch from fa301f7 to 9343a47 Compare November 14, 2024 13:21
Copy link
Contributor

@aeubanks aeubanks left a comment

Choose a reason for hiding this comment

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

I'd really rather not do this. With the new pass manager transition for the optimization pipeline, it was fine to not have this abstraction, and other similar abstractions between the legacy/new pass manager (CallGraphUpdater) have caused issues due to subtle differences between the legacy/new pass manager. We're just going to have to tear it down anyway if we remove the legacy pass manager.

@optimisan
Copy link
Contributor Author

I see. I saw this kind of abstraction being used in Attributor so thought I'd make it available here.

@optimisan optimisan closed this Nov 18, 2024
@optimisan optimisan deleted the users/Akshat-Oke/11-14-_newpm_introduce_mfanalysisgetter_for_a_common_analysis_getter branch April 7, 2025 10:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants