[all-commits] [llvm/llvm-project] d81d9e: [SplitEdge] Update SplitCriticalEdge to return a n...

Sidharth Baveja via All-commits all-commits at lists.llvm.org
Tue Apr 6 14:26:32 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: d81d9e8b8604c85709de0a22bb8dd672a28f0401
      https://github.com/llvm/llvm-project/commit/d81d9e8b8604c85709de0a22bb8dd672a28f0401
  Author: Sidharth Baveja <sidharth.baveja at ibm.com>
  Date:   2021-04-06 (Tue, 06 Apr 2021)

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

  Log Message:
  -----------
  [SplitEdge] Update SplitCriticalEdge to return a nullptr only when the edge is not critical

Summary:
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.

Reviewed By: asbirlea

Differential Revision:https://reviews.llvm.org/D94619




More information about the All-commits mailing list