LLVM  15.0.0git
Instruction.cpp
Go to the documentation of this file.
1 //===-- Instruction.cpp - Implement the Instruction class -----------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements the Instruction class for the IR library.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #include "llvm/IR/Instruction.h"
14 #include "llvm/ADT/DenseSet.h"
15 #include "llvm/IR/Constants.h"
16 #include "llvm/IR/Instructions.h"
17 #include "llvm/IR/IntrinsicInst.h"
18 #include "llvm/IR/Intrinsics.h"
19 #include "llvm/IR/Operator.h"
20 #include "llvm/IR/Type.h"
21 using namespace llvm;
22 
23 Instruction::Instruction(Type *ty, unsigned it, Use *Ops, unsigned NumOps,
24  Instruction *InsertBefore)
25  : User(ty, Value::InstructionVal + it, Ops, NumOps), Parent(nullptr) {
26 
27  // If requested, insert this instruction into a basic block...
28  if (InsertBefore) {
29  BasicBlock *BB = InsertBefore->getParent();
30  assert(BB && "Instruction to insert before is not in a basic block!");
31  BB->getInstList().insert(InsertBefore->getIterator(), this);
32  }
33 }
34 
35 Instruction::Instruction(Type *ty, unsigned it, Use *Ops, unsigned NumOps,
36  BasicBlock *InsertAtEnd)
37  : User(ty, Value::InstructionVal + it, Ops, NumOps), Parent(nullptr) {
38 
39  // append this instruction into the basic block
40  assert(InsertAtEnd && "Basic block to append to may not be NULL!");
41  InsertAtEnd->getInstList().push_back(this);
42 }
43 
45  assert(!Parent && "Instruction still linked in the program!");
46 
47  // Replace any extant metadata uses of this instruction with undef to
48  // preserve debug info accuracy. Some alternatives include:
49  // - Treat Instruction like any other Value, and point its extant metadata
50  // uses to an empty ValueAsMetadata node. This makes extant dbg.value uses
51  // trivially dead (i.e. fair game for deletion in many passes), leading to
52  // stale dbg.values being in effect for too long.
53  // - Call salvageDebugInfoOrMarkUndef. Not needed to make instruction removal
54  // correct. OTOH results in wasted work in some common cases (e.g. when all
55  // instructions in a BasicBlock are deleted).
56  if (isUsedByMetadata())
58 }
59 
60 
61 void Instruction::setParent(BasicBlock *P) {
62  Parent = P;
63 }
64 
66  return getParent()->getModule();
67 }
68 
70  return getParent()->getParent();
71 }
72 
74  getParent()->getInstList().remove(getIterator());
75 }
76 
78  return getParent()->getInstList().erase(getIterator());
79 }
80 
81 /// Insert an unlinked instruction into a basic block immediately before the
82 /// specified instruction.
84  InsertPos->getParent()->getInstList().insert(InsertPos->getIterator(), this);
85 }
86 
87 /// Insert an unlinked instruction into a basic block immediately after the
88 /// specified instruction.
90  InsertPos->getParent()->getInstList().insertAfter(InsertPos->getIterator(),
91  this);
92 }
93 
94 /// Unlink this instruction from its current basic block and insert it into the
95 /// basic block that MovePos lives in, right before MovePos.
97  moveBefore(*MovePos->getParent(), MovePos->getIterator());
98 }
99 
101  moveBefore(*MovePos->getParent(), ++MovePos->getIterator());
102 }
103 
106  assert(I == BB.end() || I->getParent() == &BB);
107  BB.getInstList().splice(I, getParent()->getInstList(), getIterator());
108 }
109 
110 bool Instruction::comesBefore(const Instruction *Other) const {
111  assert(Parent && Other->Parent &&
112  "instructions without BB parents have no order");
113  assert(Parent == Other->Parent && "cross-BB instruction order comparison");
114  if (!Parent->isInstrOrderValid())
115  Parent->renumberInstructions();
116  return Order < Other->Order;
117 }
118 
120  return any_of(operands(), [](Value *V) { return V->hasOneUser(); });
121 }
122 
124  cast<OverflowingBinaryOperator>(this)->setHasNoUnsignedWrap(b);
125 }
126 
128  cast<OverflowingBinaryOperator>(this)->setHasNoSignedWrap(b);
129 }
130 
132  cast<PossiblyExactOperator>(this)->setIsExact(b);
133 }
134 
136  return cast<OverflowingBinaryOperator>(this)->hasNoUnsignedWrap();
137 }
138 
140  return cast<OverflowingBinaryOperator>(this)->hasNoSignedWrap();
141 }
142 
144  return cast<Operator>(this)->hasPoisonGeneratingFlags();
145 }
146 
148  switch (getOpcode()) {
149  case Instruction::Add:
150  case Instruction::Sub:
151  case Instruction::Mul:
152  case Instruction::Shl:
153  cast<OverflowingBinaryOperator>(this)->setHasNoUnsignedWrap(false);
154  cast<OverflowingBinaryOperator>(this)->setHasNoSignedWrap(false);
155  break;
156 
157  case Instruction::UDiv:
158  case Instruction::SDiv:
159  case Instruction::AShr:
160  case Instruction::LShr:
161  cast<PossiblyExactOperator>(this)->setIsExact(false);
162  break;
163 
164  case Instruction::GetElementPtr:
165  cast<GetElementPtrInst>(this)->setIsInBounds(false);
166  break;
167  }
168  if (isa<FPMathOperator>(this)) {
169  setHasNoNaNs(false);
170  setHasNoInfs(false);
171  }
172 
173  assert(!hasPoisonGeneratingFlags() && "must be kept in sync");
174 }
175 
177  ArrayRef<unsigned> KnownIDs) {
178  dropUnknownNonDebugMetadata(KnownIDs);
179  auto *CB = dyn_cast<CallBase>(this);
180  if (!CB)
181  return;
182  // For call instructions, we also need to drop parameter and return attributes
183  // that are can cause UB if the call is moved to a location where the
184  // attribute is not valid.
185  AttributeList AL = CB->getAttributes();
186  if (AL.isEmpty())
187  return;
188  AttributeMask UBImplyingAttributes =
190  for (unsigned ArgNo = 0; ArgNo < CB->arg_size(); ArgNo++)
191  CB->removeParamAttrs(ArgNo, UBImplyingAttributes);
192  CB->removeRetAttrs(UBImplyingAttributes);
193 }
194 
195 bool Instruction::isExact() const {
196  return cast<PossiblyExactOperator>(this)->isExact();
197 }
198 
200  assert(isa<FPMathOperator>(this) && "setting fast-math flag on invalid op");
201  cast<FPMathOperator>(this)->setFast(B);
202 }
203 
205  assert(isa<FPMathOperator>(this) && "setting fast-math flag on invalid op");
206  cast<FPMathOperator>(this)->setHasAllowReassoc(B);
207 }
208 
210  assert(isa<FPMathOperator>(this) && "setting fast-math flag on invalid op");
211  cast<FPMathOperator>(this)->setHasNoNaNs(B);
212 }
213 
215  assert(isa<FPMathOperator>(this) && "setting fast-math flag on invalid op");
216  cast<FPMathOperator>(this)->setHasNoInfs(B);
217 }
218 
220  assert(isa<FPMathOperator>(this) && "setting fast-math flag on invalid op");
221  cast<FPMathOperator>(this)->setHasNoSignedZeros(B);
222 }
223 
225  assert(isa<FPMathOperator>(this) && "setting fast-math flag on invalid op");
226  cast<FPMathOperator>(this)->setHasAllowReciprocal(B);
227 }
228 
230  assert(isa<FPMathOperator>(this) && "setting fast-math flag on invalid op");
231  cast<FPMathOperator>(this)->setHasAllowContract(B);
232 }
233 
235  assert(isa<FPMathOperator>(this) && "setting fast-math flag on invalid op");
236  cast<FPMathOperator>(this)->setHasApproxFunc(B);
237 }
238 
240  assert(isa<FPMathOperator>(this) && "setting fast-math flag on invalid op");
241  cast<FPMathOperator>(this)->setFastMathFlags(FMF);
242 }
243 
245  assert(isa<FPMathOperator>(this) && "copying fast-math flag on invalid op");
246  cast<FPMathOperator>(this)->copyFastMathFlags(FMF);
247 }
248 
249 bool Instruction::isFast() const {
250  assert(isa<FPMathOperator>(this) && "getting fast-math flag on invalid op");
251  return cast<FPMathOperator>(this)->isFast();
252 }
253 
255  assert(isa<FPMathOperator>(this) && "getting fast-math flag on invalid op");
256  return cast<FPMathOperator>(this)->hasAllowReassoc();
257 }
258 
260  assert(isa<FPMathOperator>(this) && "getting fast-math flag on invalid op");
261  return cast<FPMathOperator>(this)->hasNoNaNs();
262 }
263 
265  assert(isa<FPMathOperator>(this) && "getting fast-math flag on invalid op");
266  return cast<FPMathOperator>(this)->hasNoInfs();
267 }
268 
270  assert(isa<FPMathOperator>(this) && "getting fast-math flag on invalid op");
271  return cast<FPMathOperator>(this)->hasNoSignedZeros();
272 }
273 
275  assert(isa<FPMathOperator>(this) && "getting fast-math flag on invalid op");
276  return cast<FPMathOperator>(this)->hasAllowReciprocal();
277 }
278 
280  assert(isa<FPMathOperator>(this) && "getting fast-math flag on invalid op");
281  return cast<FPMathOperator>(this)->hasAllowContract();
282 }
283 
285  assert(isa<FPMathOperator>(this) && "getting fast-math flag on invalid op");
286  return cast<FPMathOperator>(this)->hasApproxFunc();
287 }
288 
290  assert(isa<FPMathOperator>(this) && "getting fast-math flag on invalid op");
291  return cast<FPMathOperator>(this)->getFastMathFlags();
292 }
293 
295  copyFastMathFlags(I->getFastMathFlags());
296 }
297 
298 void Instruction::copyIRFlags(const Value *V, bool IncludeWrapFlags) {
299  // Copy the wrapping flags.
300  if (IncludeWrapFlags && isa<OverflowingBinaryOperator>(this)) {
301  if (auto *OB = dyn_cast<OverflowingBinaryOperator>(V)) {
302  setHasNoSignedWrap(OB->hasNoSignedWrap());
303  setHasNoUnsignedWrap(OB->hasNoUnsignedWrap());
304  }
305  }
306 
307  // Copy the exact flag.
308  if (auto *PE = dyn_cast<PossiblyExactOperator>(V))
309  if (isa<PossiblyExactOperator>(this))
310  setIsExact(PE->isExact());
311 
312  // Copy the fast-math flags.
313  if (auto *FP = dyn_cast<FPMathOperator>(V))
314  if (isa<FPMathOperator>(this))
315  copyFastMathFlags(FP->getFastMathFlags());
316 
317  if (auto *SrcGEP = dyn_cast<GetElementPtrInst>(V))
318  if (auto *DestGEP = dyn_cast<GetElementPtrInst>(this))
319  DestGEP->setIsInBounds(SrcGEP->isInBounds() || DestGEP->isInBounds());
320 }
321 
323  if (auto *OB = dyn_cast<OverflowingBinaryOperator>(V)) {
324  if (isa<OverflowingBinaryOperator>(this)) {
325  setHasNoSignedWrap(hasNoSignedWrap() && OB->hasNoSignedWrap());
326  setHasNoUnsignedWrap(hasNoUnsignedWrap() && OB->hasNoUnsignedWrap());
327  }
328  }
329 
330  if (auto *PE = dyn_cast<PossiblyExactOperator>(V))
331  if (isa<PossiblyExactOperator>(this))
332  setIsExact(isExact() && PE->isExact());
333 
334  if (auto *FP = dyn_cast<FPMathOperator>(V)) {
335  if (isa<FPMathOperator>(this)) {
337  FM &= FP->getFastMathFlags();
338  copyFastMathFlags(FM);
339  }
340  }
341 
342  if (auto *SrcGEP = dyn_cast<GetElementPtrInst>(V))
343  if (auto *DestGEP = dyn_cast<GetElementPtrInst>(this))
344  DestGEP->setIsInBounds(SrcGEP->isInBounds() && DestGEP->isInBounds());
345 }
346 
347 const char *Instruction::getOpcodeName(unsigned OpCode) {
348  switch (OpCode) {
349  // Terminators
350  case Ret: return "ret";
351  case Br: return "br";
352  case Switch: return "switch";
353  case IndirectBr: return "indirectbr";
354  case Invoke: return "invoke";
355  case Resume: return "resume";
356  case Unreachable: return "unreachable";
357  case CleanupRet: return "cleanupret";
358  case CatchRet: return "catchret";
359  case CatchPad: return "catchpad";
360  case CatchSwitch: return "catchswitch";
361  case CallBr: return "callbr";
362 
363  // Standard unary operators...
364  case FNeg: return "fneg";
365 
366  // Standard binary operators...
367  case Add: return "add";
368  case FAdd: return "fadd";
369  case Sub: return "sub";
370  case FSub: return "fsub";
371  case Mul: return "mul";
372  case FMul: return "fmul";
373  case UDiv: return "udiv";
374  case SDiv: return "sdiv";
375  case FDiv: return "fdiv";
376  case URem: return "urem";
377  case SRem: return "srem";
378  case FRem: return "frem";
379 
380  // Logical operators...
381  case And: return "and";
382  case Or : return "or";
383  case Xor: return "xor";
384 
385  // Memory instructions...
386  case Alloca: return "alloca";
387  case Load: return "load";
388  case Store: return "store";
389  case AtomicCmpXchg: return "cmpxchg";
390  case AtomicRMW: return "atomicrmw";
391  case Fence: return "fence";
392  case GetElementPtr: return "getelementptr";
393 
394  // Convert instructions...
395  case Trunc: return "trunc";
396  case ZExt: return "zext";
397  case SExt: return "sext";
398  case FPTrunc: return "fptrunc";
399  case FPExt: return "fpext";
400  case FPToUI: return "fptoui";
401  case FPToSI: return "fptosi";
402  case UIToFP: return "uitofp";
403  case SIToFP: return "sitofp";
404  case IntToPtr: return "inttoptr";
405  case PtrToInt: return "ptrtoint";
406  case BitCast: return "bitcast";
407  case AddrSpaceCast: return "addrspacecast";
408 
409  // Other instructions...
410  case ICmp: return "icmp";
411  case FCmp: return "fcmp";
412  case PHI: return "phi";
413  case Select: return "select";
414  case Call: return "call";
415  case Shl: return "shl";
416  case LShr: return "lshr";
417  case AShr: return "ashr";
418  case VAArg: return "va_arg";
419  case ExtractElement: return "extractelement";
420  case InsertElement: return "insertelement";
421  case ShuffleVector: return "shufflevector";
422  case ExtractValue: return "extractvalue";
423  case InsertValue: return "insertvalue";
424  case LandingPad: return "landingpad";
425  case CleanupPad: return "cleanuppad";
426  case Freeze: return "freeze";
427 
428  default: return "<Invalid operator> ";
429  }
430 }
431 
432 /// Return true if both instructions have the same special state. This must be
433 /// kept in sync with FunctionComparator::cmpOperations in
434 /// lib/Transforms/IPO/MergeFunctions.cpp.
435 static bool haveSameSpecialState(const Instruction *I1, const Instruction *I2,
436  bool IgnoreAlignment = false) {
437  assert(I1->getOpcode() == I2->getOpcode() &&
438  "Can not compare special state of different instructions");
439 
440  if (const AllocaInst *AI = dyn_cast<AllocaInst>(I1))
441  return AI->getAllocatedType() == cast<AllocaInst>(I2)->getAllocatedType() &&
442  (AI->getAlign() == cast<AllocaInst>(I2)->getAlign() ||
443  IgnoreAlignment);
444  if (const LoadInst *LI = dyn_cast<LoadInst>(I1))
445  return LI->isVolatile() == cast<LoadInst>(I2)->isVolatile() &&
446  (LI->getAlign() == cast<LoadInst>(I2)->getAlign() ||
447  IgnoreAlignment) &&
448  LI->getOrdering() == cast<LoadInst>(I2)->getOrdering() &&
449  LI->getSyncScopeID() == cast<LoadInst>(I2)->getSyncScopeID();
450  if (const StoreInst *SI = dyn_cast<StoreInst>(I1))
451  return SI->isVolatile() == cast<StoreInst>(I2)->isVolatile() &&
452  (SI->getAlign() == cast<StoreInst>(I2)->getAlign() ||
453  IgnoreAlignment) &&
454  SI->getOrdering() == cast<StoreInst>(I2)->getOrdering() &&
455  SI->getSyncScopeID() == cast<StoreInst>(I2)->getSyncScopeID();
456  if (const CmpInst *CI = dyn_cast<CmpInst>(I1))
457  return CI->getPredicate() == cast<CmpInst>(I2)->getPredicate();
458  if (const CallInst *CI = dyn_cast<CallInst>(I1))
459  return CI->isTailCall() == cast<CallInst>(I2)->isTailCall() &&
460  CI->getCallingConv() == cast<CallInst>(I2)->getCallingConv() &&
461  CI->getAttributes() == cast<CallInst>(I2)->getAttributes() &&
462  CI->hasIdenticalOperandBundleSchema(*cast<CallInst>(I2));
463  if (const InvokeInst *CI = dyn_cast<InvokeInst>(I1))
464  return CI->getCallingConv() == cast<InvokeInst>(I2)->getCallingConv() &&
465  CI->getAttributes() == cast<InvokeInst>(I2)->getAttributes() &&
466  CI->hasIdenticalOperandBundleSchema(*cast<InvokeInst>(I2));
467  if (const CallBrInst *CI = dyn_cast<CallBrInst>(I1))
468  return CI->getCallingConv() == cast<CallBrInst>(I2)->getCallingConv() &&
469  CI->getAttributes() == cast<CallBrInst>(I2)->getAttributes() &&
470  CI->hasIdenticalOperandBundleSchema(*cast<CallBrInst>(I2));
471  if (const InsertValueInst *IVI = dyn_cast<InsertValueInst>(I1))
472  return IVI->getIndices() == cast<InsertValueInst>(I2)->getIndices();
473  if (const ExtractValueInst *EVI = dyn_cast<ExtractValueInst>(I1))
474  return EVI->getIndices() == cast<ExtractValueInst>(I2)->getIndices();
475  if (const FenceInst *FI = dyn_cast<FenceInst>(I1))
476  return FI->getOrdering() == cast<FenceInst>(I2)->getOrdering() &&
477  FI->getSyncScopeID() == cast<FenceInst>(I2)->getSyncScopeID();
478  if (const AtomicCmpXchgInst *CXI = dyn_cast<AtomicCmpXchgInst>(I1))
479  return CXI->isVolatile() == cast<AtomicCmpXchgInst>(I2)->isVolatile() &&
480  CXI->isWeak() == cast<AtomicCmpXchgInst>(I2)->isWeak() &&
481  CXI->getSuccessOrdering() ==
482  cast<AtomicCmpXchgInst>(I2)->getSuccessOrdering() &&
483  CXI->getFailureOrdering() ==
484  cast<AtomicCmpXchgInst>(I2)->getFailureOrdering() &&
485  CXI->getSyncScopeID() ==
486  cast<AtomicCmpXchgInst>(I2)->getSyncScopeID();
487  if (const AtomicRMWInst *RMWI = dyn_cast<AtomicRMWInst>(I1))
488  return RMWI->getOperation() == cast<AtomicRMWInst>(I2)->getOperation() &&
489  RMWI->isVolatile() == cast<AtomicRMWInst>(I2)->isVolatile() &&
490  RMWI->getOrdering() == cast<AtomicRMWInst>(I2)->getOrdering() &&
491  RMWI->getSyncScopeID() == cast<AtomicRMWInst>(I2)->getSyncScopeID();
492  if (const ShuffleVectorInst *SVI = dyn_cast<ShuffleVectorInst>(I1))
493  return SVI->getShuffleMask() ==
494  cast<ShuffleVectorInst>(I2)->getShuffleMask();
495  if (const GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(I1))
496  return GEP->getSourceElementType() ==
497  cast<GetElementPtrInst>(I2)->getSourceElementType();
498 
499  return true;
500 }
501 
503  return isIdenticalToWhenDefined(I) &&
504  SubclassOptionalData == I->SubclassOptionalData;
505 }
506 
508  if (getOpcode() != I->getOpcode() ||
509  getNumOperands() != I->getNumOperands() ||
510  getType() != I->getType())
511  return false;
512 
513  // If both instructions have no operands, they are identical.
514  if (getNumOperands() == 0 && I->getNumOperands() == 0)
515  return haveSameSpecialState(this, I);
516 
517  // We have two instructions of identical opcode and #operands. Check to see
518  // if all operands are the same.
519  if (!std::equal(op_begin(), op_end(), I->op_begin()))
520  return false;
521 
522  // WARNING: this logic must be kept in sync with EliminateDuplicatePHINodes()!
523  if (const PHINode *thisPHI = dyn_cast<PHINode>(this)) {
524  const PHINode *otherPHI = cast<PHINode>(I);
525  return std::equal(thisPHI->block_begin(), thisPHI->block_end(),
526  otherPHI->block_begin());
527  }
528 
529  return haveSameSpecialState(this, I);
530 }
531 
532 // Keep this in sync with FunctionComparator::cmpOperations in
533 // lib/Transforms/IPO/MergeFunctions.cpp.
535  unsigned flags) const {
536  bool IgnoreAlignment = flags & CompareIgnoringAlignment;
537  bool UseScalarTypes = flags & CompareUsingScalarTypes;
538 
539  if (getOpcode() != I->getOpcode() ||
540  getNumOperands() != I->getNumOperands() ||
541  (UseScalarTypes ?
542  getType()->getScalarType() != I->getType()->getScalarType() :
543  getType() != I->getType()))
544  return false;
545 
546  // We have two instructions of identical opcode and #operands. Check to see
547  // if all operands are the same type
548  for (unsigned i = 0, e = getNumOperands(); i != e; ++i)
549  if (UseScalarTypes ?
550  getOperand(i)->getType()->getScalarType() !=
551  I->getOperand(i)->getType()->getScalarType() :
552  getOperand(i)->getType() != I->getOperand(i)->getType())
553  return false;
554 
555  return haveSameSpecialState(this, I, IgnoreAlignment);
556 }
557 
559  for (const Use &U : uses()) {
560  // PHI nodes uses values in the corresponding predecessor block. For other
561  // instructions, just check to see whether the parent of the use matches up.
562  const Instruction *I = cast<Instruction>(U.getUser());
563  const PHINode *PN = dyn_cast<PHINode>(I);
564  if (!PN) {
565  if (I->getParent() != BB)
566  return true;
567  continue;
568  }
569 
570  if (PN->getIncomingBlock(U) != BB)
571  return true;
572  }
573  return false;
574 }
575 
577  switch (getOpcode()) {
578  default: return false;
579  case Instruction::VAArg:
580  case Instruction::Load:
581  case Instruction::Fence: // FIXME: refine definition of mayReadFromMemory
582  case Instruction::AtomicCmpXchg:
583  case Instruction::AtomicRMW:
584  case Instruction::CatchPad:
585  case Instruction::CatchRet:
586  return true;
587  case Instruction::Call:
588  case Instruction::Invoke:
589  case Instruction::CallBr:
590  return !cast<CallBase>(this)->onlyWritesMemory();
591  case Instruction::Store:
592  return !cast<StoreInst>(this)->isUnordered();
593  }
594 }
595 
597  switch (getOpcode()) {
598  default: return false;
599  case Instruction::Fence: // FIXME: refine definition of mayWriteToMemory
600  case Instruction::Store:
601  case Instruction::VAArg:
602  case Instruction::AtomicCmpXchg:
603  case Instruction::AtomicRMW:
604  case Instruction::CatchPad:
605  case Instruction::CatchRet:
606  return true;
607  case Instruction::Call:
608  case Instruction::Invoke:
609  case Instruction::CallBr:
610  return !cast<CallBase>(this)->onlyReadsMemory();
611  case Instruction::Load:
612  return !cast<LoadInst>(this)->isUnordered();
613  }
614 }
615 
616 bool Instruction::isAtomic() const {
617  switch (getOpcode()) {
618  default:
619  return false;
620  case Instruction::AtomicCmpXchg:
621  case Instruction::AtomicRMW:
622  case Instruction::Fence:
623  return true;
624  case Instruction::Load:
625  return cast<LoadInst>(this)->getOrdering() != AtomicOrdering::NotAtomic;
626  case Instruction::Store:
627  return cast<StoreInst>(this)->getOrdering() != AtomicOrdering::NotAtomic;
628  }
629 }
630 
632  assert(isAtomic());
633  switch (getOpcode()) {
634  default:
635  return false;
636  case Instruction::AtomicCmpXchg:
637  case Instruction::AtomicRMW:
638  case Instruction::Load:
639  return true;
640  }
641 }
642 
644  assert(isAtomic());
645  switch (getOpcode()) {
646  default:
647  return false;
648  case Instruction::AtomicCmpXchg:
649  case Instruction::AtomicRMW:
650  case Instruction::Store:
651  return true;
652  }
653 }
654 
656  switch (getOpcode()) {
657  default:
658  return false;
659  case Instruction::AtomicRMW:
660  return cast<AtomicRMWInst>(this)->isVolatile();
661  case Instruction::Store:
662  return cast<StoreInst>(this)->isVolatile();
663  case Instruction::Load:
664  return cast<LoadInst>(this)->isVolatile();
665  case Instruction::AtomicCmpXchg:
666  return cast<AtomicCmpXchgInst>(this)->isVolatile();
667  case Instruction::Call:
668  case Instruction::Invoke:
669  // There are a very limited number of intrinsics with volatile flags.
670  if (auto *II = dyn_cast<IntrinsicInst>(this)) {
671  if (auto *MI = dyn_cast<MemIntrinsic>(II))
672  return MI->isVolatile();
673  switch (II->getIntrinsicID()) {
674  default: break;
675  case Intrinsic::matrix_column_major_load:
676  return cast<ConstantInt>(II->getArgOperand(2))->isOne();
677  case Intrinsic::matrix_column_major_store:
678  return cast<ConstantInt>(II->getArgOperand(3))->isOne();
679  }
680  }
681  return false;
682  }
683 }
684 
685 bool Instruction::mayThrow() const {
686  if (const CallInst *CI = dyn_cast<CallInst>(this))
687  return !CI->doesNotThrow();
688  if (const auto *CRI = dyn_cast<CleanupReturnInst>(this))
689  return CRI->unwindsToCaller();
690  if (const auto *CatchSwitch = dyn_cast<CatchSwitchInst>(this))
691  return CatchSwitch->unwindsToCaller();
692  return isa<ResumeInst>(this);
693 }
694 
696  return mayWriteToMemory() || mayThrow() || !willReturn();
697 }
698 
700  return (!isa<CallInst>(this) || !this->mayHaveSideEffects()) &&
701  !this->isTerminator() && !this->isEHPad();
702 }
703 
705  // Volatile store isn't guaranteed to return; see LangRef.
706  if (auto *SI = dyn_cast<StoreInst>(this))
707  return !SI->isVolatile();
708 
709  if (const auto *CB = dyn_cast<CallBase>(this))
710  // FIXME: Temporarily assume that all side-effect free intrinsics will
711  // return. Remove this workaround once all intrinsics are appropriately
712  // annotated.
713  return CB->hasFnAttr(Attribute::WillReturn) ||
714  (isa<IntrinsicInst>(CB) && CB->onlyReadsMemory());
715  return true;
716 }
717 
719  auto *II = dyn_cast<IntrinsicInst>(this);
720  if (!II)
721  return false;
722  Intrinsic::ID ID = II->getIntrinsicID();
723  return ID == Intrinsic::lifetime_start || ID == Intrinsic::lifetime_end;
724 }
725 
727  auto *II = dyn_cast<IntrinsicInst>(this);
728  if (!II)
729  return false;
730  Intrinsic::ID ID = II->getIntrinsicID();
731  return ID == Intrinsic::launder_invariant_group ||
732  ID == Intrinsic::strip_invariant_group;
733 }
734 
736  return isa<DbgInfoIntrinsic>(this) || isa<PseudoProbeInst>(this);
737 }
738 
739 const Instruction *
740 Instruction::getNextNonDebugInstruction(bool SkipPseudoOp) const {
741  for (const Instruction *I = getNextNode(); I; I = I->getNextNode())
742  if (!isa<DbgInfoIntrinsic>(I) && !(SkipPseudoOp && isa<PseudoProbeInst>(I)))
743  return I;
744  return nullptr;
745 }
746 
747 const Instruction *
748 Instruction::getPrevNonDebugInstruction(bool SkipPseudoOp) const {
749  for (const Instruction *I = getPrevNode(); I; I = I->getPrevNode())
750  if (!isa<DbgInfoIntrinsic>(I) && !(SkipPseudoOp && isa<PseudoProbeInst>(I)))
751  return I;
752  return nullptr;
753 }
754 
756  unsigned Opcode = getOpcode();
757  if (isAssociative(Opcode))
758  return true;
759 
760  switch (Opcode) {
761  case FMul:
762  case FAdd:
763  return cast<FPMathOperator>(this)->hasAllowReassoc() &&
764  cast<FPMathOperator>(this)->hasNoSignedZeros();
765  default:
766  return false;
767  }
768 }
769 
771  if (auto *II = dyn_cast<IntrinsicInst>(this))
772  return II->isCommutative();
773  // TODO: Should allow icmp/fcmp?
774  return isCommutative(getOpcode());
775 }
776 
778  switch (getOpcode()) {
779 #define HANDLE_TERM_INST(N, OPC, CLASS) \
780  case Instruction::OPC: \
781  return static_cast<const CLASS *>(this)->getNumSuccessors();
782 #include "llvm/IR/Instruction.def"
783  default:
784  break;
785  }
786  llvm_unreachable("not a terminator");
787 }
788 
789 BasicBlock *Instruction::getSuccessor(unsigned idx) const {
790  switch (getOpcode()) {
791 #define HANDLE_TERM_INST(N, OPC, CLASS) \
792  case Instruction::OPC: \
793  return static_cast<const CLASS *>(this)->getSuccessor(idx);
794 #include "llvm/IR/Instruction.def"
795  default:
796  break;
797  }
798  llvm_unreachable("not a terminator");
799 }
800 
801 void Instruction::setSuccessor(unsigned idx, BasicBlock *B) {
802  switch (getOpcode()) {
803 #define HANDLE_TERM_INST(N, OPC, CLASS) \
804  case Instruction::OPC: \
805  return static_cast<CLASS *>(this)->setSuccessor(idx, B);
806 #include "llvm/IR/Instruction.def"
807  default:
808  break;
809  }
810  llvm_unreachable("not a terminator");
811 }
812 
814  for (unsigned Idx = 0, NumSuccessors = Instruction::getNumSuccessors();
815  Idx != NumSuccessors; ++Idx)
816  if (getSuccessor(Idx) == OldBB)
817  setSuccessor(Idx, NewBB);
818 }
819 
820 Instruction *Instruction::cloneImpl() const {
821  llvm_unreachable("Subclass of Instruction failed to implement cloneImpl");
822 }
823 
825  MDNode *ProfileData = getMetadata(LLVMContext::MD_prof);
826  if (!ProfileData || ProfileData->getNumOperands() != 3 ||
827  !isa<MDString>(ProfileData->getOperand(0)))
828  return;
829 
830  MDString *MDName = cast<MDString>(ProfileData->getOperand(0));
831  if (MDName->getString() != "branch_weights")
832  return;
833 
834  // The first operand is the name. Fetch them backwards and build a new one.
835  Metadata *Ops[] = {ProfileData->getOperand(0), ProfileData->getOperand(2),
836  ProfileData->getOperand(1)};
837  setMetadata(LLVMContext::MD_prof,
838  MDNode::get(ProfileData->getContext(), Ops));
839 }
840 
842  ArrayRef<unsigned> WL) {
843  if (!SrcInst.hasMetadata())
844  return;
845 
847  for (unsigned M : WL)
848  WLS.insert(M);
849 
850  // Otherwise, enumerate and copy over metadata from the old instruction to the
851  // new one.
853  SrcInst.getAllMetadataOtherThanDebugLoc(TheMDs);
854  for (const auto &MD : TheMDs) {
855  if (WL.empty() || WLS.count(MD.first))
856  setMetadata(MD.first, MD.second);
857  }
858  if (WL.empty() || WLS.count(LLVMContext::MD_dbg))
859  setDebugLoc(SrcInst.getDebugLoc());
860 }
861 
863  Instruction *New = nullptr;
864  switch (getOpcode()) {
865  default:
866  llvm_unreachable("Unhandled Opcode.");
867 #define HANDLE_INST(num, opc, clas) \
868  case Instruction::opc: \
869  New = cast<clas>(this)->cloneImpl(); \
870  break;
871 #include "llvm/IR/Instruction.def"
872 #undef HANDLE_INST
873  }
874 
875  New->SubclassOptionalData = SubclassOptionalData;
876  New->copyMetadata(*this);
877  return New;
878 }
llvm::Instruction::getPrevNonDebugInstruction
const Instruction * getPrevNonDebugInstruction(bool SkipPseudoOp=false) const
Return a pointer to the previous non-debug instruction in the same basic block as 'this',...
Definition: Instruction.cpp:748
i
i
Definition: README.txt:29
llvm::Instruction::isTerminator
bool isTerminator() const
Definition: Instruction.h:160
CmpMode::FP
@ FP
llvm::Instruction::isAssociative
bool isAssociative() const LLVM_READONLY
Return true if the instruction is associative:
Definition: Instruction.cpp:755
MI
IRTranslator LLVM IR MI
Definition: IRTranslator.cpp:104
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
llvm::Instruction::replaceSuccessorWith
void replaceSuccessorWith(BasicBlock *OldBB, BasicBlock *NewBB)
Replace specified successor OldBB to point at the provided block.
Definition: Instruction.cpp:813
M
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
Definition: README.txt:252
llvm::Instruction::getModule
const Module * getModule() const
Return the module owning the function this instruction belongs to or nullptr it the function does not...
Definition: Instruction.cpp:65
llvm::AArch64CC::AL
@ AL
Definition: AArch64BaseInfo.h:269
it
into xmm2 addss xmm2 xmm1 xmm3 addss xmm3 movaps xmm0 unpcklps xmm0 ret seems silly when it could just be one addps Expand libm rounding functions main should enable SSE DAZ mode and other fast SSE modes Think about doing i64 math in SSE regs on x86 This testcase should have no SSE instructions in it
Definition: README-SSE.txt:81
llvm::RecurKind::Or
@ Or
Bitwise or logical OR of integers.
llvm::RecurKind::FMul
@ FMul
Product of floats.
llvm::User::operands
op_range operands()
Definition: User.h:242
llvm::Value::SubclassOptionalData
unsigned char SubclassOptionalData
Hold subclass data that can be dropped.
Definition: Value.h:90
llvm::BasicBlock::getParent
const Function * getParent() const
Return the enclosing method, or null if none.
Definition: BasicBlock.h:104
IntrinsicInst.h
llvm::Instruction::getNextNonDebugInstruction
const Instruction * getNextNonDebugInstruction(bool SkipPseudoOp=false) const
Return a pointer to the next non-debug instruction in the same basic block as 'this',...
Definition: Instruction.cpp:740
llvm::Function
Definition: Function.h:60
P
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
Definition: README-SSE.txt:411
llvm::Instruction::isVolatile
bool isVolatile() const
Return true if this instruction has a volatile memory access.
Definition: Instruction.cpp:655
llvm::ARMISD::WLS
@ WLS
Definition: ARMISelLowering.h:135
llvm::Instruction::getAllMetadataOtherThanDebugLoc
void getAllMetadataOtherThanDebugLoc(SmallVectorImpl< std::pair< unsigned, MDNode * >> &MDs) const
This does the same thing as getAllMetadata, except that it filters out the debug location.
Definition: Instruction.h:302
llvm::ilist_node_with_parent< Instruction, BasicBlock >::getNextNode
Instruction * getNextNode()
Get the next node, or nullptr for the list tail.
Definition: ilist_node.h:289
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1185
llvm::Instruction::setHasAllowContract
void setHasAllowContract(bool B)
Set or clear the allow-contract flag on this instruction, which must be an operator which supports th...
Definition: Instruction.cpp:229
llvm::AttributeFuncs::getUBImplyingAttributes
AttributeMask getUBImplyingAttributes()
Get param/return attributes which imply immediate undefined behavior if an invalid value is passed.
Definition: Attributes.cpp:1860
llvm::Instruction::hasNoUnsignedWrap
bool hasNoUnsignedWrap() const
Determine whether the no unsigned wrap flag is set.
Definition: Instruction.cpp:135
llvm::Instruction::insertBefore
void insertBefore(Instruction *InsertPos)
Insert an unlinked instruction into a basic block immediately before the specified instruction.
Definition: Instruction.cpp:83
llvm::Instruction::hasAllowReciprocal
bool hasAllowReciprocal() const
Determine whether the allow-reciprocal flag is set.
Definition: Instruction.cpp:274
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
llvm::AttributeList
Definition: Attributes.h:425
llvm::AttributeMask
Definition: Attributes.h:963
llvm::Instruction::hasApproxFunc
bool hasApproxFunc() const
Determine whether the approximate-math-functions flag is set.
Definition: Instruction.cpp:284
llvm::Instruction::comesBefore
bool comesBefore(const Instruction *Other) const
Given an instruction Other in the same basic block as this instruction, return true if this instructi...
Definition: Instruction.cpp:110
llvm::Instruction::setHasNoUnsignedWrap
void setHasNoUnsignedWrap(bool b=true)
Set or clear the nuw flag on this instruction, which must be an operator which supports this flag.
Definition: Instruction.cpp:123
llvm::Value::hasOneUser
bool hasOneUser() const
Return true if there is exactly one user of this value.
Definition: Value.cpp:153
llvm::FenceInst
An instruction for ordering other memory operations.
Definition: Instructions.h:432
llvm::Instruction::mayThrow
bool mayThrow() const
Return true if this instruction may throw an exception.
Definition: Instruction.cpp:685
Operator.h
llvm::Instruction::copyMetadata
void copyMetadata(const Instruction &SrcInst, ArrayRef< unsigned > WL=ArrayRef< unsigned >())
Copy metadata from SrcInst to this instruction.
Definition: Instruction.cpp:841
llvm::MipsISD::Ret
@ Ret
Definition: MipsISelLowering.h:119
llvm::FastMathFlags
Convenience struct for specifying and reasoning about fast-math flags.
Definition: FMF.h:21
llvm::Instruction::~Instruction
~Instruction()
Definition: Instruction.cpp:44
llvm::Instruction::setIsExact
void setIsExact(bool b=true)
Set or clear the exact flag on this instruction, which must be an operator which supports this flag.
Definition: Instruction.cpp:131
llvm::Instruction::dropUnknownNonDebugMetadata
void dropUnknownNonDebugMetadata()
Definition: Instruction.h:330
llvm::MDNode::get
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition: Metadata.h:1300
llvm::Instruction::mayHaveSideEffects
bool mayHaveSideEffects() const
Return true if the instruction may have side effects.
Definition: Instruction.cpp:695
I1
@ I1
Definition: DXILOpLowering.cpp:37
llvm::Instruction::setMetadata
void setMetadata(unsigned KindID, MDNode *Node)
Set the metadata of the specified kind to the specified node.
Definition: Metadata.cpp:1366
llvm::BasicBlock
LLVM Basic Block Representation.
Definition: BasicBlock.h:55
llvm::lltok::equal
@ equal
Definition: LLToken.h:25
llvm::MDNode::getNumOperands
unsigned getNumOperands() const
Return number of MDNode operands.
Definition: Metadata.h:1210
Instruction.h
llvm::SPII::Load
@ Load
Definition: SparcInstrInfo.h:32
llvm::Instruction::getNumSuccessors
unsigned getNumSuccessors() const
Return the number of successors that this instruction has.
Definition: Instruction.cpp:777
llvm::Instruction::insertAfter
void insertAfter(Instruction *InsertPos)
Insert an unlinked instruction into a basic block immediately after the specified instruction.
Definition: Instruction.cpp:89
llvm::Instruction::getOpcode
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
Definition: Instruction.h:157
llvm::Instruction::willReturn
bool willReturn() const
Return true if the instruction will return (unwinding is considered as a form of returning control fl...
Definition: Instruction.cpp:704
llvm::RecurKind::And
@ And
Bitwise or logical AND of integers.
Constants.h
llvm::Instruction::setHasNoSignedWrap
void setHasNoSignedWrap(bool b=true)
Set or clear the nsw flag on this instruction, which must be an operator which supports this flag.
Definition: Instruction.cpp:127
llvm::User
Definition: User.h:44
Intrinsics.h
llvm::Instruction::isIdenticalToWhenDefined
bool isIdenticalToWhenDefined(const Instruction *I) const
This is like isIdenticalTo, except that it ignores the SubclassOptionalData flags,...
Definition: Instruction.cpp:507
b
the resulting code requires compare and branches when and if the revised code is with conditional branches instead of More there is a byte word extend before each where there should be only and the condition codes are not remembered when the same two values are compared twice More LSR enhancements i8 and i32 load store addressing modes are identical int b
Definition: README.txt:418
llvm::Value::uses
iterator_range< use_iterator > uses()
Definition: Value.h:376
DenseSet.h
B
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
llvm::Instruction::getOpcodeName
const char * getOpcodeName() const
Definition: Instruction.h:159
llvm::Instruction
Definition: Instruction.h:42
llvm::UndefValue::get
static UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
Definition: Constants.cpp:1777
llvm::Instruction::getSuccessor
BasicBlock * getSuccessor(unsigned Idx) const
Return the specified successor. This instruction must be a terminator.
Definition: Instruction.cpp:789
llvm::BasicBlock::getModule
const Module * getModule() const
Return the module owning the function this basic block belongs to, or nullptr if the function does no...
Definition: BasicBlock.cpp:147
llvm::Instruction::removeFromParent
void removeFromParent()
This method unlinks 'this' from the containing basic block, but does not delete it.
Definition: Instruction.cpp:73
llvm::Instruction::isSafeToRemove
bool isSafeToRemove() const
Return true if the instruction can be removed if the result is unused.
Definition: Instruction.cpp:699
llvm::MCID::Call
@ Call
Definition: MCInstrDesc.h:155
llvm::Metadata
Root of the metadata hierarchy.
Definition: Metadata.h:62
llvm::Instruction::mayWriteToMemory
bool mayWriteToMemory() const
Return true if this instruction may modify memory.
Definition: Instruction.cpp:596
llvm::SPII::Store
@ Store
Definition: SparcInstrInfo.h:33
llvm::Instruction::isLifetimeStartOrEnd
bool isLifetimeStartOrEnd() const
Return true if the instruction is a llvm.lifetime.start or llvm.lifetime.end marker.
Definition: Instruction.cpp:718
llvm::Instruction::isLaunderOrStripInvariantGroup
bool isLaunderOrStripInvariantGroup() const
Return true if the instruction is a llvm.launder.invariant.group or llvm.strip.invariant....
Definition: Instruction.cpp:726
llvm::CallingConv::ID
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition: CallingConv.h:24
Type.h
llvm::BasicBlock::renumberInstructions
void renumberInstructions()
Renumber instructions and mark the ordering as valid.
Definition: BasicBlock.cpp:496
llvm::Instruction::getMetadata
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this Instruction.
Definition: Instruction.h:279
llvm::Instruction::isCommutative
bool isCommutative() const LLVM_READONLY
Return true if the instruction is commutative:
Definition: Instruction.cpp:770
llvm::Instruction::setHasNoNaNs
void setHasNoNaNs(bool B)
Set or clear the no-nans flag on this instruction, which must be an operator which supports this flag...
Definition: Instruction.cpp:209
llvm::Instruction::hasAtomicLoad
bool hasAtomicLoad() const
Return true if this atomic instruction loads from memory.
Definition: Instruction.cpp:631
llvm::InvokeInst
Invoke instruction.
Definition: Instructions.h:3763
llvm::CmpInst
This class is the base class for the comparison instructions.
Definition: InstrTypes.h:709
llvm::MDNode::getOperand
const MDOperand & getOperand(unsigned I) const
Definition: Metadata.h:1204
llvm::Instruction::andIRFlags
void andIRFlags(const Value *V)
Logical 'and' of any supported wrapping, exact, and fast-math flags of V and this instruction.
Definition: Instruction.cpp:322
llvm::DenseSet< unsigned >
llvm::StoreInst
An instruction for storing to memory.
Definition: Instructions.h:297
llvm::Instruction::eraseFromParent
SymbolTableList< Instruction >::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
Definition: Instruction.cpp:77
llvm::Instruction::setFast
void setFast(bool B)
Set or clear all fast-math-flags on this instruction, which must be an operator which supports this f...
Definition: Instruction.cpp:199
haveSameSpecialState
static bool haveSameSpecialState(const Instruction *I1, const Instruction *I2, bool IgnoreAlignment=false)
Return true if both instructions have the same special state.
Definition: Instruction.cpp:435
llvm::Instruction::hasAllowContract
bool hasAllowContract() const
Determine whether the allow-contract flag is set.
Definition: Instruction.cpp:279
llvm::CallBrInst
CallBr instruction, tracking function calls that may not return control but instead transfer it to a ...
Definition: Instructions.h:3972
llvm::Instruction::isIdenticalTo
bool isIdenticalTo(const Instruction *I) const
Return true if the specified instruction is exactly identical to the current one.
Definition: Instruction.cpp:502
llvm::Instruction::moveAfter
void moveAfter(Instruction *MovePos)
Unlink this instruction from its current basic block and insert it into the basic block that MovePos ...
Definition: Instruction.cpp:100
llvm::numbers::e
constexpr double e
Definition: MathExtras.h:57
llvm::Instruction::isOnlyUserOfAnyOperand
bool isOnlyUserOfAnyOperand()
It checks if this instruction is the only user of at least one of its operands.
Definition: Instruction.cpp:119
llvm::BasicBlock::isInstrOrderValid
bool isInstrOrderValid() const
Returns true if the Order field of child Instructions is valid.
Definition: BasicBlock.h:491
I
#define I(x, y, z)
Definition: MD5.cpp:58
llvm::Instruction::hasAtomicStore
bool hasAtomicStore() const
Return true if this atomic instruction stores to memory.
Definition: Instruction.cpp:643
llvm::GetElementPtrInst
an instruction for type-safe pointer arithmetic to access elements of arrays and structs
Definition: Instructions.h:916
llvm::Instruction::setDebugLoc
void setDebugLoc(DebugLoc Loc)
Set the debug location information for this instruction.
Definition: Instruction.h:364
llvm::ilist_node_with_parent< Instruction, BasicBlock >::getPrevNode
Instruction * getPrevNode()
Definition: ilist_node.h:275
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::Instruction::hasMetadata
bool hasMetadata() const
Return true if this instruction has any metadata attached to it.
Definition: Instruction.h:261
SI
StandardInstrumentations SI(Debug, VerifyEach)
llvm::Instruction::isFast
bool isFast() const
Determine whether all fast-math-flags are set.
Definition: Instruction.cpp:249
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
llvm::MDNode
Metadata node.
Definition: Metadata.h:937
llvm::PHINode::block_begin
block_iterator block_begin()
Definition: Instructions.h:2713
llvm::Instruction::clone
Instruction * clone() const
Create a copy of 'this' instruction that is identical in all ways except the following:
Definition: Instruction.cpp:862
llvm::Instruction::dropUndefImplyingAttrsAndUnknownMetadata
void dropUndefImplyingAttrsAndUnknownMetadata(ArrayRef< unsigned > KnownIDs={})
This function drops non-debug unknown metadata (through dropUnknownNonDebugMetadata).
Definition: Instruction.cpp:176
llvm::ArrayRef< unsigned >
llvm::Instruction::getFastMathFlags
FastMathFlags getFastMathFlags() const
Convenience function for getting all the fast-math flags, which must be an operator which supports th...
Definition: Instruction.cpp:289
Mul
BinaryOperator * Mul
Definition: X86PartialReduction.cpp:70
llvm::any_of
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1624
llvm::SymbolTableList
List that automatically updates parent links and symbol tables.
Definition: SymbolTableListTraits.h:60
llvm::Instruction::setSuccessor
void setSuccessor(unsigned Idx, BasicBlock *BB)
Update the specified successor to point at the provided block.
Definition: Instruction.cpp:801
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:143
llvm::Value::getType
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:255
llvm::Instruction::getFunction
const Function * getFunction() const
Return the function this instruction belongs to.
Definition: Instruction.cpp:69
llvm::ilist_node_impl::getIterator
self_iterator getIterator()
Definition: ilist_node.h:82
llvm::Instruction::isExact
bool isExact() const
Determine whether the exact flag is set.
Definition: Instruction.cpp:195
llvm::Instruction::copyFastMathFlags
void copyFastMathFlags(FastMathFlags FMF)
Convenience function for transferring all fast-math flag values to this instruction,...
Definition: Instruction.cpp:244
llvm::Instruction::mayReadFromMemory
bool mayReadFromMemory() const
Return true if this instruction may read memory.
Definition: Instruction.cpp:576
llvm::LoadInst
An instruction for reading from memory.
Definition: Instructions.h:173
llvm::AtomicRMWInst
an instruction that atomically reads a memory location, combines it with another value,...
Definition: Instructions.h:714
llvm::MDNode::getContext
LLVMContext & getContext() const
Definition: Metadata.h:1031
llvm::MCID::Select
@ Select
Definition: MCInstrDesc.h:164
llvm::Instruction::setFastMathFlags
void setFastMathFlags(FastMathFlags FMF)
Convenience function for setting multiple fast-math flags on this instruction, which must be an opera...
Definition: Instruction.cpp:239
llvm::Instruction::isAtomic
bool isAtomic() const
Return true if this instruction has an AtomicOrdering of unordered or higher.
Definition: Instruction.cpp:616
llvm::Instruction::setHasApproxFunc
void setHasApproxFunc(bool B)
Set or clear the approximate-math-functions flag on this instruction, which must be an operator which...
Definition: Instruction.cpp:234
llvm::Instruction::CompareIgnoringAlignment
@ CompareIgnoringAlignment
Check for equivalence ignoring load/store alignment.
Definition: Instruction.h:728
llvm::Instruction::Instruction
Instruction(const Instruction &)=delete
llvm::Instruction::isUsedOutsideOfBlock
bool isUsedOutsideOfBlock(const BasicBlock *BB) const
Return true if there are any uses of this instruction in blocks other than the specified block.
Definition: Instruction.cpp:558
llvm::ilist_iterator
Iterator for intrusive lists based on ilist_node.
Definition: ilist_iterator.h:57
llvm::ExtractValueInst
This instruction extracts a struct member or array element value from an aggregate value.
Definition: Instructions.h:2398
llvm::X86II::OB
@ OB
Definition: X86BaseInfo.h:801
llvm::Instruction::isEHPad
bool isEHPad() const
Return true if the instruction is a variety of EH-block.
Definition: Instruction.h:662
llvm::MCID::Add
@ Add
Definition: MCInstrDesc.h:185
llvm::Instruction::hasAllowReassoc
bool hasAllowReassoc() const
Determine whether the allow-reassociation flag is set.
Definition: Instruction.cpp:254
llvm::Instruction::isDebugOrPseudoInst
bool isDebugOrPseudoInst() const
Return true if the instruction is a DbgInfoIntrinsic or PseudoProbeInst.
Definition: Instruction.cpp:735
llvm::Instruction::hasNoNaNs
bool hasNoNaNs() const
Determine whether the no-NaNs flag is set.
Definition: Instruction.cpp:259
llvm::ValueAsMetadata::handleRAUW
static void handleRAUW(Value *From, Value *To)
Definition: Metadata.cpp:435
llvm::Instruction::hasPoisonGeneratingFlags
bool hasPoisonGeneratingFlags() const
Return true if this operator has flags which may cause this instruction to evaluate to poison despite...
Definition: Instruction.cpp:143
llvm::Instruction::setHasAllowReciprocal
void setHasAllowReciprocal(bool B)
Set or clear the allow-reciprocal flag on this instruction, which must be an operator which supports ...
Definition: Instruction.cpp:224
llvm::BasicBlock::getInstList
const InstListType & getInstList() const
Return the underlying instruction list container.
Definition: BasicBlock.h:364
llvm::ShuffleVectorInst
This instruction constructs a fixed permutation of two input vectors.
Definition: Instructions.h:1995
llvm::RecurKind::FAdd
@ FAdd
Sum of floats.
Instructions.h
llvm::User::getNumOperands
unsigned getNumOperands() const
Definition: User.h:191
llvm::Instruction::setHasNoInfs
void setHasNoInfs(bool B)
Set or clear the no-infs flag on this instruction, which must be an operator which supports this flag...
Definition: Instruction.cpp:214
llvm::Instruction::getDebugLoc
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
Definition: Instruction.h:367
llvm::Instruction::setHasNoSignedZeros
void setHasNoSignedZeros(bool B)
Set or clear the no-signed-zeros flag on this instruction, which must be an operator which supports t...
Definition: Instruction.cpp:219
llvm::Value::isUsedByMetadata
bool isUsedByMetadata() const
Return true if there is metadata referencing this value.
Definition: Value.h:557
llvm::Instruction::hasNoSignedWrap
bool hasNoSignedWrap() const
Determine whether the no signed wrap flag is set.
Definition: Instruction.cpp:139
llvm::User::op_begin
op_iterator op_begin()
Definition: User.h:234
llvm::Instruction::getParent
const BasicBlock * getParent() const
Definition: Instruction.h:91
llvm::PHINode::getIncomingBlock
BasicBlock * getIncomingBlock(unsigned i) const
Return incoming basic block number i.
Definition: Instructions.h:2767
llvm::Instruction::CompareUsingScalarTypes
@ CompareUsingScalarTypes
Check for equivalence treating a type and a vector of that type as equivalent.
Definition: Instruction.h:731
llvm::Instruction::swapProfMetadata
void swapProfMetadata()
If the instruction has "branch_weights" MD_prof metadata and the MDNode has three operands (including...
Definition: Instruction.cpp:824
llvm::PHINode
Definition: Instructions.h:2651
llvm::Instruction::copyIRFlags
void copyIRFlags(const Value *V, bool IncludeWrapFlags=true)
Convenience method to copy supported exact, fast-math, and (optionally) wrapping flags from V to this...
Definition: Instruction.cpp:298
llvm::Instruction::hasNoInfs
bool hasNoInfs() const
Determine whether the no-infs flag is set.
Definition: Instruction.cpp:264
llvm::Instruction::hasNoSignedZeros
bool hasNoSignedZeros() const
Determine whether the no-signed-zeros flag is set.
Definition: Instruction.cpp:269
llvm::CallInst
This class represents a function call, abstracting a target machine's calling convention.
Definition: Instructions.h:1461
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
GEP
Hexagon Common GEP
Definition: HexagonCommonGEP.cpp:171
llvm::AllocaInst
an instruction to allocate memory on the stack
Definition: Instructions.h:58
llvm::User::getOperand
Value * getOperand(unsigned i) const
Definition: User.h:169
llvm::MDString::getString
StringRef getString() const
Definition: Metadata.cpp:507
llvm::Instruction::isSameOperationAs
bool isSameOperationAs(const Instruction *I, unsigned flags=0) const
This function determines if the specified instruction executes the same operation as the current one.
Definition: Instruction.cpp:534
llvm::InsertValueInst
This instruction inserts a struct field of array element value into an aggregate value.
Definition: Instructions.h:2509
llvm::MDString
A single uniqued string.
Definition: Metadata.h:612
llvm::Value
LLVM Value Representation.
Definition: Value.h:74
llvm::AtomicCmpXchgInst
An instruction that atomically checks whether a specified value is in a memory location,...
Definition: Instructions.h:509
llvm::Instruction::setHasAllowReassoc
void setHasAllowReassoc(bool B)
Set or clear the reassociation flag on this instruction, which must be an operator which supports thi...
Definition: Instruction.cpp:204
llvm::Instruction::dropPoisonGeneratingFlags
void dropPoisonGeneratingFlags()
Drops flags that may cause this instruction to evaluate to poison despite having non-poison inputs.
Definition: Instruction.cpp:147
llvm::AtomicOrdering::NotAtomic
@ NotAtomic
llvm::RecurKind::Xor
@ Xor
Bitwise or logical XOR of integers.
llvm::Instruction::moveBefore
void moveBefore(Instruction *MovePos)
Unlink this instruction from its current basic block and insert it into the basic block that MovePos ...
Definition: Instruction.cpp:96
Other
Optional< std::vector< StOtherPiece > > Other
Definition: ELFYAML.cpp:1236
llvm::Use
A Use represents the edge between a Value definition and its users.
Definition: Use.h:43
llvm::Intrinsic::ID
unsigned ID
Definition: TargetTransformInfo.h:38
llvm::User::op_end
op_iterator op_end()
Definition: User.h:236