23 if (From == To)
return;
25 assert((!isa<Constant>(
this) || isa<GlobalValue>(
this)) &&
26 "Cannot call User::replaceUsesOfWith on a constant!");
45 "Alignment is insufficient for 'hung-off-uses' pieces");
47 "Alignment is insufficient for 'hung-off-uses' pieces");
54 Use *Begin =
static_cast<Use*
>(::operator
new(size));
56 (void)
new(End)
Use::UserRef(const_cast<User*>(
this), 1);
67 assert(NewNumUses > OldNumUses &&
"realloc must grow num uses");
74 std::copy(OldOps, OldOps + OldNumUses, NewOps);
79 reinterpret_cast<char *
>(OldOps + OldNumUses) +
sizeof(
Use::UserRef);
81 reinterpret_cast<char *
>(NewOps + NewNumUses) +
sizeof(
Use::UserRef);
82 std::copy(OldPtr, OldPtr + (OldNumUses *
sizeof(
BasicBlock *)), NewPtr);
84 Use::zap(OldOps, OldOps + OldNumUses,
true);
96 return {MutableARef.begin(), MutableARef.end()};
103 auto *DI =
reinterpret_cast<DescriptorInfo *
>(getIntrusiveOperands()) - 1;
104 assert(DI->SizeInBytes != 0 &&
"Should not have had a descriptor otherwise!");
107 reinterpret_cast<uint8_t *
>(DI) - DI->SizeInBytes, DI->SizeInBytes);
114 void *User::allocateFixedOperandUser(
size_t Size,
unsigned Us,
115 unsigned DescBytes) {
118 static_assert(
sizeof(
DescriptorInfo) %
sizeof(
void *) == 0,
"Required below");
120 unsigned DescBytesToAllocate =
122 assert(DescBytesToAllocate %
sizeof(
void *) == 0 &&
123 "We need this to satisfy alignment constraints for Uses");
125 uint8_t *Storage =
static_cast<uint8_t *
>(
126 ::operator
new(Size +
sizeof(
Use) * Us + DescBytesToAllocate));
127 Use *Start =
reinterpret_cast<Use *
>(Storage + DescBytesToAllocate);
135 if (DescBytes != 0) {
136 auto *DescInfo =
reinterpret_cast<DescriptorInfo *
>(Storage + DescBytes);
143 void *User::operator
new(
size_t Size,
unsigned Us) {
144 return allocateFixedOperandUser(Size, Us, 0);
147 void *User::operator
new(
size_t Size,
unsigned Us,
unsigned DescBytes) {
148 return allocateFixedOperandUser(Size, Us, DescBytes);
151 void *User::operator
new(
size_t Size) {
153 void *Storage = ::operator
new(Size +
sizeof(
Use *));
154 Use **HungOffOperandList =
static_cast<Use **
>(Storage);
155 User *Obj =
reinterpret_cast<User *
>(HungOffOperandList + 1);
159 *HungOffOperandList =
nullptr;
167 void User::operator
delete(
void *Usr) {
170 User *Obj =
static_cast<User *
>(Usr);
174 Use **HungOffOperandList =
static_cast<Use **
>(Usr) - 1;
178 ::operator
delete(HungOffOperandList);
184 uint8_t *Storage =
reinterpret_cast<uint8_t *
>(DI) - DI->SizeInBytes;
185 ::
operator delete(Storage);
190 ::operator
delete(Storage);
unsigned getNumOperands() const
const Use * getOperandList() 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)...
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
void setOperand(unsigned i, Value *Val)
ArrayRef< const uint8_t > getDescriptor() const
Returns the descriptor co-allocated with this User instance.
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
PointerIntPair< User *, 1, unsigned, UserRefPointerTraits > UserRef
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.