This is an archive of the discontinued LLVM Phabricator instance.

[PM] Teach the AAManager and AAResults layer (the worst offender for inter-analysis dependencies) to use the new invalidation infrastructure.
ClosedPublic

Authored by chandlerc on Nov 29 2016, 5:14 AM.

Details

Summary

This teaches it to invalidate itself when any of the peer function
AA results that it uses become invalid. We do this by just tracking the
originating IDs. I've kept it in a somewhat clunky API since some users
of AAResults are outside the new PM right now. We can clean this API up
if/when those users go away.

Secondly, it uses the registration on the outer analysis manager proxy
to trigger deferred invalidation when a module analysis result becomes
invalid.

I've included test cases that specifically try to trigger use-after-free
in both of these cases and they would crash or hang pretty horribly for
me even without ASan. Now they work nicely.

The "InvalidateAnalysis" utility pass required some tweaking to be
useful in this context and it still is pretty garbage. I'd like to
switch it back to the previous implementation and teach the explicit
invalidate method on the AnalysisManager to take care of correctly
triggering indirect invalidation, but I wanted to go ahead and send this
out so folks could see how all of this stuff works together in practice.
And, you know, that it does actually work. =]

Depends on D27198.

Event Timeline

chandlerc updated this revision to Diff 79546.Nov 29 2016, 5:14 AM
chandlerc retitled this revision from to [PM] Teach the AAManager and AAResults layer (the worst offender for inter-analysis dependencies) to use the new invalidation infrastructure..
chandlerc updated this object.
chandlerc added reviewers: jlebar, silvas.
chandlerc added a subscriber: llvm-commits.
silvas accepted this revision.Nov 30 2016, 11:42 PM
silvas edited edge metadata.

This is just wiring up the new machinery from D27198. Looks good.

You may want to consider in a separate patch breaking the new PM tests into a new directory (instead of just a single main huge file in test/Other). Lit's test failure diagnostics tend to be better for separate files.

This revision is now accepted and ready to land.Nov 30 2016, 11:42 PM
jlebar accepted this revision.Dec 6 2016, 6:48 PM
jlebar edited edge metadata.
jlebar added inline comments.
include/llvm/Analysis/AliasAnalysis.h
206

A thought: It would be cool if our system allowed you to check somehow that this is specifically a function analysis, even if only in debug builds. (This relates back to e.g. https://reviews.llvm.org/D27198#inline-236718.)

This revision was automatically updated to reflect the committed changes.
chandlerc added inline comments.Dec 27 2016, 12:58 AM
include/llvm/Analysis/AliasAnalysis.h
206

Just wanted to mention I'm not ignoring this, and will be thinking about a clean way to introduce it without complicating things too much.