Kixiron opened issue #5564:
Currently functions like
FunctionBuilder::emit_small_memory_copy()andFunctionBuilder::emit_small_memory_compare()only allow giving a singleMemFlagsthat (presumably) applies to both pointers when allowing disjoint flags could be beneficial, e.g. in the case where you're copying from areadonlypointer to a non-readonlypointer, or comparisons where only one side isreadonly.Additionally, the normal
FunctionBuilder::call_memcmp()andFunctionBuilder::call_memcpy()functions don't take flag arguments which could be beneficial for potentially de-duplicating calls
bjorn3 commented on issue #5564:
call_memcmpandcall_memcpydirectly generate a call instruction, so there is nothing to attach theMemFlagstoo.
jameysharp commented on issue #5564:
This is a good point! I'd guess
alignedcould have a significant impact even if it's only set on one operand.However just last month @bjorn3 proposed to introduce dedicated Cranelift IR instructions for these operations (#5479). I think we'll want to get rid of the corresponding cranelift-frontend functions entirely at that point. Also, off-hand I'm guessing we can't do many of the optimizations that dual mem-flags would enable without first plumbing these operations all the way to the backend.
So I'm going to close this, folding it into that issue as a suggestion that the new instructions should have one
MemFlagsfor each pointer operand.
jameysharp closed issue #5564:
Currently functions like
FunctionBuilder::emit_small_memory_copy()andFunctionBuilder::emit_small_memory_compare()only allow giving a singleMemFlagsthat (presumably) applies to both pointers when allowing disjoint flags could be beneficial, e.g. in the case where you're copying from areadonlypointer to a non-readonlypointer, or comparisons where only one side isreadonly.Additionally, the normal
FunctionBuilder::call_memcmp()andFunctionBuilder::call_memcpy()functions don't take flag arguments which could be beneficial for potentially de-duplicating calls
Last updated: Dec 13 2025 at 21:03 UTC