[llvm-commits] [llvm] r51136 - in /llvm/trunk: include/llvm/User.h lib/VMCore/Value.cpp
Nate Begeman
natebegeman at mac.com
Wed May 14 18:23:11 PDT 2008
Author: sampo
Date: Wed May 14 20:23:11 2008
New Revision: 51136
URL: http://llvm.org/viewvc/llvm-project?rev=51136&view=rev
Log:
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.
Modified:
llvm/trunk/include/llvm/User.h
llvm/trunk/lib/VMCore/Value.cpp
Modified: llvm/trunk/include/llvm/User.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/User.h?rev=51136&r1=51135&r2=51136&view=diff
==============================================================================
--- llvm/trunk/include/llvm/User.h (original)
+++ llvm/trunk/include/llvm/User.h Wed May 14 20:23:11 2008
@@ -227,16 +227,7 @@
///
unsigned NumOperands;
- 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;
- }
+ void *operator new(size_t s, unsigned Us);
User(const Type *Ty, unsigned vty, Use *OpList, unsigned NumOps)
: Value(Ty, vty), OperandList(OpList), NumOperands(NumOps) {}
Use *allocHungoffUses(unsigned) const;
@@ -251,13 +242,7 @@
~User() {
Use::zap(OperandList, OperandList + NumOperands);
}
- 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);
- }
+ void operator delete(void *Usr);
template <unsigned Idx> Use &Op() {
return OperandTraits<User>::op_begin(this)[Idx];
}
Modified: llvm/trunk/lib/VMCore/Value.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Value.cpp?rev=51136&r1=51135&r2=51136&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Value.cpp (original)
+++ llvm/trunk/lib/VMCore/Value.cpp Wed May 14 20:23:11 2008
@@ -355,3 +355,22 @@
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);
+}
More information about the llvm-commits
mailing list