Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/include/llvm/IR/User.h
Line
Count
Source (jump to first uncovered line)
1
//===- llvm/User.h - User class definition ----------------------*- C++ -*-===//
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 class defines the interface that one who uses a Value must implement.
10
// Each instance of the Value class keeps track of what User's have handles
11
// to it.
12
//
13
//  * Instructions are the largest class of Users.
14
//  * Constants may be users of other constants (think arrays and stuff)
15
//
16
//===----------------------------------------------------------------------===//
17
18
#ifndef LLVM_IR_USER_H
19
#define LLVM_IR_USER_H
20
21
#include "llvm/ADT/iterator.h"
22
#include "llvm/ADT/iterator_range.h"
23
#include "llvm/IR/Use.h"
24
#include "llvm/IR/Value.h"
25
#include "llvm/Support/Casting.h"
26
#include "llvm/Support/Compiler.h"
27
#include "llvm/Support/ErrorHandling.h"
28
#include <cassert>
29
#include <cstddef>
30
#include <cstdint>
31
#include <iterator>
32
33
namespace llvm {
34
35
template <typename T> class ArrayRef;
36
template <typename T> class MutableArrayRef;
37
38
/// Compile-time customization of User operands.
39
///
40
/// Customizes operand-related allocators and accessors.
41
template <class>
42
struct OperandTraits;
43
44
class User : public Value {
45
  template <unsigned>
46
  friend struct HungoffOperandTraits;
47
48
  LLVM_ATTRIBUTE_ALWAYS_INLINE inline static void *
49
  allocateFixedOperandUser(size_t, unsigned, unsigned);
50
51
protected:
52
  /// Allocate a User with an operand pointer co-allocated.
53
  ///
54
  /// This is used for subclasses which need to allocate a variable number
55
  /// of operands, ie, 'hung off uses'.
56
  void *operator new(size_t Size);
57
58
  /// Allocate a User with the operands co-allocated.
59
  ///
60
  /// This is used for subclasses which have a fixed number of operands.
61
  void *operator new(size_t Size, unsigned Us);
62
63
  /// Allocate a User with the operands co-allocated.  If DescBytes is non-zero
64
  /// then allocate an additional DescBytes bytes before the operands. These
65
  /// bytes can be accessed by calling getDescriptor.
66
  ///
67
  /// DescBytes needs to be divisible by sizeof(void *).  The allocated
68
  /// descriptor, if any, is aligned to sizeof(void *) bytes.
69
  ///
70
  /// This is used for subclasses which have a fixed number of operands.
71
  void *operator new(size_t Size, unsigned Us, unsigned DescBytes);
72
73
  User(Type *ty, unsigned vty, Use *, unsigned NumOps)
74
71.0M
      : Value(ty, vty) {
75
71.0M
    assert(NumOps < (1u << NumUserOperandsBits) && "Too many operands");
76
71.0M
    NumUserOperands = NumOps;
77
71.0M
    // If we have hung off uses, then the operand list should initially be
78
71.0M
    // null.
79
71.0M
    assert((!HasHungOffUses || !getOperandList()) &&
80
71.0M
           "Error in initializing hung off uses for User");
81
71.0M
  }
82
83
  /// Allocate the array of Uses, followed by a pointer
84
  /// (with bottom bit set) to the User.
85
  /// \param IsPhi identifies callers which are phi nodes and which need
86
  /// N BasicBlock* allocated along with N
87
  void allocHungoffUses(unsigned N, bool IsPhi = false);
88
89
  /// Grow the number of hung off uses.  Note that allocHungoffUses
90
  /// should be called if there are no uses.
91
  void growHungoffUses(unsigned N, bool IsPhi = false);
92
93
protected:
94
52.2M
  ~User() = default; // Use deleteValue() to delete a generic Instruction.
95
96
public:
97
  User(const User &) = delete;
98
99
  /// Free memory allocated for User and Use objects.
100
  void operator delete(void *Usr);
101
  /// Placement delete - required by std, called if the ctor throws.
102
0
  void operator delete(void *Usr, unsigned) {
103
0
    // Note: If a subclass manipulates the information which is required to calculate the
104
0
    // Usr memory pointer, e.g. NumUserOperands, the operator delete of that subclass has
105
0
    // to restore the changed information to the original value, since the dtor of that class
106
0
    // is not called if the ctor fails.
107
0
    User::operator delete(Usr);
108
0
109
0
#ifndef LLVM_ENABLE_EXCEPTIONS
110
0
    llvm_unreachable("Constructor throws?");
111
0
#endif
112
0
  }
113
  /// Placement delete - required by std, called if the ctor throws.
114
0
  void operator delete(void *Usr, unsigned, bool) {
115
0
    // Note: If a subclass manipulates the information which is required to calculate the
116
0
    // Usr memory pointer, e.g. NumUserOperands, the operator delete of that subclass has
117
0
    // to restore the changed information to the original value, since the dtor of that class
118
0
    // is not called if the ctor fails.
119
0
    User::operator delete(Usr);
120
0
121
0
#ifndef LLVM_ENABLE_EXCEPTIONS
122
0
    llvm_unreachable("Constructor throws?");
123
0
#endif
124
0
  }
125
126
protected:
127
3.78G
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
3.78G
    return Idx < 0
129
3.78G
      ? 
OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]3.58G
130
3.78G
      : 
OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx]201M
;
131
3.78G
  }
llvm::Use& llvm::User::OpFrom<0, llvm::GlobalVariable>(llvm::GlobalVariable const*)
Line
Count
Source
127
6.82M
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
6.82M
    return Idx < 0
129
6.82M
      ? 
OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]0
130
6.82M
      : OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx];
131
6.82M
  }
llvm::Use& llvm::User::OpFrom<0, llvm::BlockAddress>(llvm::BlockAddress const*)
Line
Count
Source
127
4.01k
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
4.01k
    return Idx < 0
129
4.01k
      ? 
OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]0
130
4.01k
      : OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx];
131
4.01k
  }
llvm::Use& llvm::User::OpFrom<1, llvm::BlockAddress>(llvm::BlockAddress const*)
Line
Count
Source
127
3.11k
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
3.11k
    return Idx < 0
129
3.11k
      ? 
OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]0
130
3.11k
      : OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx];
131
3.11k
  }
llvm::Use& llvm::User::OpFrom<0, llvm::UnaryInstruction>(llvm::UnaryInstruction const*)
Line
Count
Source
127
33.2M
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
33.2M
    return Idx < 0
129
33.2M
      ? 
OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]0
130
33.2M
      : OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx];
131
33.2M
  }
llvm::Use& llvm::User::OpFrom<-1, llvm::CallBase>(llvm::CallBase const*)
Line
Count
Source
127
1.87G
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
1.87G
    return Idx < 0
129
1.87G
      ? OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]
130
1.87G
      : 
OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx]0
;
131
1.87G
  }
llvm::Use& llvm::User::OpFrom<-1, llvm::FuncletPadInst>(llvm::FuncletPadInst const*)
Line
Count
Source
127
10.7k
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
10.7k
    return Idx < 0
129
10.7k
      ? OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]
130
10.7k
      : 
OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx]0
;
131
10.7k
  }
llvm::Use& llvm::User::OpFrom<0, llvm::CmpInst>(llvm::CmpInst const*)
Line
Count
Source
127
3.45M
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
3.45M
    return Idx < 0
129
3.45M
      ? 
OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]0
130
3.45M
      : OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx];
131
3.45M
  }
llvm::Use& llvm::User::OpFrom<1, llvm::CmpInst>(llvm::CmpInst const*)
Line
Count
Source
127
3.45M
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
3.45M
    return Idx < 0
129
3.45M
      ? 
OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]0
130
3.45M
      : OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx];
131
3.45M
  }
llvm::Use& llvm::User::OpFrom<0, llvm::SelectInst>(llvm::SelectInst const*)
Line
Count
Source
127
42.5M
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
42.5M
    return Idx < 0
129
42.5M
      ? 
OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]0
130
42.5M
      : OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx];
131
42.5M
  }
llvm::Use& llvm::User::OpFrom<1, llvm::SelectInst>(llvm::SelectInst const*)
Line
Count
Source
127
42.9M
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
42.9M
    return Idx < 0
129
42.9M
      ? 
OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]0
130
42.9M
      : OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx];
131
42.9M
  }
llvm::Use& llvm::User::OpFrom<2, llvm::SelectInst>(llvm::SelectInst const*)
Line
Count
Source
127
39.5M
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
39.5M
    return Idx < 0
129
39.5M
      ? 
OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]0
130
39.5M
      : OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx];
131
39.5M
  }
llvm::Use& llvm::User::OpFrom<0, llvm::ExtractElementInst>(llvm::ExtractElementInst const*)
Line
Count
Source
127
540k
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
540k
    return Idx < 0
129
540k
      ? 
OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]0
130
540k
      : OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx];
131
540k
  }
llvm::Use& llvm::User::OpFrom<1, llvm::ExtractElementInst>(llvm::ExtractElementInst const*)
Line
Count
Source
127
337k
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
337k
    return Idx < 0
129
337k
      ? 
OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]0
130
337k
      : OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx];
131
337k
  }
llvm::Use& llvm::User::OpFrom<0, llvm::ShuffleVectorInst>(llvm::ShuffleVectorInst const*)
Line
Count
Source
127
745k
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
745k
    return Idx < 0
129
745k
      ? 
OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]0
130
745k
      : OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx];
131
745k
  }
llvm::Use& llvm::User::OpFrom<-3, llvm::BranchInst>(llvm::BranchInst const*)
Line
Count
Source
127
372M
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
372M
    return Idx < 0
129
372M
      ? OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]
130
372M
      : 
OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx]0
;
131
372M
  }
llvm::Use& llvm::User::OpFrom<-1, llvm::BranchInst>(llvm::BranchInst const*)
Line
Count
Source
127
1.31G
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
1.31G
    return Idx < 0
129
1.31G
      ? OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]
130
1.31G
      : 
OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx]0
;
131
1.31G
  }
llvm::Use& llvm::User::OpFrom<-3, llvm::CallBase>(llvm::CallBase const*)
Line
Count
Source
127
9.82M
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
9.82M
    return Idx < 0
129
9.82M
      ? OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]
130
9.82M
      : 
OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx]0
;
131
9.82M
  }
llvm::Use& llvm::User::OpFrom<-2, llvm::CallBase>(llvm::CallBase const*)
Line
Count
Source
127
7.30M
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
7.30M
    return Idx < 0
129
7.30M
      ? OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]
130
7.30M
      : 
OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx]0
;
131
7.30M
  }
llvm::Use& llvm::User::OpFrom<0, llvm::ResumeInst>(llvm::ResumeInst const*)
Line
Count
Source
127
91.7k
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
91.7k
    return Idx < 0
129
91.7k
      ? 
OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]0
130
91.7k
      : OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx];
131
91.7k
  }
llvm::Use& llvm::User::OpFrom<0, llvm::CatchReturnInst>(llvm::CatchReturnInst const*)
Line
Count
Source
127
1.15k
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
1.15k
    return Idx < 0
129
1.15k
      ? 
OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]0
130
1.15k
      : OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx];
131
1.15k
  }
llvm::Use& llvm::User::OpFrom<1, llvm::CatchReturnInst>(llvm::CatchReturnInst const*)
Line
Count
Source
127
7.35k
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
7.35k
    return Idx < 0
129
7.35k
      ? 
OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]0
130
7.35k
      : OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx];
131
7.35k
  }
llvm::Use& llvm::User::OpFrom<0, llvm::CleanupReturnInst>(llvm::CleanupReturnInst const*)
Line
Count
Source
127
736
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
736
    return Idx < 0
129
736
      ? 
OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]0
130
736
      : OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx];
131
736
  }
llvm::Use& llvm::User::OpFrom<1, llvm::CleanupReturnInst>(llvm::CleanupReturnInst const*)
Line
Count
Source
127
1.97k
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
1.97k
    return Idx < 0
129
1.97k
      ? 
OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]0
130
1.97k
      : OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx];
131
1.97k
  }
llvm::Use& llvm::User::OpFrom<0, llvm::UnaryConstantExpr>(llvm::UnaryConstantExpr const*)
Line
Count
Source
127
367k
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
367k
    return Idx < 0
129
367k
      ? 
OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]0
130
367k
      : OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx];
131
367k
  }
llvm::Use& llvm::User::OpFrom<0, llvm::BinaryConstantExpr>(llvm::BinaryConstantExpr const*)
Line
Count
Source
127
12.7k
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
12.7k
    return Idx < 0
129
12.7k
      ? 
OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]0
130
12.7k
      : OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx];
131
12.7k
  }
llvm::Use& llvm::User::OpFrom<1, llvm::BinaryConstantExpr>(llvm::BinaryConstantExpr const*)
Line
Count
Source
127
6.38k
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
6.38k
    return Idx < 0
129
6.38k
      ? 
OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]0
130
6.38k
      : OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx];
131
6.38k
  }
llvm::Use& llvm::User::OpFrom<0, llvm::SelectConstantExpr>(llvm::SelectConstantExpr const*)
Line
Count
Source
127
188
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
188
    return Idx < 0
129
188
      ? 
OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]0
130
188
      : OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx];
131
188
  }
llvm::Use& llvm::User::OpFrom<1, llvm::SelectConstantExpr>(llvm::SelectConstantExpr const*)
Line
Count
Source
127
94
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
94
    return Idx < 0
129
94
      ? 
OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]0
130
94
      : OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx];
131
94
  }
llvm::Use& llvm::User::OpFrom<2, llvm::SelectConstantExpr>(llvm::SelectConstantExpr const*)
Line
Count
Source
127
94
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
94
    return Idx < 0
129
94
      ? 
OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]0
130
94
      : OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx];
131
94
  }
llvm::Use& llvm::User::OpFrom<0, llvm::ExtractElementConstantExpr>(llvm::ExtractElementConstantExpr const*)
Line
Count
Source
127
198
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
198
    return Idx < 0
129
198
      ? 
OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]0
130
198
      : OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx];
131
198
  }
llvm::Use& llvm::User::OpFrom<1, llvm::ExtractElementConstantExpr>(llvm::ExtractElementConstantExpr const*)
Line
Count
Source
127
99
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
99
    return Idx < 0
129
99
      ? 
OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]0
130
99
      : OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx];
131
99
  }
Unexecuted instantiation: llvm::Use& llvm::User::OpFrom<0, llvm::InsertElementConstantExpr>(llvm::InsertElementConstantExpr const*)
Unexecuted instantiation: llvm::Use& llvm::User::OpFrom<1, llvm::InsertElementConstantExpr>(llvm::InsertElementConstantExpr const*)
Unexecuted instantiation: llvm::Use& llvm::User::OpFrom<2, llvm::InsertElementConstantExpr>(llvm::InsertElementConstantExpr const*)
Unexecuted instantiation: llvm::Use& llvm::User::OpFrom<0, llvm::ShuffleVectorConstantExpr>(llvm::ShuffleVectorConstantExpr const*)
Unexecuted instantiation: llvm::Use& llvm::User::OpFrom<1, llvm::ShuffleVectorConstantExpr>(llvm::ShuffleVectorConstantExpr const*)
Unexecuted instantiation: llvm::Use& llvm::User::OpFrom<2, llvm::ShuffleVectorConstantExpr>(llvm::ShuffleVectorConstantExpr const*)
llvm::Use& llvm::User::OpFrom<0, llvm::ExtractValueConstantExpr>(llvm::ExtractValueConstantExpr const*)
Line
Count
Source
127
10
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
10
    return Idx < 0
129
10
      ? 
OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]0
130
10
      : OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx];
131
10
  }
llvm::Use& llvm::User::OpFrom<0, llvm::InsertValueConstantExpr>(llvm::InsertValueConstantExpr const*)
Line
Count
Source
127
2
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
2
    return Idx < 0
129
2
      ? 
OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]0
130
2
      : OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx];
131
2
  }
llvm::Use& llvm::User::OpFrom<1, llvm::InsertValueConstantExpr>(llvm::InsertValueConstantExpr const*)
Line
Count
Source
127
1
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
1
    return Idx < 0
129
1
      ? 
OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]0
130
1
      : OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx];
131
1
  }
llvm::Use& llvm::User::OpFrom<0, llvm::CompareConstantExpr>(llvm::CompareConstantExpr const*)
Line
Count
Source
127
1.52k
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
1.52k
    return Idx < 0
129
1.52k
      ? 
OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]0
130
1.52k
      : OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx];
131
1.52k
  }
llvm::Use& llvm::User::OpFrom<1, llvm::CompareConstantExpr>(llvm::CompareConstantExpr const*)
Line
Count
Source
127
761
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
761
    return Idx < 0
129
761
      ? 
OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]0
130
761
      : OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx];
131
761
  }
llvm::Use& llvm::User::OpFrom<0, llvm::GetElementPtrConstantExpr>(llvm::GetElementPtrConstantExpr const*)
Line
Count
Source
127
614k
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
614k
    return Idx < 0
129
614k
      ? 
OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]0
130
614k
      : OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx];
131
614k
  }
llvm::Use& llvm::User::OpFrom<0, llvm::Function>(llvm::Function const*)
Line
Count
Source
127
540k
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
540k
    return Idx < 0
129
540k
      ? 
OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]0
130
540k
      : OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx];
131
540k
  }
llvm::Use& llvm::User::OpFrom<1, llvm::Function>(llvm::Function const*)
Line
Count
Source
127
22.5k
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
22.5k
    return Idx < 0
129
22.5k
      ? 
OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]0
130
22.5k
      : OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx];
131
22.5k
  }
llvm::Use& llvm::User::OpFrom<2, llvm::Function>(llvm::Function const*)
Line
Count
Source
127
22.8k
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
22.8k
    return Idx < 0
129
22.8k
      ? 
OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]0
130
22.8k
      : OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx];
131
22.8k
  }
llvm::Use& llvm::User::OpFrom<0, llvm::GlobalIndirectSymbol>(llvm::GlobalIndirectSymbol const*)
Line
Count
Source
127
7.98k
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
7.98k
    return Idx < 0
129
7.98k
      ? 
OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]0
130
7.98k
      : OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx];
131
7.98k
  }
llvm::Use& llvm::User::OpFrom<-1, llvm::PHINode>(llvm::PHINode const*)
Line
Count
Source
127
2.96M
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
2.96M
    return Idx < 0
129
2.96M
      ? OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]
130
2.96M
      : 
OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx]0
;
131
2.96M
  }
llvm::Use& llvm::User::OpFrom<0, llvm::ReturnInst>(llvm::ReturnInst const*)
Line
Count
Source
127
1.72M
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
1.72M
    return Idx < 0
129
1.72M
      ? 
OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]0
130
1.72M
      : OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx];
131
1.72M
  }
llvm::Use& llvm::User::OpFrom<0, llvm::CatchSwitchInst>(llvm::CatchSwitchInst const*)
Line
Count
Source
127
540
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
540
    return Idx < 0
129
540
      ? 
OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]0
130
540
      : OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx];
131
540
  }
llvm::Use& llvm::User::OpFrom<-2, llvm::BranchInst>(llvm::BranchInst const*)
Line
Count
Source
127
2.81M
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
2.81M
    return Idx < 0
129
2.81M
      ? OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]
130
2.81M
      : 
OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx]0
;
131
2.81M
  }
llvm::Use& llvm::User::OpFrom<0, llvm::StoreInst>(llvm::StoreInst const*)
Line
Count
Source
127
5.03M
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
5.03M
    return Idx < 0
129
5.03M
      ? 
OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]0
130
5.03M
      : OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx];
131
5.03M
  }
llvm::Use& llvm::User::OpFrom<1, llvm::StoreInst>(llvm::StoreInst const*)
Line
Count
Source
127
5.03M
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
5.03M
    return Idx < 0
129
5.03M
      ? 
OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]0
130
5.03M
      : OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx];
131
5.03M
  }
llvm::Use& llvm::User::OpFrom<0, llvm::AtomicCmpXchgInst>(llvm::AtomicCmpXchgInst const*)
Line
Count
Source
127
9.25k
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
9.25k
    return Idx < 0
129
9.25k
      ? 
OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]0
130
9.25k
      : OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx];
131
9.25k
  }
llvm::Use& llvm::User::OpFrom<1, llvm::AtomicCmpXchgInst>(llvm::AtomicCmpXchgInst const*)
Line
Count
Source
127
9.25k
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
9.25k
    return Idx < 0
129
9.25k
      ? 
OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]0
130
9.25k
      : OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx];
131
9.25k
  }
llvm::Use& llvm::User::OpFrom<2, llvm::AtomicCmpXchgInst>(llvm::AtomicCmpXchgInst const*)
Line
Count
Source
127
9.25k
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
9.25k
    return Idx < 0
129
9.25k
      ? 
OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]0
130
9.25k
      : OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx];
131
9.25k
  }
llvm::Use& llvm::User::OpFrom<0, llvm::AtomicRMWInst>(llvm::AtomicRMWInst const*)
Line
Count
Source
127
35.9k
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
35.9k
    return Idx < 0
129
35.9k
      ? 
OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]0
130
35.9k
      : OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx];
131
35.9k
  }
llvm::Use& llvm::User::OpFrom<1, llvm::AtomicRMWInst>(llvm::AtomicRMWInst const*)
Line
Count
Source
127
35.9k
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
35.9k
    return Idx < 0
129
35.9k
      ? 
OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]0
130
35.9k
      : OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx];
131
35.9k
  }
llvm::Use& llvm::User::OpFrom<0, llvm::GetElementPtrInst>(llvm::GetElementPtrInst const*)
Line
Count
Source
127
4.49M
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
4.49M
    return Idx < 0
129
4.49M
      ? 
OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]0
130
4.49M
      : OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx];
131
4.49M
  }
llvm::Use& llvm::User::OpFrom<0, llvm::InsertElementInst>(llvm::InsertElementInst const*)
Line
Count
Source
127
101k
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
101k
    return Idx < 0
129
101k
      ? 
OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]0
130
101k
      : OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx];
131
101k
  }
llvm::Use& llvm::User::OpFrom<1, llvm::InsertElementInst>(llvm::InsertElementInst const*)
Line
Count
Source
127
101k
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
101k
    return Idx < 0
129
101k
      ? 
OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]0
130
101k
      : OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx];
131
101k
  }
llvm::Use& llvm::User::OpFrom<2, llvm::InsertElementInst>(llvm::InsertElementInst const*)
Line
Count
Source
127
101k
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
101k
    return Idx < 0
129
101k
      ? 
OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]0
130
101k
      : OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx];
131
101k
  }
llvm::Use& llvm::User::OpFrom<1, llvm::ShuffleVectorInst>(llvm::ShuffleVectorInst const*)
Line
Count
Source
127
126k
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
126k
    return Idx < 0
129
126k
      ? 
OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]0
130
126k
      : OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx];
131
126k
  }
llvm::Use& llvm::User::OpFrom<2, llvm::ShuffleVectorInst>(llvm::ShuffleVectorInst const*)
Line
Count
Source
127
125k
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
125k
    return Idx < 0
129
125k
      ? 
OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]0
130
125k
      : OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx];
131
125k
  }
llvm::Use& llvm::User::OpFrom<0, llvm::InsertValueInst>(llvm::InsertValueInst const*)
Line
Count
Source
127
52.9k
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
52.9k
    return Idx < 0
129
52.9k
      ? 
OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]0
130
52.9k
      : OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx];
131
52.9k
  }
llvm::Use& llvm::User::OpFrom<1, llvm::InsertValueInst>(llvm::InsertValueInst const*)
Line
Count
Source
127
52.9k
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
52.9k
    return Idx < 0
129
52.9k
      ? 
OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]0
130
52.9k
      : OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx];
131
52.9k
  }
llvm::Use& llvm::User::OpFrom<0, llvm::BinaryOperator>(llvm::BinaryOperator const*)
Line
Count
Source
127
4.51M
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
4.51M
    return Idx < 0
129
4.51M
      ? 
OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]0
130
4.51M
      : OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx];
131
4.51M
  }
llvm::Use& llvm::User::OpFrom<1, llvm::BinaryOperator>(llvm::BinaryOperator const*)
Line
Count
Source
127
4.51M
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
4.51M
    return Idx < 0
129
4.51M
      ? 
OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]0
130
4.51M
      : OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx];
131
4.51M
  }
llvm::Use& llvm::User::OpFrom<0, llvm::SwitchInst>(llvm::SwitchInst const*)
Line
Count
Source
127
46.7k
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
46.7k
    return Idx < 0
129
46.7k
      ? 
OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]0
130
46.7k
      : OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx];
131
46.7k
  }
llvm::Use& llvm::User::OpFrom<1, llvm::SwitchInst>(llvm::SwitchInst const*)
Line
Count
Source
127
46.7k
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
46.7k
    return Idx < 0
129
46.7k
      ? 
OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]0
130
46.7k
      : OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx];
131
46.7k
  }
llvm::Use& llvm::User::OpFrom<0, llvm::IndirectBrInst>(llvm::IndirectBrInst const*)
Line
Count
Source
127
430
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
430
    return Idx < 0
129
430
      ? 
OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]0
130
430
      : OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx];
131
430
  }
ValueList.cpp:llvm::Use& llvm::User::OpFrom<0, llvm::(anonymous namespace)::ConstantPlaceHolder>(llvm::(anonymous namespace)::ConstantPlaceHolder const*)
Line
Count
Source
127
5.80k
  template <int Idx, typename U> static Use &OpFrom(const U *that) {
128
5.80k
    return Idx < 0
129
5.80k
      ? 
OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]0
130
5.80k
      : OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx];
131
5.80k
  }
132
133
  template <int Idx> Use &Op() {
134
    return OpFrom<Idx>(this);
135
  }
136
  template <int Idx> const Use &Op() const {
137
    return OpFrom<Idx>(this);
138
  }
139
140
private:
141
1.22G
  const Use *getHungOffOperands() const {
142
1.22G
    return *(reinterpret_cast<const Use *const *>(this) - 1);
143
1.22G
  }
144
145
5.79M
  Use *&getHungOffOperands() { return *(reinterpret_cast<Use **>(this) - 1); }
146
147
3.94G
  const Use *getIntrusiveOperands() const {
148
3.94G
    return reinterpret_cast<const Use *>(this) - NumUserOperands;
149
3.94G
  }
150
151
149k
  Use *getIntrusiveOperands() {
152
149k
    return reinterpret_cast<Use *>(this) - NumUserOperands;
153
149k
  }
154
155
5.79M
  void setOperandList(Use *NewList) {
156
5.79M
    assert(HasHungOffUses &&
157
5.79M
           "Setting operand list only required for hung off uses");
158
5.79M
    getHungOffOperands() = NewList;
159
5.79M
  }
160
161
public:
162
5.16G
  const Use *getOperandList() const {
163
5.16G
    return HasHungOffUses ? 
getHungOffOperands()1.22G
:
getIntrusiveOperands()3.94G
;
164
5.16G
  }
165
2.14G
  Use *getOperandList() {
166
2.14G
    return const_cast<Use *>(static_cast<const User *>(this)->getOperandList());
167
2.14G
  }
168
169
1.94G
  Value *getOperand(unsigned i) const {
170
1.94G
    assert(i < NumUserOperands && "getOperand() out of range!");
171
1.94G
    return getOperandList()[i];
172
1.94G
  }
173
174
6.27M
  void setOperand(unsigned i, Value *Val) {
175
6.27M
    assert(i < NumUserOperands && "setOperand() out of range!");
176
6.27M
    assert((!isa<Constant>((const Value*)this) ||
177
6.27M
            isa<GlobalValue>((const Value*)this)) &&
178
6.27M
           "Cannot mutate a constant with setOperand!");
179
6.27M
    getOperandList()[i] = Val;
180
6.27M
  }
181
182
2
  const Use &getOperandUse(unsigned i) const {
183
2
    assert(i < NumUserOperands && "getOperandUse() out of range!");
184
2
    return getOperandList()[i];
185
2
  }
186
55.2M
  Use &getOperandUse(unsigned i) {
187
55.2M
    assert(i < NumUserOperands && "getOperandUse() out of range!");
188
55.2M
    return getOperandList()[i];
189
55.2M
  }
190
191
3.15G
  unsigned getNumOperands() const { return NumUserOperands; }
192
193
  /// Returns the descriptor co-allocated with this User instance.
194
  ArrayRef<const uint8_t> getDescriptor() const;
195
196
  /// Returns the descriptor co-allocated with this User instance.
197
  MutableArrayRef<uint8_t> getDescriptor();
198
199
  /// Set the number of operands on a GlobalVariable.
200
  ///
201
  /// GlobalVariable always allocates space for a single operands, but
202
  /// doesn't always use it.
203
  ///
204
  /// FIXME: As that the number of operands is used to find the start of
205
  /// the allocated memory in operator delete, we need to always think we have
206
  /// 1 operand before delete.
207
582k
  void setGlobalVariableNumOperands(unsigned NumOps) {
208
582k
    assert(NumOps <= 1 && "GlobalVariable can only have 0 or 1 operands");
209
582k
    NumUserOperands = NumOps;
210
582k
  }
211
212
  /// Subclasses with hung off uses need to manage the operand count
213
  /// themselves.  In these instances, the operand count isn't used to find the
214
  /// OperandList, so there's no issue in having the operand count change.
215
12.8M
  void setNumHungOffUseOperands(unsigned NumOps) {
216
12.8M
    assert(HasHungOffUses && "Must have hung off uses to use this method");
217
12.8M
    assert(NumOps < (1u << NumUserOperandsBits) && "Too many operands");
218
12.8M
    NumUserOperands = NumOps;
219
12.8M
  }
220
221
  // ---------------------------------------------------------------------------
222
  // Operand Iterator interface...
223
  //
224
  using op_iterator = Use*;
225
  using const_op_iterator = const Use*;
226
  using op_range = iterator_range<op_iterator>;
227
  using const_op_range = iterator_range<const_op_iterator>;
228
229
643M
  op_iterator       op_begin()       { return getOperandList(); }
230
639M
  const_op_iterator op_begin() const { return getOperandList(); }
231
641M
  op_iterator       op_end()         {
232
641M
    return getOperandList() + NumUserOperands;
233
641M
  }
234
447M
  const_op_iterator op_end()   const {
235
447M
    return getOperandList() + NumUserOperands;
236
447M
  }
237
568M
  op_range operands() {
238
568M
    return op_range(op_begin(), op_end());
239
568M
  }
240
106M
  const_op_range operands() const {
241
106M
    return const_op_range(op_begin(), op_end());
242
106M
  }
243
244
  /// Iterator for directly iterating over the operand Values.
245
  struct value_op_iterator
246
      : iterator_adaptor_base<value_op_iterator, op_iterator,
247
                              std::random_access_iterator_tag, Value *,
248
                              ptrdiff_t, Value *, Value *> {
249
72.6M
    explicit value_op_iterator(Use *U = nullptr) : iterator_adaptor_base(U) {}
250
251
102M
    Value *operator*() const { return *I; }
252
0
    Value *operator->() const { return operator*(); }
253
  };
254
255
36.3M
  value_op_iterator value_op_begin() {
256
36.3M
    return value_op_iterator(op_begin());
257
36.3M
  }
258
36.3M
  value_op_iterator value_op_end() {
259
36.3M
    return value_op_iterator(op_end());
260
36.3M
  }
261
10.4M
  iterator_range<value_op_iterator> operand_values() {
262
10.4M
    return make_range(value_op_begin(), value_op_end());
263
10.4M
  }
264
265
  struct const_value_op_iterator
266
      : iterator_adaptor_base<const_value_op_iterator, const_op_iterator,
267
                              std::random_access_iterator_tag, const Value *,
268
                              ptrdiff_t, const Value *, const Value *> {
269
    explicit const_value_op_iterator(const Use *U = nullptr) :
270
85.3M
      iterator_adaptor_base(U) {}
271
272
89.7M
    const Value *operator*() const { return *I; }
273
0
    const Value *operator->() const { return operator*(); }
274
  };
275
276
42.6M
  const_value_op_iterator value_op_begin() const {
277
42.6M
    return const_value_op_iterator(op_begin());
278
42.6M
  }
279
42.6M
  const_value_op_iterator value_op_end() const {
280
42.6M
    return const_value_op_iterator(op_end());
281
42.6M
  }
282
342k
  iterator_range<const_value_op_iterator> operand_values() const {
283
342k
    return make_range(value_op_begin(), value_op_end());
284
342k
  }
285
286
  /// Drop all references to operands.
287
  ///
288
  /// This function is in charge of "letting go" of all objects that this User
289
  /// refers to.  This allows one to 'delete' a whole class at a time, even
290
  /// though there may be circular references...  First all references are
291
  /// dropped, and all use counts go to zero.  Then everything is deleted for
292
  /// real.  Note that no operations are valid on an object that has "dropped
293
  /// all references", except operator delete.
294
28.7M
  void dropAllReferences() {
295
28.7M
    for (Use &U : operands())
296
47.9M
      U.set(nullptr);
297
28.7M
  }
298
299
  /// Replace uses of one Value with another.
300
  ///
301
  /// Replaces all references to the "From" definition with references to the
302
  /// "To" definition.
303
  void replaceUsesOfWith(Value *From, Value *To);
304
305
  // Methods for support type inquiry through isa, cast, and dyn_cast:
306
22.1M
  static bool classof(const Value *V) {
307
22.1M
    return isa<Instruction>(V) || 
isa<Constant>(V)5.27M
;
308
22.1M
  }
309
};
310
311
// Either Use objects, or a Use pointer can be prepended to User.
312
static_assert(alignof(Use) >= alignof(User),
313
              "Alignment is insufficient after objects prepended to User");
314
static_assert(alignof(Use *) >= alignof(User),
315
              "Alignment is insufficient after objects prepended to User");
316
317
template<> struct simplify_type<User::op_iterator> {
318
  using SimpleType = Value*;
319
320
2.38M
  static SimpleType getSimplifiedValue(User::op_iterator &Val) {
321
2.38M
    return Val->get();
322
2.38M
  }
323
};
324
template<> struct simplify_type<User::const_op_iterator> {
325
  using SimpleType = /*const*/ Value*;
326
327
605M
  static SimpleType getSimplifiedValue(User::const_op_iterator &Val) {
328
605M
    return Val->get();
329
605M
  }
330
};
331
332
} // end namespace llvm
333
334
#endif // LLVM_IR_USER_H