This is an archive of the discontinued LLVM Phabricator instance.

[AArch64] Remove ToBeRemoved from AArch64MIPeepholeOpt
ClosedPublic

Authored by dmgreen on Jun 8 2022, 6:27 AM.

Details

Summary

The ToBeRemoved is used to remove any MachineInstructions that are no longer needed, making sure we don't invalidate the iterator that is currently in use by erasing the instruction straight away. This makes issues for keeping the code in SSA from though, where subsequent transforms that require SSA form may have been broken by previous.

If, instead, we use make_early_inc_range the iteration issue shouldn't be present, so long as we do not remove the subsequent instruction in the peephole optimizations. That way the code between transforms is kept in SSA form, meaning hopefully less things that can go wrong.

Diff Detail

Event Timeline

dmgreen created this revision.Jun 8 2022, 6:27 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 8 2022, 6:27 AM
dmgreen requested review of this revision.Jun 8 2022, 6:27 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 8 2022, 6:27 AM
dmgreen edited the summary of this revision. (Show Details)Jun 8 2022, 6:28 AM
jaykang10 accepted this revision.Jun 8 2022, 6:42 AM

Thanks for this patch @dmgreen!
As you mentioned, the ToBeRemoved was to keep the iterator safe. I think the make_early_inc_range is better and it should be ok.
LGTM.

This revision is now accepted and ready to land.Jun 8 2022, 6:42 AM

Thanks - lets hope this doesn't cause further issues. The MIPeephole optimizations seem to be very easy to get wrong in small and subtle ways.

My testing hasn't shown anything, but please yell if anything comes up.

This revision was landed with ongoing or failed builds.Jun 8 2022, 9:26 AM
This revision was automatically updated to reflect the committed changes.