move header
[oota-llvm.git] / include / llvm / Analysis / DataStructure / CallTargets.h
1 //=- llvm/Analysis/CallTargets.h - Resolve Indirect Call Targets --*- C++ -*-=//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This pass uses DSA to map targets of all calls, and reports on if it
11 // thinks it knows all targets of a given call.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_ANALYSIS_CALLTARGETS_H
16 #define LLVM_ANALYSIS_CALLTARGETS_H
17
18 #include "llvm/Pass.h"
19 #include "llvm/Support/CallSite.h"
20
21 #include <set>
22 #include <list>
23
24 namespace llvm {
25
26   class CallTargetFinder : public ModulePass {
27     std::map<CallSite, std::vector<Function*> > IndMap;
28     std::set<CallSite> CompleteSites;
29     std::list<CallSite> AllSites;
30
31     void findIndTargets(Module &M);
32   public:
33     virtual bool runOnModule(Module &M);
34
35     virtual void getAnalysisUsage(AnalysisUsage &AU) const;
36
37     virtual void print(std::ostream &O, const Module *M) const;
38
39     // Given a CallSite, get an iterator of callees
40     std::vector<Function*>::iterator begin(CallSite cs);
41     std::vector<Function*>::iterator end(CallSite cs);
42
43     // Iterate over CallSites in program
44     std::list<CallSite>::iterator cs_begin();
45     std::list<CallSite>::iterator cs_end();
46
47     // Do we think we have complete knowledge of this site?
48     // That is, do we think there are no missing callees
49     bool isComplete(CallSite cs) const;
50   };
51   
52 }
53
54 #endif