removeUnreachableBlocks knows how to preserve the DomTree, so make use
of it instead of re-computing the DT.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
I think I wrote some of this code and it predates Kuba's incremental dominator updater. I'm fine, but I'll wait if he has opinions cc: @kuhar
I suspect that this change caused a major compile-time performance regression in GlobalOpt. Doesn't this essentially break the laziness of LookupDomTree() and force DT construction even if it will not be needed?
As the removeUnreachableBlocks() call is (presumably) expected to never actually do something outside of manually constructed IR examples, this seems like a bad tradeoff. Ideally we would only fetch the DT here if it exists, but threading that through is likely not worthwhile.
Do you have a test case handy? Assuming the DT for F is already computed, LookupDomTree should be free, but looking at the preceding passes, it looks like IPSCCP does not preserve the DTs with the LegacyPassManager (When I tried I could not get a module pass to preserve individual function analysis).
Unless we can get the DTs preserved until here, it is probably best to use getAnalysisIfAvailable<DominatorTreeWrapperPass>() here instead.
Yes, we're still on the legacy manager, so DT is not available here. I've just verified that reverting this patch does indeed reclaim a sizable part of the LLVM 10 compile-time regressions (end-to-end timings).
Hm it seems like the legacy module pass manager does not allow using getAnalysisIfAvailable for function analysis :( I've put up D72214 with a workaround. Does this fix the regression as well? Otherwise I guess the easiest would be to just revert this patch until the legacy pass manager is gone....