This is an archive of the discontinued LLVM Phabricator instance.

[LoopSimplifyCFG] Fix inconsistency in live blocks markup
ClosedPublic

Authored by mkazantsev on Jan 23 2019, 4:57 AM.

Details

Summary

When we choose whether or not we should mark block as dead, we have an
inconsistent logic in markup of live blocks.

  • We take candidate IF its terminator branches on constant AND it is immediately in current loop;
  • We mark successor live IF its terminator doesn't branch by constant OR it branches by constant and the successor is its always taken block.

What we are missing here is that when the terminator branches on a constant but is
not taken as a candidate because is it not immediately in the current loop, we will
mark only one (always taken) successor as live. Therefore, we do NOT do the actual
folding but may NOT mark one of the successors as live. So the result of markup is
wrong in this case, and we may then hit various asserts.

Thanks Jordan Rupprech for reporting this!

Diff Detail

Repository
rL LLVM

Event Timeline

mkazantsev created this revision.Jan 23 2019, 4:57 AM
rupprecht accepted this revision.Jan 23 2019, 3:57 PM

This patched in fixes the crashes we were seeing, thanks!
Would be great if you could come up for a test case that covers the .c repro, but not blocking, I suppose.
I'll leave it up to you if you want to commit this as-is or and create a second patch for the other repro, or combine it into this one.

This revision is now accepted and ready to land.Jan 23 2019, 3:57 PM
mkazantsev retitled this revision from [LoopSimplifyCFG][WIP] Fix inconsistency in live blocks markup to [LoopSimplifyCFG] Fix inconsistency in live blocks markup.
mkazantsev edited the summary of this revision. (Show Details)
mkazantsev added a subscriber: llvm-commits.
This revision was automatically updated to reflect the committed changes.