This is an archive of the discontinued LLVM Phabricator instance.

[LoopDeletion] Forget loop before setting values to undef
ClosedPublic

Authored by fhahn on Sep 23 2020, 10:13 AM.

Details

Summary

After D71539, we need to forget the loop before setting the incoming
values of phi nodes in exit blocks, because we are looking through those
phi nodes now and the SCEV expression could depend on the loop phi. If
we update the phi nodes before forgetting the loop, we miss those users
during invalidation.

Diff Detail

Event Timeline

fhahn created this revision.Sep 23 2020, 10:13 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 23 2020, 10:13 AM
fhahn requested review of this revision.Sep 23 2020, 10:13 AM
reames accepted this revision.Sep 28 2020, 11:09 AM
This revision is now accepted and ready to land.Sep 28 2020, 11:09 AM
This revision was automatically updated to reflect the committed changes.
nikic added a subscriber: nikic.Sep 29 2020, 5:21 AM
nikic added inline comments.
llvm/lib/Transforms/Utils/LoopUtils.cpp
729

This call performs an unconditional SCEV verification, probably not what you intended. Should be behind NDEBUG at least.

fhahn added inline comments.Sep 29 2020, 5:40 AM
llvm/lib/Transforms/Utils/LoopUtils.cpp
729

Yes, should be done in 7bae2bc5a8dd11c016c895e3a691fb93575773f3, thanks!

uabelho added a subscriber: uabelho.Oct 7 2020, 5:14 AM

Hi!

I just wrote
https://bugs.llvm.org/show_bug.cgi?id=47753
about a failure that starts occuring with this patch.

mkazantsev added inline comments.Oct 11 2020, 10:31 PM
llvm/lib/Transforms/Utils/LoopUtils.cpp
729

I wonder if *all* SCEV has to be correct at this point. I mean, you are only deleting one single loop while possibly doing something else in some other place and plan to invalidate SCEV later. I don't think it's a right place for an assert.

We have a test failing on this, but I cannot figure out how to make a simple repro unfortunately. The failure seems not related to the loop in question. The point is that it fails this assertion but passes when we verify all IR after each pass.

mkazantsev added inline comments.Oct 11 2020, 10:35 PM
llvm/lib/Transforms/Utils/LoopUtils.cpp
729

In my case, the test fails even if we verify SCEV in the beginning on this method. So I don't think it's correct to verify it here since the whole thing can be called on broken SCEV which we plan to fully drop later.