This should already be the case as
SomeStruct
doesn't fit into a register and thus is passed by-ref
In the mean time rust allocates space on the stack for a new SomeStruct then memcpy the original one into this allocated memory and then pass a reference to the newly created objected to the method
This is LLVM not knowing that it is fine to clobber the by-ref
st
value. MIR copy-propagation should be able to optimize this away, but I believe it is broken at the moment and also rather slow.
AFAIK rust does not tell LLVM that it is passing by value but by reference to the copied value
Also c++ have an rvalue references that is used like this: the reference is moved around until it is moved from explicitly which is where I got this idea