From 9430efa18b02e7a3f453793e48c96d5c954ed751 Mon Sep 17 00:00:00 2001 From: Max Kazantsev Date: Tue, 20 Apr 2021 13:59:03 +0700 Subject: [PATCH] [NFC] Restructure code to make it possible to insert other GCs --- llvm/lib/IR/Value.cpp | 35 +++++++++++++++++------------------ 1 file 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(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(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, -- 2.7.4