The following test program spills res onto the stack when the value res.result, which is already in a register, should be passed in a register to foo();
/* compile with: gcc -fomit-frame-pointer -S */ struct rw_res { long result; long pos_update; }; struct file { long f_pos; }; struct rw_res vfs_read(long pos); long foo(long bar); long sys_read(struct file *file) { struct rw_res res; res = vfs_read(file->f_pos); return foo(res.result); } -- Summary: code generation -- unnecessary spill of structure onto stack Product: gcc Version: 4.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c 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=25227