mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-12 17:32:19 +00:00
Move the operator new and operator delete out of line. This fixes an issue with
operator new() referring to the static initTags function, which has to be in the same linkage unit as any file including User.h. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51136 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
386f3e9d50
commit
ff155f03bd
@ -227,16 +227,7 @@ protected:
|
|||||||
///
|
///
|
||||||
unsigned NumOperands;
|
unsigned NumOperands;
|
||||||
|
|
||||||
void *operator new(size_t s, unsigned Us) {
|
void *operator new(size_t s, unsigned Us);
|
||||||
void *Storage = ::operator new(s + sizeof(Use) * Us);
|
|
||||||
Use *Start = static_cast<Use*>(Storage);
|
|
||||||
Use *End = Start + Us;
|
|
||||||
User *Obj = reinterpret_cast<User*>(End);
|
|
||||||
Obj->OperandList = Start;
|
|
||||||
Obj->NumOperands = Us;
|
|
||||||
Use::initTags(Start, End);
|
|
||||||
return Obj;
|
|
||||||
}
|
|
||||||
User(const Type *Ty, unsigned vty, Use *OpList, unsigned NumOps)
|
User(const Type *Ty, unsigned vty, Use *OpList, unsigned NumOps)
|
||||||
: Value(Ty, vty), OperandList(OpList), NumOperands(NumOps) {}
|
: Value(Ty, vty), OperandList(OpList), NumOperands(NumOps) {}
|
||||||
Use *allocHungoffUses(unsigned) const;
|
Use *allocHungoffUses(unsigned) const;
|
||||||
@ -251,13 +242,7 @@ public:
|
|||||||
~User() {
|
~User() {
|
||||||
Use::zap(OperandList, OperandList + NumOperands);
|
Use::zap(OperandList, OperandList + NumOperands);
|
||||||
}
|
}
|
||||||
void operator delete(void *Usr) {
|
void operator delete(void *Usr);
|
||||||
User *Start = static_cast<User*>(Usr);
|
|
||||||
Use *Storage = static_cast<Use*>(Usr) - Start->NumOperands;
|
|
||||||
::operator delete(Storage == Start->OperandList
|
|
||||||
? Storage
|
|
||||||
: Usr);
|
|
||||||
}
|
|
||||||
template <unsigned Idx> Use &Op() {
|
template <unsigned Idx> Use &Op() {
|
||||||
return OperandTraits<User>::op_begin(this)[Idx];
|
return OperandTraits<User>::op_begin(this)[Idx];
|
||||||
}
|
}
|
||||||
|
@ -355,3 +355,22 @@ void User::replaceUsesOfWith(Value *From, Value *To) {
|
|||||||
setOperand(i, To); // Fix it now...
|
setOperand(i, To); // Fix it now...
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void *User::operator new(size_t s, unsigned Us) {
|
||||||
|
void *Storage = ::operator new(s + sizeof(Use) * Us);
|
||||||
|
Use *Start = static_cast<Use*>(Storage);
|
||||||
|
Use *End = Start + Us;
|
||||||
|
User *Obj = reinterpret_cast<User*>(End);
|
||||||
|
Obj->OperandList = Start;
|
||||||
|
Obj->NumOperands = Us;
|
||||||
|
Use::initTags(Start, End);
|
||||||
|
return Obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
void User::operator delete(void *Usr) {
|
||||||
|
User *Start = static_cast<User*>(Usr);
|
||||||
|
Use *Storage = static_cast<Use*>(Usr) - Start->NumOperands;
|
||||||
|
::operator delete(Storage == Start->OperandList
|
||||||
|
? Storage
|
||||||
|
: Usr);
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user