Today, whilst disassembling some binaries I built earlier (clang x86_64), I came across something [seemingly] useless.
_baz: ## @baz
.cfi_startproc
## BB#0:
pushq %rax ; What?
Ltmp7:
.cfi_def_cfa_offset 16
leaq (%rsp), %rax
movq %rsi, (%rax)
xorl %edx, %edx
movq %rax, %rsi
callq _something
movq %rax, %rdi
callq _something_else
movl (%rax), %eax
popq %rcx ; What?
retq
.cfi_endproc
I see rax
being saved and then later restored to rcx
, and I don't see the point of doing that, as rax
is a scratch register (which doesn't seem to need saving here) and rcx
(another scratch register, also for 4th register-passed arg) never seems to be used here.