[PATCH] D92200: Deal with issue=>SplitEdge(BB, Succ, ...…

Bangtian Liu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 26 17:06:58 PST 2020


kobeliu85 created this revision.
kobeliu85 added reviewers: Whitney, etiotto, jamieschmeiser, bmahjour, mkazantsev, tellenbach, hoy.
kobeliu85 created this object with visibility "All Users".
Herald added subscribers: llvm-commits, dexonsmith, hiraditya.
Herald added a project: LLVM.
kobeliu85 requested review of this revision.

This PR implements the function splitBasicBlockBefore to address an issue
that occurred during SplitEdge(BB, Succ, ...), inside splitBlockBefore.
The issue occurs in SplitEdge when the Succ has a single predecessor
 and the edge between the BB and Succ is not critical. This produces
the result ‘BB->Succ->New’. The new function splitBasicBlockBefore
was added to splitBlockBefore to handle the issue and now produces
the correct result ‘BB->New->Succ’.

Below is an example of splitting the block bb1 at its first instruction.

  /// Original IR
  bb0:
  	br bb1
  bb1:
          %0 = mul i32 1, 2
  	br bb2
  bb2:



  /// IR after splitEdge(bb0, bb1) using splitBasicBlock
  bb0:
  	br bb1
  bb1:
  	br bb1.split
  bb1.split:
          %0 = mul i32 1, 2
  	br bb2
  bb2:



  /// IR after splitEdge(bb0, bb1) using splitBasicBlockBefore
  bb0:
  	br bb1.split
  bb1.split
  	br bb1
  bb1:
          %0 = mul i32 1, 2
  	br bb2
  bb2:


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92200

Files:
  llvm/include/llvm/IR/BasicBlock.h
  llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h
  llvm/lib/IR/BasicBlock.cpp
  llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
  llvm/unittests/Transforms/Utils/BasicBlockUtilsTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D92200.307937.patch
Type: text/x-patch
Size: 20692 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201127/49cb2f62/attachment.bin>


More information about the llvm-commits mailing list