An well-formed IR function definition must have an entry basic block and
a well-formed IR basic block must have one terminator so the emptiness
check can be simplified.
Also simplify the test a bit.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Thanks for the simplifications. This lgtm but please wait for @luna to confirm that the simplified test case fails without the original fix.
thanks for the simplification!
The comment for IR (test case) is just a FYI, and for the cpp change, more of a double check since I wasn't sure myself if function declaration would make a difference.
llvm/lib/Analysis/ModuleSummaryAnalysis.cpp | ||
---|---|---|
242–243 |
a well-formed IR basic block must have one terminator so the emptiness Thanks for pointing this out! I think this is true for function definition but not true for function declarations. Yet I don't know if computeFunctionSummary [1] (caller of mustBeUnreachableFunction) guarantees it's a function definition (not a function declaration). Is there a way to make this safe for function declarations (if necessary)? [1] https://github.com/llvm/llvm-project/blob/main/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp#L257 | |
llvm/test/ThinLTO/X86/Inputs/devirt_hybrid_after_filtering_unreachable_lib.ll | ||
37–39 | thanks for the simplification! The change looks good to me, and I can verify that nodevirtualization happens on simplified IRs without the fix (by using -vv on llvm-lit to print out the commands, and re-run commands using {opt, llvm-lto2} without the change. Just fyi I added -O3 (which is absent before) on the command to generate the IR, and got simpler IR for both IR [1]; so going to carry on the simplification in a pending patch (https://reviews.llvm.org/D115648) [1] https://gist.github.com/minglotus-6/aea3355e6e9a63d5a047a301dca7c7d7 for devirt_hybrid_after_filtering_unreachable.ll, and https://gist.github.com/minglotus-6/546e2a6627a8cc6823022b4ff30a7d43 for Inputs/devirt_hybrid_after_filtering_unreachable_lib.ll, |
llvm/lib/Analysis/ModuleSummaryAnalysis.cpp | ||
---|---|---|
242–243 |
After another look, caller guarantees F is a function definition, so LGTM. Maybe add a comment for mustBeUnreachableFunction that caller guarantees F is a function definition (not a function declaration)?
|
a well-formed IR basic block must have one terminator so the emptiness
check can be simplified.
Thanks for pointing this out!
I think this is true for function definition but not true for function declarations. Yet I don't know if computeFunctionSummary [1] (caller of mustBeUnreachableFunction) guarantees it's a function definition (not a function declaration).
Is there a way to make this safe for function declarations (if necessary)?
[1] https://github.com/llvm/llvm-project/blob/main/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp#L257