Index: llvm/trunk/include/llvm/Analysis/AliasAnalysis.h =================================================================== --- llvm/trunk/include/llvm/Analysis/AliasAnalysis.h +++ llvm/trunk/include/llvm/Analysis/AliasAnalysis.h @@ -911,7 +911,7 @@ private: friend AnalysisInfoMixin; - static char PassID; + static AnalysisKey Key; SmallVector { friend AnalysisInfoMixin; - static char PassID; + static AnalysisKey Key; public: typedef AssumptionCache Result; Index: llvm/trunk/include/llvm/Analysis/BasicAliasAnalysis.h =================================================================== --- llvm/trunk/include/llvm/Analysis/BasicAliasAnalysis.h +++ llvm/trunk/include/llvm/Analysis/BasicAliasAnalysis.h @@ -196,7 +196,7 @@ /// Analysis pass providing a never-invalidated alias analysis result. class BasicAA : public AnalysisInfoMixin { friend AnalysisInfoMixin; - static char PassID; + static AnalysisKey Key; public: typedef BasicAAResult Result; Index: llvm/trunk/include/llvm/Analysis/BlockFrequencyInfo.h =================================================================== --- llvm/trunk/include/llvm/Analysis/BlockFrequencyInfo.h +++ llvm/trunk/include/llvm/Analysis/BlockFrequencyInfo.h @@ -90,7 +90,7 @@ class BlockFrequencyAnalysis : public AnalysisInfoMixin { friend AnalysisInfoMixin; - static char PassID; + static AnalysisKey Key; public: /// \brief Provide the result typedef for this analysis pass. Index: llvm/trunk/include/llvm/Analysis/BranchProbabilityInfo.h =================================================================== --- llvm/trunk/include/llvm/Analysis/BranchProbabilityInfo.h +++ llvm/trunk/include/llvm/Analysis/BranchProbabilityInfo.h @@ -178,7 +178,7 @@ class BranchProbabilityAnalysis : public AnalysisInfoMixin { friend AnalysisInfoMixin; - static char PassID; + static AnalysisKey Key; public: /// \brief Provide the result typedef for this analysis pass. Index: llvm/trunk/include/llvm/Analysis/CFLAndersAliasAnalysis.h =================================================================== --- llvm/trunk/include/llvm/Analysis/CFLAndersAliasAnalysis.h +++ llvm/trunk/include/llvm/Analysis/CFLAndersAliasAnalysis.h @@ -103,7 +103,7 @@ /// in particular to leverage invalidation to trigger re-computation. class CFLAndersAA : public AnalysisInfoMixin { friend AnalysisInfoMixin; - static char PassID; + static AnalysisKey Key; public: typedef CFLAndersAAResult Result; Index: llvm/trunk/include/llvm/Analysis/CFLSteensAliasAnalysis.h =================================================================== --- llvm/trunk/include/llvm/Analysis/CFLSteensAliasAnalysis.h +++ llvm/trunk/include/llvm/Analysis/CFLSteensAliasAnalysis.h @@ -122,7 +122,7 @@ /// in particular to leverage invalidation to trigger re-computation of sets. class CFLSteensAA : public AnalysisInfoMixin { friend AnalysisInfoMixin; - static char PassID; + static AnalysisKey Key; public: typedef CFLSteensAAResult Result; Index: llvm/trunk/include/llvm/Analysis/CallGraph.h =================================================================== --- llvm/trunk/include/llvm/Analysis/CallGraph.h +++ llvm/trunk/include/llvm/Analysis/CallGraph.h @@ -297,7 +297,7 @@ /// resulting data. class CallGraphAnalysis : public AnalysisInfoMixin { friend AnalysisInfoMixin; - static char PassID; + static AnalysisKey Key; public: /// \brief A formulaic typedef to inform clients of the result type. Index: llvm/trunk/include/llvm/Analysis/DemandedBits.h =================================================================== --- llvm/trunk/include/llvm/Analysis/DemandedBits.h +++ llvm/trunk/include/llvm/Analysis/DemandedBits.h @@ -89,7 +89,7 @@ /// An analysis that produces \c DemandedBits for a function. class DemandedBitsAnalysis : public AnalysisInfoMixin { friend AnalysisInfoMixin; - static char PassID; + static AnalysisKey Key; public: /// \brief Provide the result typedef for this analysis pass. Index: llvm/trunk/include/llvm/Analysis/DependenceAnalysis.h =================================================================== --- llvm/trunk/include/llvm/Analysis/DependenceAnalysis.h +++ llvm/trunk/include/llvm/Analysis/DependenceAnalysis.h @@ -921,7 +921,7 @@ Result run(Function &F, FunctionAnalysisManager &FAM); private: - static char PassID; + static AnalysisKey Key; friend struct AnalysisInfoMixin; }; // class DependenceAnalysis Index: llvm/trunk/include/llvm/Analysis/DominanceFrontier.h =================================================================== --- llvm/trunk/include/llvm/Analysis/DominanceFrontier.h +++ llvm/trunk/include/llvm/Analysis/DominanceFrontier.h @@ -171,7 +171,7 @@ class DominanceFrontierAnalysis : public AnalysisInfoMixin { friend AnalysisInfoMixin; - static char PassID; + static AnalysisKey Key; public: /// \brief Provide the result typedef for this analysis pass. Index: llvm/trunk/include/llvm/Analysis/GlobalsModRef.h =================================================================== --- llvm/trunk/include/llvm/Analysis/GlobalsModRef.h +++ llvm/trunk/include/llvm/Analysis/GlobalsModRef.h @@ -120,7 +120,7 @@ /// Analysis pass providing a never-invalidated alias analysis result. class GlobalsAA : public AnalysisInfoMixin { friend AnalysisInfoMixin; - static char PassID; + static AnalysisKey Key; public: typedef GlobalsAAResult Result; Index: llvm/trunk/include/llvm/Analysis/IVUsers.h =================================================================== --- llvm/trunk/include/llvm/Analysis/IVUsers.h +++ llvm/trunk/include/llvm/Analysis/IVUsers.h @@ -188,7 +188,7 @@ /// Analysis pass that exposes the \c IVUsers for a loop. class IVUsersAnalysis : public AnalysisInfoMixin { friend AnalysisInfoMixin; - static char PassID; + static AnalysisKey Key; public: typedef IVUsers Result; Index: llvm/trunk/include/llvm/Analysis/LazyCallGraph.h =================================================================== --- llvm/trunk/include/llvm/Analysis/LazyCallGraph.h +++ llvm/trunk/include/llvm/Analysis/LazyCallGraph.h @@ -1145,7 +1145,7 @@ /// An analysis pass which computes the call graph for a module. class LazyCallGraphAnalysis : public AnalysisInfoMixin { friend AnalysisInfoMixin; - static char PassID; + static AnalysisKey Key; public: /// Inform generic clients of the result type. Index: llvm/trunk/include/llvm/Analysis/LazyValueInfo.h =================================================================== --- llvm/trunk/include/llvm/Analysis/LazyValueInfo.h +++ llvm/trunk/include/llvm/Analysis/LazyValueInfo.h @@ -109,7 +109,7 @@ Result run(Function &F, FunctionAnalysisManager &FAM); private: - static char PassID; + static AnalysisKey Key; friend struct AnalysisInfoMixin; }; Index: llvm/trunk/include/llvm/Analysis/LoopAccessAnalysis.h =================================================================== --- llvm/trunk/include/llvm/Analysis/LoopAccessAnalysis.h +++ llvm/trunk/include/llvm/Analysis/LoopAccessAnalysis.h @@ -749,7 +749,7 @@ class LoopAccessAnalysis : public AnalysisInfoMixin { friend AnalysisInfoMixin; - static char PassID; + static AnalysisKey Key; public: typedef LoopAccessInfo Result; Index: llvm/trunk/include/llvm/Analysis/LoopInfo.h =================================================================== --- llvm/trunk/include/llvm/Analysis/LoopInfo.h +++ llvm/trunk/include/llvm/Analysis/LoopInfo.h @@ -805,7 +805,7 @@ /// \brief Analysis pass that exposes the \c LoopInfo for a function. class LoopAnalysis : public AnalysisInfoMixin { friend AnalysisInfoMixin; - static char PassID; + static AnalysisKey Key; public: typedef LoopInfo Result; Index: llvm/trunk/include/llvm/Analysis/MemoryDependenceAnalysis.h =================================================================== --- llvm/trunk/include/llvm/Analysis/MemoryDependenceAnalysis.h +++ llvm/trunk/include/llvm/Analysis/MemoryDependenceAnalysis.h @@ -485,7 +485,7 @@ class MemoryDependenceAnalysis : public AnalysisInfoMixin { friend AnalysisInfoMixin; - static char PassID; + static AnalysisKey Key; public: typedef MemoryDependenceResults Result; Index: llvm/trunk/include/llvm/Analysis/ModuleSummaryAnalysis.h =================================================================== --- llvm/trunk/include/llvm/Analysis/ModuleSummaryAnalysis.h +++ llvm/trunk/include/llvm/Analysis/ModuleSummaryAnalysis.h @@ -38,7 +38,7 @@ class ModuleSummaryIndexAnalysis : public AnalysisInfoMixin { friend AnalysisInfoMixin; - static char PassID; + static AnalysisKey Key; public: typedef ModuleSummaryIndex Result; Index: llvm/trunk/include/llvm/Analysis/ObjCARCAliasAnalysis.h =================================================================== --- llvm/trunk/include/llvm/Analysis/ObjCARCAliasAnalysis.h +++ llvm/trunk/include/llvm/Analysis/ObjCARCAliasAnalysis.h @@ -63,7 +63,7 @@ /// Analysis pass providing a never-invalidated alias analysis result. class ObjCARCAA : public AnalysisInfoMixin { friend AnalysisInfoMixin; - static char PassID; + static AnalysisKey Key; public: typedef ObjCARCAAResult Result; Index: llvm/trunk/include/llvm/Analysis/OptimizationDiagnosticInfo.h =================================================================== --- llvm/trunk/include/llvm/Analysis/OptimizationDiagnosticInfo.h +++ llvm/trunk/include/llvm/Analysis/OptimizationDiagnosticInfo.h @@ -251,7 +251,7 @@ class OptimizationRemarkEmitterAnalysis : public AnalysisInfoMixin { friend AnalysisInfoMixin; - static char PassID; + static AnalysisKey Key; public: /// \brief Provide the result typedef for this analysis pass. Index: llvm/trunk/include/llvm/Analysis/PostDominators.h =================================================================== --- llvm/trunk/include/llvm/Analysis/PostDominators.h +++ llvm/trunk/include/llvm/Analysis/PostDominators.h @@ -32,7 +32,7 @@ class PostDominatorTreeAnalysis : public AnalysisInfoMixin { friend AnalysisInfoMixin; - static char PassID; + static AnalysisKey Key; public: /// \brief Provide the result typedef for this analysis pass. Index: llvm/trunk/include/llvm/Analysis/ProfileSummaryInfo.h =================================================================== --- llvm/trunk/include/llvm/Analysis/ProfileSummaryInfo.h +++ llvm/trunk/include/llvm/Analysis/ProfileSummaryInfo.h @@ -94,7 +94,7 @@ private: friend AnalysisInfoMixin; - static char PassID; + static AnalysisKey Key; }; /// \brief Printer pass that uses \c ProfileSummaryAnalysis. Index: llvm/trunk/include/llvm/Analysis/RegionInfo.h =================================================================== --- llvm/trunk/include/llvm/Analysis/RegionInfo.h +++ llvm/trunk/include/llvm/Analysis/RegionInfo.h @@ -933,7 +933,7 @@ /// \brief Analysis pass that exposes the \c RegionInfo for a function. class RegionInfoAnalysis : public AnalysisInfoMixin { friend AnalysisInfoMixin; - static char PassID; + static AnalysisKey Key; public: typedef RegionInfo Result; Index: llvm/trunk/include/llvm/Analysis/ScalarEvolution.h =================================================================== --- llvm/trunk/include/llvm/Analysis/ScalarEvolution.h +++ llvm/trunk/include/llvm/Analysis/ScalarEvolution.h @@ -1626,7 +1626,7 @@ class ScalarEvolutionAnalysis : public AnalysisInfoMixin { friend AnalysisInfoMixin; - static char PassID; + static AnalysisKey Key; public: typedef ScalarEvolution Result; Index: llvm/trunk/include/llvm/Analysis/ScalarEvolutionAliasAnalysis.h =================================================================== --- llvm/trunk/include/llvm/Analysis/ScalarEvolutionAliasAnalysis.h +++ llvm/trunk/include/llvm/Analysis/ScalarEvolutionAliasAnalysis.h @@ -40,7 +40,7 @@ /// Analysis pass providing a never-invalidated alias analysis result. class SCEVAA : public AnalysisInfoMixin { friend AnalysisInfoMixin; - static char PassID; + static AnalysisKey Key; public: typedef SCEVAAResult Result; Index: llvm/trunk/include/llvm/Analysis/ScopedNoAliasAA.h =================================================================== --- llvm/trunk/include/llvm/Analysis/ScopedNoAliasAA.h +++ llvm/trunk/include/llvm/Analysis/ScopedNoAliasAA.h @@ -43,7 +43,7 @@ /// Analysis pass providing a never-invalidated alias analysis result. class ScopedNoAliasAA : public AnalysisInfoMixin { friend AnalysisInfoMixin; - static char PassID; + static AnalysisKey Key; public: typedef ScopedNoAliasAAResult Result; Index: llvm/trunk/include/llvm/Analysis/TargetLibraryInfo.h =================================================================== --- llvm/trunk/include/llvm/Analysis/TargetLibraryInfo.h +++ llvm/trunk/include/llvm/Analysis/TargetLibraryInfo.h @@ -343,7 +343,7 @@ private: friend AnalysisInfoMixin; - static char PassID; + static AnalysisKey Key; Optional PresetInfoImpl; Index: llvm/trunk/include/llvm/Analysis/TargetTransformInfo.h =================================================================== --- llvm/trunk/include/llvm/Analysis/TargetTransformInfo.h +++ llvm/trunk/include/llvm/Analysis/TargetTransformInfo.h @@ -1128,7 +1128,7 @@ private: friend AnalysisInfoMixin; - static char PassID; + static AnalysisKey Key; /// \brief The callback used to produce a result. /// Index: llvm/trunk/include/llvm/Analysis/TypeBasedAliasAnalysis.h =================================================================== --- llvm/trunk/include/llvm/Analysis/TypeBasedAliasAnalysis.h +++ llvm/trunk/include/llvm/Analysis/TypeBasedAliasAnalysis.h @@ -47,7 +47,7 @@ /// Analysis pass providing a never-invalidated alias analysis result. class TypeBasedAA : public AnalysisInfoMixin { friend AnalysisInfoMixin; - static char PassID; + static AnalysisKey Key; public: typedef TypeBasedAAResult Result; Index: llvm/trunk/include/llvm/IR/Dominators.h =================================================================== --- llvm/trunk/include/llvm/IR/Dominators.h +++ llvm/trunk/include/llvm/IR/Dominators.h @@ -188,7 +188,7 @@ /// \brief Analysis pass which computes a \c DominatorTree. class DominatorTreeAnalysis : public AnalysisInfoMixin { friend AnalysisInfoMixin; - static char PassID; + static AnalysisKey Key; public: /// \brief Provide the result typedef for this analysis pass. Index: llvm/trunk/include/llvm/IR/PassManager.h =================================================================== --- llvm/trunk/include/llvm/IR/PassManager.h +++ llvm/trunk/include/llvm/IR/PassManager.h @@ -54,6 +54,14 @@ namespace llvm { +/// A special type used by analysis passes to provide an address that +/// identifies that particular analysis pass type. +/// +/// Analysis passes should have a static data member of this type and derive +/// from the \c AnalysisInfoMixin to get a static ID method used to identify +/// the analysis in the pass management infrastructure. +struct alignas(8) AnalysisKey {}; + /// \brief An abstract set of preserved analyses following a transformation pass /// run. /// @@ -71,17 +79,17 @@ /// \brief Construct a special preserved set that preserves all passes. static PreservedAnalyses all() { PreservedAnalyses PA; - PA.PreservedPassIDs.insert((void *)AllPassesID); + PA.PreservedAnalysisIDs.insert(&AllAnalysesKey); return PA; } /// \brief Mark a particular pass as preserved, adding it to the set. template void preserve() { preserve(PassT::ID()); } - /// \brief Mark an abstract PassID as preserved, adding it to the set. - void preserve(void *PassID) { + /// \brief Mark an abstract ID as preserved, adding it to the set. + void preserve(AnalysisKey *ID) { if (!areAllPreserved()) - PreservedPassIDs.insert(PassID); + PreservedAnalysisIDs.insert(ID); } /// \brief Intersect this set with another in place. @@ -92,12 +100,12 @@ if (Arg.areAllPreserved()) return; if (areAllPreserved()) { - PreservedPassIDs = Arg.PreservedPassIDs; + PreservedAnalysisIDs = Arg.PreservedAnalysisIDs; return; } - for (void *P : PreservedPassIDs) - if (!Arg.PreservedPassIDs.count(P)) - PreservedPassIDs.erase(P); + for (auto ID : PreservedAnalysisIDs) + if (!Arg.PreservedAnalysisIDs.count(ID)) + PreservedAnalysisIDs.erase(ID); } /// \brief Intersect this set with a temporary other set in place. @@ -108,12 +116,12 @@ if (Arg.areAllPreserved()) return; if (areAllPreserved()) { - PreservedPassIDs = std::move(Arg.PreservedPassIDs); + PreservedAnalysisIDs = std::move(Arg.PreservedAnalysisIDs); return; } - for (void *P : PreservedPassIDs) - if (!Arg.PreservedPassIDs.count(P)) - PreservedPassIDs.erase(P); + for (auto ID : PreservedAnalysisIDs) + if (!Arg.PreservedAnalysisIDs.count(ID)) + PreservedAnalysisIDs.erase(ID); } /// \brief Query whether a pass is marked as preserved by this set. @@ -123,17 +131,17 @@ /// \brief Query whether an abstract pass ID is marked as preserved by this /// set. - bool preserved(void *PassID) const { - return PreservedPassIDs.count((void *)AllPassesID) || - PreservedPassIDs.count(PassID); + bool preserved(AnalysisKey *ID) const { + return PreservedAnalysisIDs.count(&AllAnalysesKey) || + PreservedAnalysisIDs.count(ID); } /// \brief Query whether all of the analyses in the set are preserved. bool preserved(PreservedAnalyses Arg) { if (Arg.areAllPreserved()) return areAllPreserved(); - for (void *P : Arg.PreservedPassIDs) - if (!preserved(P)) + for (auto ID : Arg.PreservedAnalysisIDs) + if (!preserved(ID)) return false; return true; } @@ -143,15 +151,14 @@ /// This is used primarily to optimize for the case of no changes which will /// common in many scenarios. bool areAllPreserved() const { - return PreservedPassIDs.count((void *)AllPassesID); + return PreservedAnalysisIDs.count(&AllAnalysesKey); } private: - // Note that this must not be -1 or -2 as those are already used by the - // SmallPtrSet. - static const uintptr_t AllPassesID = (intptr_t)(-3); + // A special key used to indicate all analyses. + static AnalysisKey AllAnalysesKey; - SmallPtrSet PreservedPassIDs; + SmallPtrSet PreservedAnalysisIDs; }; // Forward declare the analysis manager template. @@ -179,10 +186,14 @@ /// specifically used for analyses. template struct AnalysisInfoMixin : PassInfoMixin { - /// Returns an opaque, unique ID for this pass type. + /// Returns an opaque, unique ID for this analysis type. + /// + /// This ID is a pointer type that is guaranteed to be 8-byte aligned and + /// thus suitable for use in sets, maps, and other data structures optimized + /// for pointer-like types using the alignment-provided low bits. /// - /// Note that this requires the derived type provide a static member whose - /// address can be converted to a void pointer. + /// Note that this requires the derived type provide a static \c AnalysisKey + /// member called \c Key. /// /// FIXME: The only reason the derived type needs to provide this rather than /// this mixin providing it is due to broken implementations which cannot @@ -191,8 +202,8 @@ /// instantiation. The only currently known platform with this limitation are /// 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 PassID as well. - static void *ID() { return (void *)&DerivedT::PassID; } + /// static key as well. + static AnalysisKey *ID() { return &DerivedT::Key; } }; /// A class template to provide analysis sets for IR units. @@ -205,17 +216,17 @@ /// /// Note that you must provide an explicit instantiation declaration and /// definition for this template in order to get the correct behavior on -/// Windows. Otherwise, the address of SetID will not be stable. +/// Windows. Otherwise, the address of SetKey will not be stable. template class AllAnalysesOn { public: - static void *ID() { return (void *)&SetID; } + static AnalysisKey *ID() { return &SetKey; } private: - static char SetID; + static AnalysisKey SetKey; }; -template char AllAnalysesOn::SetID; +template AnalysisKey AllAnalysesOn::SetKey; extern template class AllAnalysesOn; extern template class AllAnalysesOn; @@ -363,13 +374,13 @@ // Clear all the invalidated results associated specifically with this // function. - SmallVector InvalidatedPassIDs; + SmallVector InvalidatedIDs; auto ResultsListI = AnalysisResultLists.find(&IR); if (ResultsListI == AnalysisResultLists.end()) return; // Clear the map pointing into the results list. - for (auto &PassIDAndResult : ResultsListI->second) - AnalysisResults.erase(std::make_pair(PassIDAndResult.first, &IR)); + for (auto &IDAndResult : ResultsListI->second) + AnalysisResults.erase(std::make_pair(IDAndResult.first, &IR)); // And actually destroy and erase the results associated with this IR. AnalysisResultLists.erase(ResultsListI); @@ -479,22 +490,22 @@ // Clear all the invalidated results associated specifically with this // function. - SmallVector InvalidatedPassIDs; + SmallVector InvalidatedIDs; AnalysisResultListT &ResultsList = AnalysisResultLists[&IR]; for (typename AnalysisResultListT::iterator I = ResultsList.begin(), E = ResultsList.end(); I != E;) { - void *PassID = I->first; + AnalysisKey *ID = I->first; // Pass the invalidation down to the pass itself to see if it thinks it is // necessary. The analysis pass can return false if no action on the part // of the analysis manager is required for this invalidation event. if (I->second->invalidate(IR, PA)) { if (DebugLogging) - dbgs() << "Invalidating analysis: " << this->lookupPass(PassID).name() + dbgs() << "Invalidating analysis: " << this->lookupPass(ID).name() << "\n"; - InvalidatedPassIDs.push_back(I->first); + InvalidatedIDs.push_back(I->first); I = ResultsList.erase(I); } else { ++I; @@ -503,11 +514,10 @@ // After handling each pass, we mark it as preserved. Once we've // invalidated any stale results, the rest of the system is allowed to // start preserving this analysis again. - PA.preserve(PassID); + PA.preserve(ID); } - while (!InvalidatedPassIDs.empty()) - AnalysisResults.erase( - std::make_pair(InvalidatedPassIDs.pop_back_val(), &IR)); + while (!InvalidatedIDs.empty()) + AnalysisResults.erase(std::make_pair(InvalidatedIDs.pop_back_val(), &IR)); if (ResultsList.empty()) AnalysisResultLists.erase(&IR); @@ -516,41 +526,41 @@ private: /// \brief Lookup a registered analysis pass. - PassConceptT &lookupPass(void *PassID) { - typename AnalysisPassMapT::iterator PI = AnalysisPasses.find(PassID); + PassConceptT &lookupPass(AnalysisKey *ID) { + typename AnalysisPassMapT::iterator PI = AnalysisPasses.find(ID); assert(PI != AnalysisPasses.end() && "Analysis passes must be registered prior to being queried!"); return *PI->second; } /// \brief Lookup a registered analysis pass. - const PassConceptT &lookupPass(void *PassID) const { - typename AnalysisPassMapT::const_iterator PI = AnalysisPasses.find(PassID); + const PassConceptT &lookupPass(AnalysisKey *ID) const { + typename AnalysisPassMapT::const_iterator PI = AnalysisPasses.find(ID); assert(PI != AnalysisPasses.end() && "Analysis passes must be registered prior to being queried!"); return *PI->second; } /// \brief Get an analysis result, running the pass if necessary. - ResultConceptT &getResultImpl(void *PassID, IRUnitT &IR, + ResultConceptT &getResultImpl(AnalysisKey *ID, IRUnitT &IR, ExtraArgTs... ExtraArgs) { typename AnalysisResultMapT::iterator RI; bool Inserted; std::tie(RI, Inserted) = AnalysisResults.insert(std::make_pair( - std::make_pair(PassID, &IR), typename AnalysisResultListT::iterator())); + std::make_pair(ID, &IR), typename AnalysisResultListT::iterator())); // If we don't have a cached result for this function, look up the pass and // run it to produce a result, which we then add to the cache. if (Inserted) { - auto &P = this->lookupPass(PassID); + auto &P = this->lookupPass(ID); if (DebugLogging) dbgs() << "Running analysis: " << P.name() << "\n"; AnalysisResultListT &ResultList = AnalysisResultLists[&IR]; - ResultList.emplace_back(PassID, P.run(IR, *this, ExtraArgs...)); + ResultList.emplace_back(ID, P.run(IR, *this, ExtraArgs...)); // P.run may have inserted elements into AnalysisResults and invalidated // RI. - RI = AnalysisResults.find(std::make_pair(PassID, &IR)); + RI = AnalysisResults.find(std::make_pair(ID, &IR)); assert(RI != AnalysisResults.end() && "we just inserted it!"); RI->second = std::prev(ResultList.end()); @@ -560,28 +570,28 @@ } /// \brief Get a cached analysis result or return null. - ResultConceptT *getCachedResultImpl(void *PassID, IRUnitT &IR) const { + ResultConceptT *getCachedResultImpl(AnalysisKey *ID, IRUnitT &IR) const { typename AnalysisResultMapT::const_iterator RI = - AnalysisResults.find(std::make_pair(PassID, &IR)); + AnalysisResults.find(std::make_pair(ID, &IR)); return RI == AnalysisResults.end() ? nullptr : &*RI->second->second; } /// \brief Invalidate a function pass result. - void invalidateImpl(void *PassID, IRUnitT &IR) { + void invalidateImpl(AnalysisKey *ID, IRUnitT &IR) { typename AnalysisResultMapT::iterator RI = - AnalysisResults.find(std::make_pair(PassID, &IR)); + AnalysisResults.find(std::make_pair(ID, &IR)); if (RI == AnalysisResults.end()) return; if (DebugLogging) - dbgs() << "Invalidating analysis: " << this->lookupPass(PassID).name() + dbgs() << "Invalidating analysis: " << this->lookupPass(ID).name() << "\n"; AnalysisResultLists[&IR].erase(RI->second); AnalysisResults.erase(RI); } /// \brief Map type from module analysis pass ID to pass concept pointer. - typedef DenseMap> AnalysisPassMapT; + typedef DenseMap> AnalysisPassMapT; /// \brief Collection of module analysis passes, indexed by ID. AnalysisPassMapT AnalysisPasses; @@ -592,7 +602,7 @@ /// erases. Provides both the pass ID and concept pointer such that it is /// half of a bijection and provides storage for the actual result concept. typedef std::list>>> + AnalysisKey *, std::unique_ptr>>> AnalysisResultListT; /// \brief Map type from function pointer to our custom list type. @@ -606,7 +616,7 @@ /// \brief Map type from a pair of analysis ID and function pointer to an /// iterator into a particular result list. - typedef DenseMap, + typedef DenseMap, typename AnalysisResultListT::iterator> AnalysisResultMapT; @@ -718,14 +728,14 @@ private: friend AnalysisInfoMixin< InnerAnalysisManagerProxy>; - static char PassID; + static AnalysisKey Key; AnalysisManagerT *AM; }; template -char - InnerAnalysisManagerProxy::PassID; +AnalysisKey + InnerAnalysisManagerProxy::Key; extern template class InnerAnalysisManagerProxy; @@ -777,14 +787,14 @@ private: friend AnalysisInfoMixin< OuterAnalysisManagerProxy>; - static char PassID; + static AnalysisKey Key; const AnalysisManagerT *AM; }; template -char - OuterAnalysisManagerProxy::PassID; +AnalysisKey + OuterAnalysisManagerProxy::Key; extern template class OuterAnalysisManagerProxy; Index: llvm/trunk/include/llvm/IR/Verifier.h =================================================================== --- llvm/trunk/include/llvm/IR/Verifier.h +++ llvm/trunk/include/llvm/IR/Verifier.h @@ -58,13 +58,12 @@ /// and debug info errors. class VerifierAnalysis : public AnalysisInfoMixin { friend AnalysisInfoMixin; - static char PassID; + static AnalysisKey Key; public: struct Result { bool IRBroken, DebugInfoBroken; }; - static void *ID() { return (void *)&PassID; } Result run(Module &M, ModuleAnalysisManager &); Result run(Function &F, FunctionAnalysisManager &); }; Index: llvm/trunk/include/llvm/Transforms/Utils/MemorySSA.h =================================================================== --- llvm/trunk/include/llvm/Transforms/Utils/MemorySSA.h +++ llvm/trunk/include/llvm/Transforms/Utils/MemorySSA.h @@ -672,7 +672,7 @@ /// class MemorySSAAnalysis : public AnalysisInfoMixin { friend AnalysisInfoMixin; - static char PassID; + static AnalysisKey Key; public: // Wrap MemorySSA result to ensure address stability of internal MemorySSA Index: llvm/trunk/lib/Analysis/AliasAnalysis.cpp =================================================================== --- llvm/trunk/lib/Analysis/AliasAnalysis.cpp +++ llvm/trunk/lib/Analysis/AliasAnalysis.cpp @@ -513,7 +513,7 @@ AAResults::Concept::~Concept() {} // Provide a definition for the static object used to identify passes. -char AAManager::PassID; +AnalysisKey AAManager::Key; namespace { /// A wrapper pass for external alias analyses. This just squirrels away the Index: llvm/trunk/lib/Analysis/AssumptionCache.cpp =================================================================== --- llvm/trunk/lib/Analysis/AssumptionCache.cpp +++ llvm/trunk/lib/Analysis/AssumptionCache.cpp @@ -74,7 +74,7 @@ #endif } -char AssumptionAnalysis::PassID; +AnalysisKey AssumptionAnalysis::Key; PreservedAnalyses AssumptionPrinterPass::run(Function &F, FunctionAnalysisManager &AM) { Index: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp =================================================================== --- llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp +++ llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp @@ -1715,7 +1715,7 @@ // BasicAliasAnalysis Pass //===----------------------------------------------------------------------===// -char BasicAA::PassID; +AnalysisKey BasicAA::Key; BasicAAResult BasicAA::run(Function &F, FunctionAnalysisManager &AM) { return BasicAAResult(F.getParent()->getDataLayout(), Index: llvm/trunk/lib/Analysis/BlockFrequencyInfo.cpp =================================================================== --- llvm/trunk/lib/Analysis/BlockFrequencyInfo.cpp +++ llvm/trunk/lib/Analysis/BlockFrequencyInfo.cpp @@ -252,7 +252,7 @@ return false; } -char BlockFrequencyAnalysis::PassID; +AnalysisKey BlockFrequencyAnalysis::Key; BlockFrequencyInfo BlockFrequencyAnalysis::run(Function &F, FunctionAnalysisManager &AM) { BlockFrequencyInfo BFI; Index: llvm/trunk/lib/Analysis/BranchProbabilityInfo.cpp =================================================================== --- llvm/trunk/lib/Analysis/BranchProbabilityInfo.cpp +++ llvm/trunk/lib/Analysis/BranchProbabilityInfo.cpp @@ -711,7 +711,7 @@ BPI.print(OS); } -char BranchProbabilityAnalysis::PassID; +AnalysisKey BranchProbabilityAnalysis::Key; BranchProbabilityInfo BranchProbabilityAnalysis::run(Function &F, FunctionAnalysisManager &AM) { BranchProbabilityInfo BPI; Index: llvm/trunk/lib/Analysis/CFLAndersAliasAnalysis.cpp =================================================================== --- llvm/trunk/lib/Analysis/CFLAndersAliasAnalysis.cpp +++ llvm/trunk/lib/Analysis/CFLAndersAliasAnalysis.cpp @@ -865,7 +865,7 @@ return QueryResult; } -char CFLAndersAA::PassID; +AnalysisKey CFLAndersAA::Key; CFLAndersAAResult CFLAndersAA::run(Function &F, FunctionAnalysisManager &AM) { return CFLAndersAAResult(AM.getResult(F)); Index: llvm/trunk/lib/Analysis/CFLSteensAliasAnalysis.cpp =================================================================== --- llvm/trunk/lib/Analysis/CFLSteensAliasAnalysis.cpp +++ llvm/trunk/lib/Analysis/CFLSteensAliasAnalysis.cpp @@ -341,7 +341,7 @@ return NoAlias; } -char CFLSteensAA::PassID; +AnalysisKey CFLSteensAA::Key; CFLSteensAAResult CFLSteensAA::run(Function &F, FunctionAnalysisManager &AM) { return CFLSteensAAResult(AM.getResult(F)); Index: llvm/trunk/lib/Analysis/CallGraph.cpp =================================================================== --- llvm/trunk/lib/Analysis/CallGraph.cpp +++ llvm/trunk/lib/Analysis/CallGraph.cpp @@ -258,7 +258,7 @@ } // Provide an explicit template instantiation for the static ID. -char CallGraphAnalysis::PassID; +AnalysisKey CallGraphAnalysis::Key; PreservedAnalyses CallGraphPrinterPass::run(Module &M, ModuleAnalysisManager &AM) { Index: llvm/trunk/lib/Analysis/DemandedBits.cpp =================================================================== --- llvm/trunk/lib/Analysis/DemandedBits.cpp +++ llvm/trunk/lib/Analysis/DemandedBits.cpp @@ -386,7 +386,7 @@ return new DemandedBitsWrapperPass(); } -char DemandedBitsAnalysis::PassID; +AnalysisKey DemandedBitsAnalysis::Key; DemandedBits DemandedBitsAnalysis::run(Function &F, FunctionAnalysisManager &AM) { Index: llvm/trunk/lib/Analysis/DependenceAnalysis.cpp =================================================================== --- llvm/trunk/lib/Analysis/DependenceAnalysis.cpp +++ llvm/trunk/lib/Analysis/DependenceAnalysis.cpp @@ -122,7 +122,7 @@ return DependenceInfo(&F, &AA, &SE, &LI); } -char DependenceAnalysis::PassID; +AnalysisKey DependenceAnalysis::Key; INITIALIZE_PASS_BEGIN(DependenceAnalysisWrapperPass, "da", "Dependence Analysis", true, true) Index: llvm/trunk/lib/Analysis/DominanceFrontier.cpp =================================================================== --- llvm/trunk/lib/Analysis/DominanceFrontier.cpp +++ llvm/trunk/lib/Analysis/DominanceFrontier.cpp @@ -56,7 +56,7 @@ } #endif -char DominanceFrontierAnalysis::PassID; +AnalysisKey DominanceFrontierAnalysis::Key; DominanceFrontier DominanceFrontierAnalysis::run(Function &F, FunctionAnalysisManager &AM) { Index: llvm/trunk/lib/Analysis/GlobalsModRef.cpp =================================================================== --- llvm/trunk/lib/Analysis/GlobalsModRef.cpp +++ llvm/trunk/lib/Analysis/GlobalsModRef.cpp @@ -941,7 +941,7 @@ return Result; } -char GlobalsAA::PassID; +AnalysisKey GlobalsAA::Key; GlobalsAAResult GlobalsAA::run(Module &M, ModuleAnalysisManager &AM) { return GlobalsAAResult::analyzeModule(M, Index: llvm/trunk/lib/Analysis/IVUsers.cpp =================================================================== --- llvm/trunk/lib/Analysis/IVUsers.cpp +++ llvm/trunk/lib/Analysis/IVUsers.cpp @@ -34,7 +34,7 @@ #define DEBUG_TYPE "iv-users" -char IVUsersAnalysis::PassID; +AnalysisKey IVUsersAnalysis::Key; IVUsers IVUsersAnalysis::run(Loop &L, LoopAnalysisManager &AM) { const auto &FAM = Index: llvm/trunk/lib/Analysis/LazyCallGraph.cpp =================================================================== --- llvm/trunk/lib/Analysis/LazyCallGraph.cpp +++ llvm/trunk/lib/Analysis/LazyCallGraph.cpp @@ -1833,7 +1833,7 @@ } } -char LazyCallGraphAnalysis::PassID; +AnalysisKey LazyCallGraphAnalysis::Key; LazyCallGraphPrinterPass::LazyCallGraphPrinterPass(raw_ostream &OS) : OS(OS) {} Index: llvm/trunk/lib/Analysis/LazyValueInfo.cpp =================================================================== --- llvm/trunk/lib/Analysis/LazyValueInfo.cpp +++ llvm/trunk/lib/Analysis/LazyValueInfo.cpp @@ -51,7 +51,7 @@ FunctionPass *createLazyValueInfoPass() { return new LazyValueInfoWrapperPass(); } } -char LazyValueAnalysis::PassID; +AnalysisKey LazyValueAnalysis::Key; //===----------------------------------------------------------------------===// // LVILatticeVal Index: llvm/trunk/lib/Analysis/LoopAccessAnalysis.cpp =================================================================== --- llvm/trunk/lib/Analysis/LoopAccessAnalysis.cpp +++ llvm/trunk/lib/Analysis/LoopAccessAnalysis.cpp @@ -2067,7 +2067,7 @@ INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass) INITIALIZE_PASS_END(LoopAccessLegacyAnalysis, LAA_NAME, laa_name, false, true) -char LoopAccessAnalysis::PassID; +AnalysisKey LoopAccessAnalysis::Key; LoopAccessInfo LoopAccessAnalysis::run(Loop &L, LoopAnalysisManager &AM) { const FunctionAnalysisManager &FAM = Index: llvm/trunk/lib/Analysis/LoopInfo.cpp =================================================================== --- llvm/trunk/lib/Analysis/LoopInfo.cpp +++ llvm/trunk/lib/Analysis/LoopInfo.cpp @@ -669,7 +669,7 @@ } } -char LoopAnalysis::PassID; +AnalysisKey LoopAnalysis::Key; LoopInfo LoopAnalysis::run(Function &F, FunctionAnalysisManager &AM) { // FIXME: Currently we create a LoopInfo from scratch for every function. Index: llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp =================================================================== --- llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp +++ llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp @@ -1643,7 +1643,7 @@ #endif } -char MemoryDependenceAnalysis::PassID; +AnalysisKey MemoryDependenceAnalysis::Key; MemoryDependenceResults MemoryDependenceAnalysis::run(Function &F, FunctionAnalysisManager &AM) { Index: llvm/trunk/lib/Analysis/ModuleSummaryAnalysis.cpp =================================================================== --- llvm/trunk/lib/Analysis/ModuleSummaryAnalysis.cpp +++ llvm/trunk/lib/Analysis/ModuleSummaryAnalysis.cpp @@ -305,7 +305,7 @@ return Index; } -char ModuleSummaryIndexAnalysis::PassID; +AnalysisKey ModuleSummaryIndexAnalysis::Key; ModuleSummaryIndex ModuleSummaryIndexAnalysis::run(Module &M, ModuleAnalysisManager &AM) { Index: llvm/trunk/lib/Analysis/OptimizationDiagnosticInfo.cpp =================================================================== --- llvm/trunk/lib/Analysis/OptimizationDiagnosticInfo.cpp +++ llvm/trunk/lib/Analysis/OptimizationDiagnosticInfo.cpp @@ -237,7 +237,7 @@ AU.setPreservesAll(); } -char OptimizationRemarkEmitterAnalysis::PassID; +AnalysisKey OptimizationRemarkEmitterAnalysis::Key; OptimizationRemarkEmitter OptimizationRemarkEmitterAnalysis::run(Function &F, Index: llvm/trunk/lib/Analysis/PostDominators.cpp =================================================================== --- llvm/trunk/lib/Analysis/PostDominators.cpp +++ llvm/trunk/lib/Analysis/PostDominators.cpp @@ -44,7 +44,7 @@ return new PostDominatorTreeWrapperPass(); } -char PostDominatorTreeAnalysis::PassID; +AnalysisKey PostDominatorTreeAnalysis::Key; PostDominatorTree PostDominatorTreeAnalysis::run(Function &F, FunctionAnalysisManager &) { Index: llvm/trunk/lib/Analysis/ProfileSummaryInfo.cpp =================================================================== --- llvm/trunk/lib/Analysis/ProfileSummaryInfo.cpp +++ llvm/trunk/lib/Analysis/ProfileSummaryInfo.cpp @@ -159,7 +159,7 @@ return false; } -char ProfileSummaryAnalysis::PassID; +AnalysisKey ProfileSummaryAnalysis::Key; ProfileSummaryInfo ProfileSummaryAnalysis::run(Module &M, ModuleAnalysisManager &) { return ProfileSummaryInfo(M); Index: llvm/trunk/lib/Analysis/RegionInfo.cpp =================================================================== --- llvm/trunk/lib/Analysis/RegionInfo.cpp +++ llvm/trunk/lib/Analysis/RegionInfo.cpp @@ -181,7 +181,7 @@ // RegionInfoAnalysis implementation // -char RegionInfoAnalysis::PassID; +AnalysisKey RegionInfoAnalysis::Key; RegionInfo RegionInfoAnalysis::run(Function &F, FunctionAnalysisManager &AM) { RegionInfo RI; Index: llvm/trunk/lib/Analysis/ScalarEvolution.cpp =================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp @@ -10013,7 +10013,7 @@ // TODO: Verify more things. } -char ScalarEvolutionAnalysis::PassID; +AnalysisKey ScalarEvolutionAnalysis::Key; ScalarEvolution ScalarEvolutionAnalysis::run(Function &F, FunctionAnalysisManager &AM) { Index: llvm/trunk/lib/Analysis/ScalarEvolutionAliasAnalysis.cpp =================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolutionAliasAnalysis.cpp +++ llvm/trunk/lib/Analysis/ScalarEvolutionAliasAnalysis.cpp @@ -110,7 +110,7 @@ return nullptr; } -char SCEVAA::PassID; +AnalysisKey SCEVAA::Key; SCEVAAResult SCEVAA::run(Function &F, FunctionAnalysisManager &AM) { return SCEVAAResult(AM.getResult(F)); Index: llvm/trunk/lib/Analysis/ScopedNoAliasAA.cpp =================================================================== --- llvm/trunk/lib/Analysis/ScopedNoAliasAA.cpp +++ llvm/trunk/lib/Analysis/ScopedNoAliasAA.cpp @@ -173,7 +173,7 @@ return true; } -char ScopedNoAliasAA::PassID; +AnalysisKey ScopedNoAliasAA::Key; ScopedNoAliasAAResult ScopedNoAliasAA::run(Function &F, FunctionAnalysisManager &AM) { Index: llvm/trunk/lib/Analysis/TargetLibraryInfo.cpp =================================================================== --- llvm/trunk/lib/Analysis/TargetLibraryInfo.cpp +++ llvm/trunk/lib/Analysis/TargetLibraryInfo.cpp @@ -1265,7 +1265,7 @@ initializeTargetLibraryInfoWrapperPassPass(*PassRegistry::getPassRegistry()); } -char TargetLibraryAnalysis::PassID; +AnalysisKey TargetLibraryAnalysis::Key; // Register the basic pass. INITIALIZE_PASS(TargetLibraryInfoWrapperPass, "targetlibinfo", Index: llvm/trunk/lib/Analysis/TargetTransformInfo.cpp =================================================================== --- llvm/trunk/lib/Analysis/TargetTransformInfo.cpp +++ llvm/trunk/lib/Analysis/TargetTransformInfo.cpp @@ -473,7 +473,7 @@ return TTICallback(F); } -char TargetIRAnalysis::PassID; +AnalysisKey TargetIRAnalysis::Key; TargetIRAnalysis::Result TargetIRAnalysis::getDefaultTTI(const Function &F) { return Result(F.getParent()->getDataLayout()); Index: llvm/trunk/lib/Analysis/TypeBasedAliasAnalysis.cpp =================================================================== --- llvm/trunk/lib/Analysis/TypeBasedAliasAnalysis.cpp +++ llvm/trunk/lib/Analysis/TypeBasedAliasAnalysis.cpp @@ -550,7 +550,7 @@ return false; } -char TypeBasedAA::PassID; +AnalysisKey TypeBasedAA::Key; TypeBasedAAResult TypeBasedAA::run(Function &F, FunctionAnalysisManager &AM) { return TypeBasedAAResult(); Index: llvm/trunk/lib/IR/Dominators.cpp =================================================================== --- llvm/trunk/lib/IR/Dominators.cpp +++ llvm/trunk/lib/IR/Dominators.cpp @@ -311,7 +311,7 @@ return DT; } -char DominatorTreeAnalysis::PassID; +AnalysisKey DominatorTreeAnalysis::Key; DominatorTreePrinterPass::DominatorTreePrinterPass(raw_ostream &OS) : OS(OS) {} Index: llvm/trunk/lib/IR/PassManager.cpp =================================================================== --- llvm/trunk/lib/IR/PassManager.cpp +++ llvm/trunk/lib/IR/PassManager.cpp @@ -24,3 +24,5 @@ template class InnerAnalysisManagerProxy; template class OuterAnalysisManagerProxy; } + +AnalysisKey PreservedAnalyses::AllAnalysesKey; Index: llvm/trunk/lib/IR/Verifier.cpp =================================================================== --- llvm/trunk/lib/IR/Verifier.cpp +++ llvm/trunk/lib/IR/Verifier.cpp @@ -4473,7 +4473,7 @@ return new VerifierLegacyPass(FatalErrors); } -char VerifierAnalysis::PassID; +AnalysisKey VerifierAnalysis::Key; VerifierAnalysis::Result VerifierAnalysis::run(Module &M, ModuleAnalysisManager &) { Result Res; Index: llvm/trunk/lib/Passes/PassBuilder.cpp =================================================================== --- llvm/trunk/lib/Passes/PassBuilder.cpp +++ llvm/trunk/lib/Passes/PassBuilder.cpp @@ -152,7 +152,7 @@ /// \brief No-op module analysis. class NoOpModuleAnalysis : public AnalysisInfoMixin { friend AnalysisInfoMixin; - static char PassID; + static AnalysisKey Key; public: struct Result {}; @@ -172,7 +172,7 @@ /// \brief No-op CGSCC analysis. class NoOpCGSCCAnalysis : public AnalysisInfoMixin { friend AnalysisInfoMixin; - static char PassID; + static AnalysisKey Key; public: struct Result {}; @@ -193,7 +193,7 @@ /// \brief No-op function analysis. class NoOpFunctionAnalysis : public AnalysisInfoMixin { friend AnalysisInfoMixin; - static char PassID; + static AnalysisKey Key; public: struct Result {}; @@ -212,7 +212,7 @@ /// \brief No-op loop analysis. class NoOpLoopAnalysis : public AnalysisInfoMixin { friend AnalysisInfoMixin; - static char PassID; + static AnalysisKey Key; public: struct Result {}; @@ -220,10 +220,10 @@ static StringRef name() { return "NoOpLoopAnalysis"; } }; -char NoOpModuleAnalysis::PassID; -char NoOpCGSCCAnalysis::PassID; -char NoOpFunctionAnalysis::PassID; -char NoOpLoopAnalysis::PassID; +AnalysisKey NoOpModuleAnalysis::Key; +AnalysisKey NoOpCGSCCAnalysis::Key; +AnalysisKey NoOpFunctionAnalysis::Key; +AnalysisKey NoOpLoopAnalysis::Key; } // End anonymous namespace. Index: llvm/trunk/lib/Transforms/Utils/MemorySSA.cpp =================================================================== --- llvm/trunk/lib/Transforms/Utils/MemorySSA.cpp +++ llvm/trunk/lib/Transforms/Utils/MemorySSA.cpp @@ -2067,7 +2067,7 @@ return false; } -char MemorySSAAnalysis::PassID; +AnalysisKey MemorySSAAnalysis::Key; MemorySSAAnalysis::Result MemorySSAAnalysis::run(Function &F, FunctionAnalysisManager &AM) { Index: llvm/trunk/unittests/Analysis/CGSCCPassManagerTest.cpp =================================================================== --- llvm/trunk/unittests/Analysis/CGSCCPassManagerTest.cpp +++ llvm/trunk/unittests/Analysis/CGSCCPassManagerTest.cpp @@ -22,16 +22,13 @@ namespace { -class TestModuleAnalysis { +class TestModuleAnalysis : public AnalysisInfoMixin { public: struct Result { Result(int Count) : FunctionCount(Count) {} int FunctionCount; }; - static void *ID() { return (void *)&PassID; } - static StringRef name() { return "TestModuleAnalysis"; } - TestModuleAnalysis(int &Runs) : Runs(Runs) {} Result run(Module &M, ModuleAnalysisManager &AM) { @@ -40,23 +37,21 @@ } private: - static char PassID; + friend AnalysisInfoMixin; + static AnalysisKey Key; int &Runs; }; -char TestModuleAnalysis::PassID; +AnalysisKey TestModuleAnalysis::Key; -class TestSCCAnalysis { +class TestSCCAnalysis : public AnalysisInfoMixin { public: struct Result { Result(int Count) : FunctionCount(Count) {} int FunctionCount; }; - static void *ID() { return (void *)&PassID; } - static StringRef name() { return "TestSCCAnalysis"; } - TestSCCAnalysis(int &Runs) : Runs(Runs) {} Result run(LazyCallGraph::SCC &C, CGSCCAnalysisManager &AM, LazyCallGraph &) { @@ -65,23 +60,21 @@ } private: - static char PassID; + friend AnalysisInfoMixin; + static AnalysisKey Key; int &Runs; }; -char TestSCCAnalysis::PassID; +AnalysisKey TestSCCAnalysis::Key; -class TestFunctionAnalysis { +class TestFunctionAnalysis : public AnalysisInfoMixin { public: struct Result { Result(int Count) : InstructionCount(Count) {} int InstructionCount; }; - static void *ID() { return (void *)&PassID; } - static StringRef name() { return "TestFunctionAnalysis"; } - TestFunctionAnalysis(int &Runs) : Runs(Runs) {} Result run(Function &F, FunctionAnalysisManager &AM) { @@ -95,22 +88,21 @@ } private: - static char PassID; + friend AnalysisInfoMixin; + static AnalysisKey Key; int &Runs; }; -char TestFunctionAnalysis::PassID; +AnalysisKey TestFunctionAnalysis::Key; -class TestImmutableFunctionAnalysis { +class TestImmutableFunctionAnalysis + : public AnalysisInfoMixin { public: struct Result { bool invalidate(Function &, const PreservedAnalyses &) { return false; } }; - static void *ID() { return (void *)&PassID; } - static StringRef name() { return "TestImmutableFunctionAnalysis"; } - TestImmutableFunctionAnalysis(int &Runs) : Runs(Runs) {} Result run(Function &F, FunctionAnalysisManager &AM) { @@ -119,12 +111,13 @@ } private: - static char PassID; + friend AnalysisInfoMixin; + static AnalysisKey Key; int &Runs; }; -char TestImmutableFunctionAnalysis::PassID; +AnalysisKey TestImmutableFunctionAnalysis::Key; struct LambdaSCCPass : public PassInfoMixin { template LambdaSCCPass(T &&Arg) : Func(std::forward(Arg)) {} Index: llvm/trunk/unittests/Analysis/LoopPassManagerTest.cpp =================================================================== --- llvm/trunk/unittests/Analysis/LoopPassManagerTest.cpp +++ llvm/trunk/unittests/Analysis/LoopPassManagerTest.cpp @@ -21,9 +21,9 @@ namespace { -class TestLoopAnalysis { - /// \brief Private static data to provide unique ID. - static char PassID; +class TestLoopAnalysis : public AnalysisInfoMixin { + friend AnalysisInfoMixin; + static AnalysisKey Key; int &Runs; @@ -33,12 +33,6 @@ int BlockCount; }; - /// \brief Returns an opaque, unique ID for this pass type. - static void *ID() { return (void *)&PassID; } - - /// \brief Returns the name of the analysis. - static StringRef name() { return "TestLoopAnalysis"; } - TestLoopAnalysis(int &Runs) : Runs(Runs) {} /// \brief Run the analysis pass over the loop and return a result. @@ -52,7 +46,7 @@ } }; -char TestLoopAnalysis::PassID; +AnalysisKey TestLoopAnalysis::Key; class TestLoopPass { std::vector &VisitedLoops; Index: llvm/trunk/unittests/IR/PassManagerTest.cpp =================================================================== --- llvm/trunk/unittests/IR/PassManagerTest.cpp +++ llvm/trunk/unittests/IR/PassManagerTest.cpp @@ -41,12 +41,12 @@ private: friend AnalysisInfoMixin; - static char PassID; + static AnalysisKey Key; int &Runs; }; -char TestFunctionAnalysis::PassID; +AnalysisKey TestFunctionAnalysis::Key; class TestModuleAnalysis : public AnalysisInfoMixin { public: @@ -67,12 +67,12 @@ private: friend AnalysisInfoMixin; - static char PassID; + static AnalysisKey Key; int &Runs; }; -char TestModuleAnalysis::PassID; +AnalysisKey TestModuleAnalysis::Key; struct TestModulePass : PassInfoMixin { TestModulePass(int &RunCount) : RunCount(RunCount) {} @@ -351,10 +351,10 @@ private: friend AnalysisInfoMixin; - static char PassID; + static AnalysisKey Key; }; -char CustomizedAnalysis::PassID; +AnalysisKey CustomizedAnalysis::Key; struct CustomizedPass : PassInfoMixin { std::function Callback;