[llvm] 17dce2f - [UnifyFunctionExitNodes] Remove unused getters, NFC

David Stenberg via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 8 11:42:53 PDT 2020


Author: David Stenberg
Date: 2020-09-08T20:42:28+02:00
New Revision: 17dce2fe43c9d3335d64936ece576b0e36d8fe31

URL: https://github.com/llvm/llvm-project/commit/17dce2fe43c9d3335d64936ece576b0e36d8fe31
DIFF: https://github.com/llvm/llvm-project/commit/17dce2fe43c9d3335d64936ece576b0e36d8fe31.diff

LOG: [UnifyFunctionExitNodes] Remove unused getters, NFC

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

Reviewed By: bjope

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

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h b/llvm/include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h
index ff70446e163d..ce7cb16b3886 100644
--- a/llvm/include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h
+++ b/llvm/include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h
@@ -7,10 +7,7 @@
 //===----------------------------------------------------------------------===//
 //
 // This pass is used to ensure that functions have at most one return and one
-// unwind instruction in them.  Additionally, it keeps track of which node is
-// the new exit node of the CFG.  If there are no return or unwind instructions
-// in the function, the getReturnBlock/getUnwindBlock methods will return a null
-// pointer.
+// unreachable instruction in them.
 //
 //===----------------------------------------------------------------------===//
 
@@ -24,10 +21,6 @@ namespace llvm {
 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 +28,6 @@ struct UnifyFunctionExitNodes : public FunctionPass {
   // 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;
 };
 

diff  --git a/llvm/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp b/llvm/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp
index 9af39d9a0dd1..b124d0536254 100644
--- a/llvm/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp
+++ b/llvm/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp
@@ -6,10 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 //
-// This pass is used to ensure that functions have at most one return
-// instruction in them.  Additionally, it keeps track of which node is the new
-// exit node of the CFG.  If there are no exit nodes in the CFG, the getExitNode
-// method will return a null pointer.
+// This pass is used to ensure that functions have at most one return and one
+// unreachable instruction in them.
 //
 //===----------------------------------------------------------------------===//
 
@@ -61,12 +59,8 @@ bool UnifyFunctionExitNodes::runOnFunction(Function &F) {
       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 +70,9 @@ bool UnifyFunctionExitNodes::runOnFunction(Function &F) {
     }
   }
 
-  // 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 +104,5 @@ bool UnifyFunctionExitNodes::runOnFunction(Function &F) {
     BB->getInstList().pop_back();  // Remove the return insn
     BranchInst::Create(NewRetBlock, BB);
   }
-  ReturnBlock = NewRetBlock;
   return true;
 }


        


More information about the llvm-commits mailing list