Coverage Report

Created: 2017-10-03 07:32

/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/llvm/include/llvm/IR/InstrTypes.h
Line
Count
Source (jump to first uncovered line)
1
//===- llvm/InstrTypes.h - Important Instruction subclasses -----*- 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 various meta classes of instructions that exist in the VM
11
// representation.  Specific concrete subclasses of these may be found in the
12
// i*.h files...
13
//
14
//===----------------------------------------------------------------------===//
15
16
#ifndef LLVM_IR_INSTRTYPES_H
17
#define LLVM_IR_INSTRTYPES_H
18
19
#include "llvm/ADT/ArrayRef.h"
20
#include "llvm/ADT/None.h"
21
#include "llvm/ADT/Optional.h"
22
#include "llvm/ADT/STLExtras.h"
23
#include "llvm/ADT/StringMap.h"
24
#include "llvm/ADT/StringRef.h"
25
#include "llvm/ADT/Twine.h"
26
#include "llvm/ADT/iterator_range.h"
27
#include "llvm/IR/Attributes.h"
28
#include "llvm/IR/DerivedTypes.h"
29
#include "llvm/IR/Instruction.h"
30
#include "llvm/IR/LLVMContext.h"
31
#include "llvm/IR/OperandTraits.h"
32
#include "llvm/IR/Type.h"
33
#include "llvm/IR/User.h"
34
#include "llvm/IR/Value.h"
35
#include "llvm/Support/Casting.h"
36
#include "llvm/Support/ErrorHandling.h"
37
#include <algorithm>
38
#include <cassert>
39
#include <cstddef>
40
#include <cstdint>
41
#include <iterator>
42
#include <string>
43
#include <vector>
44
45
namespace llvm {
46
47
//===----------------------------------------------------------------------===//
48
//                            TerminatorInst Class
49
//===----------------------------------------------------------------------===//
50
51
/// Subclasses of this class are all able to terminate a basic
52
/// block. Thus, these are all the flow control type of operations.
53
///
54
class TerminatorInst : public Instruction {
55
protected:
56
  TerminatorInst(Type *Ty, Instruction::TermOps iType,
57
                 Use *Ops, unsigned NumOps,
58
                 Instruction *InsertBefore = nullptr)
59
9.14M
    : Instruction(Ty, iType, Ops, NumOps, InsertBefore) {}
60
61
  TerminatorInst(Type *Ty, Instruction::TermOps iType,
62
                 Use *Ops, unsigned NumOps, BasicBlock *InsertAtEnd)
63
2.13M
    : Instruction(Ty, iType, Ops, NumOps, InsertAtEnd) {}
64
65
public:
66
  /// Return the number of successors that this terminator has.
67
  unsigned getNumSuccessors() const;
68
69
  /// Return the specified successor.
70
  BasicBlock *getSuccessor(unsigned idx) const;
71
72
  /// Update the specified successor to point at the provided block.
73
  void setSuccessor(unsigned idx, BasicBlock *B);
74
75
  // Methods for support type inquiry through isa, cast, and dyn_cast:
76
4.36G
  static bool classof(const Instruction *I) {
77
4.36G
    return I->isTerminator();
78
4.36G
  }
79
995M
  static bool classof(const Value *V) {
80
995M
    return isa<Instruction>(V) && classof(cast<Instruction>(V));
81
995M
  }
82
83
  // \brief Returns true if this terminator relates to exception handling.
84
56.6M
  bool isExceptional() const {
85
56.6M
    switch (getOpcode()) {
86
691k
    case Instruction::CatchSwitch:
87
691k
    case Instruction::CatchRet:
88
691k
    case Instruction::CleanupRet:
89
691k
    case Instruction::Invoke:
90
691k
    case Instruction::Resume:
91
691k
      return true;
92
55.9M
    default:
93
55.9M
      return false;
94
56.6M
    }
95
56.6M
  }
96
97
  //===--------------------------------------------------------------------===//
98
  // succ_iterator definition
99
  //===--------------------------------------------------------------------===//
100
101
  template <class Term, class BB> // Successor Iterator
102
  class SuccIterator : public std::iterator<std::random_access_iterator_tag, BB,
103
                                            int, BB *, BB *> {
104
    using super =
105
        std::iterator<std::random_access_iterator_tag, BB, int, BB *, BB *>;
106
107
  public:
108
    using pointer = typename super::pointer;
109
    using reference = typename super::reference;
110
111
  private:
112
    Term TermInst;
113
    unsigned idx;
114
    using Self = SuccIterator<Term, BB>;
115
116
    inline bool index_is_valid(unsigned idx) {
117
      return idx < TermInst->getNumSuccessors();
118
    }
119
120
    /// \brief Proxy object to allow write access in operator[]
121
    class SuccessorProxy {
122
      Self it;
123
124
    public:
125
      explicit SuccessorProxy(const Self &it) : it(it) {}
126
127
      SuccessorProxy(const SuccessorProxy &) = default;
128
129
      SuccessorProxy &operator=(SuccessorProxy r) {
130
        *this = reference(r);
131
        return *this;
132
      }
133
134
      SuccessorProxy &operator=(reference r) {
135
        it.TermInst->setSuccessor(it.idx, r);
136
        return *this;
137
      }
138
139
      operator reference() const { return *it; }
140
    };
141
142
  public:
143
    // begin iterator
144
883M
    explicit inline SuccIterator(Term T) : TermInst(T), idx(0) {}
llvm::TerminatorInst::SuccIterator<llvm::TerminatorInst*, llvm::BasicBlock>::SuccIterator(llvm::TerminatorInst*)
Line
Count
Source
144
588M
    explicit inline SuccIterator(Term T) : TermInst(T), idx(0) {}
llvm::TerminatorInst::SuccIterator<llvm::TerminatorInst const*, llvm::BasicBlock const>::SuccIterator(llvm::TerminatorInst const*)
Line
Count
Source
144
295M
    explicit inline SuccIterator(Term T) : TermInst(T), idx(0) {}
145
    // end iterator
146
1.13G
    inline SuccIterator(Term T, bool) : TermInst(T) {
147
1.13G
      if (TermInst)
148
1.13G
        idx = TermInst->getNumSuccessors();
149
1.13G
      else
150
1.13G
        // Term == NULL happens, if a basic block is not fully constructed and
151
1.13G
        // consequently getTerminator() returns NULL. In this case we construct
152
1.13G
        // a SuccIterator which describes a basic block that has zero
153
1.13G
        // successors.
154
1.13G
        // Defining SuccIterator for incomplete and malformed CFGs is especially
155
1.13G
        // useful for debugging.
156
121k
        idx = 0;
157
1.13G
    }
llvm::TerminatorInst::SuccIterator<llvm::TerminatorInst const*, llvm::BasicBlock const>::SuccIterator(llvm::TerminatorInst const*, bool)
Line
Count
Source
146
410M
    inline SuccIterator(Term T, bool) : TermInst(T) {
147
410M
      if (TermInst)
148
410M
        idx = TermInst->getNumSuccessors();
149
410M
      else
150
410M
        // Term == NULL happens, if a basic block is not fully constructed and
151
410M
        // consequently getTerminator() returns NULL. In this case we construct
152
410M
        // a SuccIterator which describes a basic block that has zero
153
410M
        // successors.
154
410M
        // Defining SuccIterator for incomplete and malformed CFGs is especially
155
410M
        // useful for debugging.
156
2
        idx = 0;
157
410M
    }
llvm::TerminatorInst::SuccIterator<llvm::TerminatorInst*, llvm::BasicBlock>::SuccIterator(llvm::TerminatorInst*, bool)
Line
Count
Source
146
727M
    inline SuccIterator(Term T, bool) : TermInst(T) {
147
727M
      if (TermInst)
148
726M
        idx = TermInst->getNumSuccessors();
149
727M
      else
150
727M
        // Term == NULL happens, if a basic block is not fully constructed and
151
727M
        // consequently getTerminator() returns NULL. In this case we construct
152
727M
        // a SuccIterator which describes a basic block that has zero
153
727M
        // successors.
154
727M
        // Defining SuccIterator for incomplete and malformed CFGs is especially
155
727M
        // useful for debugging.
156
121k
        idx = 0;
157
727M
    }
158
159
    /// This is used to interface between code that wants to
160
    /// operate on terminator instructions directly.
161
76.5M
    unsigned getSuccessorIndex() const { return idx; }
llvm::TerminatorInst::SuccIterator<llvm::TerminatorInst const*, llvm::BasicBlock const>::getSuccessorIndex() const
Line
Count
Source
161
76.5M
    unsigned getSuccessorIndex() const { return idx; }
Unexecuted instantiation: llvm::TerminatorInst::SuccIterator<llvm::TerminatorInst*, llvm::BasicBlock>::getSuccessorIndex() const
162
163
1.94G
    inline bool operator==(const Self &x) const { return idx == x.idx; }
llvm::TerminatorInst::SuccIterator<llvm::TerminatorInst*, llvm::BasicBlock>::operator==(llvm::TerminatorInst::SuccIterator<llvm::TerminatorInst*, llvm::BasicBlock> const&) const
Line
Count
Source
163
1.36G
    inline bool operator==(const Self &x) const { return idx == x.idx; }
llvm::TerminatorInst::SuccIterator<llvm::TerminatorInst const*, llvm::BasicBlock const>::operator==(llvm::TerminatorInst::SuccIterator<llvm::TerminatorInst const*, llvm::BasicBlock const> const&) const
Line
Count
Source
163
575M
    inline bool operator==(const Self &x) const { return idx == x.idx; }
164
1.80G
    inline bool operator!=(const Self &x) const { return !operator==(x); }
llvm::TerminatorInst::SuccIterator<llvm::TerminatorInst const*, llvm::BasicBlock const>::operator!=(llvm::TerminatorInst::SuccIterator<llvm::TerminatorInst const*, llvm::BasicBlock const> const&) const
Line
Count
Source
164
440M
    inline bool operator!=(const Self &x) const { return !operator==(x); }
llvm::TerminatorInst::SuccIterator<llvm::TerminatorInst*, llvm::BasicBlock>::operator!=(llvm::TerminatorInst::SuccIterator<llvm::TerminatorInst*, llvm::BasicBlock> const&) const
Line
Count
Source
164
1.36G
    inline bool operator!=(const Self &x) const { return !operator==(x); }
165
166
1.18G
    inline reference operator*() const { return TermInst->getSuccessor(idx); }
llvm::TerminatorInst::SuccIterator<llvm::TerminatorInst const*, llvm::BasicBlock const>::operator*() const
Line
Count
Source
166
353M
    inline reference operator*() const { return TermInst->getSuccessor(idx); }
llvm::TerminatorInst::SuccIterator<llvm::TerminatorInst*, llvm::BasicBlock>::operator*() const
Line
Count
Source
166
834M
    inline reference operator*() const { return TermInst->getSuccessor(idx); }
167
    inline pointer operator->() const { return operator*(); }
168
169
932M
    inline Self &operator++() {
170
932M
      ++idx;
171
932M
      return *this;
172
932M
    } // Preincrement
llvm::TerminatorInst::SuccIterator<llvm::TerminatorInst const*, llvm::BasicBlock const>::operator++()
Line
Count
Source
169
308M
    inline Self &operator++() {
170
308M
      ++idx;
171
308M
      return *this;
172
308M
    } // Preincrement
llvm::TerminatorInst::SuccIterator<llvm::TerminatorInst*, llvm::BasicBlock>::operator++()
Line
Count
Source
169
623M
    inline Self &operator++() {
170
623M
      ++idx;
171
623M
      return *this;
172
623M
    } // Preincrement
173
174
255M
    inline Self operator++(int) { // Postincrement
175
255M
      Self tmp = *this;
176
255M
      ++*this;
177
255M
      return tmp;
178
255M
    }
llvm::TerminatorInst::SuccIterator<llvm::TerminatorInst*, llvm::BasicBlock>::operator++(int)
Line
Count
Source
174
140M
    inline Self operator++(int) { // Postincrement
175
140M
      Self tmp = *this;
176
140M
      ++*this;
177
140M
      return tmp;
178
140M
    }
llvm::TerminatorInst::SuccIterator<llvm::TerminatorInst const*, llvm::BasicBlock const>::operator++(int)
Line
Count
Source
174
115M
    inline Self operator++(int) { // Postincrement
175
115M
      Self tmp = *this;
176
115M
      ++*this;
177
115M
      return tmp;
178
115M
    }
179
180
354M
    inline Self &operator--() {
181
354M
      --idx;
182
354M
      return *this;
183
354M
    }                             // Predecrement
184
    inline Self operator--(int) { // Postdecrement
185
      Self tmp = *this;
186
      --*this;
187
      return tmp;
188
    }
189
190
    inline bool operator<(const Self &x) const {
191
      assert(TermInst == x.TermInst &&
192
             "Cannot compare iterators of different blocks!");
193
      return idx < x.idx;
194
    }
195
196
    inline bool operator<=(const Self &x) const {
197
      assert(TermInst == x.TermInst &&
198
             "Cannot compare iterators of different blocks!");
199
      return idx <= x.idx;
200
    }
201
    inline bool operator>=(const Self &x) const {
202
      assert(TermInst == x.TermInst &&
203
             "Cannot compare iterators of different blocks!");
204
      return idx >= x.idx;
205
    }
206
207
    inline bool operator>(const Self &x) const {
208
      assert(TermInst == x.TermInst &&
209
             "Cannot compare iterators of different blocks!");
210
      return idx > x.idx;
211
    }
212
213
3.82k
    inline Self &operator+=(int Right) {
214
3.82k
      unsigned new_idx = idx + Right;
215
3.82k
      assert(index_is_valid(new_idx) && "Iterator index out of bound");
216
3.82k
      idx = new_idx;
217
3.82k
      return *this;
218
3.82k
    }
219
220
98
    inline Self operator+(int Right) const {
221
98
      Self tmp = *this;
222
98
      tmp += Right;
223
98
      return tmp;
224
98
    }
225
226
    inline Self &operator-=(int Right) { return operator+=(-Right); }
227
228
    inline Self operator-(int Right) const { return operator+(-Right); }
229
230
170M
    inline int operator-(const Self &x) const {
231
170M
      assert(TermInst == x.TermInst &&
232
170M
             "Cannot work on iterators of different blocks!");
233
170M
      int distance = idx - x.idx;
234
170M
      return distance;
235
170M
    }
llvm::TerminatorInst::SuccIterator<llvm::TerminatorInst const*, llvm::BasicBlock const>::operator-(llvm::TerminatorInst::SuccIterator<llvm::TerminatorInst const*, llvm::BasicBlock const> const&) const
Line
Count
Source
230
28.7M
    inline int operator-(const Self &x) const {
231
28.7M
      assert(TermInst == x.TermInst &&
232
28.7M
             "Cannot work on iterators of different blocks!");
233
28.7M
      int distance = idx - x.idx;
234
28.7M
      return distance;
235
28.7M
    }
llvm::TerminatorInst::SuccIterator<llvm::TerminatorInst*, llvm::BasicBlock>::operator-(llvm::TerminatorInst::SuccIterator<llvm::TerminatorInst*, llvm::BasicBlock> const&) const
Line
Count
Source
230
141M
    inline int operator-(const Self &x) const {
231
141M
      assert(TermInst == x.TermInst &&
232
141M
             "Cannot work on iterators of different blocks!");
233
141M
      int distance = idx - x.idx;
234
141M
      return distance;
235
141M
    }
236
237
    inline SuccessorProxy operator[](int offset) {
238
      Self tmp = *this;
239
      tmp += offset;
240
      return SuccessorProxy(tmp);
241
    }
242
243
    /// Get the source BB of this iterator.
244
    inline BB *getSource() {
245
      assert(TermInst && "Source not available, if basic block was malformed");
246
      return TermInst->getParent();
247
    }
248
  };
249
250
  using succ_iterator = SuccIterator<TerminatorInst *, BasicBlock>;
251
  using succ_const_iterator =
252
      SuccIterator<const TerminatorInst *, const BasicBlock>;
253
  using succ_range = iterator_range<succ_iterator>;
254
  using succ_const_range = iterator_range<succ_const_iterator>;
255
256
private:
257
44.2M
  inline succ_iterator succ_begin() { return succ_iterator(this); }
258
2.06M
  inline succ_const_iterator succ_begin() const {
259
2.06M
    return succ_const_iterator(this);
260
2.06M
  }
261
44.2M
  inline succ_iterator succ_end() { return succ_iterator(this, true); }
262
2.06M
  inline succ_const_iterator succ_end() const {
263
2.06M
    return succ_const_iterator(this, true);
264
2.06M
  }
265
266
public:
267
44.2M
  inline succ_range successors() {
268
44.2M
    return succ_range(succ_begin(), succ_end());
269
44.2M
  }
270
2.06M
  inline succ_const_range successors() const {
271
2.06M
    return succ_const_range(succ_begin(), succ_end());
272
2.06M
  }
273
};
274
275
//===----------------------------------------------------------------------===//
276
//                          UnaryInstruction Class
277
//===----------------------------------------------------------------------===//
278
279
class UnaryInstruction : public Instruction {
280
protected:
281
  UnaryInstruction(Type *Ty, unsigned iType, Value *V,
282
                   Instruction *IB = nullptr)
283
16.4M
    : Instruction(Ty, iType, &Op<0>(), 1, IB) {
284
16.4M
    Op<0>() = V;
285
16.4M
  }
286
  UnaryInstruction(Type *Ty, unsigned iType, Value *V, BasicBlock *IAE)
287
185k
    : Instruction(Ty, iType, &Op<0>(), 1, IAE) {
288
185k
    Op<0>() = V;
289
185k
  }
290
291
public:
292
  // allocate space for exactly one operand
293
16.6M
  void *operator new(size_t s) {
294
16.6M
    return User::operator new(s, 1);
295
16.6M
  }
296
297
  /// Transparently provide more efficient getOperand methods.
298
  DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
299
300
  // Methods for support type inquiry through isa, cast, and dyn_cast:
301
11
  static bool classof(const Instruction *I) {
302
11
    return I->getOpcode() == Instruction::Alloca ||
303
11
           I->getOpcode() == Instruction::Load ||
304
11
           I->getOpcode() == Instruction::VAArg ||
305
11
           I->getOpcode() == Instruction::ExtractValue ||
306
11
           
(I->getOpcode() >= CastOpsBegin && 11
I->getOpcode() < CastOpsEnd4
);
307
11
  }
308
0
  static bool classof(const Value *V) {
309
0
    return isa<Instruction>(V) && classof(cast<Instruction>(V));
310
0
  }
311
};
312
313
template <>
314
struct OperandTraits<UnaryInstruction> :
315
  public FixedNumOperandTraits<UnaryInstruction, 1> {
316
};
317
318
DEFINE_TRANSPARENT_OPERAND_ACCESSORS(UnaryInstruction, Value)
319
320
//===----------------------------------------------------------------------===//
321
//                           BinaryOperator Class
322
//===----------------------------------------------------------------------===//
323
324
class BinaryOperator : public Instruction {
325
  void AssertOK();
326
327
protected:
328
  BinaryOperator(BinaryOps iType, Value *S1, Value *S2, Type *Ty,
329
                 const Twine &Name, Instruction *InsertBefore);
330
  BinaryOperator(BinaryOps iType, Value *S1, Value *S2, Type *Ty,
331
                 const Twine &Name, BasicBlock *InsertAtEnd);
332
333
  // Note: Instruction needs to be a friend here to call cloneImpl.
334
  friend class Instruction;
335
336
  BinaryOperator *cloneImpl() const;
337
338
public:
339
  // allocate space for exactly two operands
340
3.66M
  void *operator new(size_t s) {
341
3.66M
    return User::operator new(s, 2);
342
3.66M
  }
343
344
  /// Transparently provide more efficient getOperand methods.
345
  DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
346
347
  /// Construct a binary instruction, given the opcode and the two
348
  /// operands.  Optionally (if InstBefore is specified) insert the instruction
349
  /// into a BasicBlock right before the specified instruction.  The specified
350
  /// Instruction is allowed to be a dereferenced end iterator.
351
  ///
352
  static BinaryOperator *Create(BinaryOps Op, Value *S1, Value *S2,
353
                                const Twine &Name = Twine(),
354
                                Instruction *InsertBefore = nullptr);
355
356
  /// Construct a binary instruction, given the opcode and the two
357
  /// operands.  Also automatically insert this instruction to the end of the
358
  /// BasicBlock specified.
359
  ///
360
  static BinaryOperator *Create(BinaryOps Op, Value *S1, Value *S2,
361
                                const Twine &Name, BasicBlock *InsertAtEnd);
362
363
  /// These methods just forward to Create, and are useful when you
364
  /// statically know what type of instruction you're going to create.  These
365
  /// helpers just save some typing.
366
#define HANDLE_BINARY_INST(N, OPC, CLASS) \
367
  static BinaryOperator *Create##OPC(Value *V1, Value *V2, \
368
366k
                                     const Twine &Name = "") {\
369
366k
    return Create(Instruction::OPC, V1, V2, Name);\
370
366k
  }
llvm::BinaryOperator::CreateMul(llvm::Value*, llvm::Value*, llvm::Twine const&)
Line
Count
Source
368
737
                                     const Twine &Name = "") {\
369
737
    return Create(Instruction::OPC, V1, V2, Name);\
370
737
  }
llvm::BinaryOperator::CreateUDiv(llvm::Value*, llvm::Value*, llvm::Twine const&)
Line
Count
Source
368
2.34k
                                     const Twine &Name = "") {\
369
2.34k
    return Create(Instruction::OPC, V1, V2, Name);\
370
2.34k
  }
llvm::BinaryOperator::CreateXor(llvm::Value*, llvm::Value*, llvm::Twine const&)
Line
Count
Source
368
12.1k
                                     const Twine &Name = "") {\
369
12.1k
    return Create(Instruction::OPC, V1, V2, Name);\
370
12.1k
  }
llvm::BinaryOperator::CreateOr(llvm::Value*, llvm::Value*, llvm::Twine const&)
Line
Count
Source
368
63.8k
                                     const Twine &Name = "") {\
369
63.8k
    return Create(Instruction::OPC, V1, V2, Name);\
370
63.8k
  }
llvm::BinaryOperator::CreateAdd(llvm::Value*, llvm::Value*, llvm::Twine const&)
Line
Count
Source
368
22.9k
                                     const Twine &Name = "") {\
369
22.9k
    return Create(Instruction::OPC, V1, V2, Name);\
370
22.9k
  }
llvm::BinaryOperator::CreateAnd(llvm::Value*, llvm::Value*, llvm::Twine const&)
Line
Count
Source
368
86.6k
                                     const Twine &Name = "") {\
369
86.6k
    return Create(Instruction::OPC, V1, V2, Name);\
370
86.6k
  }
llvm::BinaryOperator::CreateFAdd(llvm::Value*, llvm::Value*, llvm::Twine const&)
Line
Count
Source
368
26.2k
                                     const Twine &Name = "") {\
369
26.2k
    return Create(Instruction::OPC, V1, V2, Name);\
370
26.2k
  }
llvm::BinaryOperator::CreateSub(llvm::Value*, llvm::Value*, llvm::Twine const&)
Line
Count
Source
368
12.4k
                                     const Twine &Name = "") {\
369
12.4k
    return Create(Instruction::OPC, V1, V2, Name);\
370
12.4k
  }
llvm::BinaryOperator::CreateFSub(llvm::Value*, llvm::Value*, llvm::Twine const&)
Line
Count
Source
368
14.2k
                                     const Twine &Name = "") {\
369
14.2k
    return Create(Instruction::OPC, V1, V2, Name);\
370
14.2k
  }
llvm::BinaryOperator::CreateAShr(llvm::Value*, llvm::Value*, llvm::Twine const&)
Line
Count
Source
368
17.5k
                                     const Twine &Name = "") {\
369
17.5k
    return Create(Instruction::OPC, V1, V2, Name);\
370
17.5k
  }
llvm::BinaryOperator::CreateLShr(llvm::Value*, llvm::Value*, llvm::Twine const&)
Line
Count
Source
368
29.7k
                                     const Twine &Name = "") {\
369
29.7k
    return Create(Instruction::OPC, V1, V2, Name);\
370
29.7k
  }
llvm::BinaryOperator::CreateShl(llvm::Value*, llvm::Value*, llvm::Twine const&)
Line
Count
Source
368
29.8k
                                     const Twine &Name = "") {\
369
29.8k
    return Create(Instruction::OPC, V1, V2, Name);\
370
29.8k
  }
llvm::BinaryOperator::CreateFRem(llvm::Value*, llvm::Value*, llvm::Twine const&)
Line
Count
Source
368
6
                                     const Twine &Name = "") {\
369
6
    return Create(Instruction::OPC, V1, V2, Name);\
370
6
  }
llvm::BinaryOperator::CreateFMul(llvm::Value*, llvm::Value*, llvm::Twine const&)
Line
Count
Source
368
20.2k
                                     const Twine &Name = "") {\
369
20.2k
    return Create(Instruction::OPC, V1, V2, Name);\
370
20.2k
  }
llvm::BinaryOperator::CreateSRem(llvm::Value*, llvm::Value*, llvm::Twine const&)
Line
Count
Source
368
1.96k
                                     const Twine &Name = "") {\
369
1.96k
    return Create(Instruction::OPC, V1, V2, Name);\
370
1.96k
  }
llvm::BinaryOperator::CreateURem(llvm::Value*, llvm::Value*, llvm::Twine const&)
Line
Count
Source
368
7.77k
                                     const Twine &Name = "") {\
369
7.77k
    return Create(Instruction::OPC, V1, V2, Name);\
370
7.77k
  }
llvm::BinaryOperator::CreateFDiv(llvm::Value*, llvm::Value*, llvm::Twine const&)
Line
Count
Source
368
11.1k
                                     const Twine &Name = "") {\
369
11.1k
    return Create(Instruction::OPC, V1, V2, Name);\
370
11.1k
  }
llvm::BinaryOperator::CreateSDiv(llvm::Value*, llvm::Value*, llvm::Twine const&)
Line
Count
Source
368
6.12k
                                     const Twine &Name = "") {\
369
6.12k
    return Create(Instruction::OPC, V1, V2, Name);\
370
6.12k
  }
371
#include "llvm/IR/Instruction.def"
372
#define HANDLE_BINARY_INST(N, OPC, CLASS) \
373
  static BinaryOperator *Create##OPC(Value *V1, Value *V2, \
374
356
                                     const Twine &Name, BasicBlock *BB) {\
375
356
    return Create(Instruction::OPC, V1, V2, Name, BB);\
376
356
  }
Unexecuted instantiation: llvm::BinaryOperator::CreateUDiv(llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::BasicBlock*)
Unexecuted instantiation: llvm::BinaryOperator::CreateSDiv(llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::BasicBlock*)
Unexecuted instantiation: llvm::BinaryOperator::CreateAnd(llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::BasicBlock*)
Unexecuted instantiation: llvm::BinaryOperator::CreateAShr(llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::BasicBlock*)
Unexecuted instantiation: llvm::BinaryOperator::CreateLShr(llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::BasicBlock*)
llvm::BinaryOperator::CreateAdd(llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::BasicBlock*)
Line
Count
Source
374
182
                                     const Twine &Name, BasicBlock *BB) {\
375
182
    return Create(Instruction::OPC, V1, V2, Name, BB);\
376
182
  }
Unexecuted instantiation: llvm::BinaryOperator::CreateFRem(llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::BasicBlock*)
Unexecuted instantiation: llvm::BinaryOperator::CreateShl(llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::BasicBlock*)
Unexecuted instantiation: llvm::BinaryOperator::CreateOr(llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::BasicBlock*)
Unexecuted instantiation: llvm::BinaryOperator::CreateXor(llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::BasicBlock*)
Unexecuted instantiation: llvm::BinaryOperator::CreateFAdd(llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::BasicBlock*)
Unexecuted instantiation: llvm::BinaryOperator::CreateSub(llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::BasicBlock*)
Unexecuted instantiation: llvm::BinaryOperator::CreateFSub(llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::BasicBlock*)
llvm::BinaryOperator::CreateMul(llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::BasicBlock*)
Line
Count
Source
374
174
                                     const Twine &Name, BasicBlock *BB) {\
375
174
    return Create(Instruction::OPC, V1, V2, Name, BB);\
376
174
  }
Unexecuted instantiation: llvm::BinaryOperator::CreateFDiv(llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::BasicBlock*)
Unexecuted instantiation: llvm::BinaryOperator::CreateURem(llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::BasicBlock*)
Unexecuted instantiation: llvm::BinaryOperator::CreateFMul(llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::BasicBlock*)
Unexecuted instantiation: llvm::BinaryOperator::CreateSRem(llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::BasicBlock*)
377
#include "llvm/IR/Instruction.def"
378
#define HANDLE_BINARY_INST(N, OPC, CLASS) \
379
  static BinaryOperator *Create##OPC(Value *V1, Value *V2, \
380
36.8k
                                     const Twine &Name, Instruction *I) {\
381
36.8k
    return Create(Instruction::OPC, V1, V2, Name, I);\
382
36.8k
  }
llvm::BinaryOperator::CreateOr(llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::Instruction*)
Line
Count
Source
380
14
                                     const Twine &Name, Instruction *I) {\
381
14
    return Create(Instruction::OPC, V1, V2, Name, I);\
382
14
  }
llvm::BinaryOperator::CreateURem(llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::Instruction*)
Line
Count
Source
380
59
                                     const Twine &Name, Instruction *I) {\
381
59
    return Create(Instruction::OPC, V1, V2, Name, I);\
382
59
  }
Unexecuted instantiation: llvm::BinaryOperator::CreateFDiv(llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::Instruction*)
llvm::BinaryOperator::CreateUDiv(llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::Instruction*)
Line
Count
Source
380
290
                                     const Twine &Name, Instruction *I) {\
381
290
    return Create(Instruction::OPC, V1, V2, Name, I);\
382
290
  }
llvm::BinaryOperator::CreateFMul(llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::Instruction*)
Line
Count
Source
380
52
                                     const Twine &Name, Instruction *I) {\
381
52
    return Create(Instruction::OPC, V1, V2, Name, I);\
382
52
  }
llvm::BinaryOperator::CreateMul(llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::Instruction*)
Line
Count
Source
380
21.0k
                                     const Twine &Name, Instruction *I) {\
381
21.0k
    return Create(Instruction::OPC, V1, V2, Name, I);\
382
21.0k
  }
Unexecuted instantiation: llvm::BinaryOperator::CreateFSub(llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::Instruction*)
Unexecuted instantiation: llvm::BinaryOperator::CreateSub(llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::Instruction*)
llvm::BinaryOperator::CreateFAdd(llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::Instruction*)
Line
Count
Source
380
48
                                     const Twine &Name, Instruction *I) {\
381
48
    return Create(Instruction::OPC, V1, V2, Name, I);\
382
48
  }
llvm::BinaryOperator::CreateAdd(llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::Instruction*)
Line
Count
Source
380
14.9k
                                     const Twine &Name, Instruction *I) {\
381
14.9k
    return Create(Instruction::OPC, V1, V2, Name, I);\
382
14.9k
  }
llvm::BinaryOperator::CreateXor(llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::Instruction*)
Line
Count
Source
380
1
                                     const Twine &Name, Instruction *I) {\
381
1
    return Create(Instruction::OPC, V1, V2, Name, I);\
382
1
  }
Unexecuted instantiation: llvm::BinaryOperator::CreateSRem(llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::Instruction*)
Unexecuted instantiation: llvm::BinaryOperator::CreateShl(llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::Instruction*)
Unexecuted instantiation: llvm::BinaryOperator::CreateFRem(llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::Instruction*)
llvm::BinaryOperator::CreateLShr(llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::Instruction*)
Line
Count
Source
380
369
                                     const Twine &Name, Instruction *I) {\
381
369
    return Create(Instruction::OPC, V1, V2, Name, I);\
382
369
  }
Unexecuted instantiation: llvm::BinaryOperator::CreateSDiv(llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::Instruction*)
llvm::BinaryOperator::CreateAShr(llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::Instruction*)
Line
Count
Source
380
36
                                     const Twine &Name, Instruction *I) {\
381
36
    return Create(Instruction::OPC, V1, V2, Name, I);\
382
36
  }
llvm::BinaryOperator::CreateAnd(llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::Instruction*)
Line
Count
Source
380
52
                                     const Twine &Name, Instruction *I) {\
381
52
    return Create(Instruction::OPC, V1, V2, Name, I);\
382
52
  }
383
#include "llvm/IR/Instruction.def"
384
385
  static BinaryOperator *CreateWithCopiedFlags(BinaryOps Opc,
386
                                               Value *V1, Value *V2,
387
                                               BinaryOperator *CopyBO,
388
41
                                               const Twine &Name = "") {
389
41
    BinaryOperator *BO = Create(Opc, V1, V2, Name);
390
41
    BO->copyIRFlags(CopyBO);
391
41
    return BO;
392
41
  }
393
394
  static BinaryOperator *CreateNSW(BinaryOps Opc, Value *V1, Value *V2,
395
0
                                   const Twine &Name = "") {
396
0
    BinaryOperator *BO = Create(Opc, V1, V2, Name);
397
0
    BO->setHasNoSignedWrap(true);
398
0
    return BO;
399
0
  }
400
  static BinaryOperator *CreateNSW(BinaryOps Opc, Value *V1, Value *V2,
401
20
                                   const Twine &Name, BasicBlock *BB) {
402
20
    BinaryOperator *BO = Create(Opc, V1, V2, Name, BB);
403
20
    BO->setHasNoSignedWrap(true);
404
20
    return BO;
405
20
  }
406
  static BinaryOperator *CreateNSW(BinaryOps Opc, Value *V1, Value *V2,
407
0
                                   const Twine &Name, Instruction *I) {
408
0
    BinaryOperator *BO = Create(Opc, V1, V2, Name, I);
409
0
    BO->setHasNoSignedWrap(true);
410
0
    return BO;
411
0
  }
412
413
  static BinaryOperator *CreateNUW(BinaryOps Opc, Value *V1, Value *V2,
414
0
                                   const Twine &Name = "") {
415
0
    BinaryOperator *BO = Create(Opc, V1, V2, Name);
416
0
    BO->setHasNoUnsignedWrap(true);
417
0
    return BO;
418
0
  }
419
  static BinaryOperator *CreateNUW(BinaryOps Opc, Value *V1, Value *V2,
420
0
                                   const Twine &Name, BasicBlock *BB) {
421
0
    BinaryOperator *BO = Create(Opc, V1, V2, Name, BB);
422
0
    BO->setHasNoUnsignedWrap(true);
423
0
    return BO;
424
0
  }
425
  static BinaryOperator *CreateNUW(BinaryOps Opc, Value *V1, Value *V2,
426
0
                                   const Twine &Name, Instruction *I) {
427
0
    BinaryOperator *BO = Create(Opc, V1, V2, Name, I);
428
0
    BO->setHasNoUnsignedWrap(true);
429
0
    return BO;
430
0
  }
431
432
  static BinaryOperator *CreateExact(BinaryOps Opc, Value *V1, Value *V2,
433
1.32k
                                     const Twine &Name = "") {
434
1.32k
    BinaryOperator *BO = Create(Opc, V1, V2, Name);
435
1.32k
    BO->setIsExact(true);
436
1.32k
    return BO;
437
1.32k
  }
438
  static BinaryOperator *CreateExact(BinaryOps Opc, Value *V1, Value *V2,
439
0
                                     const Twine &Name, BasicBlock *BB) {
440
0
    BinaryOperator *BO = Create(Opc, V1, V2, Name, BB);
441
0
    BO->setIsExact(true);
442
0
    return BO;
443
0
  }
444
  static BinaryOperator *CreateExact(BinaryOps Opc, Value *V1, Value *V2,
445
0
                                     const Twine &Name, Instruction *I) {
446
0
    BinaryOperator *BO = Create(Opc, V1, V2, Name, I);
447
0
    BO->setIsExact(true);
448
0
    return BO;
449
0
  }
450
451
#define DEFINE_HELPERS(OPC, NUWNSWEXACT)                                       \
452
  static BinaryOperator *Create##NUWNSWEXACT##OPC(Value *V1, Value *V2,        \
453
1.32k
                                                  const Twine &Name = "") {    \
454
1.32k
    return Create##NUWNSWEXACT(Instruction::OPC, V1, V2, Name);                \
455
1.32k
  }                                                                            \
Unexecuted instantiation: llvm::BinaryOperator::CreateNUWAdd(llvm::Value*, llvm::Value*, llvm::Twine const&)
Unexecuted instantiation: llvm::BinaryOperator::CreateNSWSub(llvm::Value*, llvm::Value*, llvm::Twine const&)
Unexecuted instantiation: llvm::BinaryOperator::CreateNUWSub(llvm::Value*, llvm::Value*, llvm::Twine const&)
Unexecuted instantiation: llvm::BinaryOperator::CreateNSWMul(llvm::Value*, llvm::Value*, llvm::Twine const&)
Unexecuted instantiation: llvm::BinaryOperator::CreateNSWAdd(llvm::Value*, llvm::Value*, llvm::Twine const&)
llvm::BinaryOperator::CreateExactAShr(llvm::Value*, llvm::Value*, llvm::Twine const&)
Line
Count
Source
453
334
                                                  const Twine &Name = "") {    \
454
334
    return Create##NUWNSWEXACT(Instruction::OPC, V1, V2, Name);                \
455
334
  }                                                                            \
llvm::BinaryOperator::CreateExactSDiv(llvm::Value*, llvm::Value*, llvm::Twine const&)
Line
Count
Source
453
801
                                                  const Twine &Name = "") {    \
454
801
    return Create##NUWNSWEXACT(Instruction::OPC, V1, V2, Name);                \
455
801
  }                                                                            \
Unexecuted instantiation: llvm::BinaryOperator::CreateNUWShl(llvm::Value*, llvm::Value*, llvm::Twine const&)
Unexecuted instantiation: llvm::BinaryOperator::CreateNSWShl(llvm::Value*, llvm::Value*, llvm::Twine const&)
Unexecuted instantiation: llvm::BinaryOperator::CreateNUWMul(llvm::Value*, llvm::Value*, llvm::Twine const&)
llvm::BinaryOperator::CreateExactUDiv(llvm::Value*, llvm::Value*, llvm::Twine const&)
Line
Count
Source
453
186
                                                  const Twine &Name = "") {    \
454
186
    return Create##NUWNSWEXACT(Instruction::OPC, V1, V2, Name);                \
455
186
  }                                                                            \
llvm::BinaryOperator::CreateExactLShr(llvm::Value*, llvm::Value*, llvm::Twine const&)
Line
Count
Source
453
2
                                                  const Twine &Name = "") {    \
454
2
    return Create##NUWNSWEXACT(Instruction::OPC, V1, V2, Name);                \
455
2
  }                                                                            \
456
  static BinaryOperator *Create##NUWNSWEXACT##OPC(                             \
457
0
      Value *V1, Value *V2, const Twine &Name, BasicBlock *BB) {               \
458
0
    return Create##NUWNSWEXACT(Instruction::OPC, V1, V2, Name, BB);            \
459
0
  }                                                                            \
Unexecuted instantiation: llvm::BinaryOperator::CreateExactLShr(llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::BasicBlock*)
Unexecuted instantiation: llvm::BinaryOperator::CreateNUWSub(llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::BasicBlock*)
Unexecuted instantiation: llvm::BinaryOperator::CreateNUWMul(llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::BasicBlock*)
Unexecuted instantiation: llvm::BinaryOperator::CreateNSWShl(llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::BasicBlock*)
Unexecuted instantiation: llvm::BinaryOperator::CreateNUWShl(llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::BasicBlock*)
Unexecuted instantiation: llvm::BinaryOperator::CreateExactSDiv(llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::BasicBlock*)
Unexecuted instantiation: llvm::BinaryOperator::CreateNSWAdd(llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::BasicBlock*)
Unexecuted instantiation: llvm::BinaryOperator::CreateNUWAdd(llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::BasicBlock*)
Unexecuted instantiation: llvm::BinaryOperator::CreateNSWSub(llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::BasicBlock*)
Unexecuted instantiation: llvm::BinaryOperator::CreateNSWMul(llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::BasicBlock*)
Unexecuted instantiation: llvm::BinaryOperator::CreateExactAShr(llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::BasicBlock*)
Unexecuted instantiation: llvm::BinaryOperator::CreateExactUDiv(llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::BasicBlock*)
460
  static BinaryOperator *Create##NUWNSWEXACT##OPC(                             \
461
0
      Value *V1, Value *V2, const Twine &Name, Instruction *I) {               \
462
0
    return Create##NUWNSWEXACT(Instruction::OPC, V1, V2, Name, I);             \
463
0
  }
Unexecuted instantiation: llvm::BinaryOperator::CreateNUWSub(llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::Instruction*)
Unexecuted instantiation: llvm::BinaryOperator::CreateNSWMul(llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::Instruction*)
Unexecuted instantiation: llvm::BinaryOperator::CreateNSWSub(llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::Instruction*)
Unexecuted instantiation: llvm::BinaryOperator::CreateNUWAdd(llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::Instruction*)
Unexecuted instantiation: llvm::BinaryOperator::CreateNSWAdd(llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::Instruction*)
Unexecuted instantiation: llvm::BinaryOperator::CreateNUWShl(llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::Instruction*)
Unexecuted instantiation: llvm::BinaryOperator::CreateExactUDiv(llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::Instruction*)
Unexecuted instantiation: llvm::BinaryOperator::CreateExactSDiv(llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::Instruction*)
Unexecuted instantiation: llvm::BinaryOperator::CreateNUWMul(llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::Instruction*)
Unexecuted instantiation: llvm::BinaryOperator::CreateNSWShl(llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::Instruction*)
Unexecuted instantiation: llvm::BinaryOperator::CreateExactLShr(llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::Instruction*)
Unexecuted instantiation: llvm::BinaryOperator::CreateExactAShr(llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::Instruction*)
464
465
  DEFINE_HELPERS(Add, NSW) // CreateNSWAdd
466
  DEFINE_HELPERS(Add, NUW) // CreateNUWAdd
467
  DEFINE_HELPERS(Sub, NSW) // CreateNSWSub
468
  DEFINE_HELPERS(Sub, NUW) // CreateNUWSub
469
  DEFINE_HELPERS(Mul, NSW) // CreateNSWMul
470
  DEFINE_HELPERS(Mul, NUW) // CreateNUWMul
471
  DEFINE_HELPERS(Shl, NSW) // CreateNSWShl
472
  DEFINE_HELPERS(Shl, NUW) // CreateNUWShl
473
474
  DEFINE_HELPERS(SDiv, Exact)  // CreateExactSDiv
475
  DEFINE_HELPERS(UDiv, Exact)  // CreateExactUDiv
476
  DEFINE_HELPERS(AShr, Exact)  // CreateExactAShr
477
  DEFINE_HELPERS(LShr, Exact)  // CreateExactLShr
478
479
#undef DEFINE_HELPERS
480
481
  /// Helper functions to construct and inspect unary operations (NEG and NOT)
482
  /// via binary operators SUB and XOR:
483
  ///
484
  /// Create the NEG and NOT instructions out of SUB and XOR instructions.
485
  ///
486
  static BinaryOperator *CreateNeg(Value *Op, const Twine &Name = "",
487
                                   Instruction *InsertBefore = nullptr);
488
  static BinaryOperator *CreateNeg(Value *Op, const Twine &Name,
489
                                   BasicBlock *InsertAtEnd);
490
  static BinaryOperator *CreateNSWNeg(Value *Op, const Twine &Name = "",
491
                                      Instruction *InsertBefore = nullptr);
492
  static BinaryOperator *CreateNSWNeg(Value *Op, const Twine &Name,
493
                                      BasicBlock *InsertAtEnd);
494
  static BinaryOperator *CreateNUWNeg(Value *Op, const Twine &Name = "",
495
                                      Instruction *InsertBefore = nullptr);
496
  static BinaryOperator *CreateNUWNeg(Value *Op, const Twine &Name,
497
                                      BasicBlock *InsertAtEnd);
498
  static BinaryOperator *CreateFNeg(Value *Op, const Twine &Name = "",
499
                                    Instruction *InsertBefore = nullptr);
500
  static BinaryOperator *CreateFNeg(Value *Op, const Twine &Name,
501
                                    BasicBlock *InsertAtEnd);
502
  static BinaryOperator *CreateNot(Value *Op, const Twine &Name = "",
503
                                   Instruction *InsertBefore = nullptr);
504
  static BinaryOperator *CreateNot(Value *Op, const Twine &Name,
505
                                   BasicBlock *InsertAtEnd);
506
507
  /// Check if the given Value is a NEG, FNeg, or NOT instruction.
508
  ///
509
  static bool isNeg(const Value *V);
510
  static bool isFNeg(const Value *V, bool IgnoreZeroSign=false);
511
  static bool isNot(const Value *V);
512
513
  /// Helper functions to extract the unary argument of a NEG, FNEG or NOT
514
  /// operation implemented via Sub, FSub, or Xor.
515
  ///
516
  static const Value *getNegArgument(const Value *BinOp);
517
  static       Value *getNegArgument(      Value *BinOp);
518
  static const Value *getFNegArgument(const Value *BinOp);
519
  static       Value *getFNegArgument(      Value *BinOp);
520
  static const Value *getNotArgument(const Value *BinOp);
521
  static       Value *getNotArgument(      Value *BinOp);
522
523
284M
  BinaryOps getOpcode() const {
524
284M
    return static_cast<BinaryOps>(Instruction::getOpcode());
525
284M
  }
526
527
  /// Exchange the two operands to this instruction.
528
  /// This instruction is safe to use on any binary instruction and
529
  /// does not modify the semantics of the instruction.  If the instruction
530
  /// cannot be reversed (ie, it's a Div), then return true.
531
  ///
532
  bool swapOperands();
533
534
  // Methods for support type inquiry through isa, cast, and dyn_cast:
535
772M
  static bool classof(const Instruction *I) {
536
772M
    return I->isBinaryOp();
537
772M
  }
538
663M
  static bool classof(const Value *V) {
539
529M
    return isa<Instruction>(V) && classof(cast<Instruction>(V));
540
663M
  }
541
};
542
543
template <>
544
struct OperandTraits<BinaryOperator> :
545
  public FixedNumOperandTraits<BinaryOperator, 2> {
546
};
547
548
DEFINE_TRANSPARENT_OPERAND_ACCESSORS(BinaryOperator, Value)
549
550
//===----------------------------------------------------------------------===//
551
//                               CastInst Class
552
//===----------------------------------------------------------------------===//
553
554
/// This is the base class for all instructions that perform data
555
/// casts. It is simply provided so that instruction category testing
556
/// can be performed with code like:
557
///
558
/// if (isa<CastInst>(Instr)) { ... }
559
/// @brief Base class of casting instructions.
560
class CastInst : public UnaryInstruction {
561
protected:
562
  /// @brief Constructor with insert-before-instruction semantics for subclasses
563
  CastInst(Type *Ty, unsigned iType, Value *S,
564
           const Twine &NameStr = "", Instruction *InsertBefore = nullptr)
565
6.80M
    : UnaryInstruction(Ty, iType, S, InsertBefore) {
566
6.80M
    setName(NameStr);
567
6.80M
  }
568
  /// @brief Constructor with insert-at-end-of-block semantics for subclasses
569
  CastInst(Type *Ty, unsigned iType, Value *S,
570
           const Twine &NameStr, BasicBlock *InsertAtEnd)
571
185k
    : UnaryInstruction(Ty, iType, S, InsertAtEnd) {
572
185k
    setName(NameStr);
573
185k
  }
574
575
public:
576
  /// Provides a way to construct any of the CastInst subclasses using an
577
  /// opcode instead of the subclass's constructor. The opcode must be in the
578
  /// CastOps category (Instruction::isCast(opcode) returns true). This
579
  /// constructor has insert-before-instruction semantics to automatically
580
  /// insert the new CastInst before InsertBefore (if it is non-null).
581
  /// @brief Construct any of the CastInst subclasses
582
  static CastInst *Create(
583
    Instruction::CastOps,    ///< The opcode of the cast instruction
584
    Value *S,                ///< The value to be casted (operand 0)
585
    Type *Ty,          ///< The type to which cast should be made
586
    const Twine &Name = "", ///< Name for the instruction
587
    Instruction *InsertBefore = nullptr ///< Place to insert the instruction
588
  );
589
  /// Provides a way to construct any of the CastInst subclasses using an
590
  /// opcode instead of the subclass's constructor. The opcode must be in the
591
  /// CastOps category. This constructor has insert-at-end-of-block semantics
592
  /// to automatically insert the new CastInst at the end of InsertAtEnd (if
593
  /// its non-null).
594
  /// @brief Construct any of the CastInst subclasses
595
  static CastInst *Create(
596
    Instruction::CastOps,    ///< The opcode for the cast instruction
597
    Value *S,                ///< The value to be casted (operand 0)
598
    Type *Ty,          ///< The type to which operand is casted
599
    const Twine &Name, ///< The name for the instruction
600
    BasicBlock *InsertAtEnd  ///< The block to insert the instruction into
601
  );
602
603
  /// @brief Create a ZExt or BitCast cast instruction
604
  static CastInst *CreateZExtOrBitCast(
605
    Value *S,                ///< The value to be casted (operand 0)
606
    Type *Ty,          ///< The type to which cast should be made
607
    const Twine &Name = "", ///< Name for the instruction
608
    Instruction *InsertBefore = nullptr ///< Place to insert the instruction
609
  );
610
611
  /// @brief Create a ZExt or BitCast cast instruction
612
  static CastInst *CreateZExtOrBitCast(
613
    Value *S,                ///< The value to be casted (operand 0)
614
    Type *Ty,          ///< The type to which operand is casted
615
    const Twine &Name, ///< The name for the instruction
616
    BasicBlock *InsertAtEnd  ///< The block to insert the instruction into
617
  );
618
619
  /// @brief Create a SExt or BitCast cast instruction
620
  static CastInst *CreateSExtOrBitCast(
621
    Value *S,                ///< The value to be casted (operand 0)
622
    Type *Ty,          ///< The type to which cast should be made
623
    const Twine &Name = "", ///< Name for the instruction
624
    Instruction *InsertBefore = nullptr ///< Place to insert the instruction
625
  );
626
627
  /// @brief Create a SExt or BitCast cast instruction
628
  static CastInst *CreateSExtOrBitCast(
629
    Value *S,                ///< The value to be casted (operand 0)
630
    Type *Ty,          ///< The type to which operand is casted
631
    const Twine &Name, ///< The name for the instruction
632
    BasicBlock *InsertAtEnd  ///< The block to insert the instruction into
633
  );
634
635
  /// @brief Create a BitCast AddrSpaceCast, or a PtrToInt cast instruction.
636
  static CastInst *CreatePointerCast(
637
    Value *S,                ///< The pointer value to be casted (operand 0)
638
    Type *Ty,          ///< The type to which operand is casted
639
    const Twine &Name, ///< The name for the instruction
640
    BasicBlock *InsertAtEnd  ///< The block to insert the instruction into
641
  );
642
643
  /// @brief Create a BitCast, AddrSpaceCast or a PtrToInt cast instruction.
644
  static CastInst *CreatePointerCast(
645
    Value *S,                ///< The pointer value to be casted (operand 0)
646
    Type *Ty,          ///< The type to which cast should be made
647
    const Twine &Name = "", ///< Name for the instruction
648
    Instruction *InsertBefore = nullptr ///< Place to insert the instruction
649
  );
650
651
  /// @brief Create a BitCast or an AddrSpaceCast cast instruction.
652
  static CastInst *CreatePointerBitCastOrAddrSpaceCast(
653
    Value *S,                ///< The pointer value to be casted (operand 0)
654
    Type *Ty,          ///< The type to which operand is casted
655
    const Twine &Name, ///< The name for the instruction
656
    BasicBlock *InsertAtEnd  ///< The block to insert the instruction into
657
  );
658
659
  /// @brief Create a BitCast or an AddrSpaceCast cast instruction.
660
  static CastInst *CreatePointerBitCastOrAddrSpaceCast(
661
    Value *S,                ///< The pointer value to be casted (operand 0)
662
    Type *Ty,          ///< The type to which cast should be made
663
    const Twine &Name = "", ///< Name for the instruction
664
    Instruction *InsertBefore = nullptr ///< Place to insert the instruction
665
  );
666
667
  /// @brief Create a BitCast, a PtrToInt, or an IntToPTr cast instruction.
668
  ///
669
  /// If the value is a pointer type and the destination an integer type,
670
  /// creates a PtrToInt cast. If the value is an integer type and the
671
  /// destination a pointer type, creates an IntToPtr cast. Otherwise, creates
672
  /// a bitcast.
673
  static CastInst *CreateBitOrPointerCast(
674
    Value *S,                ///< The pointer value to be casted (operand 0)
675
    Type *Ty,          ///< The type to which cast should be made
676
    const Twine &Name = "", ///< Name for the instruction
677
    Instruction *InsertBefore = nullptr ///< Place to insert the instruction
678
  );
679
680
  /// @brief Create a ZExt, BitCast, or Trunc for int -> int casts.
681
  static CastInst *CreateIntegerCast(
682
    Value *S,                ///< The pointer value to be casted (operand 0)
683
    Type *Ty,          ///< The type to which cast should be made
684
    bool isSigned,           ///< Whether to regard S as signed or not
685
    const Twine &Name = "", ///< Name for the instruction
686
    Instruction *InsertBefore = nullptr ///< Place to insert the instruction
687
  );
688
689
  /// @brief Create a ZExt, BitCast, or Trunc for int -> int casts.
690
  static CastInst *CreateIntegerCast(
691
    Value *S,                ///< The integer value to be casted (operand 0)
692
    Type *Ty,          ///< The integer type to which operand is casted
693
    bool isSigned,           ///< Whether to regard S as signed or not
694
    const Twine &Name, ///< The name for the instruction
695
    BasicBlock *InsertAtEnd  ///< The block to insert the instruction into
696
  );
697
698
  /// @brief Create an FPExt, BitCast, or FPTrunc for fp -> fp casts
699
  static CastInst *CreateFPCast(
700
    Value *S,                ///< The floating point value to be casted
701
    Type *Ty,          ///< The floating point type to cast to
702
    const Twine &Name = "", ///< Name for the instruction
703
    Instruction *InsertBefore = nullptr ///< Place to insert the instruction
704
  );
705
706
  /// @brief Create an FPExt, BitCast, or FPTrunc for fp -> fp casts
707
  static CastInst *CreateFPCast(
708
    Value *S,                ///< The floating point value to be casted
709
    Type *Ty,          ///< The floating point type to cast to
710
    const Twine &Name, ///< The name for the instruction
711
    BasicBlock *InsertAtEnd  ///< The block to insert the instruction into
712
  );
713
714
  /// @brief Create a Trunc or BitCast cast instruction
715
  static CastInst *CreateTruncOrBitCast(
716
    Value *S,                ///< The value to be casted (operand 0)
717
    Type *Ty,          ///< The type to which cast should be made
718
    const Twine &Name = "", ///< Name for the instruction
719
    Instruction *InsertBefore = nullptr ///< Place to insert the instruction
720
  );
721
722
  /// @brief Create a Trunc or BitCast cast instruction
723
  static CastInst *CreateTruncOrBitCast(
724
    Value *S,                ///< The value to be casted (operand 0)
725
    Type *Ty,          ///< The type to which operand is casted
726
    const Twine &Name, ///< The name for the instruction
727
    BasicBlock *InsertAtEnd  ///< The block to insert the instruction into
728
  );
729
730
  /// @brief Check whether it is valid to call getCastOpcode for these types.
731
  static bool isCastable(
732
    Type *SrcTy, ///< The Type from which the value should be cast.
733
    Type *DestTy ///< The Type to which the value should be cast.
734
  );
735
736
  /// @brief Check whether a bitcast between these types is valid
737
  static bool isBitCastable(
738
    Type *SrcTy, ///< The Type from which the value should be cast.
739
    Type *DestTy ///< The Type to which the value should be cast.
740
  );
741
742
  /// @brief Check whether a bitcast, inttoptr, or ptrtoint cast between these
743
  /// types is valid and a no-op.
744
  ///
745
  /// This ensures that any pointer<->integer cast has enough bits in the
746
  /// integer and any other cast is a bitcast.
747
  static bool isBitOrNoopPointerCastable(
748
      Type *SrcTy,  ///< The Type from which the value should be cast.
749
      Type *DestTy, ///< The Type to which the value should be cast.
750
      const DataLayout &DL);
751
752
  /// Returns the opcode necessary to cast Val into Ty using usual casting
753
  /// rules.
754
  /// @brief Infer the opcode for cast operand and type
755
  static Instruction::CastOps getCastOpcode(
756
    const Value *Val, ///< The value to cast
757
    bool SrcIsSigned, ///< Whether to treat the source as signed
758
    Type *Ty,   ///< The Type to which the value should be casted
759
    bool DstIsSigned  ///< Whether to treate the dest. as signed
760
  );
761
762
  /// There are several places where we need to know if a cast instruction
763
  /// only deals with integer source and destination types. To simplify that
764
  /// logic, this method is provided.
765
  /// @returns true iff the cast has only integral typed operand and dest type.
766
  /// @brief Determine if this is an integer-only cast.
767
  bool isIntegerCast() const;
768
769
  /// A lossless cast is one that does not alter the basic value. It implies
770
  /// a no-op cast but is more stringent, preventing things like int->float,
771
  /// long->double, or int->ptr.
772
  /// @returns true iff the cast is lossless.
773
  /// @brief Determine if this is a lossless cast.
774
  bool isLosslessCast() const;
775
776
  /// A no-op cast is one that can be effected without changing any bits.
777
  /// It implies that the source and destination types are the same size. The
778
  /// IntPtrTy argument is used to make accurate determinations for casts
779
  /// involving Integer and Pointer types. They are no-op casts if the integer
780
  /// is the same size as the pointer. However, pointer size varies with
781
  /// platform. Generally, the result of DataLayout::getIntPtrType() should be
782
  /// passed in. If that's not available, use Type::Int64Ty, which will make
783
  /// the isNoopCast call conservative.
784
  /// @brief Determine if the described cast is a no-op cast.
785
  static bool isNoopCast(
786
    Instruction::CastOps Opcode,  ///< Opcode of cast
787
    Type *SrcTy,   ///< SrcTy of cast
788
    Type *DstTy,   ///< DstTy of cast
789
    Type *IntPtrTy ///< Integer type corresponding to Ptr types
790
  );
791
792
  /// @brief Determine if this cast is a no-op cast.
793
  bool isNoopCast(
794
    Type *IntPtrTy ///< Integer type corresponding to pointer
795
  ) const;
796
797
  /// @brief Determine if this cast is a no-op cast.
798
  ///
799
  /// \param DL is the DataLayout to get the Int Ptr type from.
800
  bool isNoopCast(const DataLayout &DL) const;
801
802
  /// Determine how a pair of casts can be eliminated, if they can be at all.
803
  /// This is a helper function for both CastInst and ConstantExpr.
804
  /// @returns 0 if the CastInst pair can't be eliminated, otherwise
805
  /// returns Instruction::CastOps value for a cast that can replace
806
  /// the pair, casting SrcTy to DstTy.
807
  /// @brief Determine if a cast pair is eliminable
808
  static unsigned isEliminableCastPair(
809
    Instruction::CastOps firstOpcode,  ///< Opcode of first cast
810
    Instruction::CastOps secondOpcode, ///< Opcode of second cast
811
    Type *SrcTy, ///< SrcTy of 1st cast
812
    Type *MidTy, ///< DstTy of 1st cast & SrcTy of 2nd cast
813
    Type *DstTy, ///< DstTy of 2nd cast
814
    Type *SrcIntPtrTy, ///< Integer type corresponding to Ptr SrcTy, or null
815
    Type *MidIntPtrTy, ///< Integer type corresponding to Ptr MidTy, or null
816
    Type *DstIntPtrTy  ///< Integer type corresponding to Ptr DstTy, or null
817
  );
818
819
  /// @brief Return the opcode of this CastInst
820
24.5M
  Instruction::CastOps getOpcode() const {
821
24.5M
    return Instruction::CastOps(Instruction::getOpcode());
822
24.5M
  }
823
824
  /// @brief Return the source type, as a convenience
825
3.62M
  Type* getSrcTy() const { return getOperand(0)->getType(); }
826
  /// @brief Return the destination type, as a convenience
827
999k
  Type* getDestTy() const { return getType(); }
828
829
  /// This method can be used to determine if a cast from S to DstTy using
830
  /// Opcode op is valid or not.
831
  /// @returns true iff the proposed cast is valid.
832
  /// @brief Determine if a cast is valid without creating one.
833
  static bool castIsValid(Instruction::CastOps op, Value *S, Type *DstTy);
834
835
  /// @brief Methods for support type inquiry through isa, cast, and dyn_cast:
836
421M
  static bool classof(const Instruction *I) {
837
421M
    return I->isCast();
838
421M
  }
839
239M
  static bool classof(const Value *V) {
840
221M
    return isa<Instruction>(V) && classof(cast<Instruction>(V));
841
239M
  }
842
};
843
844
//===----------------------------------------------------------------------===//
845
//                               CmpInst Class
846
//===----------------------------------------------------------------------===//
847
848
/// This class is the base class for the comparison instructions.
849
/// @brief Abstract base class of comparison instructions.
850
class CmpInst : public Instruction {
851
public:
852
  /// This enumeration lists the possible predicates for CmpInst subclasses.
853
  /// Values in the range 0-31 are reserved for FCmpInst, while values in the
854
  /// range 32-64 are reserved for ICmpInst. This is necessary to ensure the
855
  /// predicate values are not overlapping between the classes.
856
  ///
857
  /// Some passes (e.g. InstCombine) depend on the bit-wise characteristics of
858
  /// FCMP_* values. Changing the bit patterns requires a potential change to
859
  /// those passes.
860
  enum Predicate {
861
    // Opcode              U L G E    Intuitive operation
862
    FCMP_FALSE =  0,  ///< 0 0 0 0    Always false (always folded)
863
    FCMP_OEQ   =  1,  ///< 0 0 0 1    True if ordered and equal
864
    FCMP_OGT   =  2,  ///< 0 0 1 0    True if ordered and greater than
865
    FCMP_OGE   =  3,  ///< 0 0 1 1    True if ordered and greater than or equal
866
    FCMP_OLT   =  4,  ///< 0 1 0 0    True if ordered and less than
867
    FCMP_OLE   =  5,  ///< 0 1 0 1    True if ordered and less than or equal
868
    FCMP_ONE   =  6,  ///< 0 1 1 0    True if ordered and operands are unequal
869
    FCMP_ORD   =  7,  ///< 0 1 1 1    True if ordered (no nans)
870
    FCMP_UNO   =  8,  ///< 1 0 0 0    True if unordered: isnan(X) | isnan(Y)
871
    FCMP_UEQ   =  9,  ///< 1 0 0 1    True if unordered or equal
872
    FCMP_UGT   = 10,  ///< 1 0 1 0    True if unordered or greater than
873
    FCMP_UGE   = 11,  ///< 1 0 1 1    True if unordered, greater than, or equal
874
    FCMP_ULT   = 12,  ///< 1 1 0 0    True if unordered or less than
875
    FCMP_ULE   = 13,  ///< 1 1 0 1    True if unordered, less than, or equal
876
    FCMP_UNE   = 14,  ///< 1 1 1 0    True if unordered or not equal
877
    FCMP_TRUE  = 15,  ///< 1 1 1 1    Always true (always folded)
878
    FIRST_FCMP_PREDICATE = FCMP_FALSE,
879
    LAST_FCMP_PREDICATE = FCMP_TRUE,
880
    BAD_FCMP_PREDICATE = FCMP_TRUE + 1,
881
    ICMP_EQ    = 32,  ///< equal
882
    ICMP_NE    = 33,  ///< not equal
883
    ICMP_UGT   = 34,  ///< unsigned greater than
884
    ICMP_UGE   = 35,  ///< unsigned greater or equal
885
    ICMP_ULT   = 36,  ///< unsigned less than
886
    ICMP_ULE   = 37,  ///< unsigned less or equal
887
    ICMP_SGT   = 38,  ///< signed greater than
888
    ICMP_SGE   = 39,  ///< signed greater or equal
889
    ICMP_SLT   = 40,  ///< signed less than
890
    ICMP_SLE   = 41,  ///< signed less or equal
891
    FIRST_ICMP_PREDICATE = ICMP_EQ,
892
    LAST_ICMP_PREDICATE = ICMP_SLE,
893
    BAD_ICMP_PREDICATE = ICMP_SLE + 1
894
  };
895
896
protected:
897
  CmpInst(Type *ty, Instruction::OtherOps op, Predicate pred,
898
          Value *LHS, Value *RHS, const Twine &Name = "",
899
          Instruction *InsertBefore = nullptr);
900
901
  CmpInst(Type *ty, Instruction::OtherOps op, Predicate pred,
902
          Value *LHS, Value *RHS, const Twine &Name,
903
          BasicBlock *InsertAtEnd);
904
905
public:
906
  // allocate space for exactly two operands
907
3.47M
  void *operator new(size_t s) {
908
3.47M
    return User::operator new(s, 2);
909
3.47M
  }
910
911
  /// Construct a compare instruction, given the opcode, the predicate and
912
  /// the two operands.  Optionally (if InstBefore is specified) insert the
913
  /// instruction into a BasicBlock right before the specified instruction.
914
  /// The specified Instruction is allowed to be a dereferenced end iterator.
915
  /// @brief Create a CmpInst
916
  static CmpInst *Create(OtherOps Op,
917
                         Predicate predicate, Value *S1,
918
                         Value *S2, const Twine &Name = "",
919
                         Instruction *InsertBefore = nullptr);
920
921
  /// Construct a compare instruction, given the opcode, the predicate and the
922
  /// two operands.  Also automatically insert this instruction to the end of
923
  /// the BasicBlock specified.
924
  /// @brief Create a CmpInst
925
  static CmpInst *Create(OtherOps Op, Predicate predicate, Value *S1,
926
                         Value *S2, const Twine &Name, BasicBlock *InsertAtEnd);
927
928
  /// @brief Get the opcode casted to the right type
929
12.6M
  OtherOps getOpcode() const {
930
12.6M
    return static_cast<OtherOps>(Instruction::getOpcode());
931
12.6M
  }
932
933
  /// @brief Return the predicate for this instruction.
934
726M
  Predicate getPredicate() const {
935
726M
    return Predicate(getSubclassDataFromInstruction());
936
726M
  }
937
938
  /// @brief Set the predicate for this instruction to the specified value.
939
3.90M
  void setPredicate(Predicate P) { setInstructionSubclassData(P); }
940
941
19.7M
  static bool isFPPredicate(Predicate P) {
942
19.7M
    return P >= FIRST_FCMP_PREDICATE && P <= LAST_FCMP_PREDICATE;
943
19.7M
  }
944
945
14.7M
  static bool isIntPredicate(Predicate P) {
946
14.5M
    return P >= FIRST_ICMP_PREDICATE && P <= LAST_ICMP_PREDICATE;
947
14.7M
  }
948
949
  static StringRef getPredicateName(Predicate P);
950
951
22.0k
  bool isFPPredicate() const { return isFPPredicate(getPredicate()); }
952
140k
  bool isIntPredicate() const { return isIntPredicate(getPredicate()); }
953
954
  /// For example, EQ -> NE, UGT -> ULE, SLT -> SGE,
955
  ///              OEQ -> UNE, UGT -> OLE, OLT -> UGE, etc.
956
  /// @returns the inverse predicate for the instruction's current predicate.
957
  /// @brief Return the inverse of the instruction's predicate.
958
20.6M
  Predicate getInversePredicate() const {
959
20.6M
    return getInversePredicate(getPredicate());
960
20.6M
  }
961
962
  /// For example, EQ -> NE, UGT -> ULE, SLT -> SGE,
963
  ///              OEQ -> UNE, UGT -> OLE, OLT -> UGE, etc.
964
  /// @returns the inverse predicate for predicate provided in \p pred.
965
  /// @brief Return the inverse of a given predicate
966
  static Predicate getInversePredicate(Predicate pred);
967
968
  /// For example, EQ->EQ, SLE->SGE, ULT->UGT,
969
  ///              OEQ->OEQ, ULE->UGE, OLT->OGT, etc.
970
  /// @returns the predicate that would be the result of exchanging the two
971
  /// operands of the CmpInst instruction without changing the result
972
  /// produced.
973
  /// @brief Return the predicate as if the operands were swapped
974
14.0M
  Predicate getSwappedPredicate() const {
975
14.0M
    return getSwappedPredicate(getPredicate());
976
14.0M
  }
977
978
  /// This is a static version that you can use without an instruction
979
  /// available.
980
  /// @brief Return the predicate as if the operands were swapped.
981
  static Predicate getSwappedPredicate(Predicate pred);
982
983
  /// @brief Provide more efficient getOperand methods.
984
  DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
985
986
  /// This is just a convenience that dispatches to the subclasses.
987
  /// @brief Swap the operands and adjust predicate accordingly to retain
988
  /// the same comparison.
989
  void swapOperands();
990
991
  /// This is just a convenience that dispatches to the subclasses.
992
  /// @brief Determine if this CmpInst is commutative.
993
  bool isCommutative() const;
994
995
  /// This is just a convenience that dispatches to the subclasses.
996
  /// @brief Determine if this is an equals/not equals predicate.
997
  bool isEquality() const;
998
999
  /// @returns true if the comparison is signed, false otherwise.
1000
  /// @brief Determine if this instruction is using a signed comparison.
1001
46.2M
  bool isSigned() const {
1002
46.2M
    return isSigned(getPredicate());
1003
46.2M
  }
1004
1005
  /// @returns true if the comparison is unsigned, false otherwise.
1006
  /// @brief Determine if this instruction is using an unsigned comparison.
1007
2.06M
  bool isUnsigned() const {
1008
2.06M
    return isUnsigned(getPredicate());
1009
2.06M
  }
1010
1011
  /// For example, ULT->SLT, ULE->SLE, UGT->SGT, UGE->SGE, SLT->Failed assert
1012
  /// @returns the signed version of the unsigned predicate pred.
1013
  /// @brief return the signed version of a predicate
1014
  static Predicate getSignedPredicate(Predicate pred);
1015
1016
  /// For example, ULT->SLT, ULE->SLE, UGT->SGT, UGE->SGE, SLT->Failed assert
1017
  /// @returns the signed version of the predicate for this instruction (which
1018
  /// has to be an unsigned predicate).
1019
  /// @brief return the signed version of a predicate
1020
0
  Predicate getSignedPredicate() {
1021
0
    return getSignedPredicate(getPredicate());
1022
0
  }
1023
1024
  /// This is just a convenience.
1025
  /// @brief Determine if this is true when both operands are the same.
1026
7.13k
  bool isTrueWhenEqual() const {
1027
7.13k
    return isTrueWhenEqual(getPredicate());
1028
7.13k
  }
1029
1030
  /// This is just a convenience.
1031
  /// @brief Determine if this is false when both operands are the same.
1032
24
  bool isFalseWhenEqual() const {
1033
24
    return isFalseWhenEqual(getPredicate());
1034
24
  }
1035
1036
  /// @returns true if the predicate is unsigned, false otherwise.
1037
  /// @brief Determine if the predicate is an unsigned operation.
1038
  static bool isUnsigned(Predicate predicate);
1039
1040
  /// @returns true if the predicate is signed, false otherwise.
1041
  /// @brief Determine if the predicate is an signed operation.
1042
  static bool isSigned(Predicate predicate);
1043
1044
  /// @brief Determine if the predicate is an ordered operation.
1045
  static bool isOrdered(Predicate predicate);
1046
1047
  /// @brief Determine if the predicate is an unordered operation.
1048
  static bool isUnordered(Predicate predicate);
1049
1050
  /// Determine if the predicate is true when comparing a value with itself.
1051
  static bool isTrueWhenEqual(Predicate predicate);
1052
1053
  /// Determine if the predicate is false when comparing a value with itself.
1054
  static bool isFalseWhenEqual(Predicate predicate);
1055
1056
  /// Determine if Pred1 implies Pred2 is true when two compares have matching
1057
  /// operands.
1058
  static bool isImpliedTrueByMatchingCmp(Predicate Pred1, Predicate Pred2);
1059
1060
  /// Determine if Pred1 implies Pred2 is false when two compares have matching
1061
  /// operands.
1062
  static bool isImpliedFalseByMatchingCmp(Predicate Pred1, Predicate Pred2);
1063
1064
  /// @brief Methods for support type inquiry through isa, cast, and dyn_cast:
1065
437M
  static bool classof(const Instruction *I) {
1066
437M
    return I->getOpcode() == Instruction::ICmp ||
1067
288M
           I->getOpcode() == Instruction::FCmp;
1068
437M
  }
1069
90.8M
  static bool classof(const Value *V) {
1070
90.2M
    return isa<Instruction>(V) && classof(cast<Instruction>(V));
1071
90.8M
  }
1072
1073
  /// @brief Create a result type for fcmp/icmp
1074
179M
  static Type* makeCmpResultType(Type* opnd_type) {
1075
179M
    if (VectorType* 
vt179M
= dyn_cast<VectorType>(opnd_type)) {
1076
113k
      return VectorType::get(Type::getInt1Ty(opnd_type->getContext()),
1077
113k
                             vt->getNumElements());
1078
113k
    }
1079
179M
    return Type::getInt1Ty(opnd_type->getContext());
1080
179M
  }
1081
1082
private:
1083
  // Shadow Value::setValueSubclassData with a private forwarding method so that
1084
  // subclasses cannot accidentally use it.
1085
0
  void setValueSubclassData(unsigned short D) {
1086
0
    Value::setValueSubclassData(D);
1087
0
  }
1088
};
1089
1090
// FIXME: these are redundant if CmpInst < BinaryOperator
1091
template <>
1092
struct OperandTraits<CmpInst> : public FixedNumOperandTraits<CmpInst, 2> {
1093
};
1094
1095
DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CmpInst, Value)
1096
1097
//===----------------------------------------------------------------------===//
1098
//                           FuncletPadInst Class
1099
//===----------------------------------------------------------------------===//
1100
class FuncletPadInst : public Instruction {
1101
private:
1102
  FuncletPadInst(const FuncletPadInst &CPI);
1103
1104
  explicit FuncletPadInst(Instruction::FuncletPadOps Op, Value *ParentPad,
1105
                          ArrayRef<Value *> Args, unsigned Values,
1106
                          const Twine &NameStr, Instruction *InsertBefore);
1107
  explicit FuncletPadInst(Instruction::FuncletPadOps Op, Value *ParentPad,
1108
                          ArrayRef<Value *> Args, unsigned Values,
1109
                          const Twine &NameStr, BasicBlock *InsertAtEnd);
1110
1111
  void init(Value *ParentPad, ArrayRef<Value *> Args, const Twine &NameStr);
1112
1113
protected:
1114
  // Note: Instruction needs to be a friend here to call cloneImpl.
1115
  friend class Instruction;
1116
  friend class CatchPadInst;
1117
  friend class CleanupPadInst;
1118
1119
  FuncletPadInst *cloneImpl() const;
1120
1121
public:
1122
  /// Provide fast operand accessors
1123
  DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
1124
1125
  /// getNumArgOperands - Return the number of funcletpad arguments.
1126
  ///
1127
612
  unsigned getNumArgOperands() const { return getNumOperands() - 1; }
1128
1129
  /// Convenience accessors
1130
1131
  /// \brief Return the outer EH-pad this funclet is nested within.
1132
  ///
1133
  /// Note: This returns the associated CatchSwitchInst if this FuncletPadInst
1134
  /// is a CatchPadInst.
1135
4.82k
  Value *getParentPad() const { return Op<-1>(); }
1136
854
  void setParentPad(Value *ParentPad) {
1137
854
    assert(ParentPad);
1138
854
    Op<-1>() = ParentPad;
1139
854
  }
1140
1141
  /// getArgOperand/setArgOperand - Return/set the i-th funcletpad argument.
1142
  ///
1143
648
  Value *getArgOperand(unsigned i) const { return getOperand(i); }
1144
0
  void setArgOperand(unsigned i, Value *v) { setOperand(i, v); }
1145
1146
  /// arg_operands - iteration adapter for range-for loops.
1147
0
  op_range arg_operands() { return op_range(op_begin(), op_end() - 1); }
1148
1149
  /// arg_operands - iteration adapter for range-for loops.
1150
0
  const_op_range arg_operands() const {
1151
0
    return const_op_range(op_begin(), op_end() - 1);
1152
0
  }
1153
1154
  // Methods for support type inquiry through isa, cast, and dyn_cast:
1155
1.71M
  static bool classof(const Instruction *I) { return I->isFuncletPad(); }
1156
4.31k
  static bool classof(const Value *V) {
1157
4.31k
    return isa<Instruction>(V) && classof(cast<Instruction>(V));
1158
4.31k
  }
1159
};
1160
1161
template <>
1162
struct OperandTraits<FuncletPadInst>
1163
    : public VariadicOperandTraits<FuncletPadInst, /*MINARITY=*/1> {};
1164
1165
DEFINE_TRANSPARENT_OPERAND_ACCESSORS(FuncletPadInst, Value)
1166
1167
/// \brief A lightweight accessor for an operand bundle meant to be passed
1168
/// around by value.
1169
struct OperandBundleUse {
1170
  ArrayRef<Use> Inputs;
1171
1172
  OperandBundleUse() = default;
1173
  explicit OperandBundleUse(StringMapEntry<uint32_t> *Tag, ArrayRef<Use> Inputs)
1174
4.72k
      : Inputs(Inputs), Tag(Tag) {}
1175
1176
  /// \brief Return true if the operand at index \p Idx in this operand bundle
1177
  /// has the attribute A.
1178
106
  bool operandHasAttr(unsigned Idx, Attribute::AttrKind A) const {
1179
106
    if (isDeoptOperandBundle())
1180
77
      
if (77
A == Attribute::ReadOnly || 77
A == Attribute::NoCapture67
)
1181
66
        return Inputs[Idx]->getType()->isPointerTy();
1182
106
1183
106
    // Conservative answer:  no operands have any attributes.
1184
40
    return false;
1185
106
  }
1186
1187
  /// \brief Return the tag of this operand bundle as a string.
1188
1.18k
  StringRef getTagName() const {
1189
1.18k
    return Tag->getKey();
1190
1.18k
  }
1191
1192
  /// \brief Return the tag of this operand bundle as an integer.
1193
  ///
1194
  /// Operand bundle tags are interned by LLVMContextImpl::getOrInsertBundleTag,
1195
  /// and this function returns the unique integer getOrInsertBundleTag
1196
  /// associated the tag of this operand bundle to.
1197
3.54k
  uint32_t getTagID() const {
1198
3.54k
    return Tag->getValue();
1199
3.54k
  }
1200
1201
  /// \brief Return true if this is a "deopt" operand bundle.
1202
106
  bool isDeoptOperandBundle() const {
1203
106
    return getTagID() == LLVMContext::OB_deopt;
1204
106
  }
1205
1206
  /// \brief Return true if this is a "funclet" operand bundle.
1207
0
  bool isFuncletOperandBundle() const {
1208
0
    return getTagID() == LLVMContext::OB_funclet;
1209
0
  }
1210
1211
private:
1212
  /// \brief Pointer to an entry in LLVMContextImpl::getOrInsertBundleTag.
1213
  StringMapEntry<uint32_t> *Tag;
1214
};
1215
1216
/// \brief A container for an operand bundle being viewed as a set of values
1217
/// rather than a set of uses.
1218
///
1219
/// Unlike OperandBundleUse, OperandBundleDefT owns the memory it carries, and
1220
/// so it is possible to create and pass around "self-contained" instances of
1221
/// OperandBundleDef and ConstOperandBundleDef.
1222
template <typename InputTy> class OperandBundleDefT {
1223
  std::string Tag;
1224
  std::vector<InputTy> Inputs;
1225
1226
public:
1227
  explicit OperandBundleDefT(std::string Tag, std::vector<InputTy> Inputs)
1228
1.06k
      : Tag(std::move(Tag)), Inputs(std::move(Inputs)) {}
1229
  explicit OperandBundleDefT(std::string Tag, ArrayRef<InputTy> Inputs)
1230
121
      : Tag(std::move(Tag)), Inputs(Inputs) {}
1231
1232
253
  explicit OperandBundleDefT(const OperandBundleUse &OBU) {
1233
253
    Tag = OBU.getTagName();
1234
253
    Inputs.insert(Inputs.end(), OBU.Inputs.begin(), OBU.Inputs.end());
1235
253
  }
1236
1237
  ArrayRef<InputTy> inputs() const { return Inputs; }
1238
1239
  using input_iterator = typename std::vector<InputTy>::const_iterator;
1240
1241
4.40k
  size_t input_size() const { return Inputs.size(); }
1242
1.24k
  input_iterator input_begin() const { return Inputs.begin(); }
1243
1.24k
  input_iterator input_end() const { return Inputs.end(); }
1244
1245
1.24k
  StringRef getTag() const { return Tag; }
1246
};
1247
1248
using OperandBundleDef = OperandBundleDefT<Value *>;
1249
using ConstOperandBundleDef = OperandBundleDefT<const Value *>;
1250
1251
/// \brief A mixin to add operand bundle functionality to llvm instruction
1252
/// classes.
1253
///
1254
/// OperandBundleUser uses the descriptor area co-allocated with the host User
1255
/// to store some meta information about which operands are "normal" operands,
1256
/// and which ones belong to some operand bundle.
1257
///
1258
/// The layout of an operand bundle user is
1259
///
1260
///          +-----------uint32_t End-------------------------------------+
1261
///          |                                                            |
1262
///          |  +--------uint32_t Begin--------------------+              |
1263
///          |  |                                          |              |
1264
///          ^  ^                                          v              v
1265
///  |------|------|----|----|----|----|----|---------|----|---------|----|-----
1266
///  | BOI0 | BOI1 | .. | DU | U0 | U1 | .. | BOI0_U0 | .. | BOI1_U0 | .. | Un
1267
///  |------|------|----|----|----|----|----|---------|----|---------|----|-----
1268
///   v  v                                  ^              ^
1269
///   |  |                                  |              |
1270
///   |  +--------uint32_t Begin------------+              |
1271
///   |                                                    |
1272
///   +-----------uint32_t End-----------------------------+
1273
///
1274
///
1275
/// BOI0, BOI1 ... are descriptions of operand bundles in this User's use list.
1276
/// These descriptions are installed and managed by this class, and they're all
1277
/// instances of OperandBundleUser<T>::BundleOpInfo.
1278
///
1279
/// DU is an additional descriptor installed by User's 'operator new' to keep
1280
/// track of the 'BOI0 ... BOIN' co-allocation.  OperandBundleUser does not
1281
/// access or modify DU in any way, it's an implementation detail private to
1282
/// User.
1283
///
1284
/// The regular Use& vector for the User starts at U0.  The operand bundle uses
1285
/// are part of the Use& vector, just like normal uses.  In the diagram above,
1286
/// the operand bundle uses start at BOI0_U0.  Each instance of BundleOpInfo has
1287
/// information about a contiguous set of uses constituting an operand bundle,
1288
/// and the total set of operand bundle uses themselves form a contiguous set of
1289
/// uses (i.e. there are no gaps between uses corresponding to individual
1290
/// operand bundles).
1291
///
1292
/// This class does not know the location of the set of operand bundle uses
1293
/// within the use list -- that is decided by the User using this class via the
1294
/// BeginIdx argument in populateBundleOperandInfos.
1295
///
1296
/// Currently operand bundle users with hung-off operands are not supported.
1297
template <typename InstrTy, typename OpIteratorTy> class OperandBundleUser {
1298
public:
1299
  /// \brief Return the number of operand bundles associated with this User.
1300
409M
  unsigned getNumOperandBundles() const {
1301
409M
    return std::distance(bundle_op_info_begin(), bundle_op_info_end());
1302
409M
  }
llvm::OperandBundleUser<llvm::InvokeInst, llvm::Use*>::getNumOperandBundles() const
Line
Count
Source
1300
3.46M
  unsigned getNumOperandBundles() const {
1301
3.46M
    return std::distance(bundle_op_info_begin(), bundle_op_info_end());
1302
3.46M
  }
llvm::OperandBundleUser<llvm::CallInst, llvm::Use*>::getNumOperandBundles() const
Line
Count
Source
1300
406M
  unsigned getNumOperandBundles() const {
1301
406M
    return std::distance(bundle_op_info_begin(), bundle_op_info_end());
1302
406M
  }
1303
1304
  /// \brief Return true if this User has any operand bundles.
1305
383M
  bool hasOperandBundles() const { return getNumOperandBundles() != 0; }
llvm::OperandBundleUser<llvm::CallInst, llvm::Use*>::hasOperandBundles() const
Line
Count
Source
1305
379M
  bool hasOperandBundles() const { return getNumOperandBundles() != 0; }
llvm::OperandBundleUser<llvm::InvokeInst, llvm::Use*>::hasOperandBundles() const
Line
Count
Source
1305
3.40M
  bool hasOperandBundles() const { return getNumOperandBundles() != 0; }
1306
1307
  /// \brief Return the index of the first bundle operand in the Use array.
1308
9.85k
  unsigned getBundleOperandsStartIndex() const {
1309
9.85k
    assert(hasOperandBundles() && "Don't call otherwise!");
1310
9.85k
    return bundle_op_info_begin()->Begin;
1311
9.85k
  }
llvm::OperandBundleUser<llvm::InvokeInst, llvm::Use*>::getBundleOperandsStartIndex() const
Line
Count
Source
1308
1.58k
  unsigned getBundleOperandsStartIndex() const {
1309
1.58k
    assert(hasOperandBundles() && "Don't call otherwise!");
1310
1.58k
    return bundle_op_info_begin()->Begin;
1311
1.58k
  }
llvm::OperandBundleUser<llvm::CallInst, llvm::Use*>::getBundleOperandsStartIndex() const
Line
Count
Source
1308
8.26k
  unsigned getBundleOperandsStartIndex() const {
1309
8.26k
    assert(hasOperandBundles() && "Don't call otherwise!");
1310
8.26k
    return bundle_op_info_begin()->Begin;
1311
8.26k
  }
1312
1313
  /// \brief Return the index of the last bundle operand in the Use array.
1314
9.79k
  unsigned getBundleOperandsEndIndex() const {
1315
9.79k
    assert(hasOperandBundles() && "Don't call otherwise!");
1316
9.79k
    return bundle_op_info_end()[-1].End;
1317
9.79k
  }
llvm::OperandBundleUser<llvm::InvokeInst, llvm::Use*>::getBundleOperandsEndIndex() const
Line
Count
Source
1314
1.56k
  unsigned getBundleOperandsEndIndex() const {
1315
1.56k
    assert(hasOperandBundles() && "Don't call otherwise!");
1316
1.56k
    return bundle_op_info_end()[-1].End;
1317
1.56k
  }
llvm::OperandBundleUser<llvm::CallInst, llvm::Use*>::getBundleOperandsEndIndex() const
Line
Count
Source
1314
8.23k
  unsigned getBundleOperandsEndIndex() const {
1315
8.23k
    assert(hasOperandBundles() && "Don't call otherwise!");
1316
8.23k
    return bundle_op_info_end()[-1].End;
1317
8.23k
  }
1318
1319
  /// Return true if the operand at index \p Idx is a bundle operand.
1320
4.08M
  bool isBundleOperand(unsigned Idx) const {
1321
154
    return hasOperandBundles() && Idx >= getBundleOperandsStartIndex() &&
1322
100
           Idx < getBundleOperandsEndIndex();
1323
4.08M
  }
llvm::OperandBundleUser<llvm::InvokeInst, llvm::Use*>::isBundleOperand(unsigned int) const
Line
Count
Source
1320
20.4k
  bool isBundleOperand(unsigned Idx) const {
1321
60
    return hasOperandBundles() && Idx >= getBundleOperandsStartIndex() &&
1322
32
           Idx < getBundleOperandsEndIndex();
1323
20.4k
  }
llvm::OperandBundleUser<llvm::CallInst, llvm::Use*>::isBundleOperand(unsigned int) const
Line
Count
Source
1320
4.06M
  bool isBundleOperand(unsigned Idx) const {
1321
94
    return hasOperandBundles() && Idx >= getBundleOperandsStartIndex() &&
1322
68
           Idx < getBundleOperandsEndIndex();
1323
4.06M
  }
1324
1325
  /// \brief Return the total number operands (not operand bundles) used by
1326
  /// every operand bundle in this OperandBundleUser.
1327
143M
  unsigned getNumTotalBundleOperands() const {
1328
143M
    if (!hasOperandBundles())
1329
143M
      return 0;
1330
143M
1331
9.69k
    unsigned Begin = getBundleOperandsStartIndex();
1332
9.69k
    unsigned End = getBundleOperandsEndIndex();
1333
9.69k
1334
9.69k
    assert(Begin <= End && "Should be!");
1335
9.69k
    return End - Begin;
1336
143M
  }
llvm::OperandBundleUser<llvm::InvokeInst, llvm::Use*>::getNumTotalBundleOperands() const
Line
Count
Source
1327
1.41M
  unsigned getNumTotalBundleOperands() const {
1328
1.41M
    if (!hasOperandBundles())
1329
1.41M
      return 0;
1330
1.41M
1331
1.52k
    unsigned Begin = getBundleOperandsStartIndex();
1332
1.52k
    unsigned End = getBundleOperandsEndIndex();
1333
1.52k
1334
1.52k
    assert(Begin <= End && "Should be!");
1335
1.52k
    return End - Begin;
1336
1.41M
  }
llvm::OperandBundleUser<llvm::CallInst, llvm::Use*>::getNumTotalBundleOperands() const
Line
Count
Source
1327
142M
  unsigned getNumTotalBundleOperands() const {
1328
142M
    if (!hasOperandBundles())
1329
141M
      return 0;
1330
142M
1331
8.16k
    unsigned Begin = getBundleOperandsStartIndex();
1332
8.16k
    unsigned End = getBundleOperandsEndIndex();
1333
8.16k
1334
8.16k
    assert(Begin <= End && "Should be!");
1335
8.16k
    return End - Begin;
1336
142M
  }
1337
1338
  /// \brief Return the operand bundle at a specific index.
1339
4.61k
  OperandBundleUse getOperandBundleAt(unsigned Index) const {
1340
4.61k
    assert(Index < getNumOperandBundles() && "Index out of bounds!");
1341
4.61k
    return operandBundleFromBundleOpInfo(*(bundle_op_info_begin() + Index));
1342
4.61k
  }
llvm::OperandBundleUser<llvm::CallInst, llvm::Use*>::getOperandBundleAt(unsigned int) const
Line
Count
Source
1339
3.52k
  OperandBundleUse getOperandBundleAt(unsigned Index) const {
1340
3.52k
    assert(Index < getNumOperandBundles() && "Index out of bounds!");
1341
3.52k
    return operandBundleFromBundleOpInfo(*(bundle_op_info_begin() + Index));
1342
3.52k
  }
llvm::OperandBundleUser<llvm::InvokeInst, llvm::Use*>::getOperandBundleAt(unsigned int) const
Line
Count
Source
1339
1.09k
  OperandBundleUse getOperandBundleAt(unsigned Index) const {
1340
1.09k
    assert(Index < getNumOperandBundles() && "Index out of bounds!");
1341
1.09k
    return operandBundleFromBundleOpInfo(*(bundle_op_info_begin() + Index));
1342
1.09k
  }
1343
1344
  /// \brief Return the number of operand bundles with the tag Name attached to
1345
  /// this instruction.
1346
  unsigned countOperandBundlesOfType(StringRef Name) const {
1347
    unsigned Count = 0;
1348
    for (unsigned i = 0, e = getNumOperandBundles(); i != e; ++i)
1349
      if (getOperandBundleAt(i).getTagName() == Name)
1350
        Count++;
1351
1352
    return Count;
1353
  }
1354
1355
  /// \brief Return the number of operand bundles with the tag ID attached to
1356
  /// this instruction.
1357
1.77M
  unsigned countOperandBundlesOfType(uint32_t ID) const {
1358
1.77M
    unsigned Count = 0;
1359
1.77M
    for (unsigned i = 0, e = getNumOperandBundles(); 
i != e1.77M
;
++i735
)
1360
735
      
if (735
getOperandBundleAt(i).getTagID() == ID735
)
1361
651
        Count++;
1362
1.77M
1363
1.77M
    return Count;
1364
1.77M
  }
llvm::OperandBundleUser<llvm::InvokeInst, llvm::Use*>::countOperandBundlesOfType(unsigned int) const
Line
Count
Source
1357
26.3k
  unsigned countOperandBundlesOfType(uint32_t ID) const {
1358
26.3k
    unsigned Count = 0;
1359
26.4k
    for (unsigned i = 0, e = getNumOperandBundles(); 
i != e26.4k
;
++i32
)
1360
32
      
if (32
getOperandBundleAt(i).getTagID() == ID32
)
1361
0
        Count++;
1362
26.3k
1363
26.3k
    return Count;
1364
26.3k
  }
llvm::OperandBundleUser<llvm::CallInst, llvm::Use*>::countOperandBundlesOfType(unsigned int) const
Line
Count
Source
1357
1.74M
  unsigned countOperandBundlesOfType(uint32_t ID) const {
1358
1.74M
    unsigned Count = 0;
1359
1.74M
    for (unsigned i = 0, e = getNumOperandBundles(); 
i != e1.74M
;
++i703
)
1360
703
      
if (703
getOperandBundleAt(i).getTagID() == ID703
)
1361
651
        Count++;
1362
1.74M
1363
1.74M
    return Count;
1364
1.74M
  }
1365
1366
  /// \brief Return an operand bundle by name, if present.
1367
  ///
1368
  /// It is an error to call this for operand bundle types that may have
1369
  /// multiple instances of them on the same instruction.
1370
  Optional<OperandBundleUse> getOperandBundle(StringRef Name) const {
1371
    assert(countOperandBundlesOfType(Name) < 2 && "Precondition violated!");
1372
1373
    for (unsigned i = 0, e = getNumOperandBundles(); i != e; ++i) {
1374
      OperandBundleUse U = getOperandBundleAt(i);
1375
      if (U.getTagName() == Name)
1376
        return U;
1377
    }
1378
1379
    return None;
1380
  }
1381
1382
  /// \brief Return an operand bundle by tag ID, if present.
1383
  ///
1384
  /// It is an error to call this for operand bundle types that may have
1385
  /// multiple instances of them on the same instruction.
1386
265k
  Optional<OperandBundleUse> getOperandBundle(uint32_t ID) const {
1387
265k
    assert(countOperandBundlesOfType(ID) < 2 && "Precondition violated!");
1388
265k
1389
265k
    for (unsigned i = 0, e = getNumOperandBundles(); 
i != e265k
;
++i130
) {
1390
861
      OperandBundleUse U = getOperandBundleAt(i);
1391
861
      if (U.getTagID() == ID)
1392
731
        return U;
1393
861
    }
1394
265k
1395
264k
    return None;
1396
265k
  }
llvm::OperandBundleUser<llvm::CallInst, llvm::Use*>::getOperandBundle(unsigned int) const
Line
Count
Source
1386
248k
  Optional<OperandBundleUse> getOperandBundle(uint32_t ID) const {
1387
248k
    assert(countOperandBundlesOfType(ID) < 2 && "Precondition violated!");
1388
248k
1389
248k
    for (unsigned i = 0, e = getNumOperandBundles(); 
i != e248k
;
++i121
) {
1390
477
      OperandBundleUse U = getOperandBundleAt(i);
1391
477
      if (U.getTagID() == ID)
1392
356
        return U;
1393
477
    }
1394
248k
1395
247k
    return None;
1396
248k
  }
llvm::OperandBundleUser<llvm::InvokeInst, llvm::Use*>::getOperandBundle(unsigned int) const
Line
Count
Source
1386
16.9k
  Optional<OperandBundleUse> getOperandBundle(uint32_t ID) const {
1387
16.9k
    assert(countOperandBundlesOfType(ID) < 2 && "Precondition violated!");
1388
16.9k
1389
16.9k
    for (unsigned i = 0, e = getNumOperandBundles(); 
i != e16.9k
;
++i9
) {
1390
384
      OperandBundleUse U = getOperandBundleAt(i);
1391
384
      if (U.getTagID() == ID)
1392
375
        return U;
1393
384
    }
1394
16.9k
1395
16.5k
    return None;
1396
16.9k
  }
1397
1398
  /// \brief Return the list of operand bundles attached to this instruction as
1399
  /// a vector of OperandBundleDefs.
1400
  ///
1401
  /// This function copies the OperandBundeUse instances associated with this
1402
  /// OperandBundleUser to a vector of OperandBundleDefs.  Note:
1403
  /// OperandBundeUses and OperandBundleDefs are non-trivially *different*
1404
  /// representations of operand bundles (see documentation above).
1405
20.3M
  void getOperandBundlesAsDefs(SmallVectorImpl<OperandBundleDef> &Defs) const {
1406
20.3M
    for (unsigned i = 0, e = getNumOperandBundles(); 
i != e20.3M
;
++i236
)
1407
236
      Defs.emplace_back(getOperandBundleAt(i));
1408
20.3M
  }
llvm::OperandBundleUser<llvm::InvokeInst, llvm::Use*>::getOperandBundlesAsDefs(llvm::SmallVectorImpl<llvm::OperandBundleDefT<llvm::Value*> >&) const
Line
Count
Source
1405
5.35k
  void getOperandBundlesAsDefs(SmallVectorImpl<OperandBundleDef> &Defs) const {
1406
5.35k
    for (unsigned i = 0, e = getNumOperandBundles(); 
i != e5.35k
;
++i2
)
1407
2
      Defs.emplace_back(getOperandBundleAt(i));
1408
5.35k
  }
llvm::OperandBundleUser<llvm::CallInst, llvm::Use*>::getOperandBundlesAsDefs(llvm::SmallVectorImpl<llvm::OperandBundleDefT<llvm::Value*> >&) const
Line
Count
Source
1405
20.3M
  void getOperandBundlesAsDefs(SmallVectorImpl<OperandBundleDef> &Defs) const {
1406
20.3M
    for (unsigned i = 0, e = getNumOperandBundles(); 
i != e20.3M
;
++i234
)
1407
234
      Defs.emplace_back(getOperandBundleAt(i));
1408
20.3M
  }
1409
1410
  /// \brief Return the operand bundle for the operand at index OpIdx.
1411
  ///
1412
  /// It is an error to call this with an OpIdx that does not correspond to an
1413
  /// bundle operand.
1414
  OperandBundleUse getOperandBundleForOperand(unsigned OpIdx) const {
1415
    return operandBundleFromBundleOpInfo(getBundleOpInfoForOperand(OpIdx));
1416
  }
1417
1418
  /// \brief Return true if this operand bundle user has operand bundles that
1419
  /// may read from the heap.
1420
188M
  bool hasReadingOperandBundles() const {
1421
188M
    // Implementation note: this is a conservative implementation of operand
1422
188M
    // bundle semantics, where *any* operand bundle forces a callsite to be at
1423
188M
    // least readonly.
1424
188M
    return hasOperandBundles();
1425
188M
  }
llvm::OperandBundleUser<llvm::CallInst, llvm::Use*>::hasReadingOperandBundles() const
Line
Count
Source
1420
187M
  bool hasReadingOperandBundles() const {
1421
187M
    // Implementation note: this is a conservative implementation of operand
1422
187M
    // bundle semantics, where *any* operand bundle forces a callsite to be at
1423
187M
    // least readonly.
1424
187M
    return hasOperandBundles();
1425
187M
  }
llvm::OperandBundleUser<llvm::InvokeInst, llvm::Use*>::hasReadingOperandBundles() const
Line
Count
Source
1420
1.54M
  bool hasReadingOperandBundles() const {
1421
1.54M
    // Implementation note: this is a conservative implementation of operand
1422
1.54M
    // bundle semantics, where *any* operand bundle forces a callsite to be at
1423
1.54M
    // least readonly.
1424
1.54M
    return hasOperandBundles();
1425
1.54M
  }
1426
1427
  /// \brief Return true if this operand bundle user has operand bundles that
1428
  /// may write to the heap.
1429
98.9M
  bool hasClobberingOperandBundles() const {
1430
789
    for (auto &BOI : bundle_op_infos()) {
1431
789
      if (BOI.Tag->second == LLVMContext::OB_deopt ||
1432
375
          BOI.Tag->second == LLVMContext::OB_funclet)
1433
686
        continue;
1434
789
1435
789
      // This instruction has an operand bundle that is not known to us.
1436
789
      // Assume the worst.
1437
103
      return true;
1438
789
    }
1439
98.9M
1440
98.9M
    return false;
1441
98.9M
  }
llvm::OperandBundleUser<llvm::InvokeInst, llvm::Use*>::hasClobberingOperandBundles() const
Line
Count
Source
1429
852k
  bool hasClobberingOperandBundles() const {
1430
7
    for (auto &BOI : bundle_op_infos()) {
1431
7
      if (BOI.Tag->second == LLVMContext::OB_deopt ||
1432
7
          BOI.Tag->second == LLVMContext::OB_funclet)
1433
7
        continue;
1434
7
1435
7
      // This instruction has an operand bundle that is not known to us.
1436
7
      // Assume the worst.
1437
0
      return true;
1438
7
    }
1439
852k
1440
852k
    return false;
1441
852k
  }
llvm::OperandBundleUser<llvm::CallInst, llvm::Use*>::hasClobberingOperandBundles() const
Line
Count
Source
1429
98.1M
  bool hasClobberingOperandBundles() const {
1430
782
    for (auto &BOI : bundle_op_infos()) {
1431
782
      if (BOI.Tag->second == LLVMContext::OB_deopt ||
1432
368
          BOI.Tag->second == LLVMContext::OB_funclet)
1433
679
        continue;
1434
782
1435
782
      // This instruction has an operand bundle that is not known to us.
1436
782
      // Assume the worst.
1437
103
      return true;
1438
782
    }
1439
98.1M
1440
98.1M
    return false;
1441
98.1M
  }
1442
1443
  /// \brief Return true if the bundle operand at index \p OpIdx has the
1444
  /// attribute \p A.
1445
106
  bool bundleOperandHasAttr(unsigned OpIdx,  Attribute::AttrKind A) const {
1446
106
    auto &BOI = getBundleOpInfoForOperand(OpIdx);
1447
106
    auto OBU = operandBundleFromBundleOpInfo(BOI);
1448
106
    return OBU.operandHasAttr(OpIdx - BOI.Begin, A);
1449
106
  }
llvm::OperandBundleUser<llvm::CallInst, llvm::Use*>::bundleOperandHasAttr(unsigned int, llvm::Attribute::AttrKind) const
Line
Count
Source
1445
106
  bool bundleOperandHasAttr(unsigned OpIdx,  Attribute::AttrKind A) const {
1446
106
    auto &BOI = getBundleOpInfoForOperand(OpIdx);
1447
106
    auto OBU = operandBundleFromBundleOpInfo(BOI);
1448
106
    return OBU.operandHasAttr(OpIdx - BOI.Begin, A);
1449
106
  }
Unexecuted instantiation: llvm::OperandBundleUser<llvm::InvokeInst, llvm::Use*>::bundleOperandHasAttr(unsigned int, llvm::Attribute::AttrKind) const
1450
1451
  /// \brief Return true if \p Other has the same sequence of operand bundle
1452
  /// tags with the same number of operands on each one of them as this
1453
  /// OperandBundleUser.
1454
  bool hasIdenticalOperandBundleSchema(
1455
1.68M
      const OperandBundleUser<InstrTy, OpIteratorTy> &Other) const {
1456
1.68M
    if (getNumOperandBundles() != Other.getNumOperandBundles())
1457
0
      return false;
1458
1.68M
1459
1.68M
    return std::equal(bundle_op_info_begin(), bundle_op_info_end(),
1460
1.68M
                      Other.bundle_op_info_begin());
1461
1.68M
  }
llvm::OperandBundleUser<llvm::CallInst, llvm::Use*>::hasIdenticalOperandBundleSchema(llvm::OperandBundleUser<llvm::CallInst, llvm::Use*> const&) const
Line
Count
Source
1455
1.68M
      const OperandBundleUser<InstrTy, OpIteratorTy> &Other) const {
1456
1.68M
    if (getNumOperandBundles() != Other.getNumOperandBundles())
1457
0
      return false;
1458
1.68M
1459
1.68M
    return std::equal(bundle_op_info_begin(), bundle_op_info_end(),
1460
1.68M
                      Other.bundle_op_info_begin());
1461
1.68M
  }
llvm::OperandBundleUser<llvm::InvokeInst, llvm::Use*>::hasIdenticalOperandBundleSchema(llvm::OperandBundleUser<llvm::InvokeInst, llvm::Use*> const&) const
Line
Count
Source
1455
2
      const OperandBundleUser<InstrTy, OpIteratorTy> &Other) const {
1456
2
    if (getNumOperandBundles() != Other.getNumOperandBundles())
1457
0
      return false;
1458
2
1459
2
    return std::equal(bundle_op_info_begin(), bundle_op_info_end(),
1460
2
                      Other.bundle_op_info_begin());
1461
2
  }
1462
1463
  /// \brief Return true if this operand bundle user contains operand bundles
1464
  /// with tags other than those specified in \p IDs.
1465
  bool hasOperandBundlesOtherThan(ArrayRef<uint32_t> IDs) const {
1466
    for (unsigned i = 0, e = getNumOperandBundles(); i != e; ++i) {
1467
      uint32_t ID = getOperandBundleAt(i).getTagID();
1468
      if (!is_contained(IDs, ID))
1469
        return true;
1470
    }
1471
    return false;
1472
  }
1473
1474
protected:
1475
  /// \brief Is the function attribute S disallowed by some operand bundle on
1476
  /// this operand bundle user?
1477
28.3k
  bool isFnAttrDisallowedByOpBundle(StringRef S) const {
1478
28.3k
    // Operand bundles only possibly disallow readnone, readonly and argmenonly
1479
28.3k
    // attributes.  All String attributes are fine.
1480
28.3k
    return false;
1481
28.3k
  }
llvm::OperandBundleUser<llvm::InvokeInst, llvm::Use*>::isFnAttrDisallowedByOpBundle(llvm::StringRef) const
Line
Count
Source
1477
34
  bool isFnAttrDisallowedByOpBundle(StringRef S) const {
1478
34
    // Operand bundles only possibly disallow readnone, readonly and argmenonly
1479
34
    // attributes.  All String attributes are fine.
1480
34
    return false;
1481
34
  }
llvm::OperandBundleUser<llvm::CallInst, llvm::Use*>::isFnAttrDisallowedByOpBundle(llvm::StringRef) const
Line
Count
Source
1477
28.2k
  bool isFnAttrDisallowedByOpBundle(StringRef S) const {
1478
28.2k
    // Operand bundles only possibly disallow readnone, readonly and argmenonly
1479
28.2k
    // attributes.  All String attributes are fine.
1480
28.2k
    return false;
1481
28.2k
  }
1482
1483
  /// \brief Is the function attribute A disallowed by some operand bundle on
1484
  /// this operand bundle user?
1485
677M
  bool isFnAttrDisallowedByOpBundle(Attribute::AttrKind A) const {
1486
677M
    switch (A) {
1487
389M
    default:
1488
389M
      return false;
1489
677M
1490
23.4M
    case Attribute::ArgMemOnly:
1491
23.4M
      return hasReadingOperandBundles();
1492
677M
1493
165M
    case Attribute::ReadNone:
1494
165M
      return hasReadingOperandBundles();
1495
677M
1496
98.9M
    case Attribute::ReadOnly:
1497
98.9M
      return hasClobberingOperandBundles();
1498
677M
    }
1499
677M
1500
0
    
llvm_unreachable0
("switch has a default case!");
1501
677M
  }
llvm::OperandBundleUser<llvm::InvokeInst, llvm::Use*>::isFnAttrDisallowedByOpBundle(llvm::Attribute::AttrKind) const
Line
Count
Source
1485
4.69M
  bool isFnAttrDisallowedByOpBundle(Attribute::AttrKind A) const {
1486
4.69M
    switch (A) {
1487
2.28M
    default:
1488
2.28M
      return false;
1489
4.69M
1490
192k
    case Attribute::ArgMemOnly:
1491
192k
      return hasReadingOperandBundles();
1492
4.69M
1493
1.35M
    case Attribute::ReadNone:
1494
1.35M
      return hasReadingOperandBundles();
1495
4.69M
1496
852k
    case Attribute::ReadOnly:
1497
852k
      return hasClobberingOperandBundles();
1498
4.69M
    }
1499
4.69M
1500
0
    
llvm_unreachable0
("switch has a default case!");
1501
  }
llvm::OperandBundleUser<llvm::CallInst, llvm::Use*>::isFnAttrDisallowedByOpBundle(llvm::Attribute::AttrKind) const
Line
Count
Source
1485
672M
  bool isFnAttrDisallowedByOpBundle(Attribute::AttrKind A) const {
1486
672M
    switch (A) {
1487
387M
    default:
1488
387M
      return false;
1489
672M
1490
23.2M
    case Attribute::ArgMemOnly:
1491
23.2M
      return hasReadingOperandBundles();
1492
672M
1493
164M
    case Attribute::ReadNone:
1494
164M
      return hasReadingOperandBundles();
1495
672M
1496
98.1M
    case Attribute::ReadOnly:
1497
98.1M
      return hasClobberingOperandBundles();
1498
672M
    }
1499
672M
1500
0
    
llvm_unreachable0
("switch has a default case!");
1501
  }
1502
1503
  /// \brief Used to keep track of an operand bundle.  See the main comment on
1504
  /// OperandBundleUser above.
1505
  struct BundleOpInfo {
1506
    /// \brief The operand bundle tag, interned by
1507
    /// LLVMContextImpl::getOrInsertBundleTag.
1508
    StringMapEntry<uint32_t> *Tag;
1509
1510
    /// \brief The index in the Use& vector where operands for this operand
1511
    /// bundle starts.
1512
    uint32_t Begin;
1513
1514
    /// \brief The index in the Use& vector where operands for this operand
1515
    /// bundle ends.
1516
    uint32_t End;
1517
1518
14
    bool operator==(const BundleOpInfo &Other) const {
1519
14
      return Tag == Other.Tag && 
Begin == Other.Begin14
&&
End == Other.End11
;
1520
14
    }
llvm::OperandBundleUser<llvm::CallInst, llvm::Use*>::BundleOpInfo::operator==(llvm::OperandBundleUser<llvm::CallInst, llvm::Use*>::BundleOpInfo const&) const
Line
Count
Source
1518
14
    bool operator==(const BundleOpInfo &Other) const {
1519
14
      return Tag == Other.Tag && 
Begin == Other.Begin14
&&
End == Other.End11
;
1520
14
    }
Unexecuted instantiation: llvm::OperandBundleUser<llvm::InvokeInst, llvm::Use*>::BundleOpInfo::operator==(llvm::OperandBundleUser<llvm::InvokeInst, llvm::Use*>::BundleOpInfo const&) const
1521
  };
1522
1523
  /// \brief Simple helper function to map a BundleOpInfo to an
1524
  /// OperandBundleUse.
1525
  OperandBundleUse
1526
4.72k
  operandBundleFromBundleOpInfo(const BundleOpInfo &BOI) const {
1527
4.72k
    auto op_begin = static_cast<const InstrTy *>(this)->op_begin();
1528
4.72k
    ArrayRef<Use> Inputs(op_begin + BOI.Begin, op_begin + BOI.End);
1529
4.72k
    return OperandBundleUse(BOI.Tag, Inputs);
1530
4.72k
  }
llvm::OperandBundleUser<llvm::InvokeInst, llvm::Use*>::operandBundleFromBundleOpInfo(llvm::OperandBundleUser<llvm::InvokeInst, llvm::Use*>::BundleOpInfo const&) const
Line
Count
Source
1526
1.09k
  operandBundleFromBundleOpInfo(const BundleOpInfo &BOI) const {
1527
1.09k
    auto op_begin = static_cast<const InstrTy *>(this)->op_begin();
1528
1.09k
    ArrayRef<Use> Inputs(op_begin + BOI.Begin, op_begin + BOI.End);
1529
1.09k
    return OperandBundleUse(BOI.Tag, Inputs);
1530
1.09k
  }
llvm::OperandBundleUser<llvm::CallInst, llvm::Use*>::operandBundleFromBundleOpInfo(llvm::OperandBundleUser<llvm::CallInst, llvm::Use*>::BundleOpInfo const&) const
Line
Count
Source
1526
3.62k
  operandBundleFromBundleOpInfo(const BundleOpInfo &BOI) const {
1527
3.62k
    auto op_begin = static_cast<const InstrTy *>(this)->op_begin();
1528
3.62k
    ArrayRef<Use> Inputs(op_begin + BOI.Begin, op_begin + BOI.End);
1529
3.62k
    return OperandBundleUse(BOI.Tag, Inputs);
1530
3.62k
  }
1531
1532
  using bundle_op_iterator = BundleOpInfo *;
1533
  using const_bundle_op_iterator = const BundleOpInfo *;
1534
1535
  /// \brief Return the start of the list of BundleOpInfo instances associated
1536
  /// with this OperandBundleUser.
1537
517M
  bundle_op_iterator bundle_op_info_begin() {
1538
517M
    if (!static_cast<InstrTy *>(this)->hasDescriptor())
1539
517M
      return nullptr;
1540
517M
1541
33.6k
    uint8_t *BytesBegin = static_cast<InstrTy *>(this)->getDescriptor().begin();
1542
33.6k
    return reinterpret_cast<bundle_op_iterator>(BytesBegin);
1543
517M
  }
llvm::OperandBundleUser<llvm::CallInst, llvm::Use*>::bundle_op_info_begin()
Line
Count
Source
1537
512M
  bundle_op_iterator bundle_op_info_begin() {
1538
512M
    if (!static_cast<InstrTy *>(this)->hasDescriptor())
1539
512M
      return nullptr;
1540
512M
1541
27.6k
    uint8_t *BytesBegin = static_cast<InstrTy *>(this)->getDescriptor().begin();
1542
27.6k
    return reinterpret_cast<bundle_op_iterator>(BytesBegin);
1543
512M
  }
llvm::OperandBundleUser<llvm::InvokeInst, llvm::Use*>::bundle_op_info_begin()
Line
Count
Source
1537
4.37M
  bundle_op_iterator bundle_op_info_begin() {
1538
4.37M
    if (!static_cast<InstrTy *>(this)->hasDescriptor())
1539
4.36M
      return nullptr;
1540
4.37M
1541
6.00k
    uint8_t *BytesBegin = static_cast<InstrTy *>(this)->getDescriptor().begin();
1542
6.00k
    return reinterpret_cast<bundle_op_iterator>(BytesBegin);
1543
4.37M
  }
1544
1545
  /// \brief Return the start of the list of BundleOpInfo instances associated
1546
  /// with this OperandBundleUser.
1547
512M
  const_bundle_op_iterator bundle_op_info_begin() const {
1548
512M
    auto *NonConstThis =
1549
512M
        const_cast<OperandBundleUser<InstrTy, OpIteratorTy> *>(this);
1550
512M
    return NonConstThis->bundle_op_info_begin();
1551
512M
  }
llvm::OperandBundleUser<llvm::InvokeInst, llvm::Use*>::bundle_op_info_begin() const
Line
Count
Source
1547
4.32M
  const_bundle_op_iterator bundle_op_info_begin() const {
1548
4.32M
    auto *NonConstThis =
1549
4.32M
        const_cast<OperandBundleUser<InstrTy, OpIteratorTy> *>(this);
1550
4.32M
    return NonConstThis->bundle_op_info_begin();
1551
4.32M
  }
llvm::OperandBundleUser<llvm::CallInst, llvm::Use*>::bundle_op_info_begin() const
Line
Count
Source
1547
507M
  const_bundle_op_iterator bundle_op_info_begin() const {
1548
507M
    auto *NonConstThis =
1549
507M
        const_cast<OperandBundleUser<InstrTy, OpIteratorTy> *>(this);
1550
507M
    return NonConstThis->bundle_op_info_begin();
1551
507M
  }
1552
1553
  /// \brief Return the end of the list of BundleOpInfo instances associated
1554
  /// with this OperandBundleUser.
1555
515M
  bundle_op_iterator bundle_op_info_end() {
1556
515M
    if (!static_cast<InstrTy *>(this)->hasDescriptor())
1557
515M
      return nullptr;
1558
515M
1559
28.8k
    uint8_t *BytesEnd = static_cast<InstrTy *>(this)->getDescriptor().end();
1560
28.8k
    return reinterpret_cast<bundle_op_iterator>(BytesEnd);
1561
515M
  }
llvm::OperandBundleUser<llvm::CallInst, llvm::Use*>::bundle_op_info_end()
Line
Count
Source
1555
510M
  bundle_op_iterator bundle_op_info_end() {
1556
510M
    if (!static_cast<InstrTy *>(this)->hasDescriptor())
1557
510M
      return nullptr;
1558
510M
1559
24.0k
    uint8_t *BytesEnd = static_cast<InstrTy *>(this)->getDescriptor().end();
1560
24.0k
    return reinterpret_cast<bundle_op_iterator>(BytesEnd);
1561
510M
  }
llvm::OperandBundleUser<llvm::InvokeInst, llvm::Use*>::bundle_op_info_end()
Line
Count
Source
1555
4.36M
  bundle_op_iterator bundle_op_info_end() {
1556
4.36M
    if (!static_cast<InstrTy *>(this)->hasDescriptor())
1557
4.35M
      return nullptr;
1558
4.36M
1559
4.83k
    uint8_t *BytesEnd = static_cast<InstrTy *>(this)->getDescriptor().end();
1560
4.83k
    return reinterpret_cast<bundle_op_iterator>(BytesEnd);
1561
4.36M
  }
1562
1563
  /// \brief Return the end of the list of BundleOpInfo instances associated
1564
  /// with this OperandBundleUser.
1565
510M
  const_bundle_op_iterator bundle_op_info_end() const {
1566
510M
    auto *NonConstThis =
1567
510M
        const_cast<OperandBundleUser<InstrTy, OpIteratorTy> *>(this);
1568
510M
    return NonConstThis->bundle_op_info_end();
1569
510M
  }
llvm::OperandBundleUser<llvm::InvokeInst, llvm::Use*>::bundle_op_info_end() const
Line
Count
Source
1565
4.32M
  const_bundle_op_iterator bundle_op_info_end() const {
1566
4.32M
    auto *NonConstThis =
1567
4.32M
        const_cast<OperandBundleUser<InstrTy, OpIteratorTy> *>(this);
1568
4.32M
    return NonConstThis->bundle_op_info_end();
1569
4.32M
  }
llvm::OperandBundleUser<llvm::CallInst, llvm::Use*>::bundle_op_info_end() const
Line
Count
Source
1565
506M
  const_bundle_op_iterator bundle_op_info_end() const {
1566
506M
    auto *NonConstThis =
1567
506M
        const_cast<OperandBundleUser<InstrTy, OpIteratorTy> *>(this);
1568
506M
    return NonConstThis->bundle_op_info_end();
1569
506M
  }
1570
1571
  /// \brief Return the range [\p bundle_op_info_begin, \p bundle_op_info_end).
1572
4.49M
  iterator_range<bundle_op_iterator> bundle_op_infos() {
1573
4.49M
    return make_range(bundle_op_info_begin(), bundle_op_info_end());
1574
4.49M
  }
llvm::OperandBundleUser<llvm::InvokeInst, llvm::Use*>::bundle_op_infos()
Line
Count
Source
1572
39.9k
  iterator_range<bundle_op_iterator> bundle_op_infos() {
1573
39.9k
    return make_range(bundle_op_info_begin(), bundle_op_info_end());
1574
39.9k
  }
llvm::OperandBundleUser<llvm::CallInst, llvm::Use*>::bundle_op_infos()
Line
Count
Source
1572
4.45M
  iterator_range<bundle_op_iterator> bundle_op_infos() {
1573
4.45M
    return make_range(bundle_op_info_begin(), bundle_op_info_end());
1574
4.45M
  }
1575
1576
  /// \brief Return the range [\p bundle_op_info_begin, \p bundle_op_info_end).
1577
98.9M
  iterator_range<const_bundle_op_iterator> bundle_op_infos() const {
1578
98.9M
    return make_range(bundle_op_info_begin(), bundle_op_info_end());
1579
98.9M
  }
llvm::OperandBundleUser<llvm::CallInst, llvm::Use*>::bundle_op_infos() const
Line
Count
Source
1577
98.1M
  iterator_range<const_bundle_op_iterator> bundle_op_infos() const {
1578
98.1M
    return make_range(bundle_op_info_begin(), bundle_op_info_end());
1579
98.1M
  }
llvm::OperandBundleUser<llvm::InvokeInst, llvm::Use*>::bundle_op_infos() const
Line
Count
Source
1577
852k
  iterator_range<const_bundle_op_iterator> bundle_op_infos() const {
1578
852k
    return make_range(bundle_op_info_begin(), bundle_op_info_end());
1579
852k
  }
1580
1581
  /// \brief Populate the BundleOpInfo instances and the Use& vector from \p
1582
  /// Bundles.  Return the op_iterator pointing to the Use& one past the last
1583
  /// last bundle operand use.
1584
  ///
1585
  /// Each \p OperandBundleDef instance is tracked by a OperandBundleInfo
1586
  /// instance allocated in this User's descriptor.
1587
  OpIteratorTy populateBundleOperandInfos(ArrayRef<OperandBundleDef> Bundles,
1588
4.49M
                                          const unsigned BeginIndex) {
1589
4.49M
    auto It = static_cast<InstrTy *>(this)->op_begin() + BeginIndex;
1590
4.49M
    for (auto &B : Bundles)
1591
1.24k
      It = std::copy(B.input_begin(), B.input_end(), It);
1592
4.49M
1593
4.49M
    auto *ContextImpl = static_cast<InstrTy *>(this)->getContext().pImpl;
1594
4.49M
    auto BI = Bundles.begin();
1595
4.49M
    unsigned CurrentIndex = BeginIndex;
1596
4.49M
1597
1.24k
    for (auto &BOI : bundle_op_infos()) {
1598
1.24k
      assert(BI != Bundles.end() && "Incorrect allocation?");
1599
1.24k
1600
1.24k
      BOI.Tag = ContextImpl->getOrInsertBundleTag(BI->getTag());
1601
1.24k
      BOI.Begin = CurrentIndex;
1602
1.24k
      BOI.End = CurrentIndex + BI->input_size();
1603
1.24k
      CurrentIndex = BOI.End;
1604
1.24k
      BI++;
1605
1.24k
    }
1606
4.49M
1607
4.49M
    assert(BI == Bundles.end() && "Incorrect allocation?");
1608
4.49M
1609
4.49M
    return It;
1610
4.49M
  }
llvm::OperandBundleUser<llvm::InvokeInst, llvm::Use*>::populateBundleOperandInfos(llvm::ArrayRef<llvm::OperandBundleDefT<llvm::Value*> >, unsigned int)
Line
Count
Source
1588
39.9k
                                          const unsigned BeginIndex) {
1589
39.9k
    auto It = static_cast<InstrTy *>(this)->op_begin() + BeginIndex;
1590
39.9k
    for (auto &B : Bundles)
1591
280
      It = std::copy(B.input_begin(), B.input_end(), It);
1592
39.9k
1593
39.9k
    auto *ContextImpl = static_cast<InstrTy *>(this)->getContext().pImpl;
1594
39.9k
    auto BI = Bundles.begin();
1595
39.9k
    unsigned CurrentIndex = BeginIndex;
1596
39.9k
1597
280
    for (auto &BOI : bundle_op_infos()) {
1598
280
      assert(BI != Bundles.end() && "Incorrect allocation?");
1599
280
1600
280
      BOI.Tag = ContextImpl->getOrInsertBundleTag(BI->getTag());
1601
280
      BOI.Begin = CurrentIndex;
1602
280
      BOI.End = CurrentIndex + BI->input_size();
1603
280
      CurrentIndex = BOI.End;
1604
280
      BI++;
1605
280
    }
1606
39.9k
1607
39.9k
    assert(BI == Bundles.end() && "Incorrect allocation?");
1608
39.9k
1609
39.9k
    return It;
1610
39.9k
  }
llvm::OperandBundleUser<llvm::CallInst, llvm::Use*>::populateBundleOperandInfos(llvm::ArrayRef<llvm::OperandBundleDefT<llvm::Value*> >, unsigned int)
Line
Count
Source
1588
4.45M
                                          const unsigned BeginIndex) {
1589
4.45M
    auto It = static_cast<InstrTy *>(this)->op_begin() + BeginIndex;
1590
4.45M
    for (auto &B : Bundles)
1591
961
      It = std::copy(B.input_begin(), B.input_end(), It);
1592
4.45M
1593
4.45M
    auto *ContextImpl = static_cast<InstrTy *>(this)->getContext().pImpl;
1594
4.45M
    auto BI = Bundles.begin();
1595
4.45M
    unsigned CurrentIndex = BeginIndex;
1596
4.45M
1597
961
    for (auto &BOI : bundle_op_infos()) {
1598
961
      assert(BI != Bundles.end() && "Incorrect allocation?");
1599
961
1600
961
      BOI.Tag = ContextImpl->getOrInsertBundleTag(BI->getTag());
1601
961
      BOI.Begin = CurrentIndex;
1602
961
      BOI.End = CurrentIndex + BI->input_size();
1603
961
      CurrentIndex = BOI.End;
1604
961
      BI++;
1605
961
    }
1606
4.45M
1607
4.45M
    assert(BI == Bundles.end() && "Incorrect allocation?");
1608
4.45M
1609
4.45M
    return It;
1610
4.45M
  }
1611
1612
  /// \brief Return the BundleOpInfo for the operand at index OpIdx.
1613
  ///
1614
  /// It is an error to call this with an OpIdx that does not correspond to an
1615
  /// bundle operand.
1616
106
  const BundleOpInfo &getBundleOpInfoForOperand(unsigned OpIdx) const {
1617
106
    for (auto &BOI : bundle_op_infos())
1618
106
      
if (106
BOI.Begin <= OpIdx && 106
OpIdx < BOI.End106
)
1619
106
        return BOI;
1620
106
1621
0
    
llvm_unreachable0
("Did not find operand bundle for operand!");
1622
106
  }
Unexecuted instantiation: llvm::OperandBundleUser<llvm::InvokeInst, llvm::Use*>::getBundleOpInfoForOperand(unsigned int) const
llvm::OperandBundleUser<llvm::CallInst, llvm::Use*>::getBundleOpInfoForOperand(unsigned int) const
Line
Count
Source
1616
106
  const BundleOpInfo &getBundleOpInfoForOperand(unsigned OpIdx) const {
1617
106
    for (auto &BOI : bundle_op_infos())
1618
106
      
if (106
BOI.Begin <= OpIdx && 106
OpIdx < BOI.End106
)
1619
106
        return BOI;
1620
106
1621
0
    
llvm_unreachable0
("Did not find operand bundle for operand!");
1622
  }
1623
1624
  /// \brief Return the total number of values used in \p Bundles.
1625
13.3M
  static unsigned CountBundleInputs(ArrayRef<OperandBundleDef> Bundles) {
1626
13.3M
    unsigned Total = 0;
1627
13.3M
    for (auto &B : Bundles)
1628
3.16k
      Total += B.input_size();
1629
13.3M
    return Total;
1630
13.3M
  }
llvm::OperandBundleUser<llvm::CallInst, llvm::Use*>::CountBundleInputs(llvm::ArrayRef<llvm::OperandBundleDefT<llvm::Value*> >)
Line
Count
Source
1625
13.3M
  static unsigned CountBundleInputs(ArrayRef<OperandBundleDef> Bundles) {
1626
13.3M
    unsigned Total = 0;
1627
13.3M
    for (auto &B : Bundles)
1628
2.88k
      Total += B.input_size();
1629
13.3M
    return Total;
1630
13.3M
  }
llvm::OperandBundleUser<llvm::InvokeInst, llvm::Use*>::CountBundleInputs(llvm::ArrayRef<llvm::OperandBundleDefT<llvm::Value*> >)
Line
Count
Source
1625
39.9k
  static unsigned CountBundleInputs(ArrayRef<OperandBundleDef> Bundles) {
1626
39.9k
    unsigned Total = 0;
1627
39.9k
    for (auto &B : Bundles)
1628
280
      Total += B.input_size();
1629
39.9k
    return Total;
1630
39.9k
  }
1631
};
1632
1633
} // end namespace llvm
1634
1635
#endif // LLVM_IR_INSTRTYPES_H