29 "Cannot call User::replaceUsesOfWith on a constant!");
31 for (
unsigned i = 0,
E = getNumOperands(); i !=
E; ++i)
32 if (getOperand(i) == From) {
41 DVI->replaceVariableLocationOp(From, To);
54 assert(HasHungOffUses &&
"alloc must have hung off uses");
57 "Alignment is insufficient for 'hung-off-uses' pieces");
63 Use *Begin =
static_cast<Use*
>(::operator
new(
size));
65 setOperandList(Begin);
66 for (; Begin != End; Begin++)
67 new (Begin)
Use(
this);
71 assert(HasHungOffUses &&
"realloc must have hung off uses");
73 unsigned OldNumUses = getNumOperands();
77 assert(NewNumUses > OldNumUses &&
"realloc must grow num uses");
79 Use *OldOps = getOperandList();
80 allocHungoffUses(NewNumUses, IsPhi);
81 Use *NewOps = getOperandList();
84 std::copy(OldOps, OldOps + OldNumUses, NewOps);
88 auto *OldPtr =
reinterpret_cast<char *
>(OldOps + OldNumUses);
89 auto *NewPtr =
reinterpret_cast<char *
>(NewOps + NewNumUses);
90 std::copy(OldPtr, OldPtr + (OldNumUses *
sizeof(
BasicBlock *)), NewPtr);
92 Use::zap(OldOps, OldOps + OldNumUses,
true);
103 auto MutableARef =
const_cast<User *
>(
this)->getDescriptor();
104 return {MutableARef.begin(), MutableARef.end()};
108 assert(HasDescriptor &&
"Don't call otherwise!");
109 assert(!HasHungOffUses &&
"Invariant!");
111 auto *DI =
reinterpret_cast<DescriptorInfo *
>(getIntrusiveOperands()) - 1;
112 assert(DI->SizeInBytes != 0 &&
"Should not have had a descriptor otherwise!");
115 reinterpret_cast<uint8_t *
>(DI) - DI->SizeInBytes, DI->SizeInBytes);
120 switch (
II->getIntrinsicID()) {
123 case Intrinsic::assume:
124 case Intrinsic::pseudoprobe:
125 case Intrinsic::experimental_noalias_scope_decl:
136void *User::allocateFixedOperandUser(
size_t Size,
unsigned Us,
137 unsigned DescBytes) {
138 assert(Us < (1u << NumUserOperandsBits) &&
"Too many operands");
140 static_assert(
sizeof(
DescriptorInfo) %
sizeof(
void *) == 0,
"Required below");
142 unsigned DescBytesToAllocate =
144 assert(DescBytesToAllocate %
sizeof(
void *) == 0 &&
145 "We need this to satisfy alignment constraints for Uses");
148 ::operator
new(
Size +
sizeof(
Use) * Us + DescBytesToAllocate));
149 Use *
Start =
reinterpret_cast<Use *
>(Storage + DescBytesToAllocate);
151 User *Obj =
reinterpret_cast<User *
>(End);
156 new (Start)
Use(Obj);
158 if (DescBytes != 0) {
159 auto *DescInfo =
reinterpret_cast<DescriptorInfo *
>(Storage + DescBytes);
166void *User::operator
new(
size_t Size, IntrusiveOperandsAllocMarker allocTrait) {
167 return allocateFixedOperandUser(
Size, allocTrait.NumOps, 0);
170void *User::operator
new(
size_t Size,
171 IntrusiveOperandsAndDescriptorAllocMarker allocTrait) {
172 return allocateFixedOperandUser(
Size, allocTrait.NumOps,
173 allocTrait.DescBytes);
176void *User::operator
new(
size_t Size, HungOffOperandsAllocMarker) {
178 void *Storage = ::operator
new(
Size +
sizeof(
Use *));
179 Use **HungOffOperandList =
static_cast<Use **
>(Storage);
180 User *Obj =
reinterpret_cast<User *
>(HungOffOperandList + 1);
184 *HungOffOperandList =
nullptr;
197 User *Obj =
static_cast<User *
>(Usr);
201 Use **HungOffOperandList =
static_cast<Use **
>(Usr) - 1;
205 ::operator
delete(HungOffOperandList);
211 uint8_t *Storage =
reinterpret_cast<uint8_t *
>(DI) - DI->SizeInBytes;
212 ::operator
delete(Storage);
217 ::operator
delete(Storage);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define LLVM_NO_SANITIZE_MEMORY_ATTRIBUTE
uint64_t IntrinsicInst * II
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
LLVM Basic Block Representation.
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
A Use represents the edge between a Value definition and its users.
static LLVM_ABI void zap(Use *Start, const Use *Stop, bool del=false)
Destroys Use operands when the number of operands of a User changes.
LLVM_ABI ArrayRef< const uint8_t > getDescriptor() const
Returns the descriptor co-allocated with this User instance.
LLVM_ABI void growHungoffUses(unsigned N, bool IsPhi=false)
Grow the number of hung off uses.
LLVM_ABI bool isDroppable() const
A droppable user is a user for which uses can be dropped without affecting correctness and should be ...
LLVM_ABI void allocHungoffUses(unsigned N, bool IsPhi=false)
Allocate the array of Uses, followed by a pointer (with bottom bit set) to the User.
LLVM_ABI bool replaceUsesOfWith(Value *From, Value *To)
Replace uses of one Value with another.
This is an optimization pass for GlobalISel generic memory operations.
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
auto dyn_cast_or_null(const Y &Val)
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.