[llvm] Use CoreCLR GC interop configuration (#14598)
commitea4ff9ba8017ca1976a594d8d6c57a9052c4c043
authorAlexander Kyte <alkyte@microsoft.com>
Fri, 24 May 2019 20:55:50 +0000 (24 16:55 -0400)
committermonojenkins <jo.shields+jenkins@xamarin.com>
Fri, 24 May 2019 20:55:50 +0000 (24 16:55 -0400)
tree1cb9f055d3046c48723479a72b05fa8a40eb0d55
parentf93d42dbf5122374f63a114fcf1ee6e824551c2e
[llvm] Use CoreCLR GC interop configuration (#14598)

[llvm] Use CoreCLR GC interop configuration

Since they're identical right now, we can use the coreclr configuration
to make our IR more easily analyzed by tools built around LLVM.

```
class CoreCLRGC : public GCStrategy {
public:
  CoreCLRGC() {
    UseStatepoints = true;
    // These options are all gc.root specific, we specify them so that the
    // gc.root lowering code doesn't run.
    InitRoots = false;
    NeededSafePoints = 0;
    UsesMetadata = false;
    CustomRoots = false;
  }

  Optional<bool> isGCManagedPointer(const Type *Ty) const override {
    // Method is only valid on pointer typed values.
    const PointerType *PT = cast<PointerType>(Ty);
    // We pick addrspace(1) as our GC managed heap.
    return (1 == PT->getAddressSpace());
  }
};

/// A GCStrategy for the Mono Runtime.
class MonoGC : public GCStrategy {
public:
  MonoGC() {
    UseStatepoints = true;
    // These options are all gc.root specific, we specify them so that the
    // gc.root lowering code doesn't run.
    InitRoots = false;
    NeededSafePoints = 0;
    UsesMetadata = false;
    CustomRoots = false;
  }
};
```

Source: https://github.com/mono/llvm/blob/64c0343537016c153894dc60316bd7b316b812c8/lib/CodeGen/BuiltinGCs.cpp#L105-L137
mono/mini/mini-llvm.c