diff options
| author | Andrew Lenharth <andrewl@lenharth.org> | 2006-05-29 22:58:38 +0000 |
|---|---|---|
| committer | Andrew Lenharth <andrewl@lenharth.org> | 2006-05-29 22:58:38 +0000 |
| commit | 632cd52162e0fa95bb3527af71476babe6052353 (patch) | |
| tree | cdf4472d4824790164e3d513ee04d0cfd7781a2a /include | |
| parent | 6d1727cf143ab033e76f39b0854aced7ba144701 (diff) | |
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).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28545 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
| -rw-r--r-- | include/llvm/Analysis/CallTargets.h | 54 | ||||
| -rw-r--r-- | include/llvm/Analysis/LinkAllAnalyses.h | 2 |
2 files changed, 56 insertions, 0 deletions
diff --git a/include/llvm/Analysis/CallTargets.h b/include/llvm/Analysis/CallTargets.h new file mode 100644 index 0000000000..d4f56e8c80 --- /dev/null +++ b/include/llvm/Analysis/CallTargets.h @@ -0,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 diff --git a/include/llvm/Analysis/LinkAllAnalyses.h b/include/llvm/Analysis/LinkAllAnalyses.h index cac2abdc4c..0be53648fb 100644 --- a/include/llvm/Analysis/LinkAllAnalyses.h +++ b/include/llvm/Analysis/LinkAllAnalyses.h @@ -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 @@ namespace { (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 |
