Skip to content
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

[CodeGen] Port FreeMachineFunction to new pass manager #79421

Merged

Conversation

paperchalice
Copy link
Contributor

This pass should be the last machine function pass in pipeline, also ignore PI.runAfterPass(*P, MF, PassPA); to avoid accessing a dangling reference.

@@ -125,8 +125,8 @@ MACHINE_FUNCTION_ANALYSIS("pass-instrumentation", PassInstrumentationAnalysis,
#ifndef MACHINE_FUNCTION_PASS
#define MACHINE_FUNCTION_PASS(NAME, PASS_NAME, CONSTRUCTOR)
#endif
MACHINE_FUNCTION_PASS("free-machine-function", FreeMachineFunctionPass, ())
Copy link
Contributor

Choose a reason for hiding this comment

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

do we somehow block running this with -run-pass? What happens if you manually run this on its own or before other passes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In theory we should never run this pass manually, MachineFunctionPassManager will always create a machine function (by getOrCreateMachineFunction). Or we shouldn't expose this pass , like BitcodeWriterPass.

@paperchalice paperchalice merged commit 12a8bc0 into llvm:main Jan 25, 2024
3 of 4 checks passed
@paperchalice paperchalice deleted the NPM/CodeGen/free-machine-function branch January 25, 2024 09:32
@aeubanks
Copy link
Contributor

the intention with FreeMachineFunction is to be able to not have all MFs in memory at once right? however, any module pass in the pipeline breaks that since we'll run passes on every machine function before the module pass

for example, there was a module pass unconditionally added to every codegen pipeline until 2021 in https://reviews.llvm.org/D99707. that makes me wonder, should we just give up on the idea of the FreeMachineFunction pass for simplification, and instead just free all the machine functions at once somehow?

@paperchalice
Copy link
Contributor Author

the intention with FreeMachineFunction is to be able to not have all MFs in memory at once right? however, any module pass in the pipeline breaks that since we'll run passes on every machine function before the module pass

for example, there was a module pass unconditionally added to every codegen pipeline until 2021 in https://reviews.llvm.org/D99707. that makes me wonder, should we just give up on the idea of the FreeMachineFunction pass for simplification, and instead just free all the machine functions at once somehow?

May need memory profile here, IIRC this is a memory space trade-off (https://discourse.llvm.org/t/rfc-introducing-classes-for-the-codegen-driven-by-new-pass-manager/55877/19).

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.

None yet

3 participants