diff --git a/lib/Transforms/Scalar/IndVarSimplify.cpp b/lib/Transforms/Scalar/IndVarSimplify.cpp index ad2c9726dac..e931382ea98 100644 --- a/lib/Transforms/Scalar/IndVarSimplify.cpp +++ b/lib/Transforms/Scalar/IndVarSimplify.cpp @@ -2013,10 +2013,11 @@ bool IndVarSimplify::runOnLoop(Loop *L, LPPassManager &LPM) { // Now that we're done iterating through lists, clean up any instructions // which are now dead. - while (!DeadInsts.empty()) - if (Instruction *Inst = - dyn_cast_or_null(&*DeadInsts.pop_back_val())) + while (!DeadInsts.empty()) { + Value *V = static_cast(DeadInsts.pop_back_val()); + if (Instruction *Inst = dyn_cast_or_null(V)) RecursivelyDeleteTriviallyDeadInstructions(Inst, TLI); + } // The Rewriter may not be used from this point on.