As of commit 4bd9d98
When compiling this source code
struct A {
int a[5];
};
extern int G(A a);
int F(A a) {
[[clang::musttail]] return G(a);
}
with -O3 -target x86_64-linux, clang generates the following assembly (only showing relevant part)
_Z1F1A: # @_Z1F1A
.cfi_startproc
# %bb.0: # %entry
movl 24(%rsp), %eax
movl %eax, 16(%rsp)
movaps 8(%rsp), %xmm0
movups %xmm0, (%rsp)
movaps %xmm0, 8(%rsp)
movl %eax, 24(%rsp)
jmp _Z1G1A@PLT # TAILCALL
.Lfunc_end0:
movups %xmm0, (%rsp) overwrites the return address of caller F, which will result in a crash.
As of commit 4bd9d98
When compiling this source code
with
-O3 -target x86_64-linux, clang generates the following assembly (only showing relevant part)movups %xmm0, (%rsp)overwrites the return address of callerF, which will result in a crash.