[PATCH] D151648: [ipsccp] Make sure Post Dominator Tree always is updated

Bjorn Pettersson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 29 05:16:05 PDT 2023


bjope created this revision.
bjope added a reviewer: labrinea.
Herald added subscribers: snehasish, ormris, hiraditya.
Herald added a project: All.
bjope requested review of this revision.
Herald added a project: LLVM.

Starting with commit 1b1232047e83b <https://reviews.llvm.org/rG1b1232047e83b69561fd64b9547cb0a0d374473a> the IPSCCP pass may use
BlockFrequencyAnalysis. Since BlockFrequencyAnalysis is using
the PostDominatorTree (PDT) analysis a PDT might be calculated
for each function during IPSCCP, even if the analysis wasn't
cached before the pass.
Before that commit IPSCCP only made sure to update PDT
during transformations if the analysis was cached before the pass
(to make sure the the PDT was preserved rather than invalidated
in such scenarios).
The problem solved in this ticket is that commit 1b1232047e83b <https://reviews.llvm.org/rG1b1232047e83b69561fd64b9547cb0a0d374473a> did
not change the criteria for when to update the PDT analysis. When
configuring the DomTreeUpdater it only provided the PDT if there
was a cached PDT analysis before IPSCCP started executing. Thus,
when the PDT was calculated as a side effect of running the
BlockFrequencyAnalysis, no DTU updates where made to that PDT, but
we still cached that (now invalid) PDT in the pass manager for future
passes.

Solution is a quick/simple fix to make sure that we calculate the
PDT before configuring the DTU. This to make sure we use the same PDT
when doing DTU updates as being used by the BlockFrequencyAnalysis.

A possible downside of this quick fix is that we might end up
calculating the PDT in many more scenarios (even when not using
the FunctionSpecializer+BlockFrequencyAnalysis). Maybe there are
ways to avoid that, but the goal with this patch is just to get rid
of crashes and potential miscompiles due to have a stale/invalid
PDT. An alternative would have been to revert 1b1232047e83b <https://reviews.llvm.org/rG1b1232047e83b69561fd64b9547cb0a0d374473a>, but
there are already other patches being based on that commit so then
I would need to find all related patches and revert all of them.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151648

Files:
  llvm/lib/Transforms/IPO/SCCP.cpp
  llvm/test/Transforms/SCCP/ipsccp-preserve-pdt.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151648.526429.patch
Type: text/x-patch
Size: 4660 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230529/38481d24/attachment.bin>


More information about the llvm-commits mailing list