public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug inline-asm/101354] New: [11/12 regression] naked function mishandled - store optimized away
@ 2021-07-06 22:33 2-gnu at 0x2c dot org
  2021-07-06 22:36 ` [Bug ipa/101354] " pinskia at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: 2-gnu at 0x2c dot org @ 2021-07-06 22:33 UTC (permalink / raw)
  To: gcc-bugs

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
}

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug ipa/101354] [11/12 regression] naked function mishandled - store optimized away
  2021-07-06 22:33 [Bug inline-asm/101354] New: [11/12 regression] naked function mishandled - store optimized away 2-gnu at 0x2c dot org
@ 2021-07-06 22:36 ` pinskia at gcc dot gnu.org
  2021-07-07  6:48 ` rguenth at gcc dot gnu.org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-07-06 22:36 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                URL|https://godbolt.org/z/4T4x8 |
                   |eb4f                        |
           Keywords|                            |wrong-code
          Component|inline-asm                  |ipa
                 CC|                            |marxin at gcc dot gnu.org

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
https://godbolt.org/z/4T4x8eb4f

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug ipa/101354] [11/12 regression] naked function mishandled - store optimized away
  2021-07-06 22:33 [Bug inline-asm/101354] New: [11/12 regression] naked function mishandled - store optimized away 2-gnu at 0x2c dot org
  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
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-07-07  6:48 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Target|                            |x86_64-*-*
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2021-07-07
   Target Milestone|---                         |11.2
             Status|UNCONFIRMED                 |NEW
                 CC|                            |hubicka at gcc dot gnu.org

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
Likely modref, but then IPA eventually generally mishandles "naked" functions. 
Note that "naked" is a target attribute so what we likely need is a target hook
computing extra "body" flags?

Or are traditional asm allowed to access & modify auto variables and
parameters?  I think only for "naked" functions such access is reliably
possible.

Not sure if there's a way for IPA to query for target attributes that have
effects on IPA semantics.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug ipa/101354] [11/12 regression] naked function mishandled - store optimized away
  2021-07-06 22:33 [Bug inline-asm/101354] New: [11/12 regression] naked function mishandled - store optimized away 2-gnu at 0x2c dot org
  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
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-07-07  6:50 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
OTOH decl-attributes.c has generic code doing

  /* A "naked" function attribute implies "noinline" and "noclone" for
     those targets that support it.  */
  if (TREE_CODE (*node) == FUNCTION_DECL
      && attributes
      && lookup_attribute ("naked", attributes) != NULL
      && lookup_attribute_spec (get_identifier ("naked")))
    {
      if (lookup_attribute ("noinline", attributes) == NULL)
        attributes = tree_cons (get_identifier ("noinline"), NULL, attributes);

      if (lookup_attribute ("noclone", attributes) == NULL)
        attributes = tree_cons (get_identifier ("noclone"),  NULL, attributes);
    }

maybe we should simply add "noipa" and eventually also "used" to it ... (if
that's enough)

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug ipa/101354] [11/12 regression] naked function mishandled - store optimized away
  2021-07-06 22:33 [Bug inline-asm/101354] New: [11/12 regression] naked function mishandled - store optimized away 2-gnu at 0x2c dot org
                   ` (2 preceding siblings ...)
  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
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-07-12  4:17 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |marxin at gcc dot gnu.org

--- Comment #4 from Martin Liška <marxin at gcc dot gnu.org> ---
I can work on that then..

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug ipa/101354] [11/12 regression] naked function mishandled - store optimized away
  2021-07-06 22:33 [Bug inline-asm/101354] New: [11/12 regression] naked function mishandled - store optimized away 2-gnu at 0x2c dot org
                   ` (3 preceding siblings ...)
  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
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-07-28  7:07 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|11.2                        |11.3

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 11.2 is being released, retargeting bugs to GCC 11.3

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug ipa/101354] [11/12 regression] naked function mishandled - store optimized away
  2021-07-06 22:33 [Bug inline-asm/101354] New: [11/12 regression] naked function mishandled - store optimized away 2-gnu at 0x2c dot org
                   ` (4 preceding siblings ...)
  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
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-08-13 14:04 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Martin Liska <marxin@gcc.gnu.org>:

https://gcc.gnu.org/g:4998404915bba9cb04c438a926cdf7126782a767

commit r12-2901-g4998404915bba9cb04c438a926cdf7126782a767
Author: Martin Liska <mliska@suse.cz>
Date:   Thu Aug 12 17:26:51 2021 +0200

    ipa: "naked" attribute implies "noipa" attribute

            PR ipa/101354

    gcc/ChangeLog:

            * attribs.c (decl_attributes): Make naked functions "noipa"
              functions.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug ipa/101354] [11 regression] naked function mishandled - store optimized away
  2021-07-06 22:33 [Bug inline-asm/101354] New: [11/12 regression] naked function mishandled - store optimized away 2-gnu at 0x2c dot org
                   ` (5 preceding siblings ...)
  2021-08-13 14:04 ` cvs-commit at gcc dot gnu.org
@ 2022-01-17 14:04 ` rguenth at gcc dot gnu.org
  2022-01-17 14:06 ` marxin at gcc dot gnu.org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-01-17 14:04 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|hubicka at gcc dot gnu.org         |marxin at gcc dot gnu.org
            Summary|[11/12 regression] naked    |[11 regression] naked
                   |function mishandled - store |function mishandled - store
                   |optimized away              |optimized away
      Known to work|                            |12.0
           Priority|P3                          |P2

--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
naked is now implying noipa for GCC 12, backport still necessary.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug ipa/101354] [11 regression] naked function mishandled - store optimized away
  2021-07-06 22:33 [Bug inline-asm/101354] New: [11/12 regression] naked function mishandled - store optimized away 2-gnu at 0x2c dot org
                   ` (6 preceding siblings ...)
  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
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-01-17 14:06 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Martin Liška <marxin at gcc dot gnu.org> ---
I'm going to do the backport.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug ipa/101354] [11 regression] naked function mishandled - store optimized away
  2021-07-06 22:33 [Bug inline-asm/101354] New: [11/12 regression] naked function mishandled - store optimized away 2-gnu at 0x2c dot org
                   ` (7 preceding siblings ...)
  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
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-01-18 13:27 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Martin Liska
<marxin@gcc.gnu.org>:

https://gcc.gnu.org/g:806d0ce8cb0c1b690e6b5774a5eb3a1404a21253

commit r11-9477-g806d0ce8cb0c1b690e6b5774a5eb3a1404a21253
Author: Martin Liska <mliska@suse.cz>
Date:   Thu Aug 12 17:26:51 2021 +0200

    ipa: "naked" attribute implies "noipa" attribute

            PR ipa/101354

    gcc/ChangeLog:

            * attribs.c (decl_attributes): Make naked functions "noipa"
              functions.

    (cherry picked from commit 4998404915bba9cb04c438a926cdf7126782a767)

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug ipa/101354] [11 regression] naked function mishandled - store optimized away
  2021-07-06 22:33 [Bug inline-asm/101354] New: [11/12 regression] naked function mishandled - store optimized away 2-gnu at 0x2c dot org
                   ` (8 preceding siblings ...)
  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
  10 siblings, 0 replies; 12+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-01-18 13:27 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #10 from Martin Liška <marxin at gcc dot gnu.org> ---
Fixed.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug ipa/101354] [11 regression] naked function mishandled - store optimized away
  2021-07-06 22:33 [Bug inline-asm/101354] New: [11/12 regression] naked function mishandled - store optimized away 2-gnu at 0x2c dot org
                   ` (9 preceding siblings ...)
  2022-01-18 13:27 ` marxin at gcc dot gnu.org
@ 2023-10-20 16:31 ` pinskia at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-10-20 16:31 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lukas.graetz@tu-darmstadt.d
                   |                            |e

--- Comment #11 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 111896 has been marked as a duplicate of this bug. ***

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2023-10-20 16:31 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-06 22:33 [Bug inline-asm/101354] New: [11/12 regression] naked function mishandled - store optimized away 2-gnu at 0x2c dot org
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

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).