LLVM  8.0.1
IndirectCallVisitor.h
Go to the documentation of this file.
1 //===-- IndirectCallVisitor.h - indirect call 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 #ifndef LLVM_ANALYSIS_INDIRECTCALLVISITOR_H
14 #define LLVM_ANALYSIS_INDIRECTCALLVISITOR_H
15 
16 #include "llvm/IR/InstVisitor.h"
17 #include <vector>
18 
19 namespace llvm {
20 // Visitor class that finds all indirect call.
21 struct PGOIndirectCallVisitor : public InstVisitor<PGOIndirectCallVisitor> {
22  std::vector<Instruction *> IndirectCalls;
24 
25  void visitCallBase(CallBase &Call) {
26  if (Call.isIndirectCall())
27  IndirectCalls.push_back(&Call);
28  }
29 };
30 
31 // Helper function that finds all indirect call sites.
32 inline std::vector<Instruction *> findIndirectCalls(Function &F) {
34  ICV.visit(F);
35  return ICV.IndirectCalls;
36 }
37 } // namespace llvm
38 
39 #endif
Base class for instruction visitors.
Definition: InstVisitor.h:81
This class represents lattice values for constants.
Definition: AllocatorList.h:24
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Definition: InstrTypes.h:1014
F(f)
bool isIndirectCall() const
Return true if the callsite is an indirect call.
void visit(Iterator Start, Iterator End)
Definition: InstVisitor.h:90
void visitCallBase(CallBase &Call)
std::vector< Instruction * > IndirectCalls
std::vector< Instruction * > findIndirectCalls(Function &F)