diff options
author | Jay Foad <jay.foad@gmail.com> | 2011-06-20 14:12:33 +0000 |
---|---|---|
committer | Jay Foad <jay.foad@gmail.com> | 2011-06-20 14:12:33 +0000 |
commit | 691c05bb29d3e2ec9c2ed6b1c082ce5d484b75da (patch) | |
tree | 5f6500ab6343f4316365cd6795fcd2044c9ba0f6 | |
parent | 689c24768bce1a3bf33b47559e9398525d11142d (diff) |
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().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133433 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/Use.h | 13 | ||||
-rw-r--r-- | lib/VMCore/Use.cpp | 8 | ||||
-rw-r--r-- | lib/VMCore/User.cpp | 8 |
3 files changed, 9 insertions, 20 deletions
diff --git a/include/llvm/Use.h b/include/llvm/Use.h index ccbdd7fcae..1bdacb48f4 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<User*, 1, unsigned> 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<User*, 1, unsigned> ref; - AugmentedUse(); // not implemented -}; - } // End llvm namespace #endif diff --git a/lib/VMCore/Use.cpp b/lib/VMCore/Use.cpp index 2258b8d985..359a1517ab 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<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; } diff --git a/lib/VMCore/User.cpp b/lib/VMCore/User.cpp index 2f4587debb..9601da7011 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<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); } |