This is an archive of the discontinued LLVM Phabricator instance.

[BBUtils] Don't add 'then' block to a loop if it's terminated with unreachable
ClosedPublic

Authored by dmakogon on Jun 8 2023, 5:04 AM.

Details

Summary

SplitBlockAndInsertIfThen utility creates two new blocks, they're called ThenBlock and Tail (true and false destinations of a conditional branch correspondingly). The function has a bool parameter Unreachable, and if it's set, then ThenBlock is terminated with an unreachable.
At the end of the function the new blocks are added to the loop of the split block. However, in case ThenBlock is terminated with an unreachable, it cannot belong to any loop.

The affected tests crashed in SimpleLoopUnswitch when it was turning guards into branches during LoopInfo verification which I added before this patch.

Diff Detail

Event Timeline

dmakogon created this revision.Jun 8 2023, 5:04 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 8 2023, 5:04 AM
dmakogon requested review of this revision.Jun 8 2023, 5:04 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 8 2023, 5:04 AM
dmakogon edited the summary of this revision. (Show Details)Jun 8 2023, 5:06 AM
dmakogon edited the summary of this revision. (Show Details)
nikic accepted this revision.Jun 13 2023, 6:20 AM

LGTM

This revision is now accepted and ready to land.Jun 13 2023, 6:20 AM
This revision was landed with ongoing or failed builds.Jun 19 2023, 6:26 AM
This revision was automatically updated to reflect the committed changes.