[llvm-commits] [llvm] r133433 - in /llvm/trunk: include/llvm/Use.h lib/VMCore/Use.cpp lib/VMCore/User.cpp
Jay Foad
jay.foad at gmail.com
Mon Jun 20 07:12:33 PDT 2011
Author: foad
Date: Mon Jun 20 09:12:33 2011
New Revision: 133433
URL: http://llvm.org/viewvc/llvm-project?rev=133433&view=rev
Log:
Remove the AugmentedUse struct.
I don't think the AugmentedUse struct buys us much, either in
correctness or in ease of use. Ditch it, and simplify Use::getUser() and
User::allocHungoffUses().
Modified:
llvm/trunk/include/llvm/Use.h
llvm/trunk/lib/VMCore/Use.cpp
llvm/trunk/lib/VMCore/User.cpp
Modified: llvm/trunk/include/llvm/Use.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Use.h?rev=133433&r1=133432&r2=133433&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Use.h (original)
+++ llvm/trunk/include/llvm/Use.h Mon Jun 20 09:12:33 2011
@@ -60,6 +60,10 @@
/// that also works with less standard-compliant compilers
void swap(Use &RHS);
+ // A type for the word following an array of hung-off Uses in memory, which is
+ // a pointer back to their User with the bottom bit set.
+ typedef PointerIntPair<User*, 1, unsigned> UserRef;
+
private:
/// Copy ctor - do not implement
Use(const Use &U);
@@ -208,15 +212,6 @@
unsigned getOperandNo() const;
};
-//===----------------------------------------------------------------------===//
-// AugmentedUse layout struct
-//===----------------------------------------------------------------------===//
-
-struct AugmentedUse : public Use {
- PointerIntPair<User*, 1, unsigned> ref;
- AugmentedUse(); // not implemented
-};
-
} // End llvm namespace
#endif
Modified: llvm/trunk/lib/VMCore/Use.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Use.cpp?rev=133433&r1=133432&r2=133433&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Use.cpp (original)
+++ llvm/trunk/lib/VMCore/Use.cpp Mon Jun 20 09:12:33 2011
@@ -135,11 +135,9 @@
User *Use::getUser() const {
const Use *End = getImpliedUser();
- const PointerIntPair<User*, 1, unsigned>&
- ref(static_cast<const AugmentedUse*>(End - 1)->ref);
- User *She = ref.getPointer();
- return ref.getInt()
- ? She
+ const UserRef *ref = reinterpret_cast<const UserRef*>(End);
+ return ref->getInt()
+ ? ref->getPointer()
: (User*)End;
}
Modified: llvm/trunk/lib/VMCore/User.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/User.cpp?rev=133433&r1=133432&r2=133433&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/User.cpp (original)
+++ llvm/trunk/lib/VMCore/User.cpp Mon Jun 20 09:12:33 2011
@@ -41,13 +41,9 @@
Use *User::allocHungoffUses(unsigned N) const {
Use *Begin = static_cast<Use*>(::operator new(sizeof(Use) * N
- + sizeof(AugmentedUse)
- - sizeof(Use)));
+ + sizeof(Use::UserRef)));
Use *End = Begin + N;
- PointerIntPair<User*, 1, unsigned>&
- ref(static_cast<AugmentedUse&>(End[-1]).ref);
- ref.setPointer(const_cast<User*>(this));
- ref.setInt(1);
+ (void) new(End) Use::UserRef(const_cast<User*>(this), 1);
return Use::initTags(Begin, End);
}
More information about the llvm-commits
mailing list