This is an archive of the discontinued LLVM Phabricator instance.

[IPSCCP] Change dead blocks to unreachable after visiting all executable blocks.
ClosedPublic

Authored by fhahn on Jun 21 2018, 5:00 AM.

Details

Summary

changeToUnreachable may remove PHI nodes from executable blocks we found values
for and we would fail to replace them. By changing dead blocks to unreachable after
we replaced constants in all executable blocks, we ensure such PHI nodes are replaced
by their known value before.

Fixes PR37780.

Diff Detail

Repository
rL LLVM

Event Timeline

fhahn created this revision.Jun 21 2018, 5:00 AM

This indeed solves the problem I saw in PR37780. Thanks!

efriedma added inline comments.Jun 21 2018, 12:01 PM
lib/Transforms/Scalar/SCCP.cpp
2030 ↗(On Diff #152252)

The "PN.getNumIncomingValues() != 2" won't work correctly in all cases.

Instead of adding this extra loop, can you just delay the call to changeToUnreachable until after we've iterated over all the blocks?

fhahn updated this revision to Diff 152637.Jun 25 2018, 1:58 AM
fhahn marked an inline comment as done.
fhahn retitled this revision from [IPSCCP] Try to replace phis before they are removed by changeToUnreachable. to [IPSCCP] Change dead blocks to unreachable after visiting all executable blocks..
fhahn edited the summary of this revision. (Show Details)

Thanks Eli, I've updated the patch as suggested.

This revision is now accepted and ready to land.Jun 25 2018, 11:31 AM
This revision was automatically updated to reflect the committed changes.