Skip to content

Custom alloc docs neglect to mention MIR_change_module_ctx #425

@asumagic

Description

@asumagic

Per the documentation:

The MIR_alloc instance passed to MIR_init2 must have a lifetime greater or equal to the resulting MIR_context, i.e. live at least as long as the subsequent call to MIR_finish. The MIR_alloc instance being destroyed or going out of scope beforehand may result in undefined behavior.

This fails to mention the usecase of MIR_change_module_ctx, which doesn't seem to reallocate data on the new context's allocator. This makes it impossible to use e.g. an arena allocator on a temporary compilation context, because the migrated module will now outlive the arena allocator, despite the above quote.

If asked, I could contribute a PR for this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions