LLVM  3.7.0
CoreCLRGC.cpp
Go to the documentation of this file.
1 //===-- CoreCLRGC.cpp - CoreCLR Runtime GC Strategy -----------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file contains a GCStrategy for the CoreCLR Runtime.
11 // The strategy is similar to Statepoint-example GC, but differs from it in
12 // certain aspects, such as:
13 // 1) Base-pointers need not be explicitly tracked and reported for
14 // interior pointers
15 // 2) Uses a different format for encoding stack-maps
16 // 3) Location of Safe-point polls: polls are only needed before loop-back edges
17 // and before tail-calls (not needed at function-entry)
18 //
19 // The above differences in behavior are to be implemented in upcoming checkins.
20 //
21 //===----------------------------------------------------------------------===//
22 
24 #include "llvm/IR/DerivedTypes.h"
25 #include "llvm/IR/Value.h"
26 
27 using namespace llvm;
28 
29 namespace {
30 class CoreCLRGC : public GCStrategy {
31 public:
32  CoreCLRGC() {
33  UseStatepoints = true;
34  // These options are all gc.root specific, we specify them so that the
35  // gc.root lowering code doesn't run.
36  InitRoots = false;
37  NeededSafePoints = 0;
38  UsesMetadata = false;
39  CustomRoots = false;
40  }
41  Optional<bool> isGCManagedPointer(const Value *V) const override {
42  // Method is only valid on pointer typed values.
43  PointerType *PT = cast<PointerType>(V->getType());
44  // We pick addrspace(1) as our GC managed heap.
45  return (1 == PT->getAddressSpace());
46  }
47 };
48 }
49 
50 static GCRegistry::Add<CoreCLRGC> X("coreclr", "CoreCLR-compatible GC");
51 
52 namespace llvm {
53 void linkCoreCLRGC() {}
54 }
unsigned getAddressSpace() const
Return the address space of the Pointer type.
Definition: DerivedTypes.h:472
void linkCoreCLRGC()
FIXME: Collector instances are not useful on their own.
Definition: CoreCLRGC.cpp:53
PointerType - Class to represent pointers.
Definition: DerivedTypes.h:449
static GCRegistry::Add< CoreCLRGC > X("coreclr","CoreCLR-compatible GC")
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:222
GCStrategy describes a garbage collector algorithm's code generation requirements, and provides overridable hooks for those needs which cannot be abstractly described.
Definition: GCStrategy.h:78
LLVM Value Representation.
Definition: Value.h:69
A static registration template.
Definition: Registry.h:201