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.
Per the documentation:
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.