[llvm-commits] CVS: llvm/include/llvm/Analysis/CallTargets.h LinkAllAnalyses.h
Andrew Lenharth
alenhar2 at cs.uiuc.edu
Mon May 29 15:58:51 PDT 2006
Changes in directory llvm/include/llvm/Analysis:
CallTargets.h added (r1.1)
LinkAllAnalyses.h updated: 1.4 -> 1.5
---
Log message:
Since there was interest on the mailing list, this is a utility pass that
uses DSA to make find targets of calls. It provides a very convinient
interface to DSA results to do things with indirect calls, such as
write a devirtualizer (which I have and may commit one of these days).
---
Diffs of the changes: (+56 -0)
CallTargets.h | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
LinkAllAnalyses.h | 2 ++
2 files changed, 56 insertions(+)
Index: llvm/include/llvm/Analysis/CallTargets.h
diff -c /dev/null llvm/include/llvm/Analysis/CallTargets.h:1.1
*** /dev/null Mon May 29 17:58:48 2006
--- llvm/include/llvm/Analysis/CallTargets.h Mon May 29 17:58:38 2006
***************
*** 0 ****
--- 1,54 ----
+ //=- llvm/Analysis/CallTargets.h - Resolve Indirect Call Targets --*- C++ -*-=//
+ //
+ // The LLVM Compiler Infrastructure
+ //
+ // This file was developed by the LLVM research group and is distributed under
+ // the University of Illinois Open Source License. See LICENSE.TXT for details.
+ //
+ //===----------------------------------------------------------------------===//
+ //
+ // This pass uses DSA to map targets of all calls, and reports on if it
+ // thinks it knows all targets of a given call.
+ //
+ //===----------------------------------------------------------------------===//
+
+ #ifndef LLVM_ANALYSIS_CALLTARGETS_H
+ #define LLVM_ANALYSIS_CALLTARGETS_H
+
+ #include "llvm/Pass.h"
+ #include "llvm/Support/CallSite.h"
+
+ #include <set>
+ #include <list>
+
+ namespace llvm {
+
+ class CallTargetFinder : public ModulePass {
+ std::map<CallSite, std::vector<Function*> > IndMap;
+ std::set<CallSite> CompleteSites;
+ std::list<CallSite> AllSites;
+
+ void findIndTargets(Module &M);
+ public:
+ virtual bool runOnModule(Module &M);
+
+ virtual void getAnalysisUsage(AnalysisUsage &AU) const;
+
+ virtual void print(std::ostream &O, const Module *M) const;
+
+ // Given a CallSite, get an iterator of callees
+ std::vector<Function*>::iterator begin(CallSite cs);
+ std::vector<Function*>::iterator end(CallSite cs);
+
+ // Iterate over CallSites in program
+ std::list<CallSite>::iterator cs_begin();
+ std::list<CallSite>::iterator cs_end();
+
+ // Do we think we have complete knowledge of this site?
+ // That is, do we think there are no missing callees
+ bool isComplete(CallSite cs) const;
+ };
+
+ }
+
+ #endif
Index: llvm/include/llvm/Analysis/LinkAllAnalyses.h
diff -u llvm/include/llvm/Analysis/LinkAllAnalyses.h:1.4 llvm/include/llvm/Analysis/LinkAllAnalyses.h:1.5
--- llvm/include/llvm/Analysis/LinkAllAnalyses.h:1.4 Wed Feb 22 10:23:42 2006
+++ llvm/include/llvm/Analysis/LinkAllAnalyses.h Mon May 29 17:58:38 2006
@@ -22,6 +22,7 @@
#include "llvm/Analysis/Passes.h"
#include "llvm/Analysis/ScalarEvolution.h"
#include "llvm/Analysis/DataStructure/DataStructure.h"
+#include "llvm/Analysis/CallTargets.h"
#include "llvm/Function.h"
#include <cstdlib>
@@ -50,6 +51,7 @@
(void)new llvm::PostDominatorSet();
(void)new llvm::FindUsedTypes();
(void)new llvm::ScalarEvolution();
+ (void)new llvm::CallTargetFinder();
((llvm::Function*)0)->viewCFGOnly();
llvm::AliasSetTracker X(*(llvm::AliasAnalysis*)0);
X.add((llvm::Value*)0, 0); // for -print-alias-sets
More information about the llvm-commits
mailing list