[SimplifyCFG] Account for N being null.
authorFlorian Hahn <flo@fhahn.com>
Sat, 7 Dec 2019 17:22:14 +0000 (17:22 +0000)
committerFlorian Hahn <flo@fhahn.com>
Sat, 7 Dec 2019 17:23:42 +0000 (17:23 +0000)
Fixes a crash, e.g.
  http://lab.llvm.org:8011/builders/clang-with-lto-ubuntu/builds/15119/

llvm/lib/Transforms/Utils/SimplifyCFG.cpp

index 1604421..d93ca4f 100644 (file)
@@ -2269,13 +2269,14 @@ static bool FoldCondBranchOnPHI(BranchInst *BI, const DataLayout &DL,
         if (!BBI->use_empty())
           TranslateMap[&*BBI] = N;
       }
-      // Insert the new instruction into its new home.
-      if (N)
+      if (N) {
+        // Insert the new instruction into its new home.
         EdgeBB->getInstList().insert(InsertPt, N);
 
-      // Register the new instruction with the assumption cache if necessary.
-      if (AC && match(N, m_Intrinsic<Intrinsic::assume>()))
-        AC->registerAssumption(cast<IntrinsicInst>(N));
+        // Register the new instruction with the assumption cache if necessary.
+        if (AC && match(N, m_Intrinsic<Intrinsic::assume>()))
+          AC->registerAssumption(cast<IntrinsicInst>(N));
+      }
     }
 
     // Loop over all of the edges from PredBB to BB, changing them to branch