LLVM API Documentation
00001 //=- llvm/Analysis/CallTargets.h - Resolve Indirect Call Targets --*- C++ -*-=// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file was developed by the LLVM research group and is distributed under 00006 // the University of Illinois Open Source License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This pass uses DSA to map targets of all calls, and reports on if it 00011 // thinks it knows all targets of a given call. 00012 // 00013 //===----------------------------------------------------------------------===// 00014 00015 #ifndef LLVM_ANALYSIS_CALLTARGETS_H 00016 #define LLVM_ANALYSIS_CALLTARGETS_H 00017 00018 #include "llvm/Pass.h" 00019 #include "llvm/Support/CallSite.h" 00020 00021 #include <set> 00022 #include <list> 00023 00024 namespace llvm { 00025 00026 class CallTargetFinder : public ModulePass { 00027 std::map<CallSite, std::vector<Function*> > IndMap; 00028 std::set<CallSite> CompleteSites; 00029 std::list<CallSite> AllSites; 00030 00031 void findIndTargets(Module &M); 00032 public: 00033 virtual bool runOnModule(Module &M); 00034 00035 virtual void getAnalysisUsage(AnalysisUsage &AU) const; 00036 00037 virtual void print(std::ostream &O, const Module *M) const; 00038 00039 // Given a CallSite, get an iterator of callees 00040 std::vector<Function*>::iterator begin(CallSite cs); 00041 std::vector<Function*>::iterator end(CallSite cs); 00042 00043 // Iterate over CallSites in program 00044 std::list<CallSite>::iterator cs_begin(); 00045 std::list<CallSite>::iterator cs_end(); 00046 00047 // Do we think we have complete knowledge of this site? 00048 // That is, do we think there are no missing callees 00049 bool isComplete(CallSite cs) const; 00050 }; 00051 00052 } 00053 00054 #endif