public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "chip at pobox dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/54585] New: stack space allocated but never used when calling functions that return structs in registers Date: Fri, 14 Sep 2012 21:11:00 -0000 [thread overview] Message-ID: <bug-54585-4@http.gcc.gnu.org/bugzilla/> (raw) http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54585 Bug #: 54585 Summary: stack space allocated but never used when calling functions that return structs in registers Classification: Unclassified Product: gcc Version: 4.7.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: rtl-optimization AssignedTo: unassigned@gcc.gnu.org ReportedBy: chip@pobox.com Now that bug #44194 is fixed, and a returned structure used as a parameter is no longer stored unnecessarily, a new bug is visible: a stack frame is being allocated that is entirely unused. On x86_64 target with the fix for 44194 backported to the 4.7 branch, this code: #include <stdint.h> struct blargh { uint32_t a, b, c; } foo(); void bar(uint32_t a, uint32_t b, uint32_t c); void func() { struct blargh s = foo(); bar(s.a, s.b, s.c); } no longer uses any stack memory at all, but still the function call reserves 24 bytes with "subq $24,%rsp" and promptly returns it with "addq $24,%rsp". The generated code looks like this: func: .cfi_startproc xorl %eax, %eax subq $24, %rsp .cfi_def_cfa_offset 32 call foo movq %rax, %rsi movl %eax, %edi addq $24, %rsp .cfi_def_cfa_offset 8 shrq $32, %rsi jmp bar .cfi_endproc
next reply other threads:[~2012-09-14 21:11 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-09-14 21:11 chip at pobox dot com [this message] 2013-09-05 20:06 ` [Bug rtl-optimization/54585] " chip at pobox dot com 2013-09-05 21:05 ` ebotcazou at gcc dot gnu.org 2013-09-23 20:05 ` chip at pobox dot com 2021-12-18 23:59 ` [Bug middle-end/54585] " pinskia at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-54585-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).