This is an archive of the discontinued LLVM Phabricator instance.

Tighten the invariants around LoopBase::invalidate
ClosedPublic

Authored by sanjoy on Sep 19 2017, 2:26 PM.

Details

Summary

With this change:

  • Methods in LoopBase trip an assert if the receiver has been invalidated
  • LoopBase::invalidate frees up the memory held the LoopBase instance

This change also shuffles things around as necessary to work with this stricter invariant.

Diff Detail

Repository
rL LLVM

Event Timeline

sanjoy created this revision.Sep 19 2017, 2:26 PM
chandlerc edited edge metadata.Sep 19 2017, 3:59 PM

Generally like the API changes here. The enum seems a big improvement.

include/llvm/Analysis/LoopInfo.h
68–82 ↗(On Diff #115904)

Given the number of formatting changes here, can you do an initial NFC commit w/ clang-format and rebase?

85 ↗(On Diff #115904)

I find clear a better name for these methods. And eventually you may just run the destructor.

I don't want it to be confused with invalidating analyses *on* the loop with a loop analysis manager.

86 ↗(On Diff #115904)

This seems redundant if you set ParentLoop to null? I guess not for top-level loops.

But it is also redundant with an empty Blocks vector. Anyways, I'd try to remove this at some point.

chandlerc requested changes to this revision.Sep 19 2017, 5:34 PM
This revision now requires changes to proceed.Sep 19 2017, 5:34 PM
sanjoy updated this revision to Diff 115949.Sep 19 2017, 6:27 PM
sanjoy edited edge metadata.
sanjoy marked 2 inline comments as done.
  • Address review comments
sanjoy added inline comments.Sep 19 2017, 6:27 PM
include/llvm/Analysis/LoopInfo.h
86 ↗(On Diff #115904)

Yes, this is equivalent to Blocks.empty(). Do you want me to roll that into this change? Or is a separate change fine?

chandlerc accepted this revision.Sep 19 2017, 6:57 PM

Generally looks good. Description should likely be updated to reflect changes made during review. Feel free to submit!

include/llvm/Transforms/Scalar/LoopPassManager.h
169 ↗(On Diff #115949)

This seems like an unrelated change? (doesn't seem bad...)

This revision is now accepted and ready to land.Sep 19 2017, 6:57 PM
sanjoy added inline comments.Sep 19 2017, 7:21 PM
include/llvm/Transforms/Scalar/LoopPassManager.h
169 ↗(On Diff #115949)

markLoopAsDeleted is called after L has been cleared. If L is the same as CurrentL then CurrentL->contains(&L) will assert.

This revision was automatically updated to reflect the committed changes.
sberg added a subscriber: sberg.Sep 20 2017, 12:40 AM
sberg added inline comments.
llvm/trunk/include/llvm/Transforms/Scalar/LoopPassManager.h
170

there's parentheses missing around the || here, right?

sanjoy added inline comments.Sep 20 2017, 10:01 AM
llvm/trunk/include/llvm/Transforms/Scalar/LoopPassManager.h
170

Since the string evaluates to true, this shouldn't matter -- "(A || B) && True" == "(A || B)" == "A || (B && True)".

Is this causing a warning on some compiler? If so, let me know and I'll fix it (or feel free to directly commit a fix yourself).

sberg added inline comments.Sep 20 2017, 11:52 PM
llvm/trunk/include/llvm/Transforms/Scalar/LoopPassManager.h
170

Since the string evaluates to true, this shouldn't matter -- "(A || B) && True" == "(A || B)" == "A || (B && True)".

Sure, but caused -Wparentheses with GCC. Anyway, found fixed meanwhile with r313780.