[all-commits] [llvm/llvm-project] 15b673: Create utility function to Merge Adjacent Basic Bl...

whitneywhtsang via All-commits all-commits at lists.llvm.org
Thu May 28 09:45:02 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 15b6730f078329b3103a7a0476bc2227df214f4a
      https://github.com/llvm/llvm-project/commit/15b6730f078329b3103a7a0476bc2227df214f4a
  Author: Sidharth Baveja <Sidharth.Baveja at ibm.com>
  Date:   2020-05-28 (Thu, 28 May 2020)

  Changed paths:
    M llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h
    M llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
    M llvm/lib/Transforms/Utils/LoopUnrollAndJam.cpp

  Log Message:
  -----------
  Create utility function to Merge Adjacent Basic Blocks

Summary: The following code from
/llvm/lib/Transforms/Utils/LoopUnrollAndJam.cpp can be used by other
transformations:

while (!MergeBlocks.empty()) {
    BasicBlock *BB = *MergeBlocks.begin();
    BranchInst *Term = dyn_cast<BranchInst>(BB->getTerminator());
    if (Term && Term->isUnconditional() &&
L->contains(Term->getSuccessor(0))) {
      BasicBlock *Dest = Term->getSuccessor(0);
      BasicBlock *Fold = Dest->getUniquePredecessor();
      if (MergeBlockIntoPredecessor(Dest, &DTU, LI)) {
        // Don't remove BB and add Fold as they are the same BB
        assert(Fold == BB);
        (void)Fold;
        MergeBlocks.erase(Dest);
      } else
        MergeBlocks.erase(BB);
    } else
      MergeBlocks.erase(BB);
  }
Hence it should be separated into its own utility function.

Authored By: sidbav
Reviewer: Whitney, Meinersbur, asbirlea, dmgreen, etiotto
Reviewed By: asbirlea
Subscribers: hiraditya, zzheng, llvm-commits
Tag: LLVM
Differential Revision: https://reviews.llvm.org/D80583




More information about the All-commits mailing list