The attached code compiled with the command line below results in the following
assembly that saves an unused register (r8) in the function prolog.
gcc -fno-strict-aliasing -fno-common -ffreestanding -Os
-fomit-frame-pointer -march=nocona -ffixed-r10 -mno-red-zone -mcmodel=kernel
-pipe -fno-reorder-blocks -fno-asynchronous-unwind-tables -funit-at-a-time
-mno-sse -mno-mmx -mno-sse2 -mno-3dnow -Wdeclaration-after-statement
-Wno-pointer-sign -S rw-double-save.c
.file "rw-double-save.c"
.text
.globl sys_read
.type sys_read, @function
sys_read:
pushq %r13
pushq %r12
pushq %rbp
pushq %rbx
pushq %r8
movq %rsi, %r13
movq %rdx, %r12
call fget_light
movq %rax, %rbx
cmpq $-1000, %rax
jle .L2
movq %rax, %rdx
jmp .L4
.L2:
movq 16(%rax), %rbp
movq %rbp, %rcx
movq %r12, %rdx
movq %r13, %rsi
movq %rax, %rdi
call vfs_read
movq %rax, %rdx
testq %rax, %rax
jle .L5
testb $16, 8(%rbx)
jne .L5
leaq (%rbp,%rax), %rax
movq %rax, 16(%rbx)
.L5:
cmpq $0, 8(%r10)
je .L4
movq %rdx, %rsi
movq %rbx, %rdi
popq %rcx
popq %rbx
popq %rbp
popq %r12
popq %r13
jmp fput_ret
.L4:
movq %rdx, %rax
popq %rdx
popq %rbx
popq %rbp
popq %r12
popq %r13
ret
.size sys_read, .-sys_read
.ident "GCC: (GNU) 4.2.0 20051202 (experimental)"
.section .note.GNU-stack,"",@progbits
--
Summary: unused register saved in function prolog
Product: gcc
Version: 4.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: bcrl at kvack dot org
GCC build triplet: x86_64-unknown-linux
GCC host triplet: x86_64-unknown-linux
GCC target triplet: x86_64-unknown-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25295