[flang-commits] [compiler-rt] [flang] [llvm] [libc] [libcxx] [clang] [clang-tools-extra] [clang][cleanup] simplify ReachableCode scanFromBlock (PR #72257)

Gábor Horváth via flang-commits flang-commits at lists.llvm.org
Thu Nov 23 16:58:34 PST 2023


================
@@ -341,30 +341,27 @@ static unsigned scanFromBlock(const CFGBlock *Start,
     // This allows us to potentially uncover some "always unreachable" code
     // within the "sometimes unreachable" code.
     // Look at the successors and mark then reachable.
-    std::optional<bool> TreatAllSuccessorsAsReachable;
-    if (!IncludeSometimesUnreachableEdges)
+    bool TreatAllSuccessorsAsReachable;
+    if (IncludeSometimesUnreachableEdges) {
+      assert(PP);
+      TreatAllSuccessorsAsReachable =
+          shouldTreatSuccessorsAsReachable(item, *PP);
+    } else {
       TreatAllSuccessorsAsReachable = false;
+    }
 
     for (CFGBlock::const_succ_iterator I = item->succ_begin(),
          E = item->succ_end(); I != E; ++I) {
       const CFGBlock *B = *I;
-      if (!B) do {
+      if (!B) {
         const CFGBlock *UB = I->getPossiblyUnreachableBlock();
         if (!UB)
           break;
----------------
Xazax-hun wrote:

This looks like a functional change. Previously this break was breaking out of the `do-while` loop, now it is breaking out of the `for` loop.

https://github.com/llvm/llvm-project/pull/72257


More information about the flang-commits mailing list