LLVM  4.0.0
IndirectCallSiteVisitor.h
Go to the documentation of this file.
1 //===-- IndirectCallSiteVisitor.h - indirect call-sites visitor -----------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements defines a visitor class and a helper function that find
11 // all indirect call-sites in a function.
12 
13 #include "llvm/IR/InstVisitor.h"
14 #include <vector>
15 
16 namespace llvm {
17 // Visitor class that finds all indirect call sites.
19  : public InstVisitor<PGOIndirectCallSiteVisitor> {
20  std::vector<Instruction *> IndirectCallInsts;
22 
24  if (CS.getCalledFunction() || !CS.getCalledValue())
25  return;
27  if (CallInst *CI = dyn_cast<CallInst>(I)) {
28  if (CI->isInlineAsm())
29  return;
30  }
31  if (isa<Constant>(CS.getCalledValue()))
32  return;
33  IndirectCallInsts.push_back(I);
34  }
35 };
36 
37 // Helper function that finds all indirect call sites.
38 static inline std::vector<Instruction *> findIndirectCallSites(Function &F) {
40  ICV.visit(F);
41  return ICV.IndirectCallInsts;
42 }
43 }
Base class for instruction visitors.
Definition: InstVisitor.h:81
This class represents a function call, abstracting a target machine's calling convention.
ValTy * getCalledValue() const
getCalledValue - Return the pointer to function that is being called.
Definition: CallSite.h:102
std::vector< Instruction * > IndirectCallInsts
void visit(Iterator Start, Iterator End)
Definition: InstVisitor.h:90
#define F(x, y, z)
Definition: MD5.cpp:51
InstrTy * getInstruction() const
Definition: CallSite.h:93
static std::vector< Instruction * > findIndirectCallSites(Function &F)
#define I(x, y, z)
Definition: MD5.cpp:54
FunTy * getCalledFunction() const
getCalledFunction - Return the function being called if this is a direct call, otherwise return null ...
Definition: CallSite.h:110