Skip to content

Refactor CodeGen Pipeline Setup into a Single Function - #162556

Open
boomanaiden154 wants to merge 1 commit into
rust-lang:mainfrom
boomanaiden154:rustc-legacy-pm-refactoring-9-9-26
Open

boomanaiden154 wants to merge 1 commit into
rust-lang:mainfrom
boomanaiden154:rustc-legacy-pm-refactoring-9-9-26

Conversation

@boomanaiden154

Copy link
Copy Markdown

This patch refactors setup of the LegacyPassManager for CodeGen into a single function. This simplifies some things (lifetime for the LegacyPM object), but is primarily aimed at enabling rustc to use the new runCodeGenPipeline abstraction (introduced in LLVM 24) which handles all of these details within LLVM and additionally defaults to the NewPM when a target opts-in/the correct LLVM flag is passed.

@rustbot rustbot added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 9, 2026
@rustbot

rustbot commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the pull request, and welcome! The Rust Project has assigned @cuviper (or someone else) to review your changes, you should hear from them (or someone else) within the next two weeks.

Please see the contribution instructions and our LLM policy for more information.

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @cuviper

@rust-bors

This comment has been minimized.

This patch refactors setup of the LegacyPassManager for CodeGen into a
single function. This simplifies some things (lifetime for the LegacyPM
object), but is primarily aimed at enabling rustc to use the new
runCodeGenPipeline abstraction (introduced in LLVM 24) which handles all
of these details within LLVM and additionally defaults to the NewPM when
a target opts-in/the correct LLVM flag is passed.
@boomanaiden154
boomanaiden154 force-pushed the rustc-legacy-pm-refactoring-9-9-26 branch from 3d1a7ac to 55d2be6 Compare September 14, 2026 16:37
@rustbot

rustbot commented Sep 14, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@cuviper cuviper left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Note, this will conflict with #162822, but that will hopefully be easy to merge first and then rebase this PR.

View changes since this review

// Apparently `addPassesToEmitFile` adds a pointer to our on-the-stack output
// stream (OS), so the only real safe place to delete this is here? Don't we
// wish this was written in Rust?
LLVMDisposePassManager(PMR);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Isn't this destructor order still relevant? With PM declared first, it will now be deleted after OS and BOS, which is what that comment warned against.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 15, 2026
@rustbot

rustbot commented Sep 15, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@rust-bors

rust-bors Bot commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #162827) made this pull request unmergeable. Please resolve the merge conflicts by rebasing.

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

Labels

A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants