codegen: Copy to an alloca when the argument is neither by-val nor by-move for indirect pointer.#155343
codegen: Copy to an alloca when the argument is neither by-val nor by-move for indirect pointer.#155343dianqk wants to merge 2 commits intorust-lang:mainfrom
Conversation
| self.codegen_argument( | ||
| bx, | ||
| op, | ||
| // Pass by-move for an explicit tail call, which has been handled above as well. |
There was a problem hiding this comment.
This feels a bit awkward; perhaps the tail call handling can be moved into codegen_argument as well.
There was a problem hiding this comment.
The issue has nothing to do with tail calls, does it...?
There was a problem hiding this comment.
But this PR is changing something about tail calls...?
Maybe it's just the comment that is confusing me. Why is it okay to always to by-move for tail call arguments? Cc @folkertdev
There was a problem hiding this comment.
Because #151143 has done a similar thing, we don't need to copy it again. IIUC, tail call is special; the same arguments on the caller must be passed to the callee. Extra copy is UB.
There was a problem hiding this comment.
#151143 says something about
Therefore we store the argument for the callee in the corresponding caller's slot.
So I guess there is code elsewhere establishing an invariant that the argument here is the equivalent slot and we can pass a pointer to it. The comment should explain that and point at that code.
| // CHECK: call void @test_simd(<4 x i32> <i32 2, i32 4, i32 6, i32 8> | ||
| test_simd(const { Simd::<i32, 4>([2, 4, 6, 8]) }); | ||
|
|
||
| // CHECK: call void @test_simd_unaligned(%"minisimd::PackedSimd<i32, 3>" %1 |
There was a problem hiding this comment.
A redundant memcpy is skipped here.
…-move for indirect pointer.
|
|
Fixes #155241.
Arguments passed indirectly via a hidden pointer must be copied to an alloca, except for by-val or by-move.
r? RalfJung (since you have already commented a lot)