diff --git a/include/llvm/Use.h b/include/llvm/Use.h index ccbdd7fcae1..1bdacb48f4d 100644 --- a/include/llvm/Use.h +++ b/include/llvm/Use.h @@ -60,6 +60,10 @@ public: /// 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 UserRef; + private: /// Copy ctor - do not implement Use(const Use &U); @@ -208,15 +212,6 @@ public: unsigned getOperandNo() const; }; -//===----------------------------------------------------------------------===// -// AugmentedUse layout struct -//===----------------------------------------------------------------------===// - -struct AugmentedUse : public Use { - PointerIntPair ref; - AugmentedUse(); // not implemented -}; - } // End llvm namespace #endif diff --git a/lib/VMCore/Use.cpp b/lib/VMCore/Use.cpp index 2258b8d985a..359a1517ab7 100644 --- a/lib/VMCore/Use.cpp +++ b/lib/VMCore/Use.cpp @@ -135,11 +135,9 @@ void Use::zap(Use *Start, const Use *Stop, bool del) { User *Use::getUser() const { const Use *End = getImpliedUser(); - const PointerIntPair& - ref(static_cast(End - 1)->ref); - User *She = ref.getPointer(); - return ref.getInt() - ? She + const UserRef *ref = reinterpret_cast(End); + return ref->getInt() + ? ref->getPointer() : (User*)End; } diff --git a/lib/VMCore/User.cpp b/lib/VMCore/User.cpp index 2f4587debb6..9601da7011e 100644 --- a/lib/VMCore/User.cpp +++ b/lib/VMCore/User.cpp @@ -41,13 +41,9 @@ void User::replaceUsesOfWith(Value *From, Value *To) { Use *User::allocHungoffUses(unsigned N) const { Use *Begin = static_cast(::operator new(sizeof(Use) * N - + sizeof(AugmentedUse) - - sizeof(Use))); + + sizeof(Use::UserRef))); Use *End = Begin + N; - PointerIntPair& - ref(static_cast(End[-1]).ref); - ref.setPointer(const_cast(this)); - ref.setInt(1); + (void) new(End) Use::UserRef(const_cast(this), 1); return Use::initTags(Begin, End); }