From: Chandler Carruth Date: Tue, 7 Feb 2017 01:50:48 +0000 (+0000) Subject: Revert r293017 and fix the actual underlying issue. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d53dbed1b05af1a70a76288501ac01744be4662c;p=llvm Revert r293017 and fix the actual underlying issue. The patch committed in r293017, as discussed on the list, doesn't really make sense but was causing an actual issue to go away. The issue turns out to be that in one place the extra template arguments were dropped from the OuterAnalysisManagerProxy. This in turn caused the types used in one set of places to access the key to be completely different from the types used in another set of places for both Loop and CGSCC cases where there are extra arguments. I have literally no idea how anything seemed to work with this bug in place. It blows my mind. But it did except for mingw64 in a DLL build. I've added a really handy static assert that helps ensure we don't break this in the future. It immediately diagnoses the issue with a compile failure and a very clear error message. Much better that staring at backtraces on a build bot. =] git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@294267 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/Analysis/CGSCCPassManager.h b/include/llvm/Analysis/CGSCCPassManager.h index 95d79e7dabb..398bbfb0c41 100644 --- a/include/llvm/Analysis/CGSCCPassManager.h +++ b/include/llvm/Analysis/CGSCCPassManager.h @@ -191,8 +191,8 @@ CGSCCAnalysisManagerModuleProxy::run(Module &M, ModuleAnalysisManager &AM); // template. extern template class InnerAnalysisManagerProxy; -extern template class OuterAnalysisManagerProxy; +extern template class OuterAnalysisManagerProxy< + ModuleAnalysisManager, LazyCallGraph::SCC, LazyCallGraph &>; /// A proxy from a \c ModuleAnalysisManager to an \c SCC. typedef OuterAnalysisManagerProxy diff --git a/include/llvm/Analysis/LoopAnalysisManager.h b/include/llvm/Analysis/LoopAnalysisManager.h index 640c086be23..17da516889b 100644 --- a/include/llvm/Analysis/LoopAnalysisManager.h +++ b/include/llvm/Analysis/LoopAnalysisManager.h @@ -141,7 +141,8 @@ LoopAnalysisManagerFunctionProxy::run(Function &F, FunctionAnalysisManager &AM); // template. extern template class InnerAnalysisManagerProxy; -extern template class OuterAnalysisManagerProxy; +extern template class OuterAnalysisManagerProxy; /// A proxy from a \c FunctionAnalysisManager to a \c Loop. typedef OuterAnalysisManagerProxy diff --git a/include/llvm/IR/PassManager.h b/include/llvm/IR/PassManager.h index 61b6278ea0b..c845112baa4 100644 --- a/include/llvm/IR/PassManager.h +++ b/include/llvm/IR/PassManager.h @@ -351,6 +351,8 @@ template class AnalysisManager; template struct PassInfoMixin { /// Gets the name of the pass we are mixed into. static StringRef name() { + static_assert(std::is_base_of::value, + "Must pass the derived type as the template argument!"); StringRef Name = getTypeName(); if (Name.startswith("llvm::")) Name = Name.drop_front(strlen("llvm::")); @@ -379,7 +381,11 @@ struct AnalysisInfoMixin : PassInfoMixin { /// known platform with this limitation is Windows DLL builds, specifically /// building each part of LLVM as a DLL. If we ever remove that build /// configuration, this mixin can provide the static key as well. - static AnalysisKey *ID() { return &DerivedT::Key; } + static AnalysisKey *ID() { + static_assert(std::is_base_of::value, + "Must pass the derived type as the template argument!"); + return &DerivedT::Key; + } }; /// \brief Manages a sequence of passes over a particular unit of IR. @@ -1028,7 +1034,7 @@ extern template class InnerAnalysisManagerProxy class OuterAnalysisManagerProxy : public AnalysisInfoMixin< - OuterAnalysisManagerProxy> { + OuterAnalysisManagerProxy> { public: /// \brief Result proxy object for \c OuterAnalysisManagerProxy. class Result { @@ -1090,7 +1096,7 @@ public: private: friend AnalysisInfoMixin< - OuterAnalysisManagerProxy>; + OuterAnalysisManagerProxy>; static AnalysisKey Key; const AnalysisManagerT *AM; diff --git a/lib/Analysis/CGSCCPassManager.cpp b/lib/Analysis/CGSCCPassManager.cpp index c93d584668d..7cede981313 100644 --- a/lib/Analysis/CGSCCPassManager.cpp +++ b/lib/Analysis/CGSCCPassManager.cpp @@ -24,7 +24,7 @@ template class PassManager; template class InnerAnalysisManagerProxy; template class OuterAnalysisManagerProxy; + LazyCallGraph::SCC, LazyCallGraph &>; template class OuterAnalysisManagerProxy; /// Explicitly specialize the pass manager run method to handle call graph diff --git a/lib/Analysis/LoopAnalysisManager.cpp b/lib/Analysis/LoopAnalysisManager.cpp index 6ca9c273771..e4a0f90b2f7 100644 --- a/lib/Analysis/LoopAnalysisManager.cpp +++ b/lib/Analysis/LoopAnalysisManager.cpp @@ -23,7 +23,8 @@ namespace llvm { template class AllAnalysesOn; template class AnalysisManager; template class InnerAnalysisManagerProxy; -template class OuterAnalysisManagerProxy; +template class OuterAnalysisManagerProxy; bool LoopAnalysisManagerFunctionProxy::Result::invalidate( Function &F, const PreservedAnalyses &PA,