public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "2-gnu at 0x2c dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug inline-asm/101354] New: [11/12 regression] naked function mishandled - store optimized away
Date: Tue, 06 Jul 2021 22:33:32 +0000	[thread overview]
Message-ID: <bug-101354-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101354

            Bug ID: 101354
           Summary: [11/12 regression] naked function mishandled - store
                    optimized away
           Product: gcc
           Version: 11.0
               URL: https://godbolt.org/z/4T4x8eb4f
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: inline-asm
          Assignee: unassigned at gcc dot gnu.org
          Reporter: 2-gnu at 0x2c dot org
  Target Milestone: ---

Stores are optimized away when a pointer is passed to a naked function.

Discovered in Nordic nRF5-SDK (17.0.2), which uses such a construct to
implement syscalls.

Minimal example:

__attribute__((naked))
//// switching to O0 will make it work
//__attribute__((optimize("O0")))
static void extfun_ptr(int *a) {
    __asm volatile("");
}

void fun() {
    int v;
    v = 1;
    extfun_ptr(&v); // &v is never initialized
}

             reply	other threads:[~2021-07-06 22:33 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-06 22:33 2-gnu at 0x2c dot org [this message]
2021-07-06 22:36 ` [Bug ipa/101354] " pinskia at gcc dot gnu.org
2021-07-07  6:48 ` rguenth at gcc dot gnu.org
2021-07-07  6:50 ` rguenth at gcc dot gnu.org
2021-07-12  4:17 ` marxin at gcc dot gnu.org
2021-07-28  7:07 ` rguenth at gcc dot gnu.org
2021-08-13 14:04 ` cvs-commit at gcc dot gnu.org
2022-01-17 14:04 ` [Bug ipa/101354] [11 " rguenth at gcc dot gnu.org
2022-01-17 14:06 ` marxin at gcc dot gnu.org
2022-01-18 13:27 ` cvs-commit at gcc dot gnu.org
2022-01-18 13:27 ` marxin at gcc dot gnu.org
2023-10-20 16:31 ` 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-101354-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: link
Be 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).