[PATCH] D46635: [SimplifyCFG] Fix a debug invariant bug in FoldBranchToCommonDest()

David Stenberg via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 10 03:32:23 PDT 2018


dstenb added inline comments.


================
Comment at: lib/Transforms/Utils/SimplifyCFG.cpp:2559
+                    E = BB->instructionsWithoutDebug().end();
+               I != E;) {
             Instruction *Curr = &*I++;
----------------
vsk wrote:
> Can this simply be written as: `for (auto &Curr : BB->instructionsWithoutDebug())`?
> 
As we may erase instructions, I don't think we can use a range-based for loop here.


================
Comment at: lib/Transforms/Utils/SimplifyCFG.cpp:2580-2585
   BasicBlock::iterator CondIt = ++Cond->getIterator();
 
   // Ignore dbg intrinsics.
   while (isa<DbgInfoIntrinsic>(CondIt))
     ++CondIt;
 
----------------
davide wrote:
> Can `Cond` be a `DbgInfoIntrinsic` here?
I guess that  `Cond` is guaranteed to be a `CmpInst` or `BinaryOperator` here, based on the guard on line 2575.


Repository:
  rL LLVM

https://reviews.llvm.org/D46635





More information about the llvm-commits mailing list