public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "sebastian.huber@embedded-brains.de" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/99151] New: Missed optimization: Superfluous stack frame and code with noreturn or __builtin_unreachable() Date: Thu, 18 Feb 2021 14:45:57 +0000 [thread overview] Message-ID: <bug-99151-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99151 Bug ID: 99151 Summary: Missed optimization: Superfluous stack frame and code with noreturn or __builtin_unreachable() Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: sebastian.huber@embedded-brains.de Target Milestone: --- The following test code: _Noreturn void r(void); void u(void); void g(void) { r(); } void f(void) { u(); __builtin_unreachable(); } Produces code the following code on a sample set of architectures. There should be no stack frame set up. There should be no instructions after the no-return function calls (for example sparc). sparc-rtems6-gcc -O2 -o - -S unreachable.c .file "unreachable.c" .section ".text" .align 4 .global g .type g, #function .proc 020 g: save %sp, -96, %sp call r, 0 nop nop .size g, .-g .align 4 .global f .type f, #function .proc 020 f: save %sp, -96, %sp call u, 0 nop nop .size f, .-f .ident "GCC: (GNU) 10.2.1 20210205 (RTEMS 6, RSB 61dcadee0825867ebe51f9f367430ef75b8fe9c0, Newlib d4a756f)" arm-rtems6-gcc -O2 -o - -S unreachable.c .cpu arm7tdmi .eabi_attribute 20, 1 .eabi_attribute 21, 1 .eabi_attribute 23, 3 .eabi_attribute 24, 1 .eabi_attribute 25, 1 .eabi_attribute 26, 2 .eabi_attribute 30, 2 .eabi_attribute 34, 0 .eabi_attribute 18, 4 .file "unreachable.c" .text .align 2 .global g .arch armv4t .syntax unified .arm .fpu softvfp .type g, %function g: @ Function supports interworking. @ Volatile: function does not return. @ args = 0, pretend = 0, frame = 0 @ frame_needed = 0, uses_anonymous_args = 0 push {r4, lr} bl r .size g, .-g .align 2 .global f .syntax unified .arm .fpu softvfp .type f, %function f: @ Function supports interworking. @ Volatile: function does not return. @ args = 0, pretend = 0, frame = 0 @ frame_needed = 0, uses_anonymous_args = 0 push {r4, lr} bl u .size f, .-f .ident "GCC: (GNU) 10.2.1 20210205 (RTEMS 6, RSB 61dcadee0825867ebe51f9f367430ef75b8fe9c0, Newlib d4a756f)" powerpc-rtems6-gcc -O2 -o - -S unreachable.c .file "unreachable.c" .machine ppc .section ".text" .align 2 .globl g .type g, @function g: .LFB0: .cfi_startproc stwu 1,-16(1) .cfi_def_cfa_offset 16 mflr 0 stw 0,20(1) .cfi_offset 65, 4 bl r .cfi_endproc .LFE0: .size g,.-g .align 2 .globl f .type f, @function f: .LFB1: .cfi_startproc stwu 1,-16(1) .cfi_def_cfa_offset 16 mflr 0 stw 0,20(1) .cfi_offset 65, 4 bl u .cfi_endproc .LFE1: .size f,.-f .ident "GCC: (GNU) 10.2.1 20210205 (RTEMS 6, RSB 61dcadee0825867ebe51f9f367430ef75b8fe9c0, Newlib d4a756f)" .section .note.GNU-stack,"",@progbits
next reply other threads:[~2021-02-18 14:45 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-02-18 14:45 sebastian.huber@embedded-brains.de [this message] 2021-02-18 14:52 ` [Bug c/99151] " jakub at gcc dot gnu.org 2021-02-18 14:56 ` sebastian.huber@embedded-brains.de 2021-02-18 19:15 ` pinskia at gcc dot gnu.org 2021-02-19 6:46 ` [Bug middle-end/99151] " sebastian.huber@embedded-brains.de 2021-03-01 11:17 ` ebotcazou at gcc dot gnu.org 2021-03-01 12:36 ` sebastian.huber@embedded-brains.de 2021-03-01 12:53 ` ebotcazou at gcc dot gnu.org 2021-03-01 13:04 ` sebastian.huber@embedded-brains.de 2021-03-01 13:21 ` jakub 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-99151-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).