Skip to content

Commit 9430efa

Browse files
committed
[NFC] Restructure code to make it possible to insert other GCs
1 parent 0b05207 commit 9430efa

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

llvm/lib/IR/Value.cpp

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -781,25 +781,24 @@ bool Value::canBeFreed() const {
781781
return true;
782782

783783
const auto &GCName = F->getGC();
784-
const StringRef StatepointExampleName("statepoint-example");
785-
if (GCName != StatepointExampleName)
786-
return true;
787-
788-
auto *PT = cast<PointerType>(this->getType());
789-
if (PT->getAddressSpace() != 1)
790-
// For the sake of this example GC, we arbitrarily pick addrspace(1) as our
791-
// GC managed heap. This must match the same check in
792-
// RewriteStatepointsForGC (and probably needs better factored.)
793-
return true;
794-
795-
// It is cheaper to scan for a declaration than to scan for a use in this
796-
// function. Note that gc.statepoint is a type overloaded function so the
797-
// usual trick of requesting declaration of the intrinsic from the module
798-
// doesn't work.
799-
for (auto &Fn : *F->getParent())
800-
if (Fn.getIntrinsicID() == Intrinsic::experimental_gc_statepoint)
784+
if (GCName == "statepoint-example") {
785+
auto *PT = cast<PointerType>(this->getType());
786+
if (PT->getAddressSpace() != 1)
787+
// For the sake of this example GC, we arbitrarily pick addrspace(1) as
788+
// our GC managed heap. This must match the same check in
789+
// RewriteStatepointsForGC (and probably needs better factored.)
801790
return true;
802-
return false;
791+
792+
// It is cheaper to scan for a declaration than to scan for a use in this
793+
// function. Note that gc.statepoint is a type overloaded function so the
794+
// usual trick of requesting declaration of the intrinsic from the module
795+
// doesn't work.
796+
for (auto &Fn : *F->getParent())
797+
if (Fn.getIntrinsicID() == Intrinsic::experimental_gc_statepoint)
798+
return true;
799+
return false;
800+
}
801+
return true;
803802
}
804803

805804
uint64_t Value::getPointerDereferenceableBytes(const DataLayout &DL,

0 commit comments

Comments
 (0)