LLVM 19.0.0git
Instruction.h
Go to the documentation of this file.
1//===-- llvm/Instruction.h - Instruction class definition -------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file contains the declaration of the Instruction class, which is the
10// base class for all of the LLVM instructions.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_IR_INSTRUCTION_H
15#define LLVM_IR_INSTRUCTION_H
16
17#include "llvm/ADT/ArrayRef.h"
18#include "llvm/ADT/Bitfields.h"
19#include "llvm/ADT/StringRef.h"
20#include "llvm/ADT/ilist_node.h"
21#include "llvm/IR/DebugLoc.h"
23#include "llvm/IR/User.h"
24#include "llvm/IR/Value.h"
26#include <cstdint>
27#include <utility>
28
29namespace llvm {
30
31class BasicBlock;
32class DataLayout;
33class DbgMarker;
34class FastMathFlags;
35class MDNode;
36class Module;
37struct AAMDNodes;
38class DbgMarker;
39class DbgRecord;
40
41template <> struct ilist_alloc_traits<Instruction> {
42 static inline void deleteNode(Instruction *V);
43};
44
47
52
53public:
54 InsertPosition(std::nullptr_t) : InsertAt() {}
55 // LLVM_DEPRECATED("Use BasicBlock::iterators for insertion instead",
56 // "BasicBlock::iterator")
57 InsertPosition(Instruction *InsertBefore);
58 InsertPosition(BasicBlock *InsertAtEnd);
59 InsertPosition(InstListType::iterator InsertAt) : InsertAt(InsertAt) {}
60 operator InstListType::iterator() const { return InsertAt; }
61 bool isValid() const { return InsertAt.isValid(); }
62 BasicBlock *getBasicBlock() { return InsertAt.getNodeParent(); }
63};
64
65class Instruction : public User,
66 public ilist_node_with_parent<Instruction, BasicBlock,
67 ilist_iterator_bits<true>,
68 ilist_parent<BasicBlock>> {
69public:
72
73private:
74 DebugLoc DbgLoc; // 'dbg' Metadata cache.
75
76 /// Relative order of this instruction in its parent basic block. Used for
77 /// O(1) local dominance checks between instructions.
78 mutable unsigned Order = 0;
79
80public:
81 /// Optional marker recording the position for debugging information that
82 /// takes effect immediately before this instruction. Null unless there is
83 /// debugging information present.
84 DbgMarker *DebugMarker = nullptr;
85
86 /// Clone any debug-info attached to \p From onto this instruction. Used to
87 /// copy debugging information from one block to another, when copying entire
88 /// blocks. \see DebugProgramInstruction.h , because the ordering of
89 /// DbgRecords is still important, fine grain control of which instructions
90 /// are moved and where they go is necessary.
91 /// \p From The instruction to clone debug-info from.
92 /// \p from_here Optional iterator to limit DbgRecords cloned to be a range
93 /// from
94 /// from_here to end().
95 /// \p InsertAtHead Whether the cloned DbgRecords should be placed at the end
96 /// or the beginning of existing DbgRecords attached to this.
97 /// \returns A range over the newly cloned DbgRecords.
99 const Instruction *From,
100 std::optional<simple_ilist<DbgRecord>::iterator> FromHere = std::nullopt,
101 bool InsertAtHead = false);
102
103 /// Return a range over the DbgRecords attached to this instruction.
105 return llvm::getDbgRecordRange(DebugMarker);
106 }
107
108 /// Return an iterator to the position of the "Next" DbgRecord after this
109 /// instruction, or std::nullopt. This is the position to pass to
110 /// BasicBlock::reinsertInstInDbgRecords when re-inserting an instruction.
111 std::optional<simple_ilist<DbgRecord>::iterator> getDbgReinsertionPosition();
112
113 /// Returns true if any DbgRecords are attached to this instruction.
114 bool hasDbgRecords() const;
115
116 /// Transfer any DbgRecords on the position \p It onto this instruction,
117 /// by simply adopting the sequence of DbgRecords (which is efficient) if
118 /// possible, by merging two sequences otherwise.
119 void adoptDbgRecords(BasicBlock *BB, InstListType::iterator It,
120 bool InsertAtHead);
121
122 /// Erase any DbgRecords attached to this instruction.
123 void dropDbgRecords();
124
125 /// Erase a single DbgRecord \p I that is attached to this instruction.
126 void dropOneDbgRecord(DbgRecord *I);
127
128 /// Handle the debug-info implications of this instruction being removed. Any
129 /// attached DbgRecords need to "fall" down onto the next instruction.
130 void handleMarkerRemoval();
131
132protected:
133 // The 15 first bits of `Value::SubclassData` are available for subclasses of
134 // `Instruction` to use.
136
137 // Template alias so that all Instruction storing alignment use the same
138 // definiton.
139 // Valid alignments are powers of two from 2^0 to 2^MaxAlignmentExponent =
140 // 2^32. We store them as Log2(Alignment), so we need 6 bits to encode the 33
141 // possible values.
142 template <unsigned Offset>
144 typename Bitfield::Element<unsigned, Offset, 6,
145 Value::MaxAlignmentExponent>;
146
147 template <unsigned Offset>
149
150 template <unsigned Offset>
153 AtomicOrdering::LAST>;
154
155private:
156 // The last bit is used to store whether the instruction has metadata attached
157 // or not.
159
160protected:
161 ~Instruction(); // Use deleteValue() to delete a generic Instruction.
162
163public:
164 Instruction(const Instruction &) = delete;
166
167 /// Specialize the methods defined in Value, as we know that an instruction
168 /// can only be used by other instructions.
169 Instruction *user_back() { return cast<Instruction>(*user_begin());}
170 const Instruction *user_back() const { return cast<Instruction>(*user_begin());}
171
172 /// Return the module owning the function this instruction belongs to
173 /// or nullptr it the function does not have a module.
174 ///
175 /// Note: this is undefined behavior if the instruction does not have a
176 /// parent, or the parent basic block does not have a parent function.
177 const Module *getModule() const;
179 return const_cast<Module *>(
180 static_cast<const Instruction *>(this)->getModule());
181 }
182
183 /// Return the function this instruction belongs to.
184 ///
185 /// Note: it is undefined behavior to call this on an instruction not
186 /// currently inserted into a function.
187 const Function *getFunction() const;
189 return const_cast<Function *>(
190 static_cast<const Instruction *>(this)->getFunction());
191 }
192
193 /// Get the data layout of the module this instruction belongs to.
194 ///
195 /// Requires the instruction to have a parent module.
196 const DataLayout &getDataLayout() const;
197
198 /// This method unlinks 'this' from the containing basic block, but does not
199 /// delete it.
200 void removeFromParent();
201
202 /// This method unlinks 'this' from the containing basic block and deletes it.
203 ///
204 /// \returns an iterator pointing to the element after the erased one
205 InstListType::iterator eraseFromParent();
206
207 /// Insert an unlinked instruction into a basic block immediately before
208 /// the specified instruction.
209 void insertBefore(Instruction *InsertPos);
210 void insertBefore(InstListType::iterator InsertPos);
211
212 /// Insert an unlinked instruction into a basic block immediately after the
213 /// specified instruction.
214 void insertAfter(Instruction *InsertPos);
215
216 /// Inserts an unlinked instruction into \p ParentBB at position \p It and
217 /// returns the iterator of the inserted instruction.
218 InstListType::iterator insertInto(BasicBlock *ParentBB,
219 InstListType::iterator It);
220
221 void insertBefore(BasicBlock &BB, InstListType::iterator InsertPos);
222
223 /// Unlink this instruction from its current basic block and insert it into
224 /// the basic block that MovePos lives in, right before MovePos.
225 void moveBefore(Instruction *MovePos);
226
227 /// Perform a \ref moveBefore operation, while signalling that the caller
228 /// intends to preserve the original ordering of instructions. This implicitly
229 /// means that any adjacent debug-info should move with this instruction.
230 /// This method is currently a no-op placeholder, but it will become meaningful
231 /// when the "RemoveDIs" project is enabled.
232 void moveBeforePreserving(Instruction *MovePos);
233
234private:
235 /// RemoveDIs project: all other moves implemented with this method,
236 /// centralising debug-info updates into one place.
237 void moveBeforeImpl(BasicBlock &BB, InstListType::iterator I, bool Preserve);
238
239public:
240 /// Unlink this instruction and insert into BB before I.
241 ///
242 /// \pre I is a valid iterator into BB.
243 void moveBefore(BasicBlock &BB, InstListType::iterator I);
244
245 /// (See other overload for moveBeforePreserving).
246 void moveBeforePreserving(BasicBlock &BB, InstListType::iterator I);
247
248 /// Unlink this instruction from its current basic block and insert it into
249 /// the basic block that MovePos lives in, right after MovePos.
250 void moveAfter(Instruction *MovePos);
251
252 /// See \ref moveBeforePreserving .
253 void moveAfterPreserving(Instruction *MovePos);
254
255 /// Given an instruction Other in the same basic block as this instruction,
256 /// return true if this instruction comes before Other. In this worst case,
257 /// this takes linear time in the number of instructions in the block. The
258 /// results are cached, so in common cases when the block remains unmodified,
259 /// it takes constant time.
260 bool comesBefore(const Instruction *Other) const;
261
262 /// Get the first insertion point at which the result of this instruction
263 /// is defined. This is *not* the directly following instruction in a number
264 /// of cases, e.g. phi nodes or terminators that return values. This function
265 /// may return null if the insertion after the definition is not possible,
266 /// e.g. due to a catchswitch terminator.
267 std::optional<InstListType::iterator> getInsertionPointAfterDef();
268
269 //===--------------------------------------------------------------------===//
270 // Subclass classification.
271 //===--------------------------------------------------------------------===//
272
273 /// Returns a member of one of the enums like Instruction::Add.
274 unsigned getOpcode() const { return getValueID() - InstructionVal; }
275
276 const char *getOpcodeName() const { return getOpcodeName(getOpcode()); }
277 bool isTerminator() const { return isTerminator(getOpcode()); }
278 bool isUnaryOp() const { return isUnaryOp(getOpcode()); }
279 bool isBinaryOp() const { return isBinaryOp(getOpcode()); }
280 bool isIntDivRem() const { return isIntDivRem(getOpcode()); }
281 bool isShift() const { return isShift(getOpcode()); }
282 bool isCast() const { return isCast(getOpcode()); }
283 bool isFuncletPad() const { return isFuncletPad(getOpcode()); }
285
286 /// It checks if this instruction is the only user of at least one of
287 /// its operands.
288 bool isOnlyUserOfAnyOperand();
289
290 static const char *getOpcodeName(unsigned Opcode);
291
292 static inline bool isTerminator(unsigned Opcode) {
293 return Opcode >= TermOpsBegin && Opcode < TermOpsEnd;
294 }
295
296 static inline bool isUnaryOp(unsigned Opcode) {
297 return Opcode >= UnaryOpsBegin && Opcode < UnaryOpsEnd;
298 }
299 static inline bool isBinaryOp(unsigned Opcode) {
300 return Opcode >= BinaryOpsBegin && Opcode < BinaryOpsEnd;
301 }
302
303 static inline bool isIntDivRem(unsigned Opcode) {
304 return Opcode == UDiv || Opcode == SDiv || Opcode == URem || Opcode == SRem;
305 }
306
307 /// Determine if the Opcode is one of the shift instructions.
308 static inline bool isShift(unsigned Opcode) {
309 return Opcode >= Shl && Opcode <= AShr;
310 }
311
312 /// Return true if this is a logical shift left or a logical shift right.
313 inline bool isLogicalShift() const {
314 return getOpcode() == Shl || getOpcode() == LShr;
315 }
316
317 /// Return true if this is an arithmetic shift right.
318 inline bool isArithmeticShift() const {
319 return getOpcode() == AShr;
320 }
321
322 /// Determine if the Opcode is and/or/xor.
323 static inline bool isBitwiseLogicOp(unsigned Opcode) {
324 return Opcode == And || Opcode == Or || Opcode == Xor;
325 }
326
327 /// Return true if this is and/or/xor.
328 inline bool isBitwiseLogicOp() const {
329 return isBitwiseLogicOp(getOpcode());
330 }
331
332 /// Determine if the Opcode is one of the CastInst instructions.
333 static inline bool isCast(unsigned Opcode) {
334 return Opcode >= CastOpsBegin && Opcode < CastOpsEnd;
335 }
336
337 /// Determine if the Opcode is one of the FuncletPadInst instructions.
338 static inline bool isFuncletPad(unsigned Opcode) {
339 return Opcode >= FuncletPadOpsBegin && Opcode < FuncletPadOpsEnd;
340 }
341
342 /// Returns true if the Opcode is a "special" terminator that does more than
343 /// branch to a successor (e.g. have a side effect or return a value).
344 static inline bool isSpecialTerminator(unsigned Opcode) {
345 switch (Opcode) {
346 case Instruction::CatchSwitch:
347 case Instruction::CatchRet:
348 case Instruction::CleanupRet:
349 case Instruction::Invoke:
350 case Instruction::Resume:
351 case Instruction::CallBr:
352 return true;
353 default:
354 return false;
355 }
356 }
357
358 //===--------------------------------------------------------------------===//
359 // Metadata manipulation.
360 //===--------------------------------------------------------------------===//
361
362 /// Return true if this instruction has any metadata attached to it.
363 bool hasMetadata() const { return DbgLoc || Value::hasMetadata(); }
364
365 /// Return true if this instruction has metadata attached to it other than a
366 /// debug location.
367 bool hasMetadataOtherThanDebugLoc() const { return Value::hasMetadata(); }
368
369 /// Return true if this instruction has the given type of metadata attached.
370 bool hasMetadata(unsigned KindID) const {
371 return getMetadata(KindID) != nullptr;
372 }
373
374 /// Return true if this instruction has the given type of metadata attached.
375 bool hasMetadata(StringRef Kind) const {
376 return getMetadata(Kind) != nullptr;
377 }
378
379 /// Get the metadata of given kind attached to this Instruction.
380 /// If the metadata is not found then return null.
381 MDNode *getMetadata(unsigned KindID) const {
382 // Handle 'dbg' as a special case since it is not stored in the hash table.
383 if (KindID == LLVMContext::MD_dbg)
384 return DbgLoc.getAsMDNode();
385 return Value::getMetadata(KindID);
386 }
387
388 /// Get the metadata of given kind attached to this Instruction.
389 /// If the metadata is not found then return null.
391 if (!hasMetadata()) return nullptr;
392 return getMetadataImpl(Kind);
393 }
394
395 /// Get all metadata attached to this Instruction. The first element of each
396 /// pair returned is the KindID, the second element is the metadata value.
397 /// This list is returned sorted by the KindID.
398 void
399 getAllMetadata(SmallVectorImpl<std::pair<unsigned, MDNode *>> &MDs) const {
400 if (hasMetadata())
401 getAllMetadataImpl(MDs);
402 }
403
404 /// This does the same thing as getAllMetadata, except that it filters out the
405 /// debug location.
407 SmallVectorImpl<std::pair<unsigned, MDNode *>> &MDs) const {
408 Value::getAllMetadata(MDs);
409 }
410
411 /// Set the metadata of the specified kind to the specified node. This updates
412 /// or replaces metadata if already present, or removes it if Node is null.
413 void setMetadata(unsigned KindID, MDNode *Node);
414 void setMetadata(StringRef Kind, MDNode *Node);
415
416 /// Copy metadata from \p SrcInst to this instruction. \p WL, if not empty,
417 /// specifies the list of meta data that needs to be copied. If \p WL is
418 /// empty, all meta data will be copied.
419 void copyMetadata(const Instruction &SrcInst,
421
422 /// Erase all metadata that matches the predicate.
423 void eraseMetadataIf(function_ref<bool(unsigned, MDNode *)> Pred);
424
425 /// If the instruction has "branch_weights" MD_prof metadata and the MDNode
426 /// has three operands (including name string), swap the order of the
427 /// metadata.
428 void swapProfMetadata();
429
430 /// Drop all unknown metadata except for debug locations.
431 /// @{
432 /// Passes are required to drop metadata they don't understand. This is a
433 /// convenience method for passes to do so.
434 /// dropUBImplyingAttrsAndUnknownMetadata should be used instead of
435 /// this API if the Instruction being modified is a call.
436 void dropUnknownNonDebugMetadata(ArrayRef<unsigned> KnownIDs);
438 return dropUnknownNonDebugMetadata(std::nullopt);
439 }
440 void dropUnknownNonDebugMetadata(unsigned ID1) {
441 return dropUnknownNonDebugMetadata(ArrayRef(ID1));
442 }
443 void dropUnknownNonDebugMetadata(unsigned ID1, unsigned ID2) {
444 unsigned IDs[] = {ID1, ID2};
445 return dropUnknownNonDebugMetadata(IDs);
446 }
447 /// @}
448
449 /// Adds an !annotation metadata node with \p Annotation to this instruction.
450 /// If this instruction already has !annotation metadata, append \p Annotation
451 /// to the existing node.
452 void addAnnotationMetadata(StringRef Annotation);
453 /// Adds an !annotation metadata node with an array of \p Annotations
454 /// as a tuple to this instruction. If this instruction already has
455 /// !annotation metadata, append the tuple to
456 /// the existing node.
457 void addAnnotationMetadata(SmallVector<StringRef> Annotations);
458 /// Returns the AA metadata for this instruction.
459 AAMDNodes getAAMetadata() const;
460
461 /// Sets the AA metadata on this instruction from the AAMDNodes structure.
462 void setAAMetadata(const AAMDNodes &N);
463
464 /// Sets the nosanitize metadata on this instruction.
465 void setNoSanitizeMetadata();
466
467 /// Retrieve total raw weight values of a branch.
468 /// Returns true on success with profile total weights filled in.
469 /// Returns false if no metadata was found.
470 bool extractProfTotalWeight(uint64_t &TotalVal) const;
471
472 /// Set the debug location information for this instruction.
473 void setDebugLoc(DebugLoc Loc) { DbgLoc = std::move(Loc); }
474
475 /// Return the debug location for this node as a DebugLoc.
476 const DebugLoc &getDebugLoc() const { return DbgLoc; }
477
478 /// Fetch the debug location for this node, unless this is a debug intrinsic,
479 /// in which case fetch the debug location of the next non-debug node.
480 const DebugLoc &getStableDebugLoc() const;
481
482 /// Set or clear the nuw flag on this instruction, which must be an operator
483 /// which supports this flag. See LangRef.html for the meaning of this flag.
484 void setHasNoUnsignedWrap(bool b = true);
485
486 /// Set or clear the nsw flag on this instruction, which must be an operator
487 /// which supports this flag. See LangRef.html for the meaning of this flag.
488 void setHasNoSignedWrap(bool b = true);
489
490 /// Set or clear the exact flag on this instruction, which must be an operator
491 /// which supports this flag. See LangRef.html for the meaning of this flag.
492 void setIsExact(bool b = true);
493
494 /// Set or clear the nneg flag on this instruction, which must be a zext
495 /// instruction.
496 void setNonNeg(bool b = true);
497
498 /// Determine whether the no unsigned wrap flag is set.
500
501 /// Determine whether the no signed wrap flag is set.
503
504 /// Determine whether the the nneg flag is set.
505 bool hasNonNeg() const LLVM_READONLY;
506
507 /// Return true if this operator has flags which may cause this instruction
508 /// to evaluate to poison despite having non-poison inputs.
509 bool hasPoisonGeneratingFlags() const LLVM_READONLY;
510
511 /// Drops flags that may cause this instruction to evaluate to poison despite
512 /// having non-poison inputs.
513 void dropPoisonGeneratingFlags();
514
515 /// Return true if this instruction has poison-generating metadata.
516 bool hasPoisonGeneratingMetadata() const LLVM_READONLY;
517
518 /// Drops metadata that may generate poison.
519 void dropPoisonGeneratingMetadata();
520
521 /// Return true if this instruction has poison-generating attribute.
522 bool hasPoisonGeneratingReturnAttributes() const LLVM_READONLY;
523
524 /// Drops return attributes that may generate poison.
525 void dropPoisonGeneratingReturnAttributes();
526
527 /// Return true if this instruction has poison-generating flags,
528 /// return attributes or metadata.
529 bool hasPoisonGeneratingAnnotations() const {
530 return hasPoisonGeneratingFlags() ||
531 hasPoisonGeneratingReturnAttributes() ||
532 hasPoisonGeneratingMetadata();
533 }
534
535 /// Drops flags, return attributes and metadata that may generate poison.
537 dropPoisonGeneratingFlags();
538 dropPoisonGeneratingReturnAttributes();
539 dropPoisonGeneratingMetadata();
540 }
541
542 /// This function drops non-debug unknown metadata (through
543 /// dropUnknownNonDebugMetadata). For calls, it also drops parameter and
544 /// return attributes that can cause undefined behaviour. Both of these should
545 /// be done by passes which move instructions in IR.
546 void dropUBImplyingAttrsAndUnknownMetadata(ArrayRef<unsigned> KnownIDs = {});
547
548 /// Drop any attributes or metadata that can cause immediate undefined
549 /// behavior. Retain other attributes/metadata on a best-effort basis.
550 /// This should be used when speculating instructions.
551 void dropUBImplyingAttrsAndMetadata();
552
553 /// Determine whether the exact flag is set.
554 bool isExact() const LLVM_READONLY;
555
556 /// Set or clear all fast-math-flags on this instruction, which must be an
557 /// operator which supports this flag. See LangRef.html for the meaning of
558 /// this flag.
559 void setFast(bool B);
560
561 /// Set or clear the reassociation flag on this instruction, which must be
562 /// an operator which supports this flag. See LangRef.html for the meaning of
563 /// this flag.
564 void setHasAllowReassoc(bool B);
565
566 /// Set or clear the no-nans flag on this instruction, which must be an
567 /// operator which supports this flag. See LangRef.html for the meaning of
568 /// this flag.
569 void setHasNoNaNs(bool B);
570
571 /// Set or clear the no-infs flag on this instruction, which must be an
572 /// operator which supports this flag. See LangRef.html for the meaning of
573 /// this flag.
574 void setHasNoInfs(bool B);
575
576 /// Set or clear the no-signed-zeros flag on this instruction, which must be
577 /// an operator which supports this flag. See LangRef.html for the meaning of
578 /// this flag.
579 void setHasNoSignedZeros(bool B);
580
581 /// Set or clear the allow-reciprocal flag on this instruction, which must be
582 /// an operator which supports this flag. See LangRef.html for the meaning of
583 /// this flag.
584 void setHasAllowReciprocal(bool B);
585
586 /// Set or clear the allow-contract flag on this instruction, which must be
587 /// an operator which supports this flag. See LangRef.html for the meaning of
588 /// this flag.
589 void setHasAllowContract(bool B);
590
591 /// Set or clear the approximate-math-functions flag on this instruction,
592 /// which must be an operator which supports this flag. See LangRef.html for
593 /// the meaning of this flag.
594 void setHasApproxFunc(bool B);
595
596 /// Convenience function for setting multiple fast-math flags on this
597 /// instruction, which must be an operator which supports these flags. See
598 /// LangRef.html for the meaning of these flags.
599 void setFastMathFlags(FastMathFlags FMF);
600
601 /// Convenience function for transferring all fast-math flag values to this
602 /// instruction, which must be an operator which supports these flags. See
603 /// LangRef.html for the meaning of these flags.
604 void copyFastMathFlags(FastMathFlags FMF);
605
606 /// Determine whether all fast-math-flags are set.
607 bool isFast() const LLVM_READONLY;
608
609 /// Determine whether the allow-reassociation flag is set.
610 bool hasAllowReassoc() const LLVM_READONLY;
611
612 /// Determine whether the no-NaNs flag is set.
613 bool hasNoNaNs() const LLVM_READONLY;
614
615 /// Determine whether the no-infs flag is set.
617
618 /// Determine whether the no-signed-zeros flag is set.
619 bool hasNoSignedZeros() const LLVM_READONLY;
620
621 /// Determine whether the allow-reciprocal flag is set.
622 bool hasAllowReciprocal() const LLVM_READONLY;
623
624 /// Determine whether the allow-contract flag is set.
625 bool hasAllowContract() const LLVM_READONLY;
626
627 /// Determine whether the approximate-math-functions flag is set.
628 bool hasApproxFunc() const LLVM_READONLY;
629
630 /// Convenience function for getting all the fast-math flags, which must be an
631 /// operator which supports these flags. See LangRef.html for the meaning of
632 /// these flags.
633 FastMathFlags getFastMathFlags() const LLVM_READONLY;
634
635 /// Copy I's fast-math flags
636 void copyFastMathFlags(const Instruction *I);
637
638 /// Convenience method to copy supported exact, fast-math, and (optionally)
639 /// wrapping flags from V to this instruction.
640 void copyIRFlags(const Value *V, bool IncludeWrapFlags = true);
641
642 /// Logical 'and' of any supported wrapping, exact, and fast-math flags of
643 /// V and this instruction.
644 void andIRFlags(const Value *V);
645
646 /// Merge 2 debug locations and apply it to the Instruction. If the
647 /// instruction is a CallIns, we need to traverse the inline chain to find
648 /// the common scope. This is not efficient for N-way merging as each time
649 /// you merge 2 iterations, you need to rebuild the hashmap to find the
650 /// common scope. However, we still choose this API because:
651 /// 1) Simplicity: it takes 2 locations instead of a list of locations.
652 /// 2) In worst case, it increases the complexity from O(N*I) to
653 /// O(2*N*I), where N is # of Instructions to merge, and I is the
654 /// maximum level of inline stack. So it is still linear.
655 /// 3) Merging of call instructions should be extremely rare in real
656 /// applications, thus the N-way merging should be in code path.
657 /// The DebugLoc attached to this instruction will be overwritten by the
658 /// merged DebugLoc.
659 void applyMergedLocation(DILocation *LocA, DILocation *LocB);
660
661 /// Updates the debug location given that the instruction has been hoisted
662 /// from a block to a predecessor of that block.
663 /// Note: it is undefined behavior to call this on an instruction not
664 /// currently inserted into a function.
665 void updateLocationAfterHoist();
666
667 /// Drop the instruction's debug location. This does not guarantee removal
668 /// of the !dbg source location attachment, as it must set a line 0 location
669 /// with scope information attached on call instructions. To guarantee
670 /// removal of the !dbg attachment, use the \ref setDebugLoc() API.
671 /// Note: it is undefined behavior to call this on an instruction not
672 /// currently inserted into a function.
673 void dropLocation();
674
675 /// Merge the DIAssignID metadata from this instruction and those attached to
676 /// instructions in \p SourceInstructions. This process performs a RAUW on
677 /// the MetadataAsValue uses of the merged DIAssignID nodes. Not every
678 /// instruction in \p SourceInstructions needs to have DIAssignID
679 /// metadata. If none of them do then nothing happens. If this instruction
680 /// does not have a DIAssignID attachment but at least one in \p
681 /// SourceInstructions does then the merged one will be attached to
682 /// it. However, instructions without attachments in \p SourceInstructions
683 /// are not modified.
684 void mergeDIAssignID(ArrayRef<const Instruction *> SourceInstructions);
685
686private:
687 // These are all implemented in Metadata.cpp.
688 MDNode *getMetadataImpl(StringRef Kind) const;
689 void
690 getAllMetadataImpl(SmallVectorImpl<std::pair<unsigned, MDNode *>> &) const;
691
692 /// Update the LLVMContext ID-to-Instruction(s) mapping. If \p ID is nullptr
693 /// then clear the mapping for this instruction.
694 void updateDIAssignIDMapping(DIAssignID *ID);
695
696public:
697 //===--------------------------------------------------------------------===//
698 // Predicates and helper methods.
699 //===--------------------------------------------------------------------===//
700
701 /// Return true if the instruction is associative:
702 ///
703 /// Associative operators satisfy: x op (y op z) === (x op y) op z
704 ///
705 /// In LLVM, the Add, Mul, And, Or, and Xor operators are associative.
706 ///
708 static bool isAssociative(unsigned Opcode) {
709 return Opcode == And || Opcode == Or || Opcode == Xor ||
710 Opcode == Add || Opcode == Mul;
711 }
712
713 /// Return true if the instruction is commutative:
714 ///
715 /// Commutative operators satisfy: (x op y) === (y op x)
716 ///
717 /// In LLVM, these are the commutative operators, plus SetEQ and SetNE, when
718 /// applied to any type.
719 ///
721 static bool isCommutative(unsigned Opcode) {
722 switch (Opcode) {
723 case Add: case FAdd:
724 case Mul: case FMul:
725 case And: case Or: case Xor:
726 return true;
727 default:
728 return false;
729 }
730 }
731
732 /// Return true if the instruction is idempotent:
733 ///
734 /// Idempotent operators satisfy: x op x === x
735 ///
736 /// In LLVM, the And and Or operators are idempotent.
737 ///
738 bool isIdempotent() const { return isIdempotent(getOpcode()); }
739 static bool isIdempotent(unsigned Opcode) {
740 return Opcode == And || Opcode == Or;
741 }
742
743 /// Return true if the instruction is nilpotent:
744 ///
745 /// Nilpotent operators satisfy: x op x === Id,
746 ///
747 /// where Id is the identity for the operator, i.e. a constant such that
748 /// x op Id === x and Id op x === x for all x.
749 ///
750 /// In LLVM, the Xor operator is nilpotent.
751 ///
752 bool isNilpotent() const { return isNilpotent(getOpcode()); }
753 static bool isNilpotent(unsigned Opcode) {
754 return Opcode == Xor;
755 }
756
757 /// Return true if this instruction may modify memory.
758 bool mayWriteToMemory() const LLVM_READONLY;
759
760 /// Return true if this instruction may read memory.
761 bool mayReadFromMemory() const LLVM_READONLY;
762
763 /// Return true if this instruction may read or write memory.
764 bool mayReadOrWriteMemory() const {
765 return mayReadFromMemory() || mayWriteToMemory();
766 }
767
768 /// Return true if this instruction has an AtomicOrdering of unordered or
769 /// higher.
770 bool isAtomic() const LLVM_READONLY;
771
772 /// Return true if this atomic instruction loads from memory.
773 bool hasAtomicLoad() const LLVM_READONLY;
774
775 /// Return true if this atomic instruction stores to memory.
776 bool hasAtomicStore() const LLVM_READONLY;
777
778 /// Return true if this instruction has a volatile memory access.
779 bool isVolatile() const LLVM_READONLY;
780
781 /// Return the type this instruction accesses in memory, if any.
783
784 /// Return true if this instruction may throw an exception.
785 ///
786 /// If IncludePhaseOneUnwind is set, this will also include cases where
787 /// phase one unwinding may unwind past this frame due to skipping of
788 /// cleanup landingpads.
789 bool mayThrow(bool IncludePhaseOneUnwind = false) const LLVM_READONLY;
790
791 /// Return true if this instruction behaves like a memory fence: it can load
792 /// or store to memory location without being given a memory location.
793 bool isFenceLike() const {
794 switch (getOpcode()) {
795 default:
796 return false;
797 // This list should be kept in sync with the list in mayWriteToMemory for
798 // all opcodes which don't have a memory location.
799 case Instruction::Fence:
800 case Instruction::CatchPad:
801 case Instruction::CatchRet:
802 case Instruction::Call:
803 case Instruction::Invoke:
804 return true;
805 }
806 }
807
808 /// Return true if the instruction may have side effects.
809 ///
810 /// Side effects are:
811 /// * Writing to memory.
812 /// * Unwinding.
813 /// * Not returning (e.g. an infinite loop).
814 ///
815 /// Note that this does not consider malloc and alloca to have side
816 /// effects because the newly allocated memory is completely invisible to
817 /// instructions which don't use the returned value. For cases where this
818 /// matters, isSafeToSpeculativelyExecute may be more appropriate.
820
821 /// Return true if the instruction can be removed if the result is unused.
822 ///
823 /// When constant folding some instructions cannot be removed even if their
824 /// results are unused. Specifically terminator instructions and calls that
825 /// may have side effects cannot be removed without semantically changing the
826 /// generated program.
827 bool isSafeToRemove() const LLVM_READONLY;
828
829 /// Return true if the instruction will return (unwinding is considered as
830 /// a form of returning control flow here).
831 bool willReturn() const LLVM_READONLY;
832
833 /// Return true if the instruction is a variety of EH-block.
834 bool isEHPad() const {
835 switch (getOpcode()) {
836 case Instruction::CatchSwitch:
837 case Instruction::CatchPad:
838 case Instruction::CleanupPad:
839 case Instruction::LandingPad:
840 return true;
841 default:
842 return false;
843 }
844 }
845
846 /// Return true if the instruction is a llvm.lifetime.start or
847 /// llvm.lifetime.end marker.
848 bool isLifetimeStartOrEnd() const LLVM_READONLY;
849
850 /// Return true if the instruction is a llvm.launder.invariant.group or
851 /// llvm.strip.invariant.group.
852 bool isLaunderOrStripInvariantGroup() const LLVM_READONLY;
853
854 /// Return true if the instruction is a DbgInfoIntrinsic or PseudoProbeInst.
855 bool isDebugOrPseudoInst() const LLVM_READONLY;
856
857 /// Return a pointer to the next non-debug instruction in the same basic
858 /// block as 'this', or nullptr if no such instruction exists. Skip any pseudo
859 /// operations if \c SkipPseudoOp is true.
861 getNextNonDebugInstruction(bool SkipPseudoOp = false) const;
862 Instruction *getNextNonDebugInstruction(bool SkipPseudoOp = false) {
863 return const_cast<Instruction *>(
864 static_cast<const Instruction *>(this)->getNextNonDebugInstruction(
865 SkipPseudoOp));
866 }
867
868 /// Return a pointer to the previous non-debug instruction in the same basic
869 /// block as 'this', or nullptr if no such instruction exists. Skip any pseudo
870 /// operations if \c SkipPseudoOp is true.
871 const Instruction *
872 getPrevNonDebugInstruction(bool SkipPseudoOp = false) const;
873 Instruction *getPrevNonDebugInstruction(bool SkipPseudoOp = false) {
874 return const_cast<Instruction *>(
875 static_cast<const Instruction *>(this)->getPrevNonDebugInstruction(
876 SkipPseudoOp));
877 }
878
879 /// Create a copy of 'this' instruction that is identical in all ways except
880 /// the following:
881 /// * The instruction has no parent
882 /// * The instruction has no name
883 ///
884 Instruction *clone() const;
885
886 /// Return true if the specified instruction is exactly identical to the
887 /// current one. This means that all operands match and any extra information
888 /// (e.g. load is volatile) agree.
889 bool isIdenticalTo(const Instruction *I) const LLVM_READONLY;
890
891 /// This is like isIdenticalTo, except that it ignores the
892 /// SubclassOptionalData flags, which may specify conditions under which the
893 /// instruction's result is undefined.
894 bool isIdenticalToWhenDefined(const Instruction *I) const LLVM_READONLY;
895
896 /// When checking for operation equivalence (using isSameOperationAs) it is
897 /// sometimes useful to ignore certain attributes.
899 /// Check for equivalence ignoring load/store alignment.
900 CompareIgnoringAlignment = 1<<0,
901 /// Check for equivalence treating a type and a vector of that type
902 /// as equivalent.
903 CompareUsingScalarTypes = 1<<1
904 };
905
906 /// This function determines if the specified instruction executes the same
907 /// operation as the current one. This means that the opcodes, type, operand
908 /// types and any other factors affecting the operation must be the same. This
909 /// is similar to isIdenticalTo except the operands themselves don't have to
910 /// be identical.
911 /// @returns true if the specified instruction is the same operation as
912 /// the current one.
913 /// Determine if one instruction is the same operation as another.
914 bool isSameOperationAs(const Instruction *I, unsigned flags = 0) const LLVM_READONLY;
915
916 /// This function determines if the speficied instruction has the same
917 /// "special" characteristics as the current one. This means that opcode
918 /// specific details are the same. As a common example, if we are comparing
919 /// loads, then hasSameSpecialState would compare the alignments (among
920 /// other things).
921 /// @returns true if the specific instruction has the same opcde specific
922 /// characteristics as the current one. Determine if one instruction has the
923 /// same state as another.
924 bool hasSameSpecialState(const Instruction *I2,
925 bool IgnoreAlignment = false) const LLVM_READONLY;
926
927 /// Return true if there are any uses of this instruction in blocks other than
928 /// the specified block. Note that PHI nodes are considered to evaluate their
929 /// operands in the corresponding predecessor block.
930 bool isUsedOutsideOfBlock(const BasicBlock *BB) const LLVM_READONLY;
931
932 /// Return the number of successors that this instruction has. The instruction
933 /// must be a terminator.
934 unsigned getNumSuccessors() const LLVM_READONLY;
935
936 /// Return the specified successor. This instruction must be a terminator.
937 BasicBlock *getSuccessor(unsigned Idx) const LLVM_READONLY;
938
939 /// Update the specified successor to point at the provided block. This
940 /// instruction must be a terminator.
941 void setSuccessor(unsigned Idx, BasicBlock *BB);
942
943 /// Replace specified successor OldBB to point at the provided block.
944 /// This instruction must be a terminator.
945 void replaceSuccessorWith(BasicBlock *OldBB, BasicBlock *NewBB);
946
947 /// Methods for support type inquiry through isa, cast, and dyn_cast:
948 static bool classof(const Value *V) {
949 return V->getValueID() >= Value::InstructionVal;
950 }
951
952 //----------------------------------------------------------------------
953 // Exported enumerations.
954 //
955 enum TermOps { // These terminate basic blocks
956#define FIRST_TERM_INST(N) TermOpsBegin = N,
957#define HANDLE_TERM_INST(N, OPC, CLASS) OPC = N,
958#define LAST_TERM_INST(N) TermOpsEnd = N+1
959#include "llvm/IR/Instruction.def"
960 };
961
962 enum UnaryOps {
963#define FIRST_UNARY_INST(N) UnaryOpsBegin = N,
964#define HANDLE_UNARY_INST(N, OPC, CLASS) OPC = N,
965#define LAST_UNARY_INST(N) UnaryOpsEnd = N+1
966#include "llvm/IR/Instruction.def"
967 };
968
970#define FIRST_BINARY_INST(N) BinaryOpsBegin = N,
971#define HANDLE_BINARY_INST(N, OPC, CLASS) OPC = N,
972#define LAST_BINARY_INST(N) BinaryOpsEnd = N+1
973#include "llvm/IR/Instruction.def"
974 };
975
977#define FIRST_MEMORY_INST(N) MemoryOpsBegin = N,
978#define HANDLE_MEMORY_INST(N, OPC, CLASS) OPC = N,
979#define LAST_MEMORY_INST(N) MemoryOpsEnd = N+1
980#include "llvm/IR/Instruction.def"
981 };
982
983 enum CastOps {
984#define FIRST_CAST_INST(N) CastOpsBegin = N,
985#define HANDLE_CAST_INST(N, OPC, CLASS) OPC = N,
986#define LAST_CAST_INST(N) CastOpsEnd = N+1
987#include "llvm/IR/Instruction.def"
988 };
989
991#define FIRST_FUNCLETPAD_INST(N) FuncletPadOpsBegin = N,
992#define HANDLE_FUNCLETPAD_INST(N, OPC, CLASS) OPC = N,
993#define LAST_FUNCLETPAD_INST(N) FuncletPadOpsEnd = N+1
994#include "llvm/IR/Instruction.def"
995 };
996
997 enum OtherOps {
998#define FIRST_OTHER_INST(N) OtherOpsBegin = N,
999#define HANDLE_OTHER_INST(N, OPC, CLASS) OPC = N,
1000#define LAST_OTHER_INST(N) OtherOpsEnd = N+1
1001#include "llvm/IR/Instruction.def"
1002 };
1003
1004private:
1005 friend class SymbolTableListTraits<Instruction, ilist_iterator_bits<true>,
1006 ilist_parent<BasicBlock>>;
1007 friend class BasicBlock; // For renumbering.
1008
1009 // Shadow Value::setValueSubclassData with a private forwarding method so that
1010 // subclasses cannot accidentally use it.
1011 void setValueSubclassData(unsigned short D) {
1012 Value::setValueSubclassData(D);
1013 }
1014
1015 unsigned short getSubclassDataFromValue() const {
1016 return Value::getSubclassDataFromValue();
1017 }
1018
1019protected:
1020 // Instruction subclasses can stick up to 15 bits of stuff into the
1021 // SubclassData field of instruction with these members.
1022
1023 template <typename BitfieldElement>
1024 typename BitfieldElement::Type getSubclassData() const {
1025 static_assert(
1026 std::is_same<BitfieldElement, HasMetadataField>::value ||
1027 !Bitfield::isOverlapping<BitfieldElement, HasMetadataField>(),
1028 "Must not overlap with the metadata bit");
1029 return Bitfield::get<BitfieldElement>(getSubclassDataFromValue());
1030 }
1031
1032 template <typename BitfieldElement>
1033 void setSubclassData(typename BitfieldElement::Type Value) {
1034 static_assert(
1035 std::is_same<BitfieldElement, HasMetadataField>::value ||
1036 !Bitfield::isOverlapping<BitfieldElement, HasMetadataField>(),
1037 "Must not overlap with the metadata bit");
1038 auto Storage = getSubclassDataFromValue();
1039 Bitfield::set<BitfieldElement>(Storage, Value);
1040 setValueSubclassData(Storage);
1041 }
1042
1043 Instruction(Type *Ty, unsigned iType, Use *Ops, unsigned NumOps,
1044 InsertPosition InsertBefore = nullptr);
1045
1046private:
1047 /// Create a copy of this instruction.
1048 Instruction *cloneImpl() const;
1049};
1050
1052 V->deleteValue();
1053}
1054
1055} // end namespace llvm
1056
1057#endif // LLVM_IR_INSTRUCTION_H
aarch64 promote const
Atomic ordering constants.
basic Basic Alias true
This file implements methods to test, set and extract typed bits from packed unsigned integers.
BlockVerifier::State From
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
#define LLVM_READONLY
Definition: Compiler.h:227
static bool hasNoInfs(const TargetOptions &Options, SDValue N)
static StringRef getOpcodeName(uint8_t Opcode, uint8_t OpcodeBase)
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
std::optional< std::vector< StOtherPiece > > Other
Definition: ELFYAML.cpp:1293
uint64_t Offset
Definition: ELF_riscv.cpp:478
static Function * getFunction(Constant *C)
Definition: Evaluator.cpp:236
static bool hasNoSignedWrap(BinaryOperator &I)
static bool hasNoUnsignedWrap(BinaryOperator &I)
static MemAccessTy getAccessType(const TargetTransformInfo &TTI, Instruction *Inst, Value *OperandVal)
Return the type of the memory being accessed.
#define I(x, y, z)
Definition: MD5.cpp:58
Machine Check Debug Module
static bool mayHaveSideEffects(MachineInstr &MI)
static bool isCommutative(Instruction *I)
static unsigned getFastMathFlags(const MachineInstr &I)
static std::optional< unsigned > getOpcode(ArrayRef< VPValue * > Values)
Returns the opcode of Values or ~0 if they do not all agree.
Definition: VPlanSLP.cpp:191
static bool isAssociative(const COFFSection &Section)
BinaryOperator * Mul
Annotations lets you mark points and ranges inside source code, for tests:
Definition: Annotations.h:53
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
LLVM Basic Block Representation.
Definition: BasicBlock.h:61
A parsed version of the target data layout string in and methods for querying it.
Definition: DataLayout.h:110
Per-instruction record of debug-info.
Base class for non-instruction debug metadata records that have positions within IR.
A debug info location.
Definition: DebugLoc.h:33
MDNode * getAsMDNode() const
Return this as a bar MDNode.
Definition: DebugLoc.h:106
bool isValid() const
Definition: Instruction.h:61
InsertPosition(InstListType::iterator InsertAt)
Definition: Instruction.h:59
BasicBlock * getBasicBlock()
Definition: Instruction.h:62
InsertPosition(std::nullptr_t)
Definition: Instruction.h:54
BitfieldElement::Type getSubclassData() const
Definition: Instruction.h:1024
bool hasMetadata(unsigned KindID) const
Return true if this instruction has the given type of metadata attached.
Definition: Instruction.h:370
static bool isBinaryOp(unsigned Opcode)
Definition: Instruction.h:299
bool isArithmeticShift() const
Return true if this is an arithmetic shift right.
Definition: Instruction.h:318
bool hasMetadata(StringRef Kind) const
Return true if this instruction has the given type of metadata attached.
Definition: Instruction.h:375
bool isCast() const
Definition: Instruction.h:282
static bool isBitwiseLogicOp(unsigned Opcode)
Determine if the Opcode is and/or/xor.
Definition: Instruction.h:323
static bool isShift(unsigned Opcode)
Determine if the Opcode is one of the shift instructions.
Definition: Instruction.h:308
Function * getFunction()
Definition: Instruction.h:188
static bool isSpecialTerminator(unsigned Opcode)
Returns true if the Opcode is a "special" terminator that does more than branch to a successor (e....
Definition: Instruction.h:344
typename Bitfield::Element< AtomicOrdering, Offset, 3, AtomicOrdering::LAST > AtomicOrderingBitfieldElementT
Definition: Instruction.h:153
iterator_range< simple_ilist< DbgRecord >::iterator > getDbgRecordRange() const
Return a range over the DbgRecords attached to this instruction.
Definition: Instruction.h:104
static bool isCast(unsigned Opcode)
Determine if the Opcode is one of the CastInst instructions.
Definition: Instruction.h:333
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
Definition: Instruction.h:476
Instruction & operator=(const Instruction &)=delete
bool hasMetadataOtherThanDebugLoc() const
Return true if this instruction has metadata attached to it other than a debug location.
Definition: Instruction.h:367
typename Bitfield::Element< bool, Offset, 1 > BoolBitfieldElementT
Definition: Instruction.h:148
bool hasMetadata() const
Return true if this instruction has any metadata attached to it.
Definition: Instruction.h:363
Module * getModule()
Definition: Instruction.h:178
bool isBinaryOp() const
Definition: Instruction.h:279
Instruction * user_back()
Specialize the methods defined in Value, as we know that an instruction can only be used by other ins...
Definition: Instruction.h:169
static bool isIdempotent(unsigned Opcode)
Definition: Instruction.h:739
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this Instruction.
Definition: Instruction.h:381
bool isFuncletPad() const
Definition: Instruction.h:283
bool isTerminator() const
Definition: Instruction.h:277
typename Bitfield::Element< unsigned, Offset, 6, Value::MaxAlignmentExponent > AlignmentBitfieldElementT
Definition: Instruction.h:145
void dropUnknownNonDebugMetadata(unsigned ID1, unsigned ID2)
Definition: Instruction.h:443
Instruction * getPrevNonDebugInstruction(bool SkipPseudoOp=false)
Definition: Instruction.h:873
bool isNilpotent() const
Return true if the instruction is nilpotent:
Definition: Instruction.h:752
void dropPoisonGeneratingAnnotations()
Drops flags, return attributes and metadata that may generate poison.
Definition: Instruction.h:536
const char * getOpcodeName() const
Definition: Instruction.h:276
const Instruction * user_back() const
Definition: Instruction.h:170
OperationEquivalenceFlags
When checking for operation equivalence (using isSameOperationAs) it is sometimes useful to ignore ce...
Definition: Instruction.h:898
MDNode * getMetadata(StringRef Kind) const
Get the metadata of given kind attached to this Instruction.
Definition: Instruction.h:390
void getAllMetadata(SmallVectorImpl< std::pair< unsigned, MDNode * > > &MDs) const
Get all metadata attached to this Instruction.
Definition: Instruction.h:399
bool isLogicalShift() const
Return true if this is a logical shift left or a logical shift right.
Definition: Instruction.h:313
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:406
static bool isFuncletPad(unsigned Opcode)
Determine if the Opcode is one of the FuncletPadInst instructions.
Definition: Instruction.h:338
static bool isUnaryOp(unsigned Opcode)
Definition: Instruction.h:296
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
Definition: Instruction.h:274
static bool isNilpotent(unsigned Opcode)
Definition: Instruction.h:753
void dropUnknownNonDebugMetadata()
Definition: Instruction.h:437
bool isBitwiseLogicOp() const
Return true if this is and/or/xor.
Definition: Instruction.h:328
bool isShift() const
Definition: Instruction.h:281
static bool isTerminator(unsigned Opcode)
Definition: Instruction.h:292
bool isUnaryOp() const
Definition: Instruction.h:278
void dropUnknownNonDebugMetadata(unsigned ID1)
Definition: Instruction.h:440
Instruction(const Instruction &)=delete
void setDebugLoc(DebugLoc Loc)
Set the debug location information for this instruction.
Definition: Instruction.h:473
static bool isIntDivRem(unsigned Opcode)
Definition: Instruction.h:303
bool isIdempotent() const
Return true if the instruction is idempotent:
Definition: Instruction.h:738
bool isIntDivRem() const
Definition: Instruction.h:280
void setSubclassData(typename BitfieldElement::Type Value)
Definition: Instruction.h:1033
bool isSpecialTerminator() const
Definition: Instruction.h:284
Metadata node.
Definition: Metadata.h:1067
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: SmallVector.h:586
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1209
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
A Use represents the edge between a Value definition and its users.
Definition: Use.h:43
LLVM Value Representation.
Definition: Value.h:74
An efficient, type-erasing, non-owning reference to a callable.
An ilist node that can access its parent list.
Definition: ilist_node.h:321
base_list_type::iterator iterator
Definition: ilist.h:121
A range adaptor for a pair of iterators.
typename ilist_select_iterator_type< OptionsT::has_iterator_bits, OptionsT, false, false >::type iterator
Definition: simple_ilist.h:97
This file defines the ilist_node class template, which is a convenient base class for creating classe...
@ BasicBlock
Various leaf nodes.
Definition: ISDOpcodes.h:71
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
bool extractProfTotalWeight(const MDNode *ProfileData, uint64_t &TotalWeights)
Retrieve the total of all weights from MD_prof data.
iterator_range< simple_ilist< DbgRecord >::iterator > getDbgRecordRange(DbgMarker *DebugMarker)
Inline helper to return a range of DbgRecords attached to a marker.
AtomicOrdering
Atomic ordering for LLVM's memory model.
@ Or
Bitwise or logical OR of integers.
@ Xor
Bitwise or logical XOR of integers.
@ FMul
Product of floats.
@ And
Bitwise or logical AND of integers.
@ FAdd
Sum of floats.
Implement std::hash so that hash_code can be used in STL containers.
Definition: BitVector.h:858
#define N
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
Definition: Metadata.h:760
Describes an element of a Bitfield.
Definition: Bitfields.h:223
Use delete by default for iplist and ilist.
Definition: ilist.h:41
static void deleteNode(NodeTy *V)
Definition: ilist.h:42
Option to add a pointer to this list's owner in every node.