1 //===-- CoreCLRGC.cpp - CoreCLR Runtime GC Strategy -----------------------===//
\r
3 // The LLVM Compiler Infrastructure
\r
5 // This file is distributed under the University of Illinois Open Source
\r
6 // License. See LICENSE.TXT for details.
\r
8 //===----------------------------------------------------------------------===//
\r
10 // This file contains a GCStrategy for the CoreCLR Runtime.
\r
11 // The strategy is similar to Statepoint-example GC, but differs from it in
\r
12 // certain aspects, such as:
\r
13 // 1) Base-pointers need not be explicitly tracked and reported for
\r
14 // interior pointers
\r
15 // 2) Uses a different format for encoding stack-maps
\r
16 // 3) Location of Safe-point polls: polls are only needed before loop-back edges
\r
17 // and before tail-calls (not needed at function-entry)
\r
19 // The above differences in behavior are to be implemented in upcoming checkins.
\r
21 //===----------------------------------------------------------------------===//
\r
23 #include "llvm/CodeGen/GCStrategy.h"
\r
24 #include "llvm/IR/DerivedTypes.h"
\r
25 #include "llvm/IR/Value.h"
\r
27 using namespace llvm;
\r
30 class CoreCLRGC : public GCStrategy {
\r
33 UseStatepoints = true;
\r
34 // These options are all gc.root specific, we specify them so that the
\r
35 // gc.root lowering code doesn't run.
\r
37 NeededSafePoints = 0;
\r
38 UsesMetadata = false;
\r
39 CustomRoots = false;
\r
41 Optional<bool> isGCManagedPointer(const Value *V) const override {
\r
42 // Method is only valid on pointer typed values.
\r
43 PointerType *PT = cast<PointerType>(V->getType());
\r
44 // We pick addrspace(1) as our GC managed heap.
\r
45 return (1 == PT->getAddressSpace());
\r
50 static GCRegistry::Add<CoreCLRGC> X("coreclr",
\r
51 "CoreCLR-compatible GC");
\r
54 void linkCoreCLRGC() {}
\r