From 9ae28b141f1c8f9f3007dcb90245efc550a7681c Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sat, 10 Apr 2010 18:26:57 +0000 Subject: fix PR6743, a case where we'd delete an instruction before using it in some cases. llvm-svn: 100937 --- llvm/lib/Transforms/Scalar/JumpThreading.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'llvm/lib') diff --git a/llvm/lib/Transforms/Scalar/JumpThreading.cpp b/llvm/lib/Transforms/Scalar/JumpThreading.cpp index a6489ecc2dc..df05b712dcb 100644 --- a/llvm/lib/Transforms/Scalar/JumpThreading.cpp +++ b/llvm/lib/Transforms/Scalar/JumpThreading.cpp @@ -670,8 +670,10 @@ bool JumpThreading::ProcessBranchOnDuplicateCond(BasicBlock *PredBB, Value *OldCond = DestBI->getCondition(); DestBI->setCondition(ConstantInt::get(Type::getInt1Ty(BB->getContext()), BranchDir)); - ConstantFoldTerminator(BB); + // Delete dead instructions before we fold the branch. Folding the branch + // can eliminate edges from the CFG which can end up deleting OldCond. RecursivelyDeleteTriviallyDeadInstructions(OldCond); + ConstantFoldTerminator(BB); return true; } -- cgit v1.2.3