This is an archive of the discontinued LLVM Phabricator instance.

[GlobalISel] Clear unreachable blocks' contents after selection.
ClosedPublic

Authored by aemerson on Oct 5 2021, 5:44 PM.

Details

Summary

If these blocks are unreachable, then we can discard all of the instructions. However, keep the block around because it may have an address taken or the block may have a stale reference from a PHI somewhere. Instead of finding those PHIs and fixing them up, just leave the block empty.

This was motivated by https://reviews.llvm.org/D110603 which ran into this problem.

Diff Detail

Event Timeline

aemerson created this revision.Oct 5 2021, 5:44 PM
aemerson requested review of this revision.Oct 5 2021, 5:44 PM
paquette accepted this revision.Oct 5 2021, 10:33 PM

This seems reasonable to me.

This revision is now accepted and ready to land.Oct 5 2021, 10:33 PM
This revision was landed with ongoing or failed builds.Oct 5 2021, 11:06 PM
This revision was automatically updated to reflect the committed changes.
uabelho added inline comments.Oct 6 2021, 1:31 AM
llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp
217

What happens if the unreachable block defines a value %val that is used in the phi? Will it be handled some way or lead to a verifier error? (I don't know this code at all so perhaps it's totally obvious it will just work out nicely.)