mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 12:41:49 +01:00
[PM] Change the static object whose address is used to uniquely identify
analyses to have a common type which is enforced rather than using a char object and a `void *` type when used as an identifier. This has a number of advantages. First, it at least helps some of the confusion raised in Justin Lebar's code review of why `void *` was being used everywhere by having a stronger type that connects to documentation about this. However, perhaps more importantly, it addresses a serious issue where the alignment of these pointer-like identifiers was unknown. This made it hard to use them in pointer-like data structures. We were already dodging this in dangerous ways to create the "all analyses" entry. In a subsequent patch I attempted to use these with TinyPtrVector and things fell apart in a very bad way. And it isn't just a compile time or type system issue. Worse than that, the actual alignment of these pointer-like opaque identifiers wasn't guaranteed to be a useful alignment as they were just characters. This change introduces a type to use as the "key" object whose address forms the opaque identifier. This both forces the objects to have proper alignment, and provides type checking that we get it right everywhere. It also makes the types somewhat less mysterious than `void *`. We could go one step further and introduce a truly opaque pointer-like type to return from the `ID()` static function rather than returning `AnalysisKey *`, but that didn't seem to be a clear win so this is just the initial change to get to a reliably typed and aligned object serving is a key for all the analyses. Thanks to Richard Smith and Justin Lebar for helping pick plausible names and avoid making this refactoring many times. =] And thanks to Sean for the super fast review! While here, I've tried to move away from the "PassID" nomenclature entirely as it wasn't really helping and is overloaded with old pass manager constructs. Now we have IDs for analyses, and key objects whose address can be used as IDs. Where possible and clear I've shortened this to just "ID". In a few places I kept "AnalysisID" to make it clear what was being identified. Differential Revision: https://reviews.llvm.org/D27031 llvm-svn: 287783
This commit is contained in:
parent
40a0781572
commit
dad102bcc9
@ -911,7 +911,7 @@ public:
|
||||
|
||||
private:
|
||||
friend AnalysisInfoMixin<AAManager>;
|
||||
static char PassID;
|
||||
static AnalysisKey Key;
|
||||
|
||||
SmallVector<void (*)(Function &F, FunctionAnalysisManager &AM,
|
||||
AAResults &AAResults),
|
||||
|
@ -95,7 +95,7 @@ public:
|
||||
/// assumption caches for a given function.
|
||||
class AssumptionAnalysis : public AnalysisInfoMixin<AssumptionAnalysis> {
|
||||
friend AnalysisInfoMixin<AssumptionAnalysis>;
|
||||
static char PassID;
|
||||
static AnalysisKey Key;
|
||||
|
||||
public:
|
||||
typedef AssumptionCache Result;
|
||||
|
@ -196,7 +196,7 @@ private:
|
||||
/// Analysis pass providing a never-invalidated alias analysis result.
|
||||
class BasicAA : public AnalysisInfoMixin<BasicAA> {
|
||||
friend AnalysisInfoMixin<BasicAA>;
|
||||
static char PassID;
|
||||
static AnalysisKey Key;
|
||||
|
||||
public:
|
||||
typedef BasicAAResult Result;
|
||||
|
@ -90,7 +90,7 @@ public:
|
||||
class BlockFrequencyAnalysis
|
||||
: public AnalysisInfoMixin<BlockFrequencyAnalysis> {
|
||||
friend AnalysisInfoMixin<BlockFrequencyAnalysis>;
|
||||
static char PassID;
|
||||
static AnalysisKey Key;
|
||||
|
||||
public:
|
||||
/// \brief Provide the result typedef for this analysis pass.
|
||||
|
@ -178,7 +178,7 @@ private:
|
||||
class BranchProbabilityAnalysis
|
||||
: public AnalysisInfoMixin<BranchProbabilityAnalysis> {
|
||||
friend AnalysisInfoMixin<BranchProbabilityAnalysis>;
|
||||
static char PassID;
|
||||
static AnalysisKey Key;
|
||||
|
||||
public:
|
||||
/// \brief Provide the result typedef for this analysis pass.
|
||||
|
@ -103,7 +103,7 @@ private:
|
||||
/// in particular to leverage invalidation to trigger re-computation.
|
||||
class CFLAndersAA : public AnalysisInfoMixin<CFLAndersAA> {
|
||||
friend AnalysisInfoMixin<CFLAndersAA>;
|
||||
static char PassID;
|
||||
static AnalysisKey Key;
|
||||
|
||||
public:
|
||||
typedef CFLAndersAAResult Result;
|
||||
|
@ -122,7 +122,7 @@ private:
|
||||
/// in particular to leverage invalidation to trigger re-computation of sets.
|
||||
class CFLSteensAA : public AnalysisInfoMixin<CFLSteensAA> {
|
||||
friend AnalysisInfoMixin<CFLSteensAA>;
|
||||
static char PassID;
|
||||
static AnalysisKey Key;
|
||||
|
||||
public:
|
||||
typedef CFLSteensAAResult Result;
|
||||
|
@ -297,7 +297,7 @@ private:
|
||||
/// resulting data.
|
||||
class CallGraphAnalysis : public AnalysisInfoMixin<CallGraphAnalysis> {
|
||||
friend AnalysisInfoMixin<CallGraphAnalysis>;
|
||||
static char PassID;
|
||||
static AnalysisKey Key;
|
||||
|
||||
public:
|
||||
/// \brief A formulaic typedef to inform clients of the result type.
|
||||
|
@ -89,7 +89,7 @@ public:
|
||||
/// An analysis that produces \c DemandedBits for a function.
|
||||
class DemandedBitsAnalysis : public AnalysisInfoMixin<DemandedBitsAnalysis> {
|
||||
friend AnalysisInfoMixin<DemandedBitsAnalysis>;
|
||||
static char PassID;
|
||||
static AnalysisKey Key;
|
||||
|
||||
public:
|
||||
/// \brief Provide the result typedef for this analysis pass.
|
||||
|
@ -921,7 +921,7 @@ template <typename T> class ArrayRef;
|
||||
Result run(Function &F, FunctionAnalysisManager &FAM);
|
||||
|
||||
private:
|
||||
static char PassID;
|
||||
static AnalysisKey Key;
|
||||
friend struct AnalysisInfoMixin<DependenceAnalysis>;
|
||||
}; // class DependenceAnalysis
|
||||
|
||||
|
@ -171,7 +171,7 @@ extern template class ForwardDominanceFrontierBase<BasicBlock>;
|
||||
class DominanceFrontierAnalysis
|
||||
: public AnalysisInfoMixin<DominanceFrontierAnalysis> {
|
||||
friend AnalysisInfoMixin<DominanceFrontierAnalysis>;
|
||||
static char PassID;
|
||||
static AnalysisKey Key;
|
||||
|
||||
public:
|
||||
/// \brief Provide the result typedef for this analysis pass.
|
||||
|
@ -120,7 +120,7 @@ private:
|
||||
/// Analysis pass providing a never-invalidated alias analysis result.
|
||||
class GlobalsAA : public AnalysisInfoMixin<GlobalsAA> {
|
||||
friend AnalysisInfoMixin<GlobalsAA>;
|
||||
static char PassID;
|
||||
static AnalysisKey Key;
|
||||
|
||||
public:
|
||||
typedef GlobalsAAResult Result;
|
||||
|
@ -188,7 +188,7 @@ public:
|
||||
/// Analysis pass that exposes the \c IVUsers for a loop.
|
||||
class IVUsersAnalysis : public AnalysisInfoMixin<IVUsersAnalysis> {
|
||||
friend AnalysisInfoMixin<IVUsersAnalysis>;
|
||||
static char PassID;
|
||||
static AnalysisKey Key;
|
||||
|
||||
public:
|
||||
typedef IVUsers Result;
|
||||
|
@ -1145,7 +1145,7 @@ template <> struct GraphTraits<LazyCallGraph *> {
|
||||
/// An analysis pass which computes the call graph for a module.
|
||||
class LazyCallGraphAnalysis : public AnalysisInfoMixin<LazyCallGraphAnalysis> {
|
||||
friend AnalysisInfoMixin<LazyCallGraphAnalysis>;
|
||||
static char PassID;
|
||||
static AnalysisKey Key;
|
||||
|
||||
public:
|
||||
/// Inform generic clients of the result type.
|
||||
|
@ -109,7 +109,7 @@ public:
|
||||
Result run(Function &F, FunctionAnalysisManager &FAM);
|
||||
|
||||
private:
|
||||
static char PassID;
|
||||
static AnalysisKey Key;
|
||||
friend struct AnalysisInfoMixin<LazyValueAnalysis>;
|
||||
};
|
||||
|
||||
|
@ -749,7 +749,7 @@ private:
|
||||
class LoopAccessAnalysis
|
||||
: public AnalysisInfoMixin<LoopAccessAnalysis> {
|
||||
friend AnalysisInfoMixin<LoopAccessAnalysis>;
|
||||
static char PassID;
|
||||
static AnalysisKey Key;
|
||||
|
||||
public:
|
||||
typedef LoopAccessInfo Result;
|
||||
|
@ -805,7 +805,7 @@ template <> struct GraphTraits<Loop*> {
|
||||
/// \brief Analysis pass that exposes the \c LoopInfo for a function.
|
||||
class LoopAnalysis : public AnalysisInfoMixin<LoopAnalysis> {
|
||||
friend AnalysisInfoMixin<LoopAnalysis>;
|
||||
static char PassID;
|
||||
static AnalysisKey Key;
|
||||
|
||||
public:
|
||||
typedef LoopInfo Result;
|
||||
|
@ -485,7 +485,7 @@ private:
|
||||
class MemoryDependenceAnalysis
|
||||
: public AnalysisInfoMixin<MemoryDependenceAnalysis> {
|
||||
friend AnalysisInfoMixin<MemoryDependenceAnalysis>;
|
||||
static char PassID;
|
||||
static AnalysisKey Key;
|
||||
|
||||
public:
|
||||
typedef MemoryDependenceResults Result;
|
||||
|
@ -38,7 +38,7 @@ ModuleSummaryIndex buildModuleSummaryIndex(
|
||||
class ModuleSummaryIndexAnalysis
|
||||
: public AnalysisInfoMixin<ModuleSummaryIndexAnalysis> {
|
||||
friend AnalysisInfoMixin<ModuleSummaryIndexAnalysis>;
|
||||
static char PassID;
|
||||
static AnalysisKey Key;
|
||||
|
||||
public:
|
||||
typedef ModuleSummaryIndex Result;
|
||||
|
@ -63,7 +63,7 @@ public:
|
||||
/// Analysis pass providing a never-invalidated alias analysis result.
|
||||
class ObjCARCAA : public AnalysisInfoMixin<ObjCARCAA> {
|
||||
friend AnalysisInfoMixin<ObjCARCAA>;
|
||||
static char PassID;
|
||||
static AnalysisKey Key;
|
||||
|
||||
public:
|
||||
typedef ObjCARCAAResult Result;
|
||||
|
@ -251,7 +251,7 @@ public:
|
||||
class OptimizationRemarkEmitterAnalysis
|
||||
: public AnalysisInfoMixin<OptimizationRemarkEmitterAnalysis> {
|
||||
friend AnalysisInfoMixin<OptimizationRemarkEmitterAnalysis>;
|
||||
static char PassID;
|
||||
static AnalysisKey Key;
|
||||
|
||||
public:
|
||||
/// \brief Provide the result typedef for this analysis pass.
|
||||
|
@ -32,7 +32,7 @@ struct PostDominatorTree : public DominatorTreeBase<BasicBlock> {
|
||||
class PostDominatorTreeAnalysis
|
||||
: public AnalysisInfoMixin<PostDominatorTreeAnalysis> {
|
||||
friend AnalysisInfoMixin<PostDominatorTreeAnalysis>;
|
||||
static char PassID;
|
||||
static AnalysisKey Key;
|
||||
|
||||
public:
|
||||
/// \brief Provide the result typedef for this analysis pass.
|
||||
|
@ -94,7 +94,7 @@ public:
|
||||
|
||||
private:
|
||||
friend AnalysisInfoMixin<ProfileSummaryAnalysis>;
|
||||
static char PassID;
|
||||
static AnalysisKey Key;
|
||||
};
|
||||
|
||||
/// \brief Printer pass that uses \c ProfileSummaryAnalysis.
|
||||
|
@ -933,7 +933,7 @@ public:
|
||||
/// \brief Analysis pass that exposes the \c RegionInfo for a function.
|
||||
class RegionInfoAnalysis : public AnalysisInfoMixin<RegionInfoAnalysis> {
|
||||
friend AnalysisInfoMixin<RegionInfoAnalysis>;
|
||||
static char PassID;
|
||||
static AnalysisKey Key;
|
||||
|
||||
public:
|
||||
typedef RegionInfo Result;
|
||||
|
@ -1626,7 +1626,7 @@ private:
|
||||
class ScalarEvolutionAnalysis
|
||||
: public AnalysisInfoMixin<ScalarEvolutionAnalysis> {
|
||||
friend AnalysisInfoMixin<ScalarEvolutionAnalysis>;
|
||||
static char PassID;
|
||||
static AnalysisKey Key;
|
||||
|
||||
public:
|
||||
typedef ScalarEvolution Result;
|
||||
|
@ -40,7 +40,7 @@ private:
|
||||
/// Analysis pass providing a never-invalidated alias analysis result.
|
||||
class SCEVAA : public AnalysisInfoMixin<SCEVAA> {
|
||||
friend AnalysisInfoMixin<SCEVAA>;
|
||||
static char PassID;
|
||||
static AnalysisKey Key;
|
||||
|
||||
public:
|
||||
typedef SCEVAAResult Result;
|
||||
|
@ -43,7 +43,7 @@ private:
|
||||
/// Analysis pass providing a never-invalidated alias analysis result.
|
||||
class ScopedNoAliasAA : public AnalysisInfoMixin<ScopedNoAliasAA> {
|
||||
friend AnalysisInfoMixin<ScopedNoAliasAA>;
|
||||
static char PassID;
|
||||
static AnalysisKey Key;
|
||||
|
||||
public:
|
||||
typedef ScopedNoAliasAAResult Result;
|
||||
|
@ -343,7 +343,7 @@ public:
|
||||
|
||||
private:
|
||||
friend AnalysisInfoMixin<TargetLibraryAnalysis>;
|
||||
static char PassID;
|
||||
static AnalysisKey Key;
|
||||
|
||||
Optional<TargetLibraryInfoImpl> PresetInfoImpl;
|
||||
|
||||
|
@ -1128,7 +1128,7 @@ public:
|
||||
|
||||
private:
|
||||
friend AnalysisInfoMixin<TargetIRAnalysis>;
|
||||
static char PassID;
|
||||
static AnalysisKey Key;
|
||||
|
||||
/// \brief The callback used to produce a result.
|
||||
///
|
||||
|
@ -47,7 +47,7 @@ private:
|
||||
/// Analysis pass providing a never-invalidated alias analysis result.
|
||||
class TypeBasedAA : public AnalysisInfoMixin<TypeBasedAA> {
|
||||
friend AnalysisInfoMixin<TypeBasedAA>;
|
||||
static char PassID;
|
||||
static AnalysisKey Key;
|
||||
|
||||
public:
|
||||
typedef TypeBasedAAResult Result;
|
||||
|
@ -188,7 +188,7 @@ template <> struct GraphTraits<DominatorTree*>
|
||||
/// \brief Analysis pass which computes a \c DominatorTree.
|
||||
class DominatorTreeAnalysis : public AnalysisInfoMixin<DominatorTreeAnalysis> {
|
||||
friend AnalysisInfoMixin<DominatorTreeAnalysis>;
|
||||
static char PassID;
|
||||
static AnalysisKey Key;
|
||||
|
||||
public:
|
||||
/// \brief Provide the result typedef for this analysis pass.
|
||||
|
@ -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 @@ public:
|
||||
/// \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 <typename PassT> 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 @@ public:
|
||||
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 @@ public:
|
||||
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 @@ public:
|
||||
|
||||
/// \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 @@ public:
|
||||
/// 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<void *, 2> PreservedPassIDs;
|
||||
SmallPtrSet<AnalysisKey *, 2> PreservedAnalysisIDs;
|
||||
};
|
||||
|
||||
// Forward declare the analysis manager template.
|
||||
@ -179,10 +186,14 @@ template <typename DerivedT> struct PassInfoMixin {
|
||||
/// specifically used for analyses.
|
||||
template <typename DerivedT>
|
||||
struct AnalysisInfoMixin : PassInfoMixin<DerivedT> {
|
||||
/// Returns an opaque, unique ID for this pass type.
|
||||
/// Returns an opaque, unique ID for this analysis type.
|
||||
///
|
||||
/// Note that this requires the derived type provide a static member whose
|
||||
/// address can be converted to a void pointer.
|
||||
/// 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 \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 @@ struct AnalysisInfoMixin : PassInfoMixin<DerivedT> {
|
||||
/// 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 @@ struct AnalysisInfoMixin : PassInfoMixin<DerivedT> {
|
||||
///
|
||||
/// 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 <typename IRUnitT>
|
||||
class AllAnalysesOn {
|
||||
public:
|
||||
static void *ID() { return (void *)&SetID; }
|
||||
static AnalysisKey *ID() { return &SetKey; }
|
||||
|
||||
private:
|
||||
static char SetID;
|
||||
static AnalysisKey SetKey;
|
||||
};
|
||||
|
||||
template <typename IRUnitT> char AllAnalysesOn<IRUnitT>::SetID;
|
||||
template <typename IRUnitT> AnalysisKey AllAnalysesOn<IRUnitT>::SetKey;
|
||||
|
||||
extern template class AllAnalysesOn<Module>;
|
||||
extern template class AllAnalysesOn<Function>;
|
||||
@ -363,13 +374,13 @@ public:
|
||||
|
||||
// Clear all the invalidated results associated specifically with this
|
||||
// function.
|
||||
SmallVector<void *, 8> InvalidatedPassIDs;
|
||||
SmallVector<AnalysisKey *, 8> 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 @@ public:
|
||||
|
||||
// Clear all the invalidated results associated specifically with this
|
||||
// function.
|
||||
SmallVector<void *, 8> InvalidatedPassIDs;
|
||||
SmallVector<AnalysisKey *, 8> 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 @@ public:
|
||||
// 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 @@ public:
|
||||
|
||||
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 @@ private:
|
||||
}
|
||||
|
||||
/// \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<void *, std::unique_ptr<PassConceptT>> AnalysisPassMapT;
|
||||
typedef DenseMap<AnalysisKey *, std::unique_ptr<PassConceptT>> AnalysisPassMapT;
|
||||
|
||||
/// \brief Collection of module analysis passes, indexed by ID.
|
||||
AnalysisPassMapT AnalysisPasses;
|
||||
@ -592,7 +602,7 @@ private:
|
||||
/// 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<std::pair<
|
||||
void *, std::unique_ptr<detail::AnalysisResultConcept<IRUnitT>>>>
|
||||
AnalysisKey *, std::unique_ptr<detail::AnalysisResultConcept<IRUnitT>>>>
|
||||
AnalysisResultListT;
|
||||
|
||||
/// \brief Map type from function pointer to our custom list type.
|
||||
@ -606,7 +616,7 @@ private:
|
||||
|
||||
/// \brief Map type from a pair of analysis ID and function pointer to an
|
||||
/// iterator into a particular result list.
|
||||
typedef DenseMap<std::pair<void *, IRUnitT *>,
|
||||
typedef DenseMap<std::pair<AnalysisKey *, IRUnitT *>,
|
||||
typename AnalysisResultListT::iterator>
|
||||
AnalysisResultMapT;
|
||||
|
||||
@ -718,14 +728,14 @@ public:
|
||||
private:
|
||||
friend AnalysisInfoMixin<
|
||||
InnerAnalysisManagerProxy<AnalysisManagerT, IRUnitT>>;
|
||||
static char PassID;
|
||||
static AnalysisKey Key;
|
||||
|
||||
AnalysisManagerT *AM;
|
||||
};
|
||||
|
||||
template <typename AnalysisManagerT, typename IRUnitT, typename... ExtraArgTs>
|
||||
char
|
||||
InnerAnalysisManagerProxy<AnalysisManagerT, IRUnitT, ExtraArgTs...>::PassID;
|
||||
AnalysisKey
|
||||
InnerAnalysisManagerProxy<AnalysisManagerT, IRUnitT, ExtraArgTs...>::Key;
|
||||
|
||||
extern template class InnerAnalysisManagerProxy<FunctionAnalysisManager,
|
||||
Module>;
|
||||
@ -777,14 +787,14 @@ public:
|
||||
private:
|
||||
friend AnalysisInfoMixin<
|
||||
OuterAnalysisManagerProxy<AnalysisManagerT, IRUnitT>>;
|
||||
static char PassID;
|
||||
static AnalysisKey Key;
|
||||
|
||||
const AnalysisManagerT *AM;
|
||||
};
|
||||
|
||||
template <typename AnalysisManagerT, typename IRUnitT, typename... ExtraArgTs>
|
||||
char
|
||||
OuterAnalysisManagerProxy<AnalysisManagerT, IRUnitT, ExtraArgTs...>::PassID;
|
||||
AnalysisKey
|
||||
OuterAnalysisManagerProxy<AnalysisManagerT, IRUnitT, ExtraArgTs...>::Key;
|
||||
|
||||
extern template class OuterAnalysisManagerProxy<ModuleAnalysisManager,
|
||||
Function>;
|
||||
|
@ -58,13 +58,12 @@ FunctionPass *createVerifierPass(bool FatalErrors = true);
|
||||
/// and debug info errors.
|
||||
class VerifierAnalysis : public AnalysisInfoMixin<VerifierAnalysis> {
|
||||
friend AnalysisInfoMixin<VerifierAnalysis>;
|
||||
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 &);
|
||||
};
|
||||
|
@ -672,7 +672,7 @@ public:
|
||||
///
|
||||
class MemorySSAAnalysis : public AnalysisInfoMixin<MemorySSAAnalysis> {
|
||||
friend AnalysisInfoMixin<MemorySSAAnalysis>;
|
||||
static char PassID;
|
||||
static AnalysisKey Key;
|
||||
|
||||
public:
|
||||
// Wrap MemorySSA result to ensure address stability of internal MemorySSA
|
||||
|
@ -513,7 +513,7 @@ bool AAResults::canInstructionRangeModRef(const Instruction &I1,
|
||||
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
|
||||
|
@ -74,7 +74,7 @@ void AssumptionCache::registerAssumption(CallInst *CI) {
|
||||
#endif
|
||||
}
|
||||
|
||||
char AssumptionAnalysis::PassID;
|
||||
AnalysisKey AssumptionAnalysis::Key;
|
||||
|
||||
PreservedAnalyses AssumptionPrinterPass::run(Function &F,
|
||||
FunctionAnalysisManager &AM) {
|
||||
|
@ -1715,7 +1715,7 @@ bool BasicAAResult::constantOffsetHeuristic(
|
||||
// BasicAliasAnalysis Pass
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
char BasicAA::PassID;
|
||||
AnalysisKey BasicAA::Key;
|
||||
|
||||
BasicAAResult BasicAA::run(Function &F, FunctionAnalysisManager &AM) {
|
||||
return BasicAAResult(F.getParent()->getDataLayout(),
|
||||
|
@ -252,7 +252,7 @@ bool BlockFrequencyInfoWrapperPass::runOnFunction(Function &F) {
|
||||
return false;
|
||||
}
|
||||
|
||||
char BlockFrequencyAnalysis::PassID;
|
||||
AnalysisKey BlockFrequencyAnalysis::Key;
|
||||
BlockFrequencyInfo BlockFrequencyAnalysis::run(Function &F,
|
||||
FunctionAnalysisManager &AM) {
|
||||
BlockFrequencyInfo BFI;
|
||||
|
@ -711,7 +711,7 @@ void BranchProbabilityInfoWrapperPass::print(raw_ostream &OS,
|
||||
BPI.print(OS);
|
||||
}
|
||||
|
||||
char BranchProbabilityAnalysis::PassID;
|
||||
AnalysisKey BranchProbabilityAnalysis::Key;
|
||||
BranchProbabilityInfo
|
||||
BranchProbabilityAnalysis::run(Function &F, FunctionAnalysisManager &AM) {
|
||||
BranchProbabilityInfo BPI;
|
||||
|
@ -865,7 +865,7 @@ AliasResult CFLAndersAAResult::alias(const MemoryLocation &LocA,
|
||||
return QueryResult;
|
||||
}
|
||||
|
||||
char CFLAndersAA::PassID;
|
||||
AnalysisKey CFLAndersAA::Key;
|
||||
|
||||
CFLAndersAAResult CFLAndersAA::run(Function &F, FunctionAnalysisManager &AM) {
|
||||
return CFLAndersAAResult(AM.getResult<TargetLibraryAnalysis>(F));
|
||||
|
@ -341,7 +341,7 @@ AliasResult CFLSteensAAResult::query(const MemoryLocation &LocA,
|
||||
return NoAlias;
|
||||
}
|
||||
|
||||
char CFLSteensAA::PassID;
|
||||
AnalysisKey CFLSteensAA::Key;
|
||||
|
||||
CFLSteensAAResult CFLSteensAA::run(Function &F, FunctionAnalysisManager &AM) {
|
||||
return CFLSteensAAResult(AM.getResult<TargetLibraryAnalysis>(F));
|
||||
|
@ -258,7 +258,7 @@ void CallGraphNode::replaceCallEdge(CallSite CS,
|
||||
}
|
||||
|
||||
// Provide an explicit template instantiation for the static ID.
|
||||
char CallGraphAnalysis::PassID;
|
||||
AnalysisKey CallGraphAnalysis::Key;
|
||||
|
||||
PreservedAnalyses CallGraphPrinterPass::run(Module &M,
|
||||
ModuleAnalysisManager &AM) {
|
||||
|
@ -386,7 +386,7 @@ FunctionPass *llvm::createDemandedBitsWrapperPass() {
|
||||
return new DemandedBitsWrapperPass();
|
||||
}
|
||||
|
||||
char DemandedBitsAnalysis::PassID;
|
||||
AnalysisKey DemandedBitsAnalysis::Key;
|
||||
|
||||
DemandedBits DemandedBitsAnalysis::run(Function &F,
|
||||
FunctionAnalysisManager &AM) {
|
||||
|
@ -122,7 +122,7 @@ DependenceAnalysis::run(Function &F, FunctionAnalysisManager &FAM) {
|
||||
return DependenceInfo(&F, &AA, &SE, &LI);
|
||||
}
|
||||
|
||||
char DependenceAnalysis::PassID;
|
||||
AnalysisKey DependenceAnalysis::Key;
|
||||
|
||||
INITIALIZE_PASS_BEGIN(DependenceAnalysisWrapperPass, "da",
|
||||
"Dependence Analysis", true, true)
|
||||
|
@ -56,7 +56,7 @@ LLVM_DUMP_METHOD void DominanceFrontierWrapperPass::dump() const {
|
||||
}
|
||||
#endif
|
||||
|
||||
char DominanceFrontierAnalysis::PassID;
|
||||
AnalysisKey DominanceFrontierAnalysis::Key;
|
||||
|
||||
DominanceFrontier DominanceFrontierAnalysis::run(Function &F,
|
||||
FunctionAnalysisManager &AM) {
|
||||
|
@ -941,7 +941,7 @@ GlobalsAAResult::analyzeModule(Module &M, const TargetLibraryInfo &TLI,
|
||||
return Result;
|
||||
}
|
||||
|
||||
char GlobalsAA::PassID;
|
||||
AnalysisKey GlobalsAA::Key;
|
||||
|
||||
GlobalsAAResult GlobalsAA::run(Module &M, ModuleAnalysisManager &AM) {
|
||||
return GlobalsAAResult::analyzeModule(M,
|
||||
|
@ -34,7 +34,7 @@ using namespace llvm;
|
||||
|
||||
#define DEBUG_TYPE "iv-users"
|
||||
|
||||
char IVUsersAnalysis::PassID;
|
||||
AnalysisKey IVUsersAnalysis::Key;
|
||||
|
||||
IVUsers IVUsersAnalysis::run(Loop &L, LoopAnalysisManager &AM) {
|
||||
const auto &FAM =
|
||||
|
@ -1833,7 +1833,7 @@ bool LazyCallGraph::buildNextRefSCCInPostOrder() {
|
||||
}
|
||||
}
|
||||
|
||||
char LazyCallGraphAnalysis::PassID;
|
||||
AnalysisKey LazyCallGraphAnalysis::Key;
|
||||
|
||||
LazyCallGraphPrinterPass::LazyCallGraphPrinterPass(raw_ostream &OS) : OS(OS) {}
|
||||
|
||||
|
@ -51,7 +51,7 @@ namespace llvm {
|
||||
FunctionPass *createLazyValueInfoPass() { return new LazyValueInfoWrapperPass(); }
|
||||
}
|
||||
|
||||
char LazyValueAnalysis::PassID;
|
||||
AnalysisKey LazyValueAnalysis::Key;
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// LVILatticeVal
|
||||
|
@ -2067,7 +2067,7 @@ INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
|
||||
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 =
|
||||
|
@ -669,7 +669,7 @@ void LoopInfo::markAsRemoved(Loop *Unloop) {
|
||||
}
|
||||
}
|
||||
|
||||
char LoopAnalysis::PassID;
|
||||
AnalysisKey LoopAnalysis::Key;
|
||||
|
||||
LoopInfo LoopAnalysis::run(Function &F, FunctionAnalysisManager &AM) {
|
||||
// FIXME: Currently we create a LoopInfo from scratch for every function.
|
||||
|
@ -1643,7 +1643,7 @@ void MemoryDependenceResults::verifyRemoved(Instruction *D) const {
|
||||
#endif
|
||||
}
|
||||
|
||||
char MemoryDependenceAnalysis::PassID;
|
||||
AnalysisKey MemoryDependenceAnalysis::Key;
|
||||
|
||||
MemoryDependenceResults
|
||||
MemoryDependenceAnalysis::run(Function &F, FunctionAnalysisManager &AM) {
|
||||
|
@ -305,7 +305,7 @@ ModuleSummaryIndex llvm::buildModuleSummaryIndex(
|
||||
return Index;
|
||||
}
|
||||
|
||||
char ModuleSummaryIndexAnalysis::PassID;
|
||||
AnalysisKey ModuleSummaryIndexAnalysis::Key;
|
||||
|
||||
ModuleSummaryIndex
|
||||
ModuleSummaryIndexAnalysis::run(Module &M, ModuleAnalysisManager &AM) {
|
||||
|
@ -237,7 +237,7 @@ void OptimizationRemarkEmitterWrapperPass::getAnalysisUsage(
|
||||
AU.setPreservesAll();
|
||||
}
|
||||
|
||||
char OptimizationRemarkEmitterAnalysis::PassID;
|
||||
AnalysisKey OptimizationRemarkEmitterAnalysis::Key;
|
||||
|
||||
OptimizationRemarkEmitter
|
||||
OptimizationRemarkEmitterAnalysis::run(Function &F,
|
||||
|
@ -44,7 +44,7 @@ FunctionPass* llvm::createPostDomTree() {
|
||||
return new PostDominatorTreeWrapperPass();
|
||||
}
|
||||
|
||||
char PostDominatorTreeAnalysis::PassID;
|
||||
AnalysisKey PostDominatorTreeAnalysis::Key;
|
||||
|
||||
PostDominatorTree PostDominatorTreeAnalysis::run(Function &F,
|
||||
FunctionAnalysisManager &) {
|
||||
|
@ -159,7 +159,7 @@ bool ProfileSummaryInfoWrapperPass::doFinalization(Module &M) {
|
||||
return false;
|
||||
}
|
||||
|
||||
char ProfileSummaryAnalysis::PassID;
|
||||
AnalysisKey ProfileSummaryAnalysis::Key;
|
||||
ProfileSummaryInfo ProfileSummaryAnalysis::run(Module &M,
|
||||
ModuleAnalysisManager &) {
|
||||
return ProfileSummaryInfo(M);
|
||||
|
@ -181,7 +181,7 @@ namespace llvm {
|
||||
// RegionInfoAnalysis implementation
|
||||
//
|
||||
|
||||
char RegionInfoAnalysis::PassID;
|
||||
AnalysisKey RegionInfoAnalysis::Key;
|
||||
|
||||
RegionInfo RegionInfoAnalysis::run(Function &F, FunctionAnalysisManager &AM) {
|
||||
RegionInfo RI;
|
||||
|
@ -10013,7 +10013,7 @@ void ScalarEvolution::verify() const {
|
||||
// TODO: Verify more things.
|
||||
}
|
||||
|
||||
char ScalarEvolutionAnalysis::PassID;
|
||||
AnalysisKey ScalarEvolutionAnalysis::Key;
|
||||
|
||||
ScalarEvolution ScalarEvolutionAnalysis::run(Function &F,
|
||||
FunctionAnalysisManager &AM) {
|
||||
|
@ -110,7 +110,7 @@ Value *SCEVAAResult::GetBaseValue(const SCEV *S) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
char SCEVAA::PassID;
|
||||
AnalysisKey SCEVAA::Key;
|
||||
|
||||
SCEVAAResult SCEVAA::run(Function &F, FunctionAnalysisManager &AM) {
|
||||
return SCEVAAResult(AM.getResult<ScalarEvolutionAnalysis>(F));
|
||||
|
@ -173,7 +173,7 @@ bool ScopedNoAliasAAResult::mayAliasInScopes(const MDNode *Scopes,
|
||||
return true;
|
||||
}
|
||||
|
||||
char ScopedNoAliasAA::PassID;
|
||||
AnalysisKey ScopedNoAliasAA::Key;
|
||||
|
||||
ScopedNoAliasAAResult ScopedNoAliasAA::run(Function &F,
|
||||
FunctionAnalysisManager &AM) {
|
||||
|
@ -1265,7 +1265,7 @@ TargetLibraryInfoWrapperPass::TargetLibraryInfoWrapperPass(
|
||||
initializeTargetLibraryInfoWrapperPassPass(*PassRegistry::getPassRegistry());
|
||||
}
|
||||
|
||||
char TargetLibraryAnalysis::PassID;
|
||||
AnalysisKey TargetLibraryAnalysis::Key;
|
||||
|
||||
// Register the basic pass.
|
||||
INITIALIZE_PASS(TargetLibraryInfoWrapperPass, "targetlibinfo",
|
||||
|
@ -473,7 +473,7 @@ TargetIRAnalysis::Result TargetIRAnalysis::run(const Function &F,
|
||||
return TTICallback(F);
|
||||
}
|
||||
|
||||
char TargetIRAnalysis::PassID;
|
||||
AnalysisKey TargetIRAnalysis::Key;
|
||||
|
||||
TargetIRAnalysis::Result TargetIRAnalysis::getDefaultTTI(const Function &F) {
|
||||
return Result(F.getParent()->getDataLayout());
|
||||
|
@ -550,7 +550,7 @@ bool TypeBasedAAResult::Aliases(const MDNode *A, const MDNode *B) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
char TypeBasedAA::PassID;
|
||||
AnalysisKey TypeBasedAA::Key;
|
||||
|
||||
TypeBasedAAResult TypeBasedAA::run(Function &F, FunctionAnalysisManager &AM) {
|
||||
return TypeBasedAAResult();
|
||||
|
@ -311,7 +311,7 @@ DominatorTree DominatorTreeAnalysis::run(Function &F,
|
||||
return DT;
|
||||
}
|
||||
|
||||
char DominatorTreeAnalysis::PassID;
|
||||
AnalysisKey DominatorTreeAnalysis::Key;
|
||||
|
||||
DominatorTreePrinterPass::DominatorTreePrinterPass(raw_ostream &OS) : OS(OS) {}
|
||||
|
||||
|
@ -24,3 +24,5 @@ template class AnalysisManager<Function>;
|
||||
template class InnerAnalysisManagerProxy<FunctionAnalysisManager, Module>;
|
||||
template class OuterAnalysisManagerProxy<ModuleAnalysisManager, Function>;
|
||||
}
|
||||
|
||||
AnalysisKey PreservedAnalyses::AllAnalysesKey;
|
||||
|
@ -4473,7 +4473,7 @@ FunctionPass *llvm::createVerifierPass(bool FatalErrors) {
|
||||
return new VerifierLegacyPass(FatalErrors);
|
||||
}
|
||||
|
||||
char VerifierAnalysis::PassID;
|
||||
AnalysisKey VerifierAnalysis::Key;
|
||||
VerifierAnalysis::Result VerifierAnalysis::run(Module &M,
|
||||
ModuleAnalysisManager &) {
|
||||
Result Res;
|
||||
|
@ -152,7 +152,7 @@ struct NoOpModulePass {
|
||||
/// \brief No-op module analysis.
|
||||
class NoOpModuleAnalysis : public AnalysisInfoMixin<NoOpModuleAnalysis> {
|
||||
friend AnalysisInfoMixin<NoOpModuleAnalysis>;
|
||||
static char PassID;
|
||||
static AnalysisKey Key;
|
||||
|
||||
public:
|
||||
struct Result {};
|
||||
@ -172,7 +172,7 @@ struct NoOpCGSCCPass {
|
||||
/// \brief No-op CGSCC analysis.
|
||||
class NoOpCGSCCAnalysis : public AnalysisInfoMixin<NoOpCGSCCAnalysis> {
|
||||
friend AnalysisInfoMixin<NoOpCGSCCAnalysis>;
|
||||
static char PassID;
|
||||
static AnalysisKey Key;
|
||||
|
||||
public:
|
||||
struct Result {};
|
||||
@ -193,7 +193,7 @@ struct NoOpFunctionPass {
|
||||
/// \brief No-op function analysis.
|
||||
class NoOpFunctionAnalysis : public AnalysisInfoMixin<NoOpFunctionAnalysis> {
|
||||
friend AnalysisInfoMixin<NoOpFunctionAnalysis>;
|
||||
static char PassID;
|
||||
static AnalysisKey Key;
|
||||
|
||||
public:
|
||||
struct Result {};
|
||||
@ -212,7 +212,7 @@ struct NoOpLoopPass {
|
||||
/// \brief No-op loop analysis.
|
||||
class NoOpLoopAnalysis : public AnalysisInfoMixin<NoOpLoopAnalysis> {
|
||||
friend AnalysisInfoMixin<NoOpLoopAnalysis>;
|
||||
static char PassID;
|
||||
static AnalysisKey Key;
|
||||
|
||||
public:
|
||||
struct Result {};
|
||||
@ -220,10 +220,10 @@ public:
|
||||
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.
|
||||
|
||||
|
@ -2067,7 +2067,7 @@ bool MemorySSAPrinterLegacyPass::runOnFunction(Function &F) {
|
||||
return false;
|
||||
}
|
||||
|
||||
char MemorySSAAnalysis::PassID;
|
||||
AnalysisKey MemorySSAAnalysis::Key;
|
||||
|
||||
MemorySSAAnalysis::Result MemorySSAAnalysis::run(Function &F,
|
||||
FunctionAnalysisManager &AM) {
|
||||
|
@ -22,16 +22,13 @@ using namespace llvm;
|
||||
|
||||
namespace {
|
||||
|
||||
class TestModuleAnalysis {
|
||||
class TestModuleAnalysis : public AnalysisInfoMixin<TestModuleAnalysis> {
|
||||
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 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
static char PassID;
|
||||
friend AnalysisInfoMixin<TestModuleAnalysis>;
|
||||
static AnalysisKey Key;
|
||||
|
||||
int &Runs;
|
||||
};
|
||||
|
||||
char TestModuleAnalysis::PassID;
|
||||
AnalysisKey TestModuleAnalysis::Key;
|
||||
|
||||
class TestSCCAnalysis {
|
||||
class TestSCCAnalysis : public AnalysisInfoMixin<TestSCCAnalysis> {
|
||||
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 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
static char PassID;
|
||||
friend AnalysisInfoMixin<TestSCCAnalysis>;
|
||||
static AnalysisKey Key;
|
||||
|
||||
int &Runs;
|
||||
};
|
||||
|
||||
char TestSCCAnalysis::PassID;
|
||||
AnalysisKey TestSCCAnalysis::Key;
|
||||
|
||||
class TestFunctionAnalysis {
|
||||
class TestFunctionAnalysis : public AnalysisInfoMixin<TestFunctionAnalysis> {
|
||||
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 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
static char PassID;
|
||||
friend AnalysisInfoMixin<TestFunctionAnalysis>;
|
||||
static AnalysisKey Key;
|
||||
|
||||
int &Runs;
|
||||
};
|
||||
|
||||
char TestFunctionAnalysis::PassID;
|
||||
AnalysisKey TestFunctionAnalysis::Key;
|
||||
|
||||
class TestImmutableFunctionAnalysis {
|
||||
class TestImmutableFunctionAnalysis
|
||||
: public AnalysisInfoMixin<TestImmutableFunctionAnalysis> {
|
||||
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 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
static char PassID;
|
||||
friend AnalysisInfoMixin<TestImmutableFunctionAnalysis>;
|
||||
static AnalysisKey Key;
|
||||
|
||||
int &Runs;
|
||||
};
|
||||
|
||||
char TestImmutableFunctionAnalysis::PassID;
|
||||
AnalysisKey TestImmutableFunctionAnalysis::Key;
|
||||
|
||||
struct LambdaSCCPass : public PassInfoMixin<LambdaSCCPass> {
|
||||
template <typename T> LambdaSCCPass(T &&Arg) : Func(std::forward<T>(Arg)) {}
|
||||
|
@ -21,9 +21,9 @@ using namespace llvm;
|
||||
|
||||
namespace {
|
||||
|
||||
class TestLoopAnalysis {
|
||||
/// \brief Private static data to provide unique ID.
|
||||
static char PassID;
|
||||
class TestLoopAnalysis : public AnalysisInfoMixin<TestLoopAnalysis> {
|
||||
friend AnalysisInfoMixin<TestLoopAnalysis>;
|
||||
static AnalysisKey Key;
|
||||
|
||||
int &Runs;
|
||||
|
||||
@ -33,12 +33,6 @@ public:
|
||||
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 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
char TestLoopAnalysis::PassID;
|
||||
AnalysisKey TestLoopAnalysis::Key;
|
||||
|
||||
class TestLoopPass {
|
||||
std::vector<StringRef> &VisitedLoops;
|
||||
|
@ -41,12 +41,12 @@ public:
|
||||
|
||||
private:
|
||||
friend AnalysisInfoMixin<TestFunctionAnalysis>;
|
||||
static char PassID;
|
||||
static AnalysisKey Key;
|
||||
|
||||
int &Runs;
|
||||
};
|
||||
|
||||
char TestFunctionAnalysis::PassID;
|
||||
AnalysisKey TestFunctionAnalysis::Key;
|
||||
|
||||
class TestModuleAnalysis : public AnalysisInfoMixin<TestModuleAnalysis> {
|
||||
public:
|
||||
@ -67,12 +67,12 @@ public:
|
||||
|
||||
private:
|
||||
friend AnalysisInfoMixin<TestModuleAnalysis>;
|
||||
static char PassID;
|
||||
static AnalysisKey Key;
|
||||
|
||||
int &Runs;
|
||||
};
|
||||
|
||||
char TestModuleAnalysis::PassID;
|
||||
AnalysisKey TestModuleAnalysis::Key;
|
||||
|
||||
struct TestModulePass : PassInfoMixin<TestModulePass> {
|
||||
TestModulePass(int &RunCount) : RunCount(RunCount) {}
|
||||
@ -351,10 +351,10 @@ public:
|
||||
|
||||
private:
|
||||
friend AnalysisInfoMixin<CustomizedAnalysis>;
|
||||
static char PassID;
|
||||
static AnalysisKey Key;
|
||||
};
|
||||
|
||||
char CustomizedAnalysis::PassID;
|
||||
AnalysisKey CustomizedAnalysis::Key;
|
||||
|
||||
struct CustomizedPass : PassInfoMixin<CustomizedPass> {
|
||||
std::function<void(CustomizedAnalysis::Result &, int &)> Callback;
|
||||
|
Loading…
x
Reference in New Issue
Block a user