Open
Description
Custom allocators (#[global_alloc]
) come with all sorts of exciting interactions with the operational semantics:
- The compiler is allowed to optimize away calls to them even if these calls have side-effects. Is there some operational way to rationalize this?
- Something exciting happens with provenance of pointers that move in and out of the allocator. But what? See for example this. LLVM has return-position
noalias
to reflect this magic. That attribute is super strong though. - Also, which allocators are even affected by this? Right now, we tell LLVM that the registered global_allocator is magic, but direct calls to an allocator (whether it uses the
GlobalAlloc
trait or theAllocator
trait) are just regular function calls. But maybe we want those to be magic as well for more optimizations? Or maybe we at least want a way for an allocator to opt-in to such magic? AnAllocator
that returns memory from some previously-allocated buffer certainly violates LLVM return-positionnoalias
so we can't give them the full treatment (at least not without first working with LLVM to improve their semantics -- maybe the scope of the return-positionnoalias
only lasts untilfree
is called, not until the end of the program). - Also, the first point from this issue shows that
dealloc
resets memory to "uninit" before the custom allocator function runs.
Metadata
Metadata
Assignees
Labels
No labels