-
Notifications
You must be signed in to change notification settings - Fork 14.1k
Allow loading LLVM plugins with both legacy and new pass manager #91125
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
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
97cf461
Add a codegen option to allow loading LLVM pass plugins
eskarn c4f29fa
Use the existing llvm-plugins option for both legacy and new pm regis…
eskarn 75d1208
Fix conditions for using legacy or new pm plugins
eskarn 052961b
rustc_codegen_llvm: move should_use_new_llvm_pass_manager function to…
eskarn f431df0
Load new pass manager plugins only if the new pm is actually used
eskarn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If
new_llvm_pass_managerreturnsNone, the new pass manager is used when the llvm version is at least 13 and the target is not s390x. Seerust/compiler/rustc_codegen_llvm/src/back/write.rs
Lines 397 to 410 in 8b09ba6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that's what i was mentioning at the end of #91125 (comment).
What i'm proposing is to condition the new PM plugin loading only on the explicit
new_llvm_pass_manager=yesand not the actual usage of the new PM later. Since there are exceptions and a default value hardcoded, we can't trust the option to reflect reality.If we do want to condition on the actual usage of the new PM then i see two potential issues:
llvm-pluginswhen updating to a llvm13 based rust will trigger PassPlugin::Load on their legacy plugins since the new PM is enabled by default. They will need to explicitly setnew_llvm_pass_manager=falseshould_use_new_llvm_pass_managerin llvm_util.rs, maybe just move it to llvm_util.rs to make it more widely available ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bjorn3 do you think the current code is acceptable regarding the explicit usage of
new_llvm_pass_manageror i shouldpropose the alternative described in my last reply ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the late reply. Missed your previous comment.
At least in that case you will get an error message rather than silently ignoring it, right?
Makes sense I think.
I think using
should_use_new_llvm_pass_manageris better. I don't strongly object to the current code though.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem, i should have pinged you earlier but i was busy on other tasks anyway.
Indeed, in that case
cargo buildfails with an error and i can see original LLVM error message directly in cargo non verbose logs like this:Plugin entry point not found in '/tmp/libLLVMPlugin.so'. Is this a legacy plugin?Ok let's try it.
Ok thank you for your feedback, i'll try doing it this way and see how that goes.