This is an archive of the discontinued LLVM Phabricator instance.

[ArgPromotion] Delay dead GEP removal until doPromotion.
ClosedPublic

Authored by fhahn on Jan 3 2021, 7:48 AM.

Details

Summary

Currently ArgPromotion removes dead GEPs as part of the legality check
in isSafeToPromoteArgument. If no promotion happens, this means the pass
claims no modifications happened, even though GEPs were removed.

This patch fixes the issue by delaying removal of dead GEPs until
doPromotion: isSafeToPromoteArgument can simply skips dead GEPs and
the code in doPromotion dealing with GEPs is updated to account for
dead GEPs. Once we committed to promotion, it should be safe to
remove dead GEPs.

Alternatively isSafeToPromoteArgument could return an additional boolean
to indicate whether it made changes, but this is quite cumbersome and
there should be no real benefit of weeding out some dead GEPs here if we
do not perform promotion.

I added a test for the case where dead GEPs need to be removed when
promotion happens in 578c5a0c6e71.

Fixes PR47477.

Diff Detail

Event Timeline

fhahn created this revision.Jan 3 2021, 7:48 AM
fhahn requested review of this revision.Jan 3 2021, 7:48 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 3 2021, 7:48 AM
fhahn edited the summary of this revision. (Show Details)Jan 3 2021, 7:51 AM
This revision is now accepted and ready to land.Jan 3 2021, 10:01 AM
This revision was automatically updated to reflect the committed changes.