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