[llvm] 9430efa - [NFC] Restructure code to make it possible to insert other GCs

Max Kazantsev via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 20 00:25:00 PDT 2021


Author: Max Kazantsev
Date: 2021-04-20T14:24:38+07:00
New Revision: 9430efa18b02e7a3f453793e48c96d5c954ed751

URL: https://github.com/llvm/llvm-project/commit/9430efa18b02e7a3f453793e48c96d5c954ed751
DIFF: https://github.com/llvm/llvm-project/commit/9430efa18b02e7a3f453793e48c96d5c954ed751.diff

LOG: [NFC] Restructure code to make it possible to insert other GCs

Added: 
    

Modified: 
    llvm/lib/IR/Value.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/IR/Value.cpp b/llvm/lib/IR/Value.cpp
index e0b72dca3ed69..47a5be4e5d709 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,


        


More information about the llvm-commits mailing list