[PATCH] D14996: [WinEH] Avoid infinite loop in BranchFolding for multiple single block funclets

Andy Kaylor via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 30 13:25:44 PST 2015


andrew.w.kaylor added a comment.

After looking at this closer, I don't think the problem can arise without EH pads.

The condition for moving a block to the end looks like this:

  if (FallThrough != MF.end() &&
            !TII->AnalyzeBranch(PrevBB, PrevTBB, PrevFBB, PrevCond, true) &&
            PrevBB.isSuccessor(&*FallThrough)) {

There are some complications regarding where FallThrough gets its value, but I think that as a reasonable approximation, this condition means that the candidate block to be moved must have a block before it (PrevBB) and a block after it (FallThrough) such that PrevBB ends with an analyzable branch and FallThrough is a successor of PrevBB, and for the infinite looping condition to occur, there must be multiple blocks that meet this condition with the same PrevBB.  This happens in the Windows EH case (and currently only Windows EH) because PrevBB can end with an unconditional branch to a normal block and still have multiple EH pad successors.

Simple if-else conditions are handled earlier in the loop where there is already a check against swapping two blocks back and forth (isBetterFallthrough).


Repository:
  rL LLVM

http://reviews.llvm.org/D14996





More information about the llvm-commits mailing list