[PATCH] D14996: [WinEH] Avoid infinite loop in BranchFolding for multiple single block funclets
Andy Kaylor via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 1 12:09:27 PST 2015
andrew.w.kaylor added a comment.
OK, I'm back to having convinced myself that we can't get into the infinite loop condition with non-exception code.
Here is the basic pattern when I'm seeing the "move-to-end" code being hit in non-exception code:
BB1:
...
<conditional branch> BB3
; else fall through to BB2
BB2:
<conditional branch> BB4
<unconditional branch> BB5
BB3:
; Anything that doesn't fall through
BB4:
; Anything
BB5:
; Anything
In this case, BB3 will be moved to the end because (1) the previous block doesn't fall through to BB3, (2) BB3 doesn't fall through to any block, and (3) the previous block has an analyzable branch condition and the block immediately following BB3 is one of the previous block's successors.
The infinite loop condition can only occur when the following pattern becomes present at the end of a function:
BB1:
; non-fallthrough successors BB2 and BB3
BB2:
; Whatever
BB3:
; Whatever
If BB1 jumps unconditionally to either of these blocks, the edge will be rewritten to fall through. The code will consider the previous block to not have an analyzable branch if it contains conditional branches to more than one destination, so the previous block can have at most two destinations in non-exceptional code and one of them must be unconditional.
QED
So, I think the code is correct as I have it in the review.
Repository:
rL LLVM
http://reviews.llvm.org/D14996
More information about the llvm-commits
mailing list