llir-opt
0.0.1
Low-Level Post-Link Optimiser for OCaml and C
|
#include <emitter/annot_printer.h>
Public Member Functions | |
AnnotPrinter (char &ID, llvm::MCContext *ctx, llvm::MCStreamer *os, const llvm::MCObjectFileInfo *objInfo, const llvm::DataLayout &layout, const ISelMapping &mapping, bool shared) | |
Initialises the pass which prints data sections. | |
Protected Member Functions | |
virtual std::optional< unsigned > | GetRegisterIndex (llvm::Register reg)=0 |
Returns the GC index of a register. | |
virtual llvm::StringRef | GetRegisterName (unsigned reg)=0 |
Returns the name of a register. | |
virtual llvm::Register | GetStackPointer ()=0 |
Returns the stack pointer of the target. | |
virtual unsigned | GetImplicitStackSize () const =0 |
Returns the implicit stack size, besides the frame adjustment. | |
virtual int64_t | GetFrameOffset (const llvm::MachineInstr &MI) const |
Return the offset to apply to a label. | |
Protected Attributes | |
const ISelMapping & | mapping_ |
Instruction selector pass containing info for annotations. | |
llvm::MCContext * | ctx_ |
LLVM context. | |
llvm::MCStreamer * | os_ |
Streamer to emit output to. | |
const llvm::MCObjectFileInfo * | objInfo_ |
Object-file specific information. | |
const llvm::DataLayout | layout_ |
Data layout. | |
std::vector< FrameInfo > | frames_ |
List of frames to emit information for. | |
std::vector< RootInfo > | roots_ |
List of root frames. | |
std::unordered_map< DebugKey, DebugInfos, DebugKeyHash > | debug_ |
Mapping of debug objects. | |
std::unordered_map< std::pair< std::string, std::string >, DefinitionInfo > | defs_ |
Mapping from definitions to labels. | |
std::unordered_map< std::string, llvm::MCSymbol * > | files_ |
Mapping from file names to labels. | |
bool | shared_ |
Flag to indicate whether a shared library is emitted. | |
Annotation emitter pass.
Emits the metadata required by OCaml for garbage collection and stack traces. For each call site, the label after the call (the return address) is mapped to a descriptor, which in turn can link to debug information.
The descriptor contains is composed of a flag, offsets and allocation sizes. The flag contains the stack frame size, which must be a multiple of 8. the 1st bit indicates whether the call allocates, while the 0th bit indicates the presence of debug information.
If the call allocates, the record encodes the sizes of all objects allocated at that point.
If debug information is present, a list of a single index to a debug node is added to non-allocating calls, while allocating clals have a debug entry for the individual allocations bundled into the call.