In regular LTO, analyze IR and discard unreachable functions when finding virtual call targets.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp | ||
---|---|---|
1057 | Since you are adding the IR check above, thinking that to optimize for compile time this lookup should be ignored if we have the def of Fn available (avoids an extra hash table lookup and analysis). |
Save one index lookup if function def is present for IR analysis. Also simplify test case.
thanks for review!
I simplify the test case here, and could do the same for the previous two test cases either here or in a separate patch.
llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp | ||
---|---|---|
1057 | Done by "first analyze function def in IR if that's present, and use export summary as a fallback". I took the liberty to add a comment like [1]; I'm wondering what's the idiomatic way to provide pointer a line of code w/ commit for reference? [1] // FWIW, the writer of `ExportSummary` guarantees that function declarations // won't have an entry in `ExportSummary`; // see llvm/lib/Analysis/ModuleSummaryAnalysis.cpp#L785 at commit cf9e61a for // a reference. |
lgtm
llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp | ||
---|---|---|
1057 | That's a good question on code reference. Usually I see references to the file or function granularity, not this specific. However, I don't think it is really needed here. Note on that below. | |
2117 | I don't think this comment is really relevant here. Note you are coming into this part of the handling specifically when we *do* have a function declaration in this module, so it is a little confusing to explain why we don't create a summary for them. The reason why we may have a summary for what is a function decl in this combined regular LTO module is that we have the combined summaries of all of the ThinLTO modules, and the def is in one of those. So I would just keep the first sentence of this comment block ("Learn unreachability from ..."). |
Remove comments on function declarations, as a combined index may contain entries for func declarations.
thanks!
llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp | ||
---|---|---|
1057 | Got it, thanks for the inputs! | |
2117 |
I will keep this in mind, thanks for pointing it out! Removed the comment for function declaration. |
Since you are adding the IR check above, thinking that to optimize for compile time this lookup should be ignored if we have the def of Fn available (avoids an extra hash table lookup and analysis).