//===- GCMetadata.h - Garbage collector metadata ----------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This file declares the GCFunctionInfo and GCModuleInfo classes, which are // used as a communication channel from the target code generator to the target // garbage collectors. This interface allows code generators and garbage // collectors to be developed independently. // // The GCFunctionInfo class logs the data necessary to build a type accurate // stack map. The code generator outputs: // // - Safe points as specified by the GCStrategy's NeededSafePoints. // - Stack offsets for GC roots, as specified by calls to llvm.gcroot // // As a refinement, liveness analysis calculates the set of live roots at each // safe point. Liveness analysis is not presently performed by the code // generator, so all roots are assumed live. // // GCModuleInfo simply collects GCFunctionInfo instances for each Function as // they are compiled. This accretion is necessary for collectors which must emit // a stack map for the compilation unit as a whole. Therefore, GCFunctionInfo // outlives the MachineFunction from which it is derived and must not refer to // any code generator data structures. // //===----------------------------------------------------------------------===// #ifndef LLVM_CODEGEN_GCMETADATA_H #define LLVM_CODEGEN_GCMETADATA_H #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringRef.h" #include "llvm/IR/DebugLoc.h" #include "llvm/IR/GCStrategy.h" #include "llvm/IR/PassManager.h" #include "llvm/Pass.h" #include <algorithm> #include <cstddef> #include <cstdint> #include <memory> #include <vector> namespace llvm { class Constant; class Function; class MCSymbol; /// GCPoint - Metadata for a collector-safe point in machine code. /// struct GCPoint { … }; /// GCRoot - Metadata for a pointer to an object managed by the garbage /// collector. struct GCRoot { … }; /// Garbage collection metadata for a single function. Currently, this /// information only applies to GCStrategies which use GCRoot. class GCFunctionInfo { … }; struct GCStrategyMap { … }; /// An analysis pass which caches information about the entire Module. /// Records a cache of the 'active' gc strategy objects for the current Module. class CollectorMetadataAnalysis : public AnalysisInfoMixin<CollectorMetadataAnalysis> { … }; /// An analysis pass which caches information about the Function. /// Records the function level information used by GCRoots. /// This pass depends on `CollectorMetadataAnalysis`. class GCFunctionAnalysis : public AnalysisInfoMixin<GCFunctionAnalysis> { … }; /// LowerIntrinsics - This pass rewrites calls to the llvm.gcread or /// llvm.gcwrite intrinsics, replacing them with simple loads and stores as /// directed by the GCStrategy. It also performs automatic root initialization /// and custom intrinsic lowering. /// /// This pass requires `CollectorMetadataAnalysis`. class GCLoweringPass : public PassInfoMixin<GCLoweringPass> { … }; /// An analysis pass which caches information about the entire Module. /// Records both the function level information used by GCRoots and a /// cache of the 'active' gc strategy objects for the current Module. class GCModuleInfo : public ImmutablePass { … }; } // end namespace llvm #endif // LLVM_CODEGEN_GCMETADATA_H