Skip to content

Commit 683e91c

Browse files
committed
Apply review feedback
1 parent 9998ee3 commit 683e91c

File tree

2 files changed

+11
-31
lines changed

2 files changed

+11
-31
lines changed

llvm/include/llvm/IR/User.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,22 +56,22 @@ class User : public Value {
5656
/// Indicates this User has operands "hung off" in another allocation.
5757
struct HungOffOperandsAllocMarker {
5858
/// The number of operands for this User.
59-
const unsigned NumOps;
59+
unsigned NumOps;
6060
};
6161

6262
/// Indicates this User has operands co-allocated.
6363
struct IntrusiveOperandsAllocMarker {
6464
/// The number of operands for this User.
65-
const unsigned NumOps;
65+
unsigned NumOps;
6666
};
6767

68-
/// Indicates this User has operands and a descriptor co-allocated .
68+
/// Indicates this User has operands and a descriptor co-allocated.
6969
struct IntrusiveOperandsAndDescriptorAllocMarker {
7070
/// The number of operands for this User.
71-
const unsigned NumOps;
71+
unsigned NumOps;
7272
/// The number of bytes to allocate for the descriptor. Must be divisible by
7373
/// `sizeof(void *)`.
74-
const unsigned DescBytes;
74+
unsigned DescBytes;
7575
};
7676

7777
/// Information about how a User object was allocated, to be passed into the

llvm/lib/IR/User.cpp

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,13 @@ class BasicBlock;
2020

2121
bool User::replaceUsesOfWith(Value *From, Value *To) {
2222
bool Changed = false;
23-
if (From == To)
24-
return Changed; // Duh what?
23+
if (From == To) return Changed; // Duh what?
2524

2625
assert((!isa<Constant>(this) || isa<GlobalValue>(this)) &&
2726
"Cannot call User::replaceUsesOfWith on a constant!");
2827

2928
for (unsigned i = 0, E = getNumOperands(); i != E; ++i)
30-
if (getOperand(i) == From) { // Is This operand is pointing to oldval?
29+
if (getOperand(i) == From) { // Is This operand is pointing to oldval?
3130
// The side effects of this setOperand call include linking to
3231
// "To", adding "this" to the uses list of To, and
3332
// most importantly, removing "this" from the use list of "From".
@@ -58,7 +57,7 @@ void User::allocHungoffUses(unsigned N, bool IsPhi) {
5857
size_t size = N * sizeof(Use);
5958
if (IsPhi)
6059
size += N * sizeof(BasicBlock *);
61-
Use *Begin = static_cast<Use *>(::operator new(size));
60+
Use *Begin = static_cast<Use*>(::operator new(size));
6261
Use *End = Begin + N;
6362
setOperandList(Begin);
6463
for (; Begin != End; Begin++)
@@ -146,9 +145,6 @@ void *User::allocateFixedOperandUser(size_t Size, unsigned Us,
146145
Use *Start = reinterpret_cast<Use *>(Storage + DescBytesToAllocate);
147146
Use *End = Start + Us;
148147
User *Obj = reinterpret_cast<User *>(End);
149-
Obj->NumUserOperands = Us;
150-
Obj->HasHungOffUses = false;
151-
Obj->HasDescriptor = DescBytes != 0;
152148
for (; Start != End; Start++)
153149
new (Start) Use(Obj);
154150

@@ -175,9 +171,6 @@ void *User::operator new(size_t Size, HungOffOperandsAllocMarker) {
175171
void *Storage = ::operator new(Size + sizeof(Use *));
176172
Use **HungOffOperandList = static_cast<Use **>(Storage);
177173
User *Obj = reinterpret_cast<User *>(HungOffOperandList + 1);
178-
Obj->NumUserOperands = 0;
179-
Obj->HasHungOffUses = true;
180-
Obj->HasDescriptor = false;
181174
*HungOffOperandList = nullptr;
182175
return Obj;
183176
}
@@ -214,12 +207,7 @@ LLVM_NO_SANITIZE_MEMORY_ATTRIBUTE void User::operator delete(void *Usr) {
214207
// Repress memory sanitization, due to use-after-destroy by operator
215208
// delete. Bug report 24578 identifies this issue.
216209
LLVM_NO_SANITIZE_MEMORY_ATTRIBUTE void
217-
User::operator delete(void *Usr, const HungOffOperandsAllocMarker Marker) {
218-
// Note: If a subclass manipulates the information which is required to
219-
// calculate the Usr memory pointer, e.g. NumUserOperands, the operator
220-
// delete of that subclass has to restore the changed information to the
221-
// original value, since the dtor of that class is not called if the ctor
222-
// fails.
210+
User::operator delete(void *Usr, HungOffOperandsAllocMarker Marker) {
223211
Use **HungOffOperandList = static_cast<Use **>(Usr) - 1;
224212
// drop the hung off uses.
225213
Use::zap(*HungOffOperandList, *HungOffOperandList + Marker.NumOps,
@@ -230,11 +218,7 @@ User::operator delete(void *Usr, const HungOffOperandsAllocMarker Marker) {
230218
// Repress memory sanitization, due to use-after-destroy by operator
231219
// delete. Bug report 24578 identifies this issue.
232220
LLVM_NO_SANITIZE_MEMORY_ATTRIBUTE void
233-
User::operator delete(void *Usr, const IntrusiveOperandsAllocMarker Marker) {
234-
// Note: If a subclass manipulates the information which is required to
235-
// calculate the Usr memory pointer, e.g. NumUserOperands, the operator delete
236-
// of that subclass has to restore the changed information to the original
237-
// value, since the dtor of that class is not called if the ctor fails.
221+
User::operator delete(void *Usr, IntrusiveOperandsAllocMarker Marker) {
238222
Use *Storage = static_cast<Use *>(Usr) - Marker.NumOps;
239223
Use::zap(Storage, Storage + Marker.NumOps, /* Delete */ false);
240224
::operator delete(Storage);
@@ -244,11 +228,7 @@ User::operator delete(void *Usr, const IntrusiveOperandsAllocMarker Marker) {
244228
// delete. Bug report 24578 identifies this issue.
245229
LLVM_NO_SANITIZE_MEMORY_ATTRIBUTE void
246230
User::operator delete(void *Usr,
247-
const IntrusiveOperandsAndDescriptorAllocMarker Marker) {
248-
// Note: If a subclass manipulates the information which is required to
249-
// calculate the Usr memory pointer, e.g. NumUserOperands, the operator delete
250-
// of that subclass has to restore the changed information to the original
251-
// value, since the dtor of that class is not called if the ctor fails.
231+
IntrusiveOperandsAndDescriptorAllocMarker Marker) {
252232
Use *UseBegin = static_cast<Use *>(Usr) - Marker.NumOps;
253233
Use::zap(UseBegin, UseBegin + Marker.NumOps, /* Delete */ false);
254234

0 commit comments

Comments
 (0)