From 7d30653259ea08b06945239c2124d13a7401ee53 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Tue, 28 Aug 2018 00:55:19 +0000 Subject: [PATCH] Revert "[CodeGenPrepare] Scan past debug intrinsics to find select candidates (NFC)" This causes crashes due to the interleaved dbg.value intrinsics being left at the end of basic blocks, causing the actual terminators (br, etc) to be not where they should be (not at the end of the block), leading to later crashes. Further discussion on the original commit thread. This reverts commit r340368. llvm-svn: 340794 --- llvm/lib/CodeGen/CodeGenPrepare.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp index d3cbec736da5..2083869b0325 100644 --- a/llvm/lib/CodeGen/CodeGenPrepare.cpp +++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp @@ -5602,10 +5602,9 @@ bool CodeGenPrepare::optimizeSelectInst(SelectInst *SI) { // Find all consecutive select instructions that share the same condition. SmallVector ASI; ASI.push_back(SI); - for (Instruction *NextInst = SI->getNextNonDebugInstruction(); - NextInst != SI->getParent()->getTerminator(); - NextInst = NextInst->getNextNonDebugInstruction()) { - SelectInst *I = dyn_cast(NextInst); + for (BasicBlock::iterator It = ++BasicBlock::iterator(SI); + It != SI->getParent()->end(); ++It) { + SelectInst *I = dyn_cast(&*It); if (I && SI->getCondition() == I->getCondition()) { ASI.push_back(I); } else {