[PATCH] D142169: [RS4GC] Add a GCStrategy option to enable RS4GC
Campbell Suter via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 19 17:42:07 PST 2023
znix created this revision.
znix added reviewers: dantrushin, reames, mkazantsev.
Herald added subscribers: StephenFan, hiraditya.
Herald added a project: All.
znix requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Currently, the RewriteStatepointsForGC pass has a hardcoded list of GC
strategies that it operates on, forcing downstream projects to patch
LLVM to enable it for their own strategies. The diff D141110 <https://reviews.llvm.org/D141110> changes
that to each GCStrategy having a flag to enable or disable RS4GC.
This patch adds that flag. It currently doesn't do anything, but is
provided so downstream projects can enable it to smooth the transition.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D142169
Files:
llvm/include/llvm/IR/GCStrategy.h
llvm/lib/IR/BuiltinGCs.cpp
Index: llvm/lib/IR/BuiltinGCs.cpp
===================================================================
--- llvm/lib/IR/BuiltinGCs.cpp
+++ llvm/lib/IR/BuiltinGCs.cpp
@@ -66,6 +66,7 @@
public:
StatepointGC() {
UseStatepoints = true;
+ UseRS4GC = true;
// These options are all gc.root specific, we specify them so that the
// gc.root lowering code doesn't run.
NeededSafePoints = false;
@@ -98,6 +99,7 @@
public:
CoreCLRGC() {
UseStatepoints = true;
+ UseRS4GC = true;
// These options are all gc.root specific, we specify them so that the
// gc.root lowering code doesn't run.
NeededSafePoints = false;
Index: llvm/include/llvm/IR/GCStrategy.h
===================================================================
--- llvm/include/llvm/IR/GCStrategy.h
+++ llvm/include/llvm/IR/GCStrategy.h
@@ -68,8 +68,13 @@
protected:
bool UseStatepoints = false; /// Uses gc.statepoints as opposed to gc.roots,
- /// if set, none of the other options can be
- /// anything but their default values.
+ /// if set, NeededSafePoints and UsesMetadata
+ /// should be left at their default values.
+
+ bool UseRS4GC = false; /// If UseStatepoints is set, this determines whether
+ /// the RewriteStatepointsForGC pass should rewrite
+ /// this function's calls.
+ /// This should only be set if UseStatepoints is set.
bool NeededSafePoints = false; ///< if set, calls are inferred to be safepoints
bool UsesMetadata = false; ///< If set, backend must emit metadata tables.
@@ -96,6 +101,15 @@
virtual std::optional<bool> isGCManagedPointer(const Type *Ty) const {
return std::nullopt;
}
+
+ /// Returns true if the RewriteStatepointsForGC pass should run on functions
+ /// using this GC.
+ bool useRS4GC() const {
+ return UseRS4GC;
+ assert(useStatepoints() &&
+ "GC strategy has useRS4GC but not useStatepoints set");
+ }
+
///@}
/// If set, appropriate metadata tables must be emitted by the back-end
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142169.490692.patch
Type: text/x-patch
Size: 2189 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230120/8007301e/attachment.bin>
More information about the llvm-commits
mailing list