summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2015-01-22 21:53:09 +0000
committerChandler Carruth <chandlerc@gmail.com>2015-01-22 21:53:09 +0000
commitdf8b223deae9e2a4a127d379a9ce2701b68c8414 (patch)
tree6635f253a020787f7e090bbf90e149f904cbc717 /llvm/lib
parentcb36becbeb84826dcfff19243051d97c71d57211 (diff)
downloadbcm5719-llvm-df8b223deae9e2a4a127d379a9ce2701b68c8414.tar.gz
bcm5719-llvm-df8b223deae9e2a4a127d379a9ce2701b68c8414.zip
[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. =] llvm-svn: 226868
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Analysis/AssumptionCache.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/AssumptionCache.cpp b/llvm/lib/Analysis/AssumptionCache.cpp
index da5ba18fc43..f468a43ef0b 100644
--- a/llvm/lib/Analysis/AssumptionCache.cpp
+++ b/llvm/lib/Analysis/AssumptionCache.cpp
@@ -18,6 +18,7 @@
#include "llvm/IR/Function.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
+#include "llvm/IR/PassManager.h"
#include "llvm/IR/PatternMatch.h"
#include "llvm/Support/Debug.h"
using namespace llvm;
@@ -73,6 +74,20 @@ void AssumptionCache::registerAssumption(CallInst *CI) {
#endif
}
+char AssumptionAnalysis::PassID;
+
+PreservedAnalyses AssumptionPrinterPass::run(Function &F,
+ AnalysisManager<Function> *AM) {
+ AssumptionCache &AC = AM->getResult<AssumptionAnalysis>(F);
+
+ OS << "Cached assumptions for function: " << F.getName() << "\n";
+ for (auto &VH : AC.assumptions())
+ if (VH)
+ OS << " " << *cast<CallInst>(VH)->getArgOperand(0) << "\n";
+
+ return PreservedAnalyses::all();
+}
+
void AssumptionCacheTracker::FunctionCallbackVH::deleted() {
auto I = ACT->AssumptionCaches.find_as(cast<Function>(getValPtr()));
if (I != ACT->AssumptionCaches.end())
OpenPOWER on IntegriCloud