[PATCH] D94619: [SplitEdge] Update to handle cases which were not previously considered when the edge is critical.

Sidharth Baveja via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 13 11:02:13 PST 2021


sidbav created this revision.
sidbav added reviewers: jamieschmeiser, bmahjour, Whitney, GorNishanov, fhahn.
Herald added subscribers: lxfind, hiraditya.
sidbav requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

The function SplitCriticalEdge (called by SplitEdge) can return a nullptr in cases where the edge is a critical. SplitEdge uses SplitCriticalEdge assuming it can always split all critical edges, which is an incorrect assumption.

The three cases where the function SplitCriticalEdge will return a nullptr is:

1. DestBB is an exception block
2. Options.IgnoreUnreachableDests is set to true and isa(DestBB->getFirstNonPHIOrDbgOrLifetime()) is not equal to a nullptr
3. LoopSimplify form must be preserved (Options.PreserveLoopSimplify is true) and it cannot be maintained for a loop due to indirect branches

For each of these situations they are handled in the following way:

1. Modified the function ehAwareSplitEdge originally from llvm/lib/Transforms/Coroutines/CoroFrame.cpp to handle the cases when the DestBB is an exception block. This function is called directly in SplitEdge. SplitEdge does not call SplitCriticalEdge in this case
2. Options.IgnoreUnreachableDests is set to false by default, so this situation does not apply.
3. Return a nullptr in this situation since the SplitCriticalEdge also returned nullptr. Nothing we can do in this case.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D94619

Files:
  llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h
  llvm/lib/Transforms/Coroutines/CoroFrame.cpp
  llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
  llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp
  llvm/unittests/Transforms/Utils/BasicBlockUtilsTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D94619.316451.patch
Type: text/x-patch
Size: 22426 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210113/efad3920/attachment.bin>


More information about the llvm-commits mailing list