diff --git a/llvm/lib/Transforms/Scalar/LoopDeletion.cpp b/llvm/lib/Transforms/Scalar/LoopDeletion.cpp --- a/llvm/lib/Transforms/Scalar/LoopDeletion.cpp +++ b/llvm/lib/Transforms/Scalar/LoopDeletion.cpp @@ -228,8 +228,8 @@ SmallPtrSet LiveBlocks; // Edges that are reachable on the 1st iteration. DenseSet LiveEdges; - LiveBlocks.insert(L->getHeader()); + LiveBlocks.insert(Header); SmallPtrSet Visited; auto MarkLiveEdge = [&](BasicBlock *From, BasicBlock *To) { assert(LiveBlocks.count(From) && "Must be live!"); @@ -286,21 +286,21 @@ // iteration, mark this successor live. // 3b. If we cannot prove it, conservatively assume that all successors are // live. - auto &DL = L->getHeader()->getModule()->getDataLayout(); + auto &DL = Header->getModule()->getDataLayout(); const SimplifyQuery SQ(DL); for (auto *BB : RPOT) { Visited.insert(BB); // This block is not reachable on the 1st iterations. if (!LiveBlocks.count(BB)) continue; // Skip inner loops. if (LI.getLoopFor(BB) != L) { MarkAllSuccessorsLive(BB); continue; } // If Phi has only one input from all live input blocks, use it. for (auto &PN : BB->phis()) { if (!PN.getType()->isIntegerTy())