1 //===-- StatepointDefaultGC.cpp - The default statepoint GC strategy ------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file contains a GCStrategy which serves as an example for the usage
11 // of a statepoint based lowering strategy. This GCStrategy is intended to
12 // suitable as a default implementation usable with any collector which can
13 // consume the standard stackmap format generated by statepoints, uses the
14 // default addrespace to distinguish between gc managed and non-gc managed
15 // pointers, and has reasonable relocation semantics.
17 //===----------------------------------------------------------------------===//
19 #include "llvm/CodeGen/GCStrategy.h"
20 #include "llvm/IR/Value.h"
21 #include "llvm/IR/DerivedTypes.h"
26 class StatepointGC : public GCStrategy {
29 UseStatepoints = true;
30 // These options are all gc.root specific, we specify them so that the
31 // gc.root lowering code doesn't run.
36 CustomSafePoints = false;
38 Optional<bool> isGCManagedPointer(const Value *V) const override {
39 // Method is only valid on pointer typed values.
40 PointerType *PT = cast<PointerType>(V->getType());
41 // For the sake of this example GC, we arbitrarily pick addrspace(1) as our
42 // GC managed heap. We know that a pointer into this heap needs to be
43 // updated and that no other pointer does.
44 return (1 == PT->getAddressSpace());
49 static GCRegistry::Add<StatepointGC>
50 X("statepoint-example", "an example strategy for statepoint");
53 void linkStatepointExampleGC() {}