[llvm-commits] [llvm] r49717 - /llvm/branches/ggreif/use-diet/include/llvm/User.h
Gabor Greif
ggreif at gmail.com
Tue Apr 15 02:17:50 PDT 2008
Author: ggreif
Date: Tue Apr 15 04:17:49 2008
New Revision: 49717
URL: http://llvm.org/viewvc/llvm-project?rev=49717&view=rev
Log:
prettify allocHungoffUses
Modified:
llvm/branches/ggreif/use-diet/include/llvm/User.h
Modified: llvm/branches/ggreif/use-diet/include/llvm/User.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/User.h?rev=49717&r1=49716&r2=49717&view=diff
==============================================================================
--- llvm/branches/ggreif/use-diet/include/llvm/User.h (original)
+++ llvm/branches/ggreif/use-diet/include/llvm/User.h Tue Apr 15 04:17:49 2008
@@ -245,9 +245,9 @@
void operator delete(void *Usr) {
User *Start = static_cast<User*>(Usr);
Use *Storage = static_cast<Use*>(Usr) - Start->NumOperands;
- if (Storage == Start->OperandList)
- ::operator delete(Storage);
- else ::operator delete(Usr);
+ ::operator delete(Storage == Start->OperandList
+ ? Storage
+ : Usr);
}
public:
template <unsigned Idx> Use &Op() {
@@ -320,10 +320,21 @@
return U->getNumOperands();
}
+enum Tag { noTag, tagOne, tagTwo, tagThree };
+
+template <typename T, typename TAG>
+inline T *addTag(T *P, TAG Tag) {
+ return reinterpret_cast<T*>(ptrdiff_t(P) | Tag);
+}
+
Use *User::allocHungoffUses(unsigned N) const {
- Use *Begin = static_cast<Use*>(::operator new(sizeof(Use) * N + sizeof this));
- Use *End = Begin + N;
- (*(User**)End) = (User*)(ptrdiff_t(this) | 1);
+ struct AugmentedUse : Use {
+ User *ref;
+ AugmentedUse(); // not implemented
+ };
+ Use *Begin = static_cast<Use*>(::operator new(sizeof(Use) * N + sizeof(AugmentedUse) - sizeof(Use)));
+ AugmentedUse *End = static_cast<AugmentedUse*>(Begin + N);
+ End->ref = (User*)(ptrdiff_t(this) | tagOne);
Use::initTags(Begin, End);
return Begin;
}
More information about the llvm-commits
mailing list