[LCSSA] Skip updating users in unreachable blocks.
authorFlorian Hahn <flo@fhahn.com>
Fri, 26 Aug 2022 14:09:46 +0000 (15:09 +0100)
committerFlorian Hahn <flo@fhahn.com>
Fri, 26 Aug 2022 14:09:46 +0000 (15:09 +0100)
Don't waste time trying to update users in unreachable blocks.

llvm/lib/Transforms/Utils/LCSSA.cpp

index 6de59f9..020a40b 100644 (file)
@@ -111,6 +111,10 @@ bool llvm::formLCSSAForInstructions(SmallVectorImpl<Instruction *> &Worklist,
       Instruction *User = cast<Instruction>(U.getUser());
       BasicBlock *UserBB = User->getParent();
 
+      // Skip uses in unreachable blocks.
+      if (!DT.isReachableFromEntry(UserBB))
+        continue;
+
       // For practical purposes, we consider that the use in a PHI
       // occurs in the respective predecessor block. For more info,
       // see the `phi` doc in LangRef and the LCSSA doc.