[llvm] 1936bb8 - [ConstantHoisting] use BasicBlock::getFirstInsertionPt NFC

Nick Desaulniers via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 12 09:50:51 PDT 2023


Author: Nick Desaulniers
Date: 2023-07-12T09:40:54-07:00
New Revision: 1936bb81aafdbb3b4c9770a24fc77ba07669bd19

URL: https://github.com/llvm/llvm-project/commit/1936bb81aafdbb3b4c9770a24fc77ba07669bd19
DIFF: https://github.com/llvm/llvm-project/commit/1936bb81aafdbb3b4c9770a24fc77ba07669bd19.diff

LOG: [ConstantHoisting] use BasicBlock::getFirstInsertionPt NFC

Rather than open coding the same implementation.

Reviewed By: MaskRay, void

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

Added: 
    

Modified: 
    llvm/lib/Transforms/Scalar/ConstantHoisting.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Scalar/ConstantHoisting.cpp b/llvm/lib/Transforms/Scalar/ConstantHoisting.cpp
index 4ef51703d1c2d8..18c9d039a5100b 100644
--- a/llvm/lib/Transforms/Scalar/ConstantHoisting.cpp
+++ b/llvm/lib/Transforms/Scalar/ConstantHoisting.cpp
@@ -323,12 +323,8 @@ SetVector<Instruction *> ConstantHoistingPass::findConstantInsertionPoint(
 
   if (BFI) {
     findBestInsertionSet(*DT, *BFI, Entry, BBs);
-    for (auto *BB : BBs) {
-      BasicBlock::iterator InsertPt = BB->begin();
-      for (; isa<PHINode>(InsertPt) || InsertPt->isEHPad(); ++InsertPt)
-        ;
-      InsertPts.insert(&*InsertPt);
-    }
+    for (BasicBlock *BB : BBs)
+      InsertPts.insert(&*BB->getFirstInsertionPt());
     return InsertPts;
   }
 


        


More information about the llvm-commits mailing list