-
Notifications
You must be signed in to change notification settings - Fork 14.3k
Fix crash from [CGData] Global Merge Functions (#112671) #116241
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
6010da4
to
c24e064
Compare
This fixes the crash I reported in #112671 (comment) I think it would be good to add a testcase though. There is a reproducer in #112671 (comment) so it's easy to make a testcase out of that. |
cc. @nocchijiang |
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.
Oh, it is kind of my fault letting it slip through. I had observed the same crash during my local testing but forgot to report the issue.
@@ -0,0 +1,6 @@ | |||
; This test checks if the global merge func pass should not build module summary. |
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.
Just a nitpick: should we move the test file into llvm/test/CodeGen/AArch64/
or even llvm/test/CodeGen/Generic/
since this is not a ThinLTO/backend-specific test?
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.
lgtm if this resolves the crash
@@ -666,7 +666,6 @@ bool GlobalMergeFuncPassWrapper::runOnModule(Module &M) { | |||
|
|||
PreservedAnalyses GlobalMergeFuncPass::run(Module &M, | |||
AnalysisManager<Module> &AM) { | |||
ModuleSummaryIndex *Index = &(AM.getResult<ModuleSummaryIndexAnalysis>(M)); | |||
bool Changed = GlobalMergeFunc(Index).run(M); | |||
bool Changed = GlobalMergeFunc(ImportSummary).run(M); |
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 GlobalMergeFunc doesn't need ModuleSummaryIndex, why not just initialize without the parameter? Is there some weird side effect from some other thing that requires passing it in even though it's not used?
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.
This pass only uses this combined summary to determine if it's a LTO mode -- https://github.com/llvm/llvm-project/blob/main/llvm/lib/CodeGen/GlobalMergeFunctions.cpp#L539-L542.
Currently, this pass is utilized in a pre-codegen pass that employs the legacy createGlobalMergeFuncPass()
. As per the review comment, I have also incorporated an option for the new pass manager, GlobalMergeFuncPass()
. If we intend to use this with the typical new PM, such as buildThinLTODefaultPipeline()
, it is necessary to pass ImportSummary
to the constructor.
35b8603
to
ac281be
Compare
ac281be
to
f96d717
Compare
Module summary index is optional for this pass, and we shouldn't run it, but import it as necessary.