This is an archive of the discontinued LLVM Phabricator instance.

[LegacyPM] Fix PR37888 by teaching the legacy loop pass manager how to clear out deleted loops from the current queue beyond just the current loop.
ClosedPublic

Authored by chandlerc on Jun 21 2018, 7:07 PM.

Details

Summary

This is important because SimpleLoopUnswitch will now enqueue the same
loop to be re-processed. When it does this with the legacy PM, we don't
have a way of canceling the rest of the pipeline and so we can end up
deleting the loop before we reprocess it. =/

This change also makes it easy to support deleting other loops in the
queue to process, although I don't have any use cases for that.

Diff Detail

Repository
rL LLVM

Event Timeline

chandlerc created this revision.Jun 21 2018, 7:07 PM
sanjoy accepted this revision.Jun 21 2018, 7:09 PM
sanjoy added inline comments.
llvm/lib/Analysis/LoopPass.cpp
149 ↗(On Diff #152421)

Can we have the same loop multiple times in the loop queue? If not would be nice to assert that and use the single iterator version of erase.

This revision is now accepted and ready to land.Jun 21 2018, 7:09 PM
chandlerc added inline comments.Jun 21 2018, 7:27 PM
llvm/lib/Analysis/LoopPass.cpp
149 ↗(On Diff #152421)

Yeah, technically... You could have two SimpleLoopUnswitch passes in the same pipeline, and because of how this works, both could run, find something to transform, transform it, and re-enqueue the loop to be processed. Then we'll end up re-visiting it twice too.

We could prevent this, but it'd take a bunch of code and doesn't seem worth it when we can just handle it here.

This revision was automatically updated to reflect the committed changes.