LLVM  13.0.0git
GVNExpression.h
Go to the documentation of this file.
1 //===- GVNExpression.h - GVN Expression classes -----------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 /// \file
10 ///
11 /// The header file for the GVN pass that contains expression handling
12 /// classes
13 //
14 //===----------------------------------------------------------------------===//
15 
16 #ifndef LLVM_TRANSFORMS_SCALAR_GVNEXPRESSION_H
17 #define LLVM_TRANSFORMS_SCALAR_GVNEXPRESSION_H
18 
19 #include "llvm/ADT/Hashing.h"
22 #include "llvm/IR/Constant.h"
23 #include "llvm/IR/Instructions.h"
24 #include "llvm/IR/Value.h"
25 #include "llvm/Support/Allocator.h"
27 #include "llvm/Support/Casting.h"
28 #include "llvm/Support/Compiler.h"
30 #include <algorithm>
31 #include <cassert>
32 #include <iterator>
33 #include <utility>
34 
35 namespace llvm {
36 
37 class BasicBlock;
38 class Type;
39 
40 namespace GVNExpression {
41 
58 };
59 
60 class Expression {
61 private:
62  ExpressionType EType;
63  unsigned Opcode;
64  mutable hash_code HashVal = 0;
65 
66 public:
67  Expression(ExpressionType ET = ET_Base, unsigned O = ~2U)
68  : EType(ET), Opcode(O) {}
69  Expression(const Expression &) = delete;
70  Expression &operator=(const Expression &) = delete;
71  virtual ~Expression();
72 
73  static unsigned getEmptyKey() { return ~0U; }
74  static unsigned getTombstoneKey() { return ~1U; }
75 
76  bool operator!=(const Expression &Other) const { return !(*this == Other); }
77  bool operator==(const Expression &Other) const {
78  if (getOpcode() != Other.getOpcode())
79  return false;
80  if (getOpcode() == getEmptyKey() || getOpcode() == getTombstoneKey())
81  return true;
82  // Compare the expression type for anything but load and store.
83  // For load and store we set the opcode to zero to make them equal.
85  getExpressionType() != Other.getExpressionType())
86  return false;
87 
88  return equals(Other);
89  }
90 
92  // It's theoretically possible for a thing to hash to zero. In that case,
93  // we will just compute the hash a few extra times, which is no worse that
94  // we did before, which was to compute it always.
95  if (static_cast<unsigned>(HashVal) == 0)
96  HashVal = getHashValue();
97  return HashVal;
98  }
99 
100  virtual bool equals(const Expression &Other) const { return true; }
101 
102  // Return true if the two expressions are exactly the same, including the
103  // normally ignored fields.
104  virtual bool exactlyEquals(const Expression &Other) const {
105  return getExpressionType() == Other.getExpressionType() && equals(Other);
106  }
107 
108  unsigned getOpcode() const { return Opcode; }
109  void setOpcode(unsigned opcode) { Opcode = opcode; }
110  ExpressionType getExpressionType() const { return EType; }
111 
112  // We deliberately leave the expression type out of the hash value.
113  virtual hash_code getHashValue() const { return getOpcode(); }
114 
115  // Debugging support
116  virtual void printInternal(raw_ostream &OS, bool PrintEType) const {
117  if (PrintEType)
118  OS << "etype = " << getExpressionType() << ",";
119  OS << "opcode = " << getOpcode() << ", ";
120  }
121 
122  void print(raw_ostream &OS) const {
123  OS << "{ ";
124  printInternal(OS, true);
125  OS << "}";
126  }
127 
128  LLVM_DUMP_METHOD void dump() const;
129 };
130 
132  E.print(OS);
133  return OS;
134 }
135 
136 class BasicExpression : public Expression {
137 private:
140 
141  Value **Operands = nullptr;
142  unsigned MaxOperands;
143  unsigned NumOperands = 0;
144  Type *ValueType = nullptr;
145 
146 public:
147  BasicExpression(unsigned NumOperands)
148  : BasicExpression(NumOperands, ET_Basic) {}
149  BasicExpression(unsigned NumOperands, ExpressionType ET)
150  : Expression(ET), MaxOperands(NumOperands) {}
151  BasicExpression() = delete;
152  BasicExpression(const BasicExpression &) = delete;
153  BasicExpression &operator=(const BasicExpression &) = delete;
154  ~BasicExpression() override;
155 
156  static bool classof(const Expression *EB) {
158  return ET > ET_BasicStart && ET < ET_BasicEnd;
159  }
160 
161  /// Swap two operands. Used during GVN to put commutative operands in
162  /// order.
163  void swapOperands(unsigned First, unsigned Second) {
164  std::swap(Operands[First], Operands[Second]);
165  }
166 
167  Value *getOperand(unsigned N) const {
168  assert(Operands && "Operands not allocated");
169  assert(N < NumOperands && "Operand out of range");
170  return Operands[N];
171  }
172 
173  void setOperand(unsigned N, Value *V) {
174  assert(Operands && "Operands not allocated before setting");
175  assert(N < NumOperands && "Operand out of range");
176  Operands[N] = V;
177  }
178 
179  unsigned getNumOperands() const { return NumOperands; }
180 
181  using op_iterator = Value **;
182  using const_op_iterator = Value *const *;
183 
185  op_iterator op_end() { return Operands + NumOperands; }
186  const_op_iterator op_begin() const { return Operands; }
187  const_op_iterator op_end() const { return Operands + NumOperands; }
190  }
193  }
194 
196  assert(NumOperands < MaxOperands && "Tried to add too many operands");
197  assert(Operands && "Operandss not allocated before pushing");
198  Operands[NumOperands++] = Arg;
199  }
200  bool op_empty() const { return getNumOperands() == 0; }
201 
203  assert(!Operands && "Operands already allocated");
204  Operands = Recycler.allocate(RecyclerCapacity::get(MaxOperands), Allocator);
205  }
207  Recycler.deallocate(RecyclerCapacity::get(MaxOperands), Operands);
208  }
209 
210  void setType(Type *T) { ValueType = T; }
211  Type *getType() const { return ValueType; }
212 
213  bool equals(const Expression &Other) const override {
214  if (getOpcode() != Other.getOpcode())
215  return false;
216 
217  const auto &OE = cast<BasicExpression>(Other);
218  return getType() == OE.getType() && NumOperands == OE.NumOperands &&
219  std::equal(op_begin(), op_end(), OE.op_begin());
220  }
221 
222  hash_code getHashValue() const override {
223  return hash_combine(this->Expression::getHashValue(), ValueType,
225  }
226 
227  // Debugging support
228  void printInternal(raw_ostream &OS, bool PrintEType) const override {
229  if (PrintEType)
230  OS << "ExpressionTypeBasic, ";
231 
232  this->Expression::printInternal(OS, false);
233  OS << "operands = {";
234  for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
235  OS << "[" << i << "] = ";
236  Operands[i]->printAsOperand(OS);
237  OS << " ";
238  }
239  OS << "} ";
240  }
241 };
242 
243 class op_inserter {
244 private:
245  using Container = BasicExpression;
246 
247  Container *BE;
248 
249 public:
250  using iterator_category = std::output_iterator_tag;
251  using value_type = void;
252  using difference_type = void;
253  using pointer = void;
254  using reference = void;
255 
256  explicit op_inserter(BasicExpression &E) : BE(&E) {}
257  explicit op_inserter(BasicExpression *E) : BE(E) {}
258 
260  BE->op_push_back(val);
261  return *this;
262  }
263  op_inserter &operator*() { return *this; }
264  op_inserter &operator++() { return *this; }
265  op_inserter &operator++(int) { return *this; }
266 };
267 
269 private:
270  const MemoryAccess *MemoryLeader;
271 
272 public:
273  MemoryExpression(unsigned NumOperands, enum ExpressionType EType,
274  const MemoryAccess *MemoryLeader)
275  : BasicExpression(NumOperands, EType), MemoryLeader(MemoryLeader) {}
276  MemoryExpression() = delete;
277  MemoryExpression(const MemoryExpression &) = delete;
278  MemoryExpression &operator=(const MemoryExpression &) = delete;
279 
280  static bool classof(const Expression *EB) {
281  return EB->getExpressionType() > ET_MemoryStart &&
283  }
284 
285  hash_code getHashValue() const override {
286  return hash_combine(this->BasicExpression::getHashValue(), MemoryLeader);
287  }
288 
289  bool equals(const Expression &Other) const override {
290  if (!this->BasicExpression::equals(Other))
291  return false;
292  const MemoryExpression &OtherMCE = cast<MemoryExpression>(Other);
293 
294  return MemoryLeader == OtherMCE.MemoryLeader;
295  }
296 
297  const MemoryAccess *getMemoryLeader() const { return MemoryLeader; }
298  void setMemoryLeader(const MemoryAccess *ML) { MemoryLeader = ML; }
299 };
300 
301 class CallExpression final : public MemoryExpression {
302 private:
303  CallInst *Call;
304 
305 public:
306  CallExpression(unsigned NumOperands, CallInst *C,
307  const MemoryAccess *MemoryLeader)
308  : MemoryExpression(NumOperands, ET_Call, MemoryLeader), Call(C) {}
309  CallExpression() = delete;
310  CallExpression(const CallExpression &) = delete;
311  CallExpression &operator=(const CallExpression &) = delete;
312  ~CallExpression() override;
313 
314  static bool classof(const Expression *EB) {
315  return EB->getExpressionType() == ET_Call;
316  }
317 
318  // Debugging support
319  void printInternal(raw_ostream &OS, bool PrintEType) const override {
320  if (PrintEType)
321  OS << "ExpressionTypeCall, ";
322  this->BasicExpression::printInternal(OS, false);
323  OS << " represents call at ";
324  Call->printAsOperand(OS);
325  }
326 };
327 
328 class LoadExpression final : public MemoryExpression {
329 private:
330  LoadInst *Load;
331 
332 public:
333  LoadExpression(unsigned NumOperands, LoadInst *L,
334  const MemoryAccess *MemoryLeader)
335  : LoadExpression(ET_Load, NumOperands, L, MemoryLeader) {}
336 
337  LoadExpression(enum ExpressionType EType, unsigned NumOperands, LoadInst *L,
338  const MemoryAccess *MemoryLeader)
339  : MemoryExpression(NumOperands, EType, MemoryLeader), Load(L) {}
340 
341  LoadExpression() = delete;
342  LoadExpression(const LoadExpression &) = delete;
343  LoadExpression &operator=(const LoadExpression &) = delete;
344  ~LoadExpression() override;
345 
346  static bool classof(const Expression *EB) {
347  return EB->getExpressionType() == ET_Load;
348  }
349 
350  LoadInst *getLoadInst() const { return Load; }
351  void setLoadInst(LoadInst *L) { Load = L; }
352 
353  bool equals(const Expression &Other) const override;
354  bool exactlyEquals(const Expression &Other) const override {
356  cast<LoadExpression>(Other).getLoadInst() == getLoadInst();
357  }
358 
359  // Debugging support
360  void printInternal(raw_ostream &OS, bool PrintEType) const override {
361  if (PrintEType)
362  OS << "ExpressionTypeLoad, ";
363  this->BasicExpression::printInternal(OS, false);
364  OS << " represents Load at ";
365  Load->printAsOperand(OS);
366  OS << " with MemoryLeader " << *getMemoryLeader();
367  }
368 };
369 
370 class StoreExpression final : public MemoryExpression {
371 private:
372  StoreInst *Store;
373  Value *StoredValue;
374 
375 public:
376  StoreExpression(unsigned NumOperands, StoreInst *S, Value *StoredValue,
377  const MemoryAccess *MemoryLeader)
378  : MemoryExpression(NumOperands, ET_Store, MemoryLeader), Store(S),
379  StoredValue(StoredValue) {}
380  StoreExpression() = delete;
381  StoreExpression(const StoreExpression &) = delete;
382  StoreExpression &operator=(const StoreExpression &) = delete;
383  ~StoreExpression() override;
384 
385  static bool classof(const Expression *EB) {
386  return EB->getExpressionType() == ET_Store;
387  }
388 
389  StoreInst *getStoreInst() const { return Store; }
390  Value *getStoredValue() const { return StoredValue; }
391 
392  bool equals(const Expression &Other) const override;
393 
394  bool exactlyEquals(const Expression &Other) const override {
396  cast<StoreExpression>(Other).getStoreInst() == getStoreInst();
397  }
398 
399  // Debugging support
400  void printInternal(raw_ostream &OS, bool PrintEType) const override {
401  if (PrintEType)
402  OS << "ExpressionTypeStore, ";
403  this->BasicExpression::printInternal(OS, false);
404  OS << " represents Store " << *Store;
405  OS << " with StoredValue ";
406  StoredValue->printAsOperand(OS);
407  OS << " and MemoryLeader " << *getMemoryLeader();
408  }
409 };
410 
412 private:
413  unsigned MaxIntOperands;
414  unsigned NumIntOperands = 0;
415  unsigned *IntOperands = nullptr;
416 
417 public:
418  AggregateValueExpression(unsigned NumOperands, unsigned NumIntOperands)
419  : BasicExpression(NumOperands, ET_AggregateValue),
420  MaxIntOperands(NumIntOperands) {}
421  AggregateValueExpression() = delete;
424  operator=(const AggregateValueExpression &) = delete;
425  ~AggregateValueExpression() override;
426 
427  static bool classof(const Expression *EB) {
428  return EB->getExpressionType() == ET_AggregateValue;
429  }
430 
431  using int_arg_iterator = unsigned *;
432  using const_int_arg_iterator = const unsigned *;
433 
434  int_arg_iterator int_op_begin() { return IntOperands; }
435  int_arg_iterator int_op_end() { return IntOperands + NumIntOperands; }
436  const_int_arg_iterator int_op_begin() const { return IntOperands; }
438  return IntOperands + NumIntOperands;
439  }
440  unsigned int_op_size() const { return NumIntOperands; }
441  bool int_op_empty() const { return NumIntOperands == 0; }
442  void int_op_push_back(unsigned IntOperand) {
443  assert(NumIntOperands < MaxIntOperands &&
444  "Tried to add too many int operands");
445  assert(IntOperands && "Operands not allocated before pushing");
446  IntOperands[NumIntOperands++] = IntOperand;
447  }
448 
450  assert(!IntOperands && "Operands already allocated");
451  IntOperands = Allocator.Allocate<unsigned>(MaxIntOperands);
452  }
453 
454  bool equals(const Expression &Other) const override {
455  if (!this->BasicExpression::equals(Other))
456  return false;
457  const AggregateValueExpression &OE = cast<AggregateValueExpression>(Other);
458  return NumIntOperands == OE.NumIntOperands &&
460  }
461 
462  hash_code getHashValue() const override {
465  }
466 
467  // Debugging support
468  void printInternal(raw_ostream &OS, bool PrintEType) const override {
469  if (PrintEType)
470  OS << "ExpressionTypeAggregateValue, ";
471  this->BasicExpression::printInternal(OS, false);
472  OS << ", intoperands = {";
473  for (unsigned i = 0, e = int_op_size(); i != e; ++i) {
474  OS << "[" << i << "] = " << IntOperands[i] << " ";
475  }
476  OS << "}";
477  }
478 };
479 
481 private:
483 
484  Container *AVE;
485 
486 public:
487  using iterator_category = std::output_iterator_tag;
488  using value_type = void;
489  using difference_type = void;
490  using pointer = void;
491  using reference = void;
492 
495 
496  int_op_inserter &operator=(unsigned int val) {
497  AVE->int_op_push_back(val);
498  return *this;
499  }
500  int_op_inserter &operator*() { return *this; }
501  int_op_inserter &operator++() { return *this; }
502  int_op_inserter &operator++(int) { return *this; }
503 };
504 
505 class PHIExpression final : public BasicExpression {
506 private:
507  BasicBlock *BB;
508 
509 public:
510  PHIExpression(unsigned NumOperands, BasicBlock *B)
511  : BasicExpression(NumOperands, ET_Phi), BB(B) {}
512  PHIExpression() = delete;
513  PHIExpression(const PHIExpression &) = delete;
514  PHIExpression &operator=(const PHIExpression &) = delete;
515  ~PHIExpression() override;
516 
517  static bool classof(const Expression *EB) {
518  return EB->getExpressionType() == ET_Phi;
519  }
520 
521  bool equals(const Expression &Other) const override {
522  if (!this->BasicExpression::equals(Other))
523  return false;
524  const PHIExpression &OE = cast<PHIExpression>(Other);
525  return BB == OE.BB;
526  }
527 
528  hash_code getHashValue() const override {
529  return hash_combine(this->BasicExpression::getHashValue(), BB);
530  }
531 
532  // Debugging support
533  void printInternal(raw_ostream &OS, bool PrintEType) const override {
534  if (PrintEType)
535  OS << "ExpressionTypePhi, ";
536  this->BasicExpression::printInternal(OS, false);
537  OS << "bb = " << BB;
538  }
539 };
540 
541 class DeadExpression final : public Expression {
542 public:
544  DeadExpression(const DeadExpression &) = delete;
545  DeadExpression &operator=(const DeadExpression &) = delete;
546 
547  static bool classof(const Expression *E) {
548  return E->getExpressionType() == ET_Dead;
549  }
550 };
551 
552 class VariableExpression final : public Expression {
553 private:
554  Value *VariableValue;
555 
556 public:
557  VariableExpression(Value *V) : Expression(ET_Variable), VariableValue(V) {}
558  VariableExpression() = delete;
559  VariableExpression(const VariableExpression &) = delete;
561 
562  static bool classof(const Expression *EB) {
563  return EB->getExpressionType() == ET_Variable;
564  }
565 
566  Value *getVariableValue() const { return VariableValue; }
567  void setVariableValue(Value *V) { VariableValue = V; }
568 
569  bool equals(const Expression &Other) const override {
570  const VariableExpression &OC = cast<VariableExpression>(Other);
571  return VariableValue == OC.VariableValue;
572  }
573 
574  hash_code getHashValue() const override {
575  return hash_combine(this->Expression::getHashValue(),
576  VariableValue->getType(), VariableValue);
577  }
578 
579  // Debugging support
580  void printInternal(raw_ostream &OS, bool PrintEType) const override {
581  if (PrintEType)
582  OS << "ExpressionTypeVariable, ";
583  this->Expression::printInternal(OS, false);
584  OS << " variable = " << *VariableValue;
585  }
586 };
587 
588 class ConstantExpression final : public Expression {
589 private:
590  Constant *ConstantValue = nullptr;
591 
592 public:
594  ConstantExpression(Constant *constantValue)
595  : Expression(ET_Constant), ConstantValue(constantValue) {}
596  ConstantExpression(const ConstantExpression &) = delete;
598 
599  static bool classof(const Expression *EB) {
600  return EB->getExpressionType() == ET_Constant;
601  }
602 
603  Constant *getConstantValue() const { return ConstantValue; }
604  void setConstantValue(Constant *V) { ConstantValue = V; }
605 
606  bool equals(const Expression &Other) const override {
607  const ConstantExpression &OC = cast<ConstantExpression>(Other);
608  return ConstantValue == OC.ConstantValue;
609  }
610 
611  hash_code getHashValue() const override {
612  return hash_combine(this->Expression::getHashValue(),
613  ConstantValue->getType(), ConstantValue);
614  }
615 
616  // Debugging support
617  void printInternal(raw_ostream &OS, bool PrintEType) const override {
618  if (PrintEType)
619  OS << "ExpressionTypeConstant, ";
620  this->Expression::printInternal(OS, false);
621  OS << " constant = " << *ConstantValue;
622  }
623 };
624 
625 class UnknownExpression final : public Expression {
626 private:
627  Instruction *Inst;
628 
629 public:
631  UnknownExpression() = delete;
632  UnknownExpression(const UnknownExpression &) = delete;
633  UnknownExpression &operator=(const UnknownExpression &) = delete;
634 
635  static bool classof(const Expression *EB) {
636  return EB->getExpressionType() == ET_Unknown;
637  }
638 
639  Instruction *getInstruction() const { return Inst; }
640  void setInstruction(Instruction *I) { Inst = I; }
641 
642  bool equals(const Expression &Other) const override {
643  const auto &OU = cast<UnknownExpression>(Other);
644  return Inst == OU.Inst;
645  }
646 
647  hash_code getHashValue() const override {
648  return hash_combine(this->Expression::getHashValue(), Inst);
649  }
650 
651  // Debugging support
652  void printInternal(raw_ostream &OS, bool PrintEType) const override {
653  if (PrintEType)
654  OS << "ExpressionTypeUnknown, ";
655  this->Expression::printInternal(OS, false);
656  OS << " inst = " << *Inst;
657  }
658 };
659 
660 } // end namespace GVNExpression
661 
662 } // end namespace llvm
663 
664 #endif // LLVM_TRANSFORMS_SCALAR_GVNEXPRESSION_H
llvm::GVNExpression::ET_Store
@ ET_Store
Definition: GVNExpression.h:55
llvm::GVNExpression::int_op_inserter::operator=
int_op_inserter & operator=(unsigned int val)
Definition: GVNExpression.h:496
i
i
Definition: README.txt:29
llvm::GVNExpression::op_inserter::op_inserter
op_inserter(BasicExpression *E)
Definition: GVNExpression.h:257
llvm::GVNExpression::ConstantExpression::classof
static bool classof(const Expression *EB)
Definition: GVNExpression.h:599
llvm::GVNExpression::BasicExpression::op_end
op_iterator op_end()
Definition: GVNExpression.h:185
llvm::GVNExpression::ET_Load
@ ET_Load
Definition: GVNExpression.h:54
llvm::GVNExpression::MemoryExpression::MemoryExpression
MemoryExpression(unsigned NumOperands, enum ExpressionType EType, const MemoryAccess *MemoryLeader)
Definition: GVNExpression.h:273
LLVM_DUMP_METHOD
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
Definition: Compiler.h:499
llvm::GVNExpression::BasicExpression::swapOperands
void swapOperands(unsigned First, unsigned Second)
Swap two operands.
Definition: GVNExpression.h:163
llvm
Definition: AllocatorList.h:23
llvm::GVNExpression::ET_Unknown
@ ET_Unknown
Definition: GVNExpression.h:47
llvm::GVNExpression::Expression::getEmptyKey
static unsigned getEmptyKey()
Definition: GVNExpression.h:73
llvm::GVNExpression::Expression::getExpressionType
ExpressionType getExpressionType() const
Definition: GVNExpression.h:110
llvm::GVNExpression::VariableExpression::equals
bool equals(const Expression &Other) const override
Definition: GVNExpression.h:569
llvm::GVNExpression::LoadExpression::LoadExpression
LoadExpression()=delete
llvm::GVNExpression::CallExpression::CallExpression
CallExpression(unsigned NumOperands, CallInst *C, const MemoryAccess *MemoryLeader)
Definition: GVNExpression.h:306
llvm::GVNExpression::LoadExpression::printInternal
void printInternal(raw_ostream &OS, bool PrintEType) const override
Definition: GVNExpression.h:360
llvm::GVNExpression::Expression::getHashValue
virtual hash_code getHashValue() const
Definition: GVNExpression.h:113
llvm::GVNExpression::UnknownExpression::UnknownExpression
UnknownExpression()=delete
llvm::GVNExpression::Expression::getOpcode
unsigned getOpcode() const
Definition: GVNExpression.h:108
llvm::GVNExpression::AggregateValueExpression::classof
static bool classof(const Expression *EB)
Definition: GVNExpression.h:427
llvm::GVNExpression::StoreExpression::StoreExpression
StoreExpression()=delete
llvm::GVNExpression::MemoryExpression::setMemoryLeader
void setMemoryLeader(const MemoryAccess *ML)
Definition: GVNExpression.h:298
llvm::GVNExpression::AggregateValueExpression::int_op_empty
bool int_op_empty() const
Definition: GVNExpression.h:441
llvm::GVNExpression::VariableExpression::getVariableValue
Value * getVariableValue() const
Definition: GVNExpression.h:566
llvm::GVNExpression::Expression::printInternal
virtual void printInternal(raw_ostream &OS, bool PrintEType) const
Definition: GVNExpression.h:116
llvm::GVNExpression::operator<<
raw_ostream & operator<<(raw_ostream &OS, const Expression &E)
Definition: GVNExpression.h:131
Allocator.h
llvm::GVNExpression::MemoryExpression::operator=
MemoryExpression & operator=(const MemoryExpression &)=delete
llvm::GVNExpression::AggregateValueExpression::AggregateValueExpression
AggregateValueExpression(unsigned NumOperands, unsigned NumIntOperands)
Definition: GVNExpression.h:418
llvm::GVNExpression::StoreExpression::StoreExpression
StoreExpression(unsigned NumOperands, StoreInst *S, Value *StoredValue, const MemoryAccess *MemoryLeader)
Definition: GVNExpression.h:376
llvm::GVNExpression::MemoryExpression
Definition: GVNExpression.h:268
llvm::GVNExpression::PHIExpression::equals
bool equals(const Expression &Other) const override
Definition: GVNExpression.h:521
llvm::ArrayRecycler::Capacity::get
static Capacity get(size_t N)
Get the capacity of an array that can hold at least N elements.
Definition: ArrayRecycler.h:79
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:46
llvm::GVNExpression::DeadExpression::classof
static bool classof(const Expression *E)
Definition: GVNExpression.h:547
llvm::GVNExpression::ET_AggregateValue
@ ET_AggregateValue
Definition: GVNExpression.h:50
llvm::GVNExpression::int_op_inserter::pointer
void pointer
Definition: GVNExpression.h:490
llvm::GVNExpression::BasicExpression::setOperand
void setOperand(unsigned N, Value *V)
Definition: GVNExpression.h:173
T
#define T
Definition: Mips16ISelLowering.cpp:341
llvm::GVNExpression::Expression::operator==
bool operator==(const Expression &Other) const
Definition: GVNExpression.h:77
llvm::GVNExpression::ET_Constant
@ ET_Constant
Definition: GVNExpression.h:44
llvm::GVNExpression::StoreExpression::~StoreExpression
~StoreExpression() override
llvm::GVNExpression::int_op_inserter::int_op_inserter
int_op_inserter(AggregateValueExpression *E)
Definition: GVNExpression.h:494
Hashing.h
llvm::GVNExpression::Expression::equals
virtual bool equals(const Expression &Other) const
Definition: GVNExpression.h:100
llvm::GVNExpression::UnknownExpression::classof
static bool classof(const Expression *EB)
Definition: GVNExpression.h:635
llvm::GVNExpression::int_op_inserter::iterator_category
std::output_iterator_tag iterator_category
Definition: GVNExpression.h:487
llvm::GVNExpression::VariableExpression::classof
static bool classof(const Expression *EB)
Definition: GVNExpression.h:562
llvm::GVNExpression::PHIExpression::operator=
PHIExpression & operator=(const PHIExpression &)=delete
llvm::GVNExpression::CallExpression::~CallExpression
~CallExpression() override
llvm::GVNExpression::int_op_inserter::value_type
void value_type
Definition: GVNExpression.h:488
llvm::GVNExpression::MemoryExpression::equals
bool equals(const Expression &Other) const override
Definition: GVNExpression.h:289
llvm::BasicBlock
LLVM Basic Block Representation.
Definition: BasicBlock.h:58
llvm::lltok::equal
@ equal
Definition: LLToken.h:25
llvm::GVNExpression::int_op_inserter::operator++
int_op_inserter & operator++(int)
Definition: GVNExpression.h:502
llvm::GVNExpression::op_inserter::reference
void reference
Definition: GVNExpression.h:254
llvm::GVNExpression::LoadExpression::classof
static bool classof(const Expression *EB)
Definition: GVNExpression.h:346
llvm::GVNExpression::LoadExpression::LoadExpression
LoadExpression(enum ExpressionType EType, unsigned NumOperands, LoadInst *L, const MemoryAccess *MemoryLeader)
Definition: GVNExpression.h:337
llvm::GVNExpression::UnknownExpression::UnknownExpression
UnknownExpression(Instruction *I)
Definition: GVNExpression.h:630
llvm::GVNExpression::UnknownExpression
Definition: GVNExpression.h:625
Arg
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
Definition: AMDGPULibCalls.cpp:206
llvm::GVNExpression::int_op_inserter
Definition: GVNExpression.h:480
llvm::GVNExpression::ConstantExpression
Definition: GVNExpression.h:588
llvm::GVNExpression::LoadExpression::setLoadInst
void setLoadInst(LoadInst *L)
Definition: GVNExpression.h:351
llvm::GVNExpression::StoreExpression::getStoredValue
Value * getStoredValue() const
Definition: GVNExpression.h:390
llvm::GVNExpression::AggregateValueExpression::AggregateValueExpression
AggregateValueExpression()=delete
llvm::GVNExpression::AggregateValueExpression::printInternal
void printInternal(raw_ostream &OS, bool PrintEType) const override
Definition: GVNExpression.h:468
llvm::GVNExpression::BasicExpression::const_op_iterator
Value *const * const_op_iterator
Definition: GVNExpression.h:182
llvm::GVNExpression::PHIExpression
Definition: GVNExpression.h:505
llvm::GVNExpression::Expression::print
void print(raw_ostream &OS) const
Definition: GVNExpression.h:122
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
llvm::GVNExpression::BasicExpression::operands
iterator_range< op_iterator > operands()
Definition: GVNExpression.h:188
llvm::GVNExpression::int_op_inserter::int_op_inserter
int_op_inserter(AggregateValueExpression &E)
Definition: GVNExpression.h:493
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::GVNExpression::PHIExpression::classof
static bool classof(const Expression *EB)
Definition: GVNExpression.h:517
llvm::GVNExpression::UnknownExpression::getInstruction
Instruction * getInstruction() const
Definition: GVNExpression.h:639
llvm::GVNExpression::LoadExpression::equals
bool equals(const Expression &Other) const override
Definition: NewGVN.cpp:911
B
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
First
into llvm powi allowing the code generator to produce balanced multiplication trees First
Definition: README.txt:54
llvm::GVNExpression::PHIExpression::PHIExpression
PHIExpression(unsigned NumOperands, BasicBlock *B)
Definition: GVNExpression.h:510
llvm::GVNExpression::CallExpression::operator=
CallExpression & operator=(const CallExpression &)=delete
llvm::GVNExpression::Expression
Definition: GVNExpression.h:60
llvm::Instruction
Definition: Instruction.h:45
llvm::GVNExpression::MemoryExpression::MemoryExpression
MemoryExpression()=delete
llvm::GVNExpression::AggregateValueExpression::int_op_begin
int_arg_iterator int_op_begin()
Definition: GVNExpression.h:434
llvm::GVNExpression::LoadExpression::exactlyEquals
bool exactlyEquals(const Expression &Other) const override
Definition: GVNExpression.h:354
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:50
llvm::GVNExpression::BasicExpression::~BasicExpression
~BasicExpression() override
llvm::GVNExpression::AggregateValueExpression::getHashValue
hash_code getHashValue() const override
Definition: GVNExpression.h:462
llvm::GVNExpression::BasicExpression::getOperand
Value * getOperand(unsigned N) const
Definition: GVNExpression.h:167
llvm::GVNExpression::BasicExpression::BasicExpression
BasicExpression(unsigned NumOperands)
Definition: GVNExpression.h:147
llvm::GVNExpression::ET_Call
@ ET_Call
Definition: GVNExpression.h:53
llvm::GVNExpression::PHIExpression::~PHIExpression
~PHIExpression() override
llvm::GVNExpression::op_inserter::operator*
op_inserter & operator*()
Definition: GVNExpression.h:263
llvm::GVNExpression::Expression::operator=
Expression & operator=(const Expression &)=delete
llvm::GVNExpression::BasicExpression::op_push_back
void op_push_back(Value *Arg)
Definition: GVNExpression.h:195
llvm::GVNExpression::VariableExpression::printInternal
void printInternal(raw_ostream &OS, bool PrintEType) const override
Definition: GVNExpression.h:580
llvm::GVNExpression::op_inserter::operator++
op_inserter & operator++(int)
Definition: GVNExpression.h:265
llvm::GVNExpression::LoadExpression::operator=
LoadExpression & operator=(const LoadExpression &)=delete
llvm::GVNExpression::op_inserter::pointer
void pointer
Definition: GVNExpression.h:253
llvm::GVNExpression::BasicExpression::getType
Type * getType() const
Definition: GVNExpression.h:211
llvm::GVNExpression::PHIExpression::printInternal
void printInternal(raw_ostream &OS, bool PrintEType) const override
Definition: GVNExpression.h:533
Operands
mir Rename Register Operands
Definition: MIRNamerPass.cpp:78
llvm::GVNExpression::Expression::exactlyEquals
virtual bool exactlyEquals(const Expression &Other) const
Definition: GVNExpression.h:104
llvm::GVNExpression::BasicExpression::operands
iterator_range< const_op_iterator > operands() const
Definition: GVNExpression.h:191
llvm::GVNExpression::BasicExpression::printInternal
void printInternal(raw_ostream &OS, bool PrintEType) const override
Definition: GVNExpression.h:228
val
The initial backend is deliberately restricted to z10 We should add support for later architectures at some point If an asm ties an i32 r result to an i64 the input will be treated as an leaving the upper bits uninitialised For i64 store i32 val
Definition: README.txt:15
llvm::GVNExpression::op_inserter::op_inserter
op_inserter(BasicExpression &E)
Definition: GVNExpression.h:256
llvm::GVNExpression::AggregateValueExpression::int_op_end
const_int_arg_iterator int_op_end() const
Definition: GVNExpression.h:437
llvm::GVNExpression::AggregateValueExpression::int_op_end
int_arg_iterator int_op_end()
Definition: GVNExpression.h:435
llvm::RISCVFenceField::O
@ O
Definition: RISCVBaseInfo.h:179
llvm::GVNExpression::MemoryExpression::classof
static bool classof(const Expression *EB)
Definition: GVNExpression.h:280
llvm::StoreInst
An instruction for storing to memory.
Definition: Instructions.h:303
llvm::GVNExpression::BasicExpression::deallocateOperands
void deallocateOperands(RecyclerType &Recycler)
Definition: GVNExpression.h:206
llvm::Constant
This is an important base class in LLVM.
Definition: Constant.h:41
llvm::GVNExpression::ConstantExpression::equals
bool equals(const Expression &Other) const override
Definition: GVNExpression.h:606
llvm::GVNExpression::UnknownExpression::setInstruction
void setInstruction(Instruction *I)
Definition: GVNExpression.h:640
llvm::GVNExpression::ET_Variable
@ ET_Variable
Definition: GVNExpression.h:45
llvm::GVNExpression::VariableExpression::getHashValue
hash_code getHashValue() const override
Definition: GVNExpression.h:574
llvm::GVNExpression::AggregateValueExpression::operator=
AggregateValueExpression & operator=(const AggregateValueExpression &)=delete
llvm::GVNExpression::ET_Dead
@ ET_Dead
Definition: GVNExpression.h:46
llvm::GVNExpression::Expression::getComputedHash
hash_code getComputedHash() const
Definition: GVNExpression.h:91
llvm::GVNExpression::AggregateValueExpression::~AggregateValueExpression
~AggregateValueExpression() override
llvm::GVNExpression::BasicExpression::operator=
BasicExpression & operator=(const BasicExpression &)=delete
llvm::GVNExpression::LoadExpression::getLoadInst
LoadInst * getLoadInst() const
Definition: GVNExpression.h:350
llvm::GVNExpression::StoreExpression::exactlyEquals
bool exactlyEquals(const Expression &Other) const override
Definition: GVNExpression.h:394
llvm::BumpPtrAllocatorImpl
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition: Allocator.h:67
llvm::numbers::e
constexpr double e
Definition: MathExtras.h:57
llvm::GVNExpression::VariableExpression::VariableExpression
VariableExpression()=delete
llvm::GVNExpression::VariableExpression::operator=
VariableExpression & operator=(const VariableExpression &)=delete
llvm::GVNExpression::ConstantExpression::getConstantValue
Constant * getConstantValue() const
Definition: GVNExpression.h:603
llvm::GVNExpression::UnknownExpression::getHashValue
hash_code getHashValue() const override
Definition: GVNExpression.h:647
I
#define I(x, y, z)
Definition: MD5.cpp:59
llvm::GVNExpression::StoreExpression::classof
static bool classof(const Expression *EB)
Definition: GVNExpression.h:385
llvm::GVNExpression::DeadExpression::operator=
DeadExpression & operator=(const DeadExpression &)=delete
llvm::GVNExpression::int_op_inserter::difference_type
void difference_type
Definition: GVNExpression.h:489
llvm::GVNExpression::AggregateValueExpression::equals
bool equals(const Expression &Other) const override
Definition: GVNExpression.h:454
llvm::GVNExpression::UnknownExpression::printInternal
void printInternal(raw_ostream &OS, bool PrintEType) const override
Definition: GVNExpression.h:652
TemplateParamKind::Type
@ Type
llvm::GVNExpression::ConstantExpression::ConstantExpression
ConstantExpression(Constant *constantValue)
Definition: GVNExpression.h:594
llvm::GVNExpression::DeadExpression::DeadExpression
DeadExpression()
Definition: GVNExpression.h:543
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
std::swap
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Definition: BitVector.h:840
llvm::GVNExpression::op_inserter::operator++
op_inserter & operator++()
Definition: GVNExpression.h:264
llvm::GVNExpression::StoreExpression
Definition: GVNExpression.h:370
llvm::GVNExpression::VariableExpression
Definition: GVNExpression.h:552
llvm::SystemZISD::OC
@ OC
Definition: SystemZISelLowering.h:128
llvm::GVNExpression::int_op_inserter::operator*
int_op_inserter & operator*()
Definition: GVNExpression.h:500
iterator_range.h
llvm::ISD::BasicBlock
@ BasicBlock
Various leaf nodes.
Definition: ISDOpcodes.h:64
llvm::GVNExpression::ConstantExpression::getHashValue
hash_code getHashValue() const override
Definition: GVNExpression.h:611
llvm::Recycler
Recycler - This class manages a linked-list of deallocated nodes and facilitates reusing deallocated ...
Definition: Recycler.h:34
llvm::GVNExpression::BasicExpression::getNumOperands
unsigned getNumOperands() const
Definition: GVNExpression.h:179
llvm::GVNExpression::ET_Base
@ ET_Base
Definition: GVNExpression.h:43
llvm::GVNExpression::BasicExpression::op_empty
bool op_empty() const
Definition: GVNExpression.h:200
llvm::GVNExpression::StoreExpression::operator=
StoreExpression & operator=(const StoreExpression &)=delete
llvm::GVNExpression::BasicExpression::allocateOperands
void allocateOperands(RecyclerType &Recycler, BumpPtrAllocator &Allocator)
Definition: GVNExpression.h:202
llvm::Value::printAsOperand
void printAsOperand(raw_ostream &O, bool PrintType=true, const Module *M=nullptr) const
Print the name of this Value out to the specified raw_ostream.
Definition: AsmWriter.cpp:4700
llvm::GVNExpression::StoreExpression::equals
bool equals(const Expression &Other) const override
Definition: NewGVN.cpp:915
llvm::GVNExpression::ConstantExpression::ConstantExpression
ConstantExpression()
Definition: GVNExpression.h:593
llvm::GVNExpression::BasicExpression::BasicExpression
BasicExpression(unsigned NumOperands, ExpressionType ET)
Definition: GVNExpression.h:149
llvm::GVNExpression::Expression::getTombstoneKey
static unsigned getTombstoneKey()
Definition: GVNExpression.h:74
llvm::Value::getType
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:256
llvm::GVNExpression::CallExpression::CallExpression
CallExpression()=delete
llvm::GVNExpression::ExpressionType
ExpressionType
Definition: GVNExpression.h:42
Compiler.h
llvm::GVNExpression::BasicExpression::op_begin
const_op_iterator op_begin() const
Definition: GVNExpression.h:186
llvm::GVNExpression::AggregateValueExpression::int_op_begin
const_int_arg_iterator int_op_begin() const
Definition: GVNExpression.h:436
llvm::GVNExpression::UnknownExpression::equals
bool equals(const Expression &Other) const override
Definition: GVNExpression.h:642
llvm::ArrayRecycler::Capacity
The size of an allocated array is represented by a Capacity instance.
Definition: ArrayRecycler.h:71
llvm::GVNExpression::Expression::dump
LLVM_DUMP_METHOD void dump() const
Definition: GVNSink.cpp:91
llvm::GVNExpression::AggregateValueExpression::allocateIntOperands
virtual void allocateIntOperands(BumpPtrAllocator &Allocator)
Definition: GVNExpression.h:449
llvm::GVNExpression::BasicExpression::getHashValue
hash_code getHashValue() const override
Definition: GVNExpression.h:222
S
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Definition: README.txt:210
llvm::GVNExpression::CallExpression
Definition: GVNExpression.h:301
llvm::MemoryAccess
Definition: MemorySSA.h:140
llvm::LoadInst
An instruction for reading from memory.
Definition: Instructions.h:174
llvm::GVNExpression::ET_MemoryEnd
@ ET_MemoryEnd
Definition: GVNExpression.h:56
llvm::GVNExpression::PHIExpression::PHIExpression
PHIExpression()=delete
llvm::GVNExpression::Expression::Expression
Expression(ExpressionType ET=ET_Base, unsigned O=~2U)
Definition: GVNExpression.h:67
llvm::GVNExpression::VariableExpression::VariableExpression
VariableExpression(Value *V)
Definition: GVNExpression.h:557
llvm::PointerUnion< const Value *, const PseudoSourceValue * >
llvm::GVNExpression::StoreExpression::getStoreInst
StoreInst * getStoreInst() const
Definition: GVNExpression.h:389
llvm::GVNExpression::ConstantExpression::operator=
ConstantExpression & operator=(const ConstantExpression &)=delete
llvm::ArrayRecycler
Recycle small arrays allocated from a BumpPtrAllocator.
Definition: ArrayRecycler.h:28
llvm::GVNExpression::AggregateValueExpression::int_op_size
unsigned int_op_size() const
Definition: GVNExpression.h:440
llvm::GVNExpression::Expression::~Expression
virtual ~Expression()
Constant.h
llvm::GVNExpression::PHIExpression::getHashValue
hash_code getHashValue() const override
Definition: GVNExpression.h:528
llvm::GVNExpression::Expression::operator!=
bool operator!=(const Expression &Other) const
Definition: GVNExpression.h:76
llvm::GVNExpression::BasicExpression::op_end
const_op_iterator op_end() const
Definition: GVNExpression.h:187
Casting.h
llvm::GVNExpression::op_inserter::operator=
op_inserter & operator=(Value *val)
Definition: GVNExpression.h:259
llvm::GVNExpression::DeadExpression
Definition: GVNExpression.h:541
llvm::GVNExpression::MemoryExpression::getHashValue
hash_code getHashValue() const override
Definition: GVNExpression.h:285
llvm::GVNExpression::ET_MemoryStart
@ ET_MemoryStart
Definition: GVNExpression.h:52
llvm::GVNExpression::ConstantExpression::printInternal
void printInternal(raw_ostream &OS, bool PrintEType) const override
Definition: GVNExpression.h:617
llvm::GVNExpression::Expression::setOpcode
void setOpcode(unsigned opcode)
Definition: GVNExpression.h:109
llvm::GVNExpression::StoreExpression::printInternal
void printInternal(raw_ostream &OS, bool PrintEType) const override
Definition: GVNExpression.h:400
llvm::GVNExpression::BasicExpression::equals
bool equals(const Expression &Other) const override
Definition: GVNExpression.h:213
llvm::GVNExpression::op_inserter::difference_type
void difference_type
Definition: GVNExpression.h:252
llvm::GVNExpression::int_op_inserter::operator++
int_op_inserter & operator++()
Definition: GVNExpression.h:501
llvm::GVNExpression::LoadExpression::~LoadExpression
~LoadExpression() override
llvm::GVNExpression::AggregateValueExpression::const_int_arg_iterator
const unsigned * const_int_arg_iterator
Definition: GVNExpression.h:432
llvm::GVNExpression::ConstantExpression::setConstantValue
void setConstantValue(Constant *V)
Definition: GVNExpression.h:604
llvm::GVNExpression::CallExpression::classof
static bool classof(const Expression *EB)
Definition: GVNExpression.h:314
MemorySSA.h
Instructions.h
llvm::GVNExpression::AggregateValueExpression
Definition: GVNExpression.h:411
llvm::GVNExpression::BasicExpression::classof
static bool classof(const Expression *EB)
Definition: GVNExpression.h:156
llvm::hash_combine
hash_code hash_combine(const Ts &...args)
Combine values into a single hash_code.
Definition: Hashing.h:604
ArrayRecycler.h
llvm::GVNExpression::ET_Basic
@ ET_Basic
Definition: GVNExpression.h:49
Allocator
Basic Register Allocator
Definition: RegAllocBasic.cpp:146
llvm::GVNExpression::MemoryExpression::getMemoryLeader
const MemoryAccess * getMemoryLeader() const
Definition: GVNExpression.h:297
N
#define N
llvm::hash_combine_range
hash_code hash_combine_range(InputIteratorT first, InputIteratorT last)
Compute a hash_code for a sequence of values.
Definition: Hashing.h:482
llvm::GVNExpression::UnknownExpression::operator=
UnknownExpression & operator=(const UnknownExpression &)=delete
llvm::GVNExpression::op_inserter::value_type
void value_type
Definition: GVNExpression.h:251
llvm::GVNExpression::ET_BasicStart
@ ET_BasicStart
Definition: GVNExpression.h:48
llvm::iterator_range
A range adaptor for a pair of iterators.
Definition: iterator_range.h:30
llvm::GVNExpression::BasicExpression
Definition: GVNExpression.h:136
llvm::GVNExpression::VariableExpression::setVariableValue
void setVariableValue(Value *V)
Definition: GVNExpression.h:567
llvm::GVNExpression::AggregateValueExpression::int_op_push_back
void int_op_push_back(unsigned IntOperand)
Definition: GVNExpression.h:442
llvm::CallInst
This class represents a function call, abstracting a target machine's calling convention.
Definition: Instructions.h:1478
BB
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM BB
Definition: README.txt:39
llvm::GVNExpression::op_inserter
Definition: GVNExpression.h:243
llvm::GVNExpression::LoadExpression::LoadExpression
LoadExpression(unsigned NumOperands, LoadInst *L, const MemoryAccess *MemoryLeader)
Definition: GVNExpression.h:333
llvm::GVNExpression::BasicExpression::BasicExpression
BasicExpression()=delete
llvm::GVNExpression::BasicExpression::op_begin
op_iterator op_begin()
Definition: GVNExpression.h:184
llvm::GVNExpression::AggregateValueExpression::int_arg_iterator
unsigned * int_arg_iterator
Definition: GVNExpression.h:431
llvm::GVNExpression::op_inserter::iterator_category
std::output_iterator_tag iterator_category
Definition: GVNExpression.h:250
raw_ostream.h
llvm::GVNExpression::CallExpression::printInternal
void printInternal(raw_ostream &OS, bool PrintEType) const override
Definition: GVNExpression.h:319
Value.h
llvm::GVNExpression::BasicExpression::setType
void setType(Type *T)
Definition: GVNExpression.h:210
llvm::GVNExpression::LoadExpression
Definition: GVNExpression.h:328
llvm::GVNExpression::ET_BasicEnd
@ ET_BasicEnd
Definition: GVNExpression.h:57
llvm::Value
LLVM Value Representation.
Definition: Value.h:75
Other
Optional< std::vector< StOtherPiece > > Other
Definition: ELFYAML.cpp:1169
llvm::GVNExpression::int_op_inserter::reference
void reference
Definition: GVNExpression.h:491
llvm::hash_code
An opaque object representing a hash code.
Definition: Hashing.h:72
llvm::GVNExpression::ET_Phi
@ ET_Phi
Definition: GVNExpression.h:51