[llvm] 1cf1dc3 - [IR] Convert check to assertion in PredIterator (NFC) (#137931)

via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 30 03:22:07 PDT 2025


Author: Nikita Popov
Date: 2025-04-30T12:22:03+02:00
New Revision: 1cf1dc340dcc265423c33ef9e62fd8f0ecfae1bc

URL: https://github.com/llvm/llvm-project/commit/1cf1dc340dcc265423c33ef9e62fd8f0ecfae1bc
DIFF: https://github.com/llvm/llvm-project/commit/1cf1dc340dcc265423c33ef9e62fd8f0ecfae1bc.diff

LOG: [IR] Convert check to assertion in PredIterator (NFC) (#137931)

After https://github.com/llvm/llvm-project/pull/137799 and
https://github.com/llvm/llvm-project/pull/137816, instruction uses of
BasicBlocks are always terminators, so assert that instead of checking
it.

Added: 
    

Modified: 
    llvm/include/llvm/IR/CFG.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/IR/CFG.h b/llvm/include/llvm/IR/CFG.h
index f8ec0971517a9..7c7e988fa9e8f 100644
--- a/llvm/include/llvm/IR/CFG.h
+++ b/llvm/include/llvm/IR/CFG.h
@@ -54,9 +54,10 @@ class PredIterator {
   inline void advancePastNonTerminators() {
     // Loop to ignore non-terminator uses (for example BlockAddresses).
     while (!It.atEnd()) {
-      if (auto *Inst = dyn_cast<Instruction>(*It))
-        if (Inst->isTerminator())
-          break;
+      if (auto *Inst = dyn_cast<Instruction>(*It)) {
+        assert(Inst->isTerminator() && "BasicBlock used in non-terminator");
+        break;
+      }
 
       ++It;
     }


        


More information about the llvm-commits mailing list