[llvm-commits] [llvm] r57641 - in /llvm/trunk: include/llvm/Use.h lib/VMCore/Use.cpp
Gabor Greif
ggreif at gmail.com
Thu Oct 16 08:33:05 PDT 2008
Author: ggreif
Date: Thu Oct 16 10:33:02 2008
New Revision: 57641
URL: http://llvm.org/viewvc/llvm-project?rev=57641&view=rev
Log:
Introduce a typing refinenement on tagged data
using the 'volatile' qualifier. This should not have any operational consequences
on code, because tags should always be stripped off (giving a non-volatile pointer)
before dereferencing. The new qualification is there to catch some attempts to use
tagged pointers in a context where an untagged pointer is appropriate.
Notably this approach does not catch dereferencing of tagged pointers, but helps
in separating the two concepts a bit.
Modified:
llvm/trunk/include/llvm/Use.h
llvm/trunk/lib/VMCore/Use.cpp
Modified: llvm/trunk/include/llvm/Use.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Use.h?rev=57641&r1=57640&r2=57641&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Use.h (original)
+++ llvm/trunk/include/llvm/Use.h Thu Oct 16 10:33:02 2008
@@ -34,27 +34,27 @@
/// addTag - insert tag bits into an (untagged) pointer
template <typename T, typename TAG>
-inline T *addTag(const T *P, TAG Tag) {
+inline volatile T *addTag(const T *P, TAG Tag) {
return reinterpret_cast<T*>(ptrdiff_t(P) | Tag);
}
/// stripTag - remove tag bits from a pointer,
/// making it dereferencable
template <ptrdiff_t MASK, typename T>
-inline T *stripTag(const T *P) {
+inline T *stripTag(const volatile T *P) {
return reinterpret_cast<T*>(ptrdiff_t(P) & ~MASK);
}
/// extractTag - extract tag bits from a pointer
template <typename TAG, TAG MASK, typename T>
-inline TAG extractTag(const T *P) {
+inline TAG extractTag(const volatile T *P) {
return TAG(ptrdiff_t(P) & MASK);
}
/// transferTag - transfer tag bits from a pointer,
/// to an untagged pointer
template <ptrdiff_t MASK, typename T>
-inline T *transferTag(const T *From, const T *To) {
+inline volatile T *transferTag(const volatile T *From, const T *To) {
return reinterpret_cast<T*>((ptrdiff_t(From) & MASK) | ptrdiff_t(To));
}
@@ -126,7 +126,7 @@
static Use *initTags(Use *Start, Use *Stop, ptrdiff_t Done = 0);
Value *Val;
- Use *Next, **Prev;
+ Use *Next, *volatile*Prev;
void setPrev(Use **NewPrev) {
Prev = transferTag<fullStopTag>(Prev, NewPrev);
Modified: llvm/trunk/lib/VMCore/Use.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Use.cpp?rev=57641&r1=57640&r2=57641&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Use.cpp (original)
+++ llvm/trunk/lib/VMCore/Use.cpp Thu Oct 16 10:33:02 2008
@@ -127,7 +127,7 @@
//===----------------------------------------------------------------------===//
struct AugmentedUse : Use {
- User *ref;
+ volatile User *ref;
AugmentedUse(); // not implemented
};
@@ -138,12 +138,10 @@
User *Use::getUser() const {
const Use *End = getImpliedUser();
- User *She = static_cast<const AugmentedUse*>(End - 1)->ref;
- She = extractTag<Tag, tagOne>(She)
+ 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));
-
- return She;
}
//===----------------------------------------------------------------------===//
More information about the llvm-commits
mailing list