diff options
author | Gabor Greif <ggreif@gmail.com> | 2009-01-05 16:05:32 +0000 |
---|---|---|
committer | Gabor Greif <ggreif@gmail.com> | 2009-01-05 16:05:32 +0000 |
commit | fd095b6389ec7c794e094f2a5dc8851bdc108999 (patch) | |
tree | b8dfad42f12dc67a6b69332c4c026b3cdb2a8ea1 /lib/VMCore/Use.cpp | |
parent | 4050a2324ce3c5e292ca8e2e025971766017f0e4 (diff) | |
download | llvm-fd095b6389ec7c794e094f2a5dc8851bdc108999.tar.gz llvm-fd095b6389ec7c794e094f2a5dc8851bdc108999.tar.bz2 llvm-fd095b6389ec7c794e094f2a5dc8851bdc108999.tar.xz |
Get rid of the tagging functions and use PointerIntPair.
This means that we have to include an additional header.
This patch should be functionally equivalent. I cannot outrule any performance
degradation, though I do not expect any.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61694 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Use.cpp')
-rw-r--r-- | lib/VMCore/Use.cpp | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/lib/VMCore/Use.cpp b/lib/VMCore/Use.cpp index 5eadaadbb3..da21eba132 100644 --- a/lib/VMCore/Use.cpp +++ b/lib/VMCore/Use.cpp @@ -52,7 +52,7 @@ const Use *Use::getImpliedUser() const { const Use *Current = this; while (true) { - unsigned Tag = extractTag<PrevPtrTag, fullStopTag>((Current++)->Prev); + unsigned Tag = (Current++)->Prev.getInt(); switch (Tag) { case zeroDigitTag: case oneDigitTag: @@ -62,7 +62,7 @@ const Use *Use::getImpliedUser() const { ++Current; ptrdiff_t Offset = 1; while (true) { - unsigned Tag = extractTag<PrevPtrTag, fullStopTag>(Current->Prev); + unsigned Tag = Current->Prev.getInt(); switch (Tag) { case zeroDigitTag: case oneDigitTag: @@ -91,11 +91,11 @@ Use *Use::initTags(Use * const Start, Use *Stop, ptrdiff_t Done) { --Stop; Stop->Val = 0; if (!Count) { - Stop->Prev = reinterpret_cast<Use**>(Done == 0 ? fullStopTag : stopTag); + Stop->Prev.setFromOpaqueValue(reinterpret_cast<Use**>(Done == 0 ? fullStopTag : stopTag)); ++Done; Count = Done; } else { - Stop->Prev = reinterpret_cast<Use**>(Count & 1); + Stop->Prev.setFromOpaqueValue(reinterpret_cast<Use**>(Count & 1)); Count >>= 1; ++Done; } @@ -127,7 +127,7 @@ void Use::zap(Use *Start, const Use *Stop, bool del) { //===----------------------------------------------------------------------===// struct AugmentedUse : Use { - volatile User *ref; + PointerIntPair<User*, 1, Tag> ref; AugmentedUse(); // not implemented }; @@ -138,10 +138,11 @@ struct AugmentedUse : Use { User *Use::getUser() const { const Use *End = getImpliedUser(); - volatile User *She = static_cast<const AugmentedUse*>(End - 1)->ref; - return extractTag<Tag, tagOne>(She) - ? llvm::stripTag<tagOne>(She) - : reinterpret_cast<User*>(const_cast<Use*>(End)); + PointerIntPair<User*, 1, Tag>& ref(static_cast<const AugmentedUse*>(End - 1)->ref); + User *She = ref.getPointer(); + return ref.getInt() + ? She + : (User*)End; } //===----------------------------------------------------------------------===// @@ -153,7 +154,9 @@ Use *User::allocHungoffUses(unsigned N) const { + sizeof(AugmentedUse) - sizeof(Use))); Use *End = Begin + N; - static_cast<AugmentedUse&>(End[-1]).ref = addTag(this, tagOne); + PointerIntPair<User*, 1, Tag>& ref(static_cast<AugmentedUse&>(End[-1]).ref); + ref.setPointer(const_cast<User*>(this)); + ref.setInt(tagOne); return Use::initTags(Begin, End); } |