22 void User::anchor() {}
25 if (From == To)
return;
27 assert((!isa<Constant>(
this) || isa<GlobalValue>(
this)) &&
28 "Cannot call User::replaceUsesOfWith on a constant!");
47 "Alignment is insufficient for 'hung-off-uses' pieces");
49 "Alignment is insufficient for 'hung-off-uses' pieces");
56 Use *Begin =
static_cast<Use*
>(::operator
new(size));
58 (void)
new(End)
Use::UserRef(const_cast<User*>(
this), 1);
69 assert(NewNumUses > OldNumUses &&
"realloc must grow num uses");
76 std::copy(OldOps, OldOps + OldNumUses, NewOps);
81 reinterpret_cast<char *
>(OldOps + OldNumUses) +
sizeof(
Use::UserRef);
83 reinterpret_cast<char *
>(NewOps + NewNumUses) +
sizeof(
Use::UserRef);
84 std::copy(OldPtr, OldPtr + (OldNumUses *
sizeof(
BasicBlock *)), NewPtr);
86 Use::zap(OldOps, OldOps + OldNumUses,
true);
98 return {MutableARef.begin(), MutableARef.end()};
105 auto *DI =
reinterpret_cast<DescriptorInfo *
>(getIntrusiveOperands()) - 1;
106 assert(DI->SizeInBytes != 0 &&
"Should not have had a descriptor otherwise!");
109 reinterpret_cast<uint8_t *
>(DI) - DI->SizeInBytes, DI->SizeInBytes);
116 void *User::allocateFixedOperandUser(
size_t Size,
unsigned Us,
117 unsigned DescBytes) {
120 static_assert(
sizeof(
DescriptorInfo) %
sizeof(
void *) == 0,
"Required below");
122 unsigned DescBytesToAllocate =
124 assert(DescBytesToAllocate %
sizeof(
void *) == 0 &&
125 "We need this to satisfy alignment constraints for Uses");
127 uint8_t *Storage =
static_cast<uint8_t *
>(
128 ::operator
new(Size +
sizeof(
Use) * Us + DescBytesToAllocate));
129 Use *Start =
reinterpret_cast<Use *
>(Storage + DescBytesToAllocate);
137 if (DescBytes != 0) {
138 auto *DescInfo =
reinterpret_cast<DescriptorInfo *
>(Storage + DescBytes);
145 void *User::operator
new(
size_t Size,
unsigned Us) {
146 return allocateFixedOperandUser(Size, Us, 0);
149 void *User::operator
new(
size_t Size,
unsigned Us,
unsigned DescBytes) {
150 return allocateFixedOperandUser(Size, Us, DescBytes);
153 void *User::operator
new(
size_t Size) {
155 void *Storage = ::operator
new(Size +
sizeof(
Use *));
156 Use **HungOffOperandList =
static_cast<Use **
>(Storage);
157 User *Obj =
reinterpret_cast<User *
>(HungOffOperandList + 1);
161 *HungOffOperandList =
nullptr;
169 void User::operator
delete(
void *Usr) {
172 User *Obj =
static_cast<User *
>(Usr);
176 Use **HungOffOperandList =
static_cast<Use **
>(Usr) - 1;
180 ::operator
delete(HungOffOperandList);
186 uint8_t *Storage =
reinterpret_cast<uint8_t *
>(DI) - DI->SizeInBytes;
187 ::
operator delete(Storage);
192 ::operator
delete(Storage);
unsigned getNumOperands() const
A Use represents the edge between a Value definition and its users.
void growHungoffUses(unsigned N, bool IsPhi=false)
Grow the number of hung off uses.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
void replaceUsesOfWith(Value *From, Value *To)
Replace uses of one Value with another.
LLVM Basic Block Representation.
PointerIntPair - This class implements a pair of a pointer and small integer.
static Use * initTags(Use *Start, Use *Stop)
Initializes the waymarking tags on an array of Uses.
static const unsigned End
Value * getOperand(unsigned i) const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
PointerIntPair< User *, 1, unsigned > UserRef
void setOperand(unsigned i, Value *Val)
ArrayRef< const uint8_t > getDescriptor() const
Returns the descriptor co-allocated with this User instance.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
void allocHungoffUses(unsigned N, bool IsPhi=false)
Allocate the array of Uses, followed by a pointer (with bottom bit set) to the User.
static void zap(Use *Start, const Use *Stop, bool del=false)
Destroys Use operands when the number of operands of a User changes.