This is an archive of the discontinued LLVM Phabricator instance.

LowerSwitch: Fix producing invalid IR on unreachable code
ClosedPublic

Authored by arsenm on Mar 13 2017, 3:28 PM.

Details

Reviewers
hans
Summary

If a switch was an unreachable block that branched to an unreachable block, it would leave phis with missing predecessors.

Diff Detail

Event Timeline

arsenm created this revision.Mar 13 2017, 3:28 PM
arsenm updated this revision to Diff 91639.Mar 13 2017, 3:51 PM

Handle branch to self also

arsenm added a reviewer: hans.Apr 21 2017, 2:56 PM
hans accepted this revision.Apr 21 2017, 4:44 PM

lgtm

It's been a long time since I did anything with LowerSwitch, but this seems like a straight-forward fix.

lib/Transforms/Utils/LowerSwitch.cpp
406

I'd suggest a comment here.

test/Transforms/LowerSwitch/phi-in-dead-block.ll
4

Did we really get left with a switch before?

This revision is now accepted and ready to land.Apr 21 2017, 4:44 PM
arsenm added inline comments.Apr 21 2017, 4:53 PM
test/Transforms/LowerSwitch/phi-in-dead-block.ll
4

No. The verifier failed, but if I disable it the output has the expanded branches

arsenm closed this revision.Apr 21 2017, 5:07 PM

r301064