CoreCLRGC.cpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. #include "llvm/CodeGen/GCStrategy.h"
  23. #include "llvm/IR/DerivedTypes.h"
  24. #include "llvm/IR/Value.h"
  25. using namespace llvm;
  26. namespace {
  27. class CoreCLRGC : public GCStrategy {
  28. public:
  29. CoreCLRGC() {
  30. UseStatepoints = true;
  31. // These options are all gc.root specific, we specify them so that the
  32. // gc.root lowering code doesn't run.
  33. InitRoots = false;
  34. NeededSafePoints = 0;
  35. UsesMetadata = false;
  36. CustomRoots = false;
  37. }
  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. // We pick addrspace(1) as our GC managed heap.
  42. return (1 == PT->getAddressSpace());
  43. }
  44. };
  45. }
  46. static GCRegistry::Add<CoreCLRGC> X("coreclr", "CoreCLR-compatible GC");
  47. namespace llvm {
  48. void linkCoreCLRGC() {}
  49. }