diff --git a/llvm/lib/CodeGen/WasmEHPrepare.cpp b/llvm/lib/CodeGen/WasmEHPrepare.cpp --- a/llvm/lib/CodeGen/WasmEHPrepare.cpp +++ b/llvm/lib/CodeGen/WasmEHPrepare.cpp @@ -182,8 +182,7 @@ Changed = true; auto *BB = ThrowI->getParent(); SmallVector Succs(successors(BB)); - auto &InstList = BB->getInstList(); - InstList.erase(std::next(BasicBlock::iterator(ThrowI)), InstList.end()); + BB->erase(std::next(BasicBlock::iterator(ThrowI)), BB->end()); IRB.SetInsertPoint(BB); IRB.CreateUnreachable(); eraseDeadBBsAndChildren(Succs);