From c25de56905b104fb2b90559ce5863f4fec93a974 Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Sat, 7 Dec 2019 17:22:14 +0000 Subject: [PATCH] [SimplifyCFG] Account for N being null. Fixes a crash, e.g. http://lab.llvm.org:8011/builders/clang-with-lto-ubuntu/builds/15119/ --- llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index 1604421..d93ca4f 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -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())) - AC->registerAssumption(cast(N)); + // Register the new instruction with the assumption cache if necessary. + if (AC && match(N, m_Intrinsic())) + AC->registerAssumption(cast(N)); + } } // Loop over all of the edges from PredBB to BB, changing them to branch -- 2.7.4