summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilip Reames <listmail@philipreames.com>2015-12-23 01:42:15 +0000
committerPhilip Reames <listmail@philipreames.com>2015-12-23 01:42:15 +0000
commitee8f0553273549b3ce6b6656a50beab3446300df (patch)
treed2f23bdbb207b6e6e81e61d8d4b406dcf7c7dbe9
parent7300afa36a60766834d9431a16896768d1d18305 (diff)
downloadbcm5719-llvm-ee8f0553273549b3ce6b6656a50beab3446300df.tar.gz
bcm5719-llvm-ee8f0553273549b3ce6b6656a50beab3446300df.zip
[GC] Make GCStrategy::isGCManagedPointer a type predicate not a value predicate [NFC]
Reasons: 1) The existing form was a form of false generality. None of the implemented GCStrategies use anything other than a type. Its becoming more and more clear we're going to need some type of strong GC pointer in the type system and we shouldn't pretend otherwise at this point. 2) The API was awkward when applied to vectors-of-pointers. The old one could have been made to work, but calling isGCManagedPointer(Ty->getScalarType()) is much cleaner than the Value alternatives. 3) The rewriting implementation effectively assumes the type based predicate as well. We should be consistent. llvm-svn: 256312
-rw-r--r--llvm/include/llvm/CodeGen/GCStrategy.h4
-rw-r--r--llvm/lib/CodeGen/CoreCLRGC.cpp4
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp6
-rw-r--r--llvm/lib/CodeGen/StatepointExampleGC.cpp4
-rw-r--r--llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp2
5 files changed, 10 insertions, 10 deletions
diff --git a/llvm/include/llvm/CodeGen/GCStrategy.h b/llvm/include/llvm/CodeGen/GCStrategy.h
index a1b8e895898..3088a86a326 100644
--- a/llvm/include/llvm/CodeGen/GCStrategy.h
+++ b/llvm/include/llvm/CodeGen/GCStrategy.h
@@ -117,11 +117,11 @@ public:
/** @name Statepoint Specific Properties */
///@{
- /// If the value specified can be reliably distinguished, returns true for
+ /// If the type specified can be reliably distinguished, returns true for
/// pointers to GC managed locations and false for pointers to non-GC
/// managed locations. Note a GCStrategy can always return 'None' (i.e. an
/// empty optional indicating it can't reliably distinguish.
- virtual Optional<bool> isGCManagedPointer(const Value *V) const {
+ virtual Optional<bool> isGCManagedPointer(const Type *Ty) const {
return None;
}
///@}
diff --git a/llvm/lib/CodeGen/CoreCLRGC.cpp b/llvm/lib/CodeGen/CoreCLRGC.cpp
index 28c97ba71bd..ff7c0d5dc0a 100644
--- a/llvm/lib/CodeGen/CoreCLRGC.cpp
+++ b/llvm/lib/CodeGen/CoreCLRGC.cpp
@@ -38,9 +38,9 @@ public:
UsesMetadata = false;
CustomRoots = false;
}
- Optional<bool> isGCManagedPointer(const Value *V) const override {
+ Optional<bool> isGCManagedPointer(const Type *Ty) const override {
// Method is only valid on pointer typed values.
- PointerType *PT = cast<PointerType>(V->getType());
+ const PointerType *PT = cast<PointerType>(Ty);
// We pick addrspace(1) as our GC managed heap.
return (1 == PT->getAddressSpace());
}
diff --git a/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
index a74d15371ca..87373154c87 100644
--- a/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
@@ -509,21 +509,21 @@ static void lowerStatepointMetaArgs(SmallVectorImpl<SDValue> &Ops,
// to the GCStrategy from there (yet).
GCStrategy &S = Builder.GFI->getStrategy();
for (const Value *V : Bases) {
- auto Opt = S.isGCManagedPointer(V);
+ auto Opt = S.isGCManagedPointer(V->getType());
if (Opt.hasValue()) {
assert(Opt.getValue() &&
"non gc managed base pointer found in statepoint");
}
}
for (const Value *V : Ptrs) {
- auto Opt = S.isGCManagedPointer(V);
+ auto Opt = S.isGCManagedPointer(V->getType());
if (Opt.hasValue()) {
assert(Opt.getValue() &&
"non gc managed derived pointer found in statepoint");
}
}
for (const Value *V : Relocations) {
- auto Opt = S.isGCManagedPointer(V);
+ auto Opt = S.isGCManagedPointer(V->getType());
if (Opt.hasValue()) {
assert(Opt.getValue() && "non gc managed pointer relocated");
}
diff --git a/llvm/lib/CodeGen/StatepointExampleGC.cpp b/llvm/lib/CodeGen/StatepointExampleGC.cpp
index 95dfd75018c..3f60e18fafa 100644
--- a/llvm/lib/CodeGen/StatepointExampleGC.cpp
+++ b/llvm/lib/CodeGen/StatepointExampleGC.cpp
@@ -34,9 +34,9 @@ public:
UsesMetadata = false;
CustomRoots = false;
}
- Optional<bool> isGCManagedPointer(const Value *V) const override {
+ Optional<bool> isGCManagedPointer(const Type *Ty) const override {
// Method is only valid on pointer typed values.
- PointerType *PT = cast<PointerType>(V->getType());
+ const PointerType *PT = cast<PointerType>(Ty);
// For the sake of this example GC, we arbitrarily pick addrspace(1) as our
// GC managed heap. We know that a pointer into this heap needs to be
// updated and that no other pointer does. Note that addrspace(1) is used
diff --git a/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp b/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
index 062fba5cdad..0a61d4b5da0 100644
--- a/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
+++ b/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
@@ -215,7 +215,7 @@ static void findLiveSetAtInst(Instruction *inst, GCPtrLivenessData &Data,
StatepointLiveSetTy &out);
// TODO: Once we can get to the GCStrategy, this becomes
-// Optional<bool> isGCManagedPointer(const Value *V) const override {
+// Optional<bool> isGCManagedPointer(const Type *Ty) const override {
static bool isGCPointerType(Type *T) {
if (auto *PT = dyn_cast<PointerType>(T))
OpenPOWER on IntegriCloud