Simplify User::operator delete().

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124330 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Jay Foad 2011-01-26 21:56:10 +00:00
parent 1fe3aa15e9
commit adede0387b
2 changed files with 4 additions and 10 deletions

View File

@ -53,6 +53,7 @@ protected:
void dropHungoffUses() { void dropHungoffUses() {
Use::zap(OperandList, OperandList + NumOperands, true); Use::zap(OperandList, OperandList + NumOperands, true);
OperandList = 0; OperandList = 0;
// Reset NumOperands so User::operator delete() does the right thing.
NumOperands = 0; NumOperands = 0;
} }
public: public:

View File

@ -73,16 +73,9 @@ void *User::operator new(size_t s, unsigned Us) {
void User::operator delete(void *Usr) { void User::operator delete(void *Usr) {
User *Start = static_cast<User*>(Usr); User *Start = static_cast<User*>(Usr);
Use *Storage = static_cast<Use*>(Usr) - Start->NumOperands; Use *Storage = static_cast<Use*>(Usr) - Start->NumOperands;
// // If there were hung-off uses, they will have been freed already and
// look for a variadic User // NumOperands reset to 0, so here we just free the User itself.
if (Storage == Start->OperandList) { ::operator delete(Storage);
::operator delete(Storage);
return;
}
//
// in all other cases just delete the nullary User (covers hung-off
// uses also
::operator delete(Usr);
} }
} // End llvm namespace } // End llvm namespace