Does the compiler provides extra stack space for byte-spilling?
Posted
by
xuwicha
on Stack Overflow
See other posts from Stack Overflow
or by xuwicha
Published on 2014-04-30T11:50:02Z
Indexed on
2014/06/02
3:27 UTC
Read the original article
Hit count: 281
compiler
|disassembling
From the sample code below which I got here, I don't understand why the value of registers are move to specific part in stack when byte-spilling is performed.
pushq %rbp
movq %rsp, %rbp
subq $96, %rsp
leaq L__unnamed_cfstring_23(%rip), %rax
leaq L__unnamed_cfstring_26(%rip), %rcx
movl $42, %edx
leaq l_objc_msgSend_fixup_alloc(%rip), %r8
movl $0, -4(%rbp)
movl %edi, -8(%rbp)
movq %rsi, -16(%rbp)
movq %rax, -48(%rbp) ## 8-byte Spill
movq %rcx, -56(%rbp) ## 8-byte Spill
movq %r8, -64(%rbp) ## 8-byte Spill
movl %edx, -68(%rbp) ## 4-byte Spill
callq _objc_autoreleasePoolPush
movq L_OBJC_CLASSLIST_REFERENCES_$_(%rip), %rcx
movq %rcx, %rdi
movq -64(%rbp), %rsi ## 8-byte Reload
movq %rax, -80(%rbp) ## 8-byte Spill
callq *l_objc_msgSend_fixup_alloc(%rip)
movq L_OBJC_SELECTOR_REFERENCES_27(%rip), %rsi
movq %rax, %rdi
movq -56(%rbp), %rdx ## 8-byte Reload
movl -68(%rbp), %ecx ## 4-byte Reload
And also, I don't know what is the purpose of byte-spilling since the program logic can still be achieved if the function is the one saving the value of the registers it will be used inside it.
I really have no idea why is this happening. Please help me understand this.
© Stack Overflow or respective owner