LLVM 17.0.0git
IndirectCallVisitor.h
Go to the documentation of this file.
1//===-- IndirectCallVisitor.h - indirect call visitor ---------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file implements defines a visitor class and a helper function that find
10// all indirect call-sites in a function.
11
12#ifndef LLVM_ANALYSIS_INDIRECTCALLVISITOR_H
13#define LLVM_ANALYSIS_INDIRECTCALLVISITOR_H
14
15#include "llvm/IR/InstVisitor.h"
16#include <vector>
17
18namespace llvm {
19// Visitor class that finds all indirect call.
20struct PGOIndirectCallVisitor : public InstVisitor<PGOIndirectCallVisitor> {
21 std::vector<CallBase *> IndirectCalls;
23
24 void visitCallBase(CallBase &Call) {
25 if (Call.isIndirectCall())
26 IndirectCalls.push_back(&Call);
27 }
28};
29
30// Helper function that finds all indirect call sites.
31inline std::vector<CallBase *> findIndirectCalls(Function &F) {
33 ICV.visit(F);
34 return ICV.IndirectCalls;
35}
36} // namespace llvm
37
38#endif
#define F(x, y, z)
Definition: MD5.cpp:55
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Definition: InstrTypes.h:1190
Base class for instruction visitors.
Definition: InstVisitor.h:78
void visit(Iterator Start, Iterator End)
Definition: InstVisitor.h:87
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
std::vector< CallBase * > findIndirectCalls(Function &F)
std::vector< CallBase * > IndirectCalls
void visitCallBase(CallBase &Call)