aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/Value.cpp
diff options
context:
space:
mode:
authorMax Kazantsev <mkazantsev@azul.com>2021-04-20 13:59:03 +0700
committerMax Kazantsev <mkazantsev@azul.com>2021-04-20 14:24:38 +0700
commit9430efa18b02e7a3f453793e48c96d5c954ed751 (patch)
tree4d9e516bae63d4f01d7c348153a927422157058a /llvm/lib/IR/Value.cpp
parent0b05207e45ef01899f5bdae5e35a1a93fa2f564f (diff)
downloadllvm-9430efa18b02e7a3f453793e48c96d5c954ed751.zip
llvm-9430efa18b02e7a3f453793e48c96d5c954ed751.tar.gz
llvm-9430efa18b02e7a3f453793e48c96d5c954ed751.tar.bz2
[NFC] Restructure code to make it possible to insert other GCs
Diffstat (limited to 'llvm/lib/IR/Value.cpp')
-rw-r--r--llvm/lib/IR/Value.cpp35
1 files changed, 17 insertions, 18 deletions
diff --git a/llvm/lib/IR/Value.cpp b/llvm/lib/IR/Value.cpp
index e0b72dc..47a5be4 100644
--- a/llvm/lib/IR/Value.cpp
+++ b/llvm/lib/IR/Value.cpp
@@ -781,25 +781,24 @@ bool Value::canBeFreed() const {
return true;
const auto &GCName = F->getGC();
- const StringRef StatepointExampleName("statepoint-example");
- if (GCName != StatepointExampleName)
- return true;
-
- auto *PT = cast<PointerType>(this->getType());
- if (PT->getAddressSpace() != 1)
- // For the sake of this example GC, we arbitrarily pick addrspace(1) as our
- // GC managed heap. This must match the same check in
- // RewriteStatepointsForGC (and probably needs better factored.)
- return true;
-
- // It is cheaper to scan for a declaration than to scan for a use in this
- // function. Note that gc.statepoint is a type overloaded function so the
- // usual trick of requesting declaration of the intrinsic from the module
- // doesn't work.
- for (auto &Fn : *F->getParent())
- if (Fn.getIntrinsicID() == Intrinsic::experimental_gc_statepoint)
+ if (GCName == "statepoint-example") {
+ auto *PT = cast<PointerType>(this->getType());
+ if (PT->getAddressSpace() != 1)
+ // For the sake of this example GC, we arbitrarily pick addrspace(1) as
+ // our GC managed heap. This must match the same check in
+ // RewriteStatepointsForGC (and probably needs better factored.)
return true;
- return false;
+
+ // It is cheaper to scan for a declaration than to scan for a use in this
+ // function. Note that gc.statepoint is a type overloaded function so the
+ // usual trick of requesting declaration of the intrinsic from the module
+ // doesn't work.
+ for (auto &Fn : *F->getParent())
+ if (Fn.getIntrinsicID() == Intrinsic::experimental_gc_statepoint)
+ return true;
+ return false;
+ }
+ return true;
}
uint64_t Value::getPointerDereferenceableBytes(const DataLayout &DL,