Coverage Report

Created: 2018-09-17 19:50

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/include/llvm/PassInfo.h
Line
Count
Source (jump to first uncovered line)
1
//===- llvm/PassInfo.h - Pass Info class ------------------------*- C++ -*-===//
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 defines and implements the PassInfo class.
11
//
12
//===----------------------------------------------------------------------===//
13
14
#ifndef LLVM_PASSINFO_H
15
#define LLVM_PASSINFO_H
16
17
#include "llvm/ADT/StringRef.h"
18
#include <cassert>
19
#include <vector>
20
21
namespace llvm {
22
23
class Pass;
24
25
//===---------------------------------------------------------------------------
26
/// PassInfo class - An instance of this class exists for every pass known by
27
/// the system, and can be obtained from a live Pass by calling its
28
/// getPassInfo() method.  These objects are set up by the RegisterPass<>
29
/// template.
30
///
31
class PassInfo {
32
public:
33
  using NormalCtor_t = Pass* (*)();
34
35
private:
36
  StringRef PassName;     // Nice name for Pass
37
  StringRef PassArgument; // Command Line argument to run this pass
38
  const void *PassID;
39
  const bool IsCFGOnlyPass = false;      // Pass only looks at the CFG.
40
  const bool IsAnalysis;                 // True if an analysis pass.
41
  const bool IsAnalysisGroup;            // True if an analysis group.
42
  std::vector<const PassInfo *> ItfImpl; // Interfaces implemented by this pass
43
  NormalCtor_t NormalCtor = nullptr;
44
45
public:
46
  /// PassInfo ctor - Do not call this directly, this should only be invoked
47
  /// through RegisterPass.
48
  PassInfo(StringRef name, StringRef arg, const void *pi, NormalCtor_t normal,
49
           bool isCFGOnly, bool is_analysis)
50
      : PassName(name), PassArgument(arg), PassID(pi), IsCFGOnlyPass(isCFGOnly),
51
23.5M
        IsAnalysis(is_analysis), IsAnalysisGroup(false), NormalCtor(normal) {}
52
53
  /// PassInfo ctor - Do not call this directly, this should only be invoked
54
  /// through RegisterPass. This version is for use by analysis groups; it
55
  /// does not auto-register the pass.
56
  PassInfo(StringRef name, const void *pi)
57
0
      : PassName(name), PassID(pi), IsAnalysis(false), IsAnalysisGroup(true) {}
58
59
  PassInfo(const PassInfo &) = delete;
60
  PassInfo &operator=(const PassInfo &) = delete;
61
62
  /// getPassName - Return the friendly name for the pass, never returns null
63
52.3M
  StringRef getPassName() const { return PassName; }
64
65
  /// getPassArgument - Return the command line option that may be passed to
66
  /// 'opt' that will cause this pass to be run.  This will return null if there
67
  /// is no argument.
68
176M
  StringRef getPassArgument() const { return PassArgument; }
69
70
  /// getTypeInfo - Return the id object for the pass...
71
  /// TODO : Rename
72
51.2M
  const void *getTypeInfo() const { return PassID; }
73
74
  /// Return true if this PassID implements the specified ID pointer.
75
  bool isPassID(const void *IDPtr) const { return PassID == IDPtr; }
76
77
  /// isAnalysisGroup - Return true if this is an analysis group, not a normal
78
  /// pass.
79
8.54k
  bool isAnalysisGroup() const { return IsAnalysisGroup; }
80
24.9M
  bool isAnalysis() const { return IsAnalysis; }
81
82
  /// isCFGOnlyPass - return true if this pass only looks at the CFG for the
83
  /// function.
84
496M
  bool isCFGOnlyPass() const { return IsCFGOnlyPass; }
85
86
  /// getNormalCtor - Return a pointer to a function, that when called, creates
87
  /// an instance of the pass and returns it.  This pointer may be null if there
88
  /// is no default constructor for the pass.
89
51.1M
  NormalCtor_t getNormalCtor() const {
90
51.1M
    return NormalCtor;
91
51.1M
  }
92
0
  void setNormalCtor(NormalCtor_t Ctor) {
93
0
    NormalCtor = Ctor;
94
0
  }
95
96
  /// createPass() - Use this method to create an instance of this pass.
97
5.81M
  Pass *createPass() const {
98
5.81M
    assert((!isAnalysisGroup() || NormalCtor) &&
99
5.81M
           "No default implementation found for analysis group!");
100
5.81M
    assert(NormalCtor &&
101
5.81M
           "Cannot call createPass on PassInfo without default ctor!");
102
5.81M
    return NormalCtor();
103
5.81M
  }
104
105
  /// addInterfaceImplemented - This method is called when this pass is
106
  /// registered as a member of an analysis group with the RegisterAnalysisGroup
107
  /// template.
108
0
  void addInterfaceImplemented(const PassInfo *ItfPI) {
109
0
    ItfImpl.push_back(ItfPI);
110
0
  }
111
112
  /// getInterfacesImplemented - Return a list of all of the analysis group
113
  /// interfaces implemented by this pass.
114
320M
  const std::vector<const PassInfo*> &getInterfacesImplemented() const {
115
320M
    return ItfImpl;
116
320M
  }
117
};
118
119
} // end namespace llvm
120
121
#endif // LLVM_PASSINFO_H