[SimplifyCFG] Sanity assert in iterativelySimplifyCFG

We observe a hang within iterativelySimplifyCFG due to infinite
loop execution. Currently, there is no limit to this loop, so
in case of bug it just works forever. This patch adds an assert
that will break it after 1000 iterations if it didn't converge.
This commit is contained in:
Max Kazantsev 2021-10-25 16:43:11 +07:00
parent e6df795759
commit a9b0776a81
1 changed files with 4 additions and 0 deletions

View File

@ -224,7 +224,11 @@ static bool iterativelySimplifyCFG(Function &F, const TargetTransformInfo &TTI,
SmallVector<WeakVH, 16> LoopHeaders(UniqueLoopHeaders.begin(),
UniqueLoopHeaders.end());
unsigned IterCnt = 0;
(void)IterCnt;
while (LocalChange) {
assert(IterCnt++ < 1000 &&
"Sanity: iterative simplification didn't converge!");
LocalChange = false;
// Loop over all of the basic blocks and remove them if they are unneeded.