Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/include/llvm/Analysis/IndirectCallVisitor.h
Line
Count
Source
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
18
namespace llvm {
19
// Visitor class that finds all indirect call.
20
struct PGOIndirectCallVisitor : public InstVisitor<PGOIndirectCallVisitor> {
21
  std::vector<Instruction *> IndirectCalls;
22
1.19k
  PGOIndirectCallVisitor() {}
23
24
756
  void visitCallBase(CallBase &Call) {
25
756
    if (Call.isIndirectCall())
26
75
      IndirectCalls.push_back(&Call);
27
756
  }
28
};
29
30
// Helper function that finds all indirect call sites.
31
1.19k
inline std::vector<Instruction *> findIndirectCalls(Function &F) {
32
1.19k
  PGOIndirectCallVisitor ICV;
33
1.19k
  ICV.visit(F);
34
1.19k
  return ICV.IndirectCalls;
35
1.19k
}
36
} // namespace llvm
37
38
#endif