LLVM 22.0.0git
llvm::GCStrategy Class Reference

GCStrategy describes a garbage collector algorithm's code generation requirements, and provides overridable hooks for those needs which cannot be abstractly described. More...

#include "llvm/IR/GCStrategy.h"

Public Member Functions

LLVM_ABI GCStrategy ()
virtual ~GCStrategy ()=default
const std::string & getName () const
 Return the name of the GC strategy.
bool useStatepoints () const
 Returns true if this strategy is expecting the use of gc.statepoints, and false otherwise.
bool usesMetadata () const
 If set, appropriate metadata tables must be emitted by the back-end (assembler, JIT, or otherwise).
Statepoint Specific Properties
virtual std::optional< boolisGCManagedPointer (const Type *Ty) const
 If the type specified can be reliably distinguished, returns true for pointers to GC managed locations and false for pointers to non-GC managed locations.
bool useRS4GC () const
 Returns true if the RewriteStatepointsForGC pass should run on functions using this GC.
GCRoot Specific Properties

These properties and overrides only apply to collector strategies using GCRoot.

bool needsSafePoints () const
 True if safe points need to be inferred on call sites.

Protected Attributes

bool UseStatepoints = false
bool UseRS4GC = false
 Uses gc.statepoints as opposed to gc.roots, if set, NeededSafePoints and UsesMetadata should be left at their default values.
bool NeededSafePoints = false
 If UseStatepoints is set, this determines whether the RewriteStatepointsForGC pass should rewrite this function's calls.
bool UsesMetadata = false
 If set, backend must emit metadata tables.

Friends

class GCModuleInfo
class CollectorMetadataAnalysis

Detailed Description

GCStrategy describes a garbage collector algorithm's code generation requirements, and provides overridable hooks for those needs which cannot be abstractly described.

GCStrategy objects must be looked up through the Function. The objects themselves are owned by the Context and must be immutable.

Definition at line 64 of file GCStrategy.h.

Constructor & Destructor Documentation

◆ GCStrategy()

GCStrategy::GCStrategy ( )
default

References LLVM_ABI.

◆ ~GCStrategy()

virtual llvm::GCStrategy::~GCStrategy ( )
virtualdefault

Member Function Documentation

◆ getName()

const std::string & llvm::GCStrategy::getName ( ) const
inline

Return the name of the GC strategy.

This is the value of the collector name string specified on functions which use this strategy.

Definition at line 90 of file GCStrategy.h.

◆ isGCManagedPointer()

virtual std::optional< bool > llvm::GCStrategy::isGCManagedPointer ( const Type * Ty) const
inlinevirtual

If the type specified can be reliably distinguished, returns true for pointers to GC managed locations and false for pointers to non-GC managed locations.

Note a GCStrategy can always return 'std::nullopt' (i.e. an empty optional indicating it can't reliably distinguish.

Definition at line 103 of file GCStrategy.h.

◆ needsSafePoints()

bool llvm::GCStrategy::needsSafePoints ( ) const
inline

True if safe points need to be inferred on call sites.

Definition at line 129 of file GCStrategy.h.

References NeededSafePoints.

◆ useRS4GC()

bool llvm::GCStrategy::useRS4GC ( ) const
inline

Returns true if the RewriteStatepointsForGC pass should run on functions using this GC.

Definition at line 109 of file GCStrategy.h.

References assert(), UseRS4GC, and useStatepoints().

◆ usesMetadata()

bool llvm::GCStrategy::usesMetadata ( ) const
inline

If set, appropriate metadata tables must be emitted by the back-end (assembler, JIT, or otherwise).

The default stackmap information can be found in the StackMap section as described in the documentation.

Definition at line 120 of file GCStrategy.h.

References UsesMetadata.

◆ useStatepoints()

bool llvm::GCStrategy::useStatepoints ( ) const
inline

Returns true if this strategy is expecting the use of gc.statepoints, and false otherwise.

Definition at line 94 of file GCStrategy.h.

References UseStatepoints.

Referenced by useRS4GC().

◆ CollectorMetadataAnalysis

friend class CollectorMetadataAnalysis
friend

Definition at line 67 of file GCStrategy.h.

References CollectorMetadataAnalysis.

Referenced by CollectorMetadataAnalysis.

◆ GCModuleInfo

friend class GCModuleInfo
friend

Definition at line 66 of file GCStrategy.h.

References GCModuleInfo.

Referenced by GCModuleInfo.

Member Data Documentation

◆ NeededSafePoints

bool llvm::GCStrategy::NeededSafePoints = false
protected

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. if set, calls are inferred to be safepoints

Definition at line 81 of file GCStrategy.h.

Referenced by needsSafePoints().

◆ UseRS4GC

bool llvm::GCStrategy::UseRS4GC = false
protected

Uses gc.statepoints as opposed to gc.roots, if set, NeededSafePoints and UsesMetadata should be left at their default values.

Definition at line 76 of file GCStrategy.h.

Referenced by useRS4GC().

◆ UsesMetadata

bool llvm::GCStrategy::UsesMetadata = false
protected

If set, backend must emit metadata tables.

Definition at line 82 of file GCStrategy.h.

Referenced by usesMetadata().

◆ UseStatepoints

bool llvm::GCStrategy::UseStatepoints = false
protected

Definition at line 72 of file GCStrategy.h.

Referenced by useStatepoints().


The documentation for this class was generated from the following files: