[llvm] r340794 - Revert "[CodeGenPrepare] Scan past debug intrinsics to find select candidates (NFC)"

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 27 17:55:19 PDT 2018


Author: dblaikie
Date: Mon Aug 27 17:55:19 2018
New Revision: 340794

URL: http://llvm.org/viewvc/llvm-project?rev=340794&view=rev
Log:
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.

Modified:
    llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp

Modified: llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp?rev=340794&r1=340793&r2=340794&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp (original)
+++ llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp Mon Aug 27 17:55:19 2018
@@ -5602,10 +5602,9 @@ bool CodeGenPrepare::optimizeSelectInst(
   // Find all consecutive select instructions that share the same condition.
   SmallVector<SelectInst *, 2> ASI;
   ASI.push_back(SI);
-  for (Instruction *NextInst = SI->getNextNonDebugInstruction();
-       NextInst != SI->getParent()->getTerminator();
-       NextInst = NextInst->getNextNonDebugInstruction()) {
-    SelectInst *I = dyn_cast<SelectInst>(NextInst);
+  for (BasicBlock::iterator It = ++BasicBlock::iterator(SI);
+       It != SI->getParent()->end(); ++It) {
+    SelectInst *I = dyn_cast<SelectInst>(&*It);
     if (I && SI->getCondition() == I->getCondition()) {
       ASI.push_back(I);
     } else {




More information about the llvm-commits mailing list