Skip to content

Commit

Permalink
Add Mono GC (llvm#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
luhenry authored and imhameed committed Jun 2, 2021
1 parent c6f5a3a commit 76826e6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
13 changes: 13 additions & 0 deletions llvm/lib/CodeGen/BuiltinGCs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,18 @@ class CoreCLRGC : public GCStrategy {
}
};

/// 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.
NeededSafePoints = 0;
UsesMetadata = false;
}
};

} // end anonymous namespace

// Register all the above so that they can be found at runtime. Note that
Expand All @@ -125,6 +137,7 @@ static GCRegistry::Add<ShadowStackGC>
static GCRegistry::Add<StatepointGC> D("statepoint-example",
"an example strategy for statepoint");
static GCRegistry::Add<CoreCLRGC> E("coreclr", "CoreCLR-compatible GC");
static GCRegistry::Add<MonoGC> F("mono", "Mono-compatible GC");

// Provide hook to ensure the containing library is fully loaded.
void llvm::linkAllBuiltinGCs() {}
4 changes: 3 additions & 1 deletion llvm/lib/Transforms/Scalar/PlaceSafepoints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,8 +450,10 @@ static bool shouldRewriteFunction(Function &F) {
const auto &FunctionGCName = F.getGC();
const StringRef StatepointExampleName("statepoint-example");
const StringRef CoreCLRName("coreclr");
const StringRef MonoName("mono");
return (StatepointExampleName == FunctionGCName) ||
(CoreCLRName == FunctionGCName);
(CoreCLRName == FunctionGCName) ||
(MonoName == FunctionGCName);
} else
return false;
}
Expand Down

0 comments on commit 76826e6

Please sign in to comment.