[PATCH] D87078: [UnifyFunctionExitNodes] Remove unused getters, NFC

David Stenberg via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 3 02:18:27 PDT 2020


dstenb created this revision.
dstenb added a reviewer: bjope.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
dstenb requested review of this revision.

The get{Return,Unwind,Unreachable}Block functions in
UnifyFunctionExitNodes have not been used for many years,
so just remove them.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87078

Files:
  llvm/include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h
  llvm/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp


Index: llvm/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp
===================================================================
--- llvm/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp
+++ llvm/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp
@@ -61,12 +61,8 @@
       UnreachableBlocks.push_back(&I);
 
   // Then unreachable blocks.
-  if (UnreachableBlocks.empty()) {
-    UnreachableBlock = nullptr;
-  } else if (UnreachableBlocks.size() == 1) {
-    UnreachableBlock = UnreachableBlocks.front();
-  } else {
-    UnreachableBlock = BasicBlock::Create(F.getContext(),
+  if (UnreachableBlocks.size() > 1) {
+    BasicBlock *UnreachableBlock = BasicBlock::Create(F.getContext(),
                                           "UnifiedUnreachableBlock", &F);
     new UnreachableInst(F.getContext(), UnreachableBlock);
 
@@ -76,14 +72,9 @@
     }
   }
 
-  // Now handle return blocks.
-  if (ReturningBlocks.empty()) {
-    ReturnBlock = nullptr;
-    return false;                          // No blocks return
-  } else if (ReturningBlocks.size() == 1) {
-    ReturnBlock = ReturningBlocks.front(); // Already has a single return block
+  // There is nothing more to do if we do not have multiple return blocks.
+  if (ReturningBlocks.size() <= 1)
     return false;
-  }
 
   // Otherwise, we need to insert a new basic block into the function, add a PHI
   // nodes (if the function returns values), and convert all of the return
@@ -115,6 +106,5 @@
     BB->getInstList().pop_back();  // Remove the return insn
     BranchInst::Create(NewRetBlock, BB);
   }
-  ReturnBlock = NewRetBlock;
   return true;
 }
Index: llvm/include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h
===================================================================
--- llvm/include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h
+++ llvm/include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h
@@ -24,10 +24,6 @@
 class BasicBlock;
 
 struct UnifyFunctionExitNodes : public FunctionPass {
-  BasicBlock *ReturnBlock = nullptr;
-  BasicBlock *UnwindBlock = nullptr;
-  BasicBlock *UnreachableBlock;
-
 public:
   static char ID; // Pass identification, replacement for typeid
   UnifyFunctionExitNodes();
@@ -35,13 +31,6 @@
   // We can preserve non-critical-edgeness when we unify function exit nodes
   void getAnalysisUsage(AnalysisUsage &AU) const override;
 
-  // getReturn|Unwind|UnreachableBlock - Return the new single (or nonexistent)
-  // return, unwind, or unreachable  basic blocks in the CFG.
-  //
-  BasicBlock *getReturnBlock() const { return ReturnBlock; }
-  BasicBlock *getUnwindBlock() const { return UnwindBlock; }
-  BasicBlock *getUnreachableBlock() const { return UnreachableBlock; }
-
   bool runOnFunction(Function &F) override;
 };
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87078.289664.patch
Type: text/x-patch
Size: 2741 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200903/c1f698f1/attachment.bin>


More information about the llvm-commits mailing list