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
This commit is contained in:
Jay Foad 2011-06-20 14:12:33 +00:00
parent 689c24768b
commit 691c05bb29
3 changed files with 9 additions and 20 deletions

View File

@ -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

View File

@ -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;
}

View File

@ -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);
}