Erase instructions _after_ checking their type.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132256 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/DwarfEHPrepare.cpp b/lib/CodeGen/DwarfEHPrepare.cpp
index 6a53e69..873ddd2 100644
--- a/lib/CodeGen/DwarfEHPrepare.cpp
+++ b/lib/CodeGen/DwarfEHPrepare.cpp
@@ -532,13 +532,14 @@
if (isa<UnwindInst>(RI))
new UnreachableInst(RI->getContext(), RI);
- // Nuke the resume instruction.
- RI->eraseFromParent();
-
if (isa<UnwindInst>(RI))
++NumUnwindsLowered;
else
++NumResumesLowered;
+
+ // Nuke the resume instruction.
+ RI->eraseFromParent();
+
Changed = true;
}