mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-24 08:24:33 +00:00
[PM] Actually add the new pass manager support for the assumption cache.
I had already factored this analysis specifically to enable doing this, but hadn't actually committed the necessary wiring to get at this from the new pass manager. This also nicely shows how the separate cache object can be directly managed by the new pass manager. This analysis didn't have any direct tests and so I've added a printer pass and a boring test case. I chose to print the i1 value which is being assumed rather than the call to llvm.assume as that seems much more useful for testing... but suggestions on an even better printing strategy welcome. My main goal was to make sure things actually work. =] git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226868 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -27,6 +27,11 @@
|
||||
|
||||
namespace llvm {
|
||||
|
||||
// FIXME: Replace this brittle forward declaration with the include of the new
|
||||
// PassManager.h when doing so doesn't break the PassManagerBuilder.
|
||||
template <typename IRUnitT> class AnalysisManager;
|
||||
class PreservedAnalyses;
|
||||
|
||||
/// \brief A cache of @llvm.assume calls within a function.
|
||||
///
|
||||
/// This cache provides fast lookup of assumptions within a function by caching
|
||||
@ -88,6 +93,42 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
/// \brief A function analysis which provides an \c AssumptionCache.
|
||||
///
|
||||
/// This analysis is intended for use with the new pass manager and will vend
|
||||
/// assumption caches for a given function.
|
||||
class AssumptionAnalysis {
|
||||
static char PassID;
|
||||
|
||||
public:
|
||||
typedef AssumptionCache Result;
|
||||
|
||||
/// \brief Opaque, unique identifier for this analysis pass.
|
||||
static void *ID() { return (void *)&PassID; }
|
||||
|
||||
/// \brief Provide a name for the analysis for debugging and logging.
|
||||
static StringRef name() { return "AssumptionAnalysis"; }
|
||||
|
||||
AssumptionAnalysis() {}
|
||||
AssumptionAnalysis(const AssumptionAnalysis &Arg) {}
|
||||
AssumptionAnalysis(AssumptionAnalysis &&Arg) {}
|
||||
AssumptionAnalysis &operator=(const AssumptionAnalysis &RHS) { return *this; }
|
||||
AssumptionAnalysis &operator=(AssumptionAnalysis &&RHS) { return *this; }
|
||||
|
||||
AssumptionCache run(Function &F) { return AssumptionCache(F); }
|
||||
};
|
||||
|
||||
/// \brief Printer pass for the \c AssumptionAnalysis results.
|
||||
class AssumptionPrinterPass {
|
||||
raw_ostream &OS;
|
||||
|
||||
public:
|
||||
explicit AssumptionPrinterPass(raw_ostream &OS) : OS(OS) {}
|
||||
PreservedAnalyses run(Function &F, AnalysisManager<Function> *AM);
|
||||
|
||||
static StringRef name() { return "AssumptionPrinterPass"; }
|
||||
};
|
||||
|
||||
/// \brief An immutable pass that tracks lazily created \c AssumptionCache
|
||||
/// objects.
|
||||
///
|
||||
|
Reference in New Issue
Block a user