[PM] Redesign how the new PM detects whether an analysis result provides
authorChandler Carruth <chandlerc@gmail.com>
Fri, 19 Aug 2016 07:49:23 +0000 (07:49 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Fri, 19 Aug 2016 07:49:23 +0000 (07:49 +0000)
commit92d3c7e8e226344ed4d63e17617cb414ee7e3d7b
tree1e6bd912f8133e860edd765897273299dca0094a
parentb7be5b6479723482073ce88491422852e0c72ab7
[PM] Redesign how the new PM detects whether an analysis result provides
its own invalidate method.

Previously, the technique would assume that if a result didn't have an
invalidate method that didn't exactly match the expected signature it
didn't have one at all. This is in fact not the case. And we had
analyses with incorrect signatures for the invalidate method in the
tree that would be erroneously invalidated in certain cases! Yikes.

Moreover a result might legitimately want to have multiple overloads for
the invalidate method, and if one changes or a new one is needed we
again really want a compiler error. For example in the tree we had not
added the overload for a *function* IR unit to the invalidate routine
for TLI. Doh.

So a new techique for the SFINAE detection here: if the result has *any*
member spelled "invalidate" we turn off the synthesis of a default
version. We don't care if it is a member function or a member variable
or how many overloads there are. Once a result has something by that
name it must provide suitable overloads for the contexts in which it is
used. This seems much more resilient and durable.

Huge props to Richard Smith who helped me figure out how on earth we
could even do this in C++. It took quite some doing. The technique is
remarkably clean however, and merely requires that the analysis results
are not *final* classes. I think that's a requirement we can live with
even if it is a bit odd.

I've fixed the two bad in-tree analysis results. And this will make my
next change which changes the API for invalidate much easier to
validate as correct.

llvm-svn: 279217
llvm/include/llvm/Analysis/TargetLibraryInfo.h
llvm/include/llvm/IR/PassManager.h
llvm/include/llvm/IR/PassManagerInternal.h