public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug debug/104337] New: ICE when compiling with optimize attribute at -m32 -g3 -O0
@ 2022-02-01 22:52 tlwang at uwaterloo dot ca
  2022-02-02  5:11 ` [Bug debug/104337] [9/10/11/12 Regression] " pinskia at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: tlwang at uwaterloo dot ca @ 2022-02-01 22:52 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 104337
           Summary: ICE when compiling with optimize attribute at -m32 -g3
                    -O0
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tlwang at uwaterloo dot ca
  Target Milestone: ---

This occurs in attributes_transformed_program0_preprocessed.c, shown below:

$ gcc-trunk -v
Using built-in specs.
COLLECT_GCC=gcc-trunk
COLLECT_LTO_WRAPPER=/scratch/software/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/12.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /tmp/tmp.JKF7BF3fiK-gcc-builder/gcc/configure
--enable-languages=c,c++,lto --enable-checking-yes --enable-multiarch
--prefix=/scratch/software/gcc-trunk --disable-bootstrap
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 12.0.1 20220201 (experimental) [master -g1bb526625] (GCC)
$
$ cat attributes_transformed_program0_preprocessed.c
struct a {
  unsigned b : 7;
};
__attribute__((optimize(3))) __attribute__((always_inline)) struct a c() {
  struct a d;
  return d;
}
void e() {
  for (;;)
    c();
}
int main() {}
$
$ gcc-trunk -m32 -O0 -g3 attributes_transformed_program0_preprocessed.c
attributes_transformed_program0_preprocessed.c:4:70: warning: ‘always_inline’
function might not be inlinable [-Wattributes]
    4 | __attribute__((optimize(3))) __attribute__((always_inline)) struct a
c() {
      |                                                                      ^
during RTL pass: final
attributes_transformed_program0_preprocessed.c: In function ‘e’:
attributes_transformed_program0_preprocessed.c:11:1: internal compiler error:
in decl_ultimate_origin, at dwarf2out.cc:4466
   11 | }
      | ^
0x71239e decl_ultimate_origin
        /tmp/tmp.JKF7BF3fiK-gcc-builder/gcc/gcc/dwarf2out.cc:4466
0x71239e decl_ultimate_origin
        /tmp/tmp.JKF7BF3fiK-gcc-builder/gcc/gcc/dwarf2out.cc:4454
0xbb0b17 process_scope_var
        /tmp/tmp.JKF7BF3fiK-gcc-builder/gcc/gcc/dwarf2out.cc:26452
0xbb0c2f decls_for_scope
        /tmp/tmp.JKF7BF3fiK-gcc-builder/gcc/gcc/dwarf2out.cc:26515
0xbd36c6 gen_inlined_subroutine_die
        /tmp/tmp.JKF7BF3fiK-gcc-builder/gcc/gcc/dwarf2out.cc:24964
0xbd36c6 gen_block_die
        /tmp/tmp.JKF7BF3fiK-gcc-builder/gcc/gcc/dwarf2out.cc:26419
0xbb0cea decls_for_scope
        /tmp/tmp.JKF7BF3fiK-gcc-builder/gcc/gcc/dwarf2out.cc:26544
0xbb14a2 gen_subprogram_die
        /tmp/tmp.JKF7BF3fiK-gcc-builder/gcc/gcc/dwarf2out.cc:24026
0xbcf88f gen_decl_die
        /tmp/tmp.JKF7BF3fiK-gcc-builder/gcc/gcc/dwarf2out.cc:26952
0xbd11f6 dwarf2out_decl
        /tmp/tmp.JKF7BF3fiK-gcc-builder/gcc/gcc/dwarf2out.cc:27530
0xbd1572 dwarf2out_function_decl
        /tmp/tmp.JKF7BF3fiK-gcc-builder/gcc/gcc/dwarf2out.cc:27545
0xc34e70 rest_of_handle_final
        /tmp/tmp.JKF7BF3fiK-gcc-builder/gcc/gcc/final.cc:4321
0xc34e70 execute
        /tmp/tmp.JKF7BF3fiK-gcc-builder/gcc/gcc/final.cc:4363
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

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

* [Bug debug/104337] [9/10/11/12 Regression] ICE when compiling with optimize attribute at -m32 -g3 -O0
  2022-02-01 22:52 [Bug debug/104337] New: ICE when compiling with optimize attribute at -m32 -g3 -O0 tlwang at uwaterloo dot ca
@ 2022-02-02  5:11 ` pinskia at gcc dot gnu.org
  2022-02-02  5:16 ` [Bug debug/104337] [9/10/11/12 Regression] ICE when compiling with optimize attribute and always_inline " pinskia at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-02-02  5:11 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-on-valid-code
   Target Milestone|---                         |9.0
      Known to fail|                            |11.2.0, 9.1.0
      Known to work|                            |6.1.0, 7.1.0, 8.1.0, 8.5.0
            Summary|ICE when compiling with     |[9/10/11/12 Regression] ICE
                   |optimize attribute at -m32  |when compiling with
                   |-g3 -O0                     |optimize attribute at -m32
                   |                            |-g3 -O0

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

* [Bug debug/104337] [9/10/11/12 Regression] ICE when compiling with optimize attribute and always_inline at -m32 -g3 -O0
  2022-02-01 22:52 [Bug debug/104337] New: ICE when compiling with optimize attribute at -m32 -g3 -O0 tlwang at uwaterloo dot ca
  2022-02-02  5:11 ` [Bug debug/104337] [9/10/11/12 Regression] " pinskia at gcc dot gnu.org
@ 2022-02-02  5:16 ` pinskia at gcc dot gnu.org
  2022-02-02 10:20 ` rguenth at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-02-02  5:16 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2022-02-02
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed. We inline c but something goes wrong otherwise.

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

* [Bug debug/104337] [9/10/11/12 Regression] ICE when compiling with optimize attribute and always_inline at -m32 -g3 -O0
  2022-02-01 22:52 [Bug debug/104337] New: ICE when compiling with optimize attribute at -m32 -g3 -O0 tlwang at uwaterloo dot ca
  2022-02-02  5:11 ` [Bug debug/104337] [9/10/11/12 Regression] " pinskia at gcc dot gnu.org
  2022-02-02  5:16 ` [Bug debug/104337] [9/10/11/12 Regression] ICE when compiling with optimize attribute and always_inline " pinskia at gcc dot gnu.org
@ 2022-02-02 10:20 ` rguenth at gcc dot gnu.org
  2022-02-02 10:20 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-02-02 10:20 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
             Target|                            |x86_64-*-*
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot gnu.org

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
I will have a look.  Note this is the inline copy of the result decl of 'c'
which is the RESULT_DECL 'd' having an abstract origin of the VAR_DECL 'd'.

This abstract origin is set by NRV:

  /* At this point we know that all the return statements return the
     same local which has suitable attributes for NRV.   Copy debugging
     information from FOUND to RESULT if it will be useful.  But don't set
     DECL_ABSTRACT_ORIGIN to point at another function.  */
  if (!DECL_IGNORED_P (found)
      && !(DECL_ABSTRACT_ORIGIN (found)
           && DECL_CONTEXT (DECL_ABSTRACT_ORIGIN (found)) !=
current_function_decl))
    {
      DECL_NAME (result) = DECL_NAME (found);
      DECL_SOURCE_LOCATION (result) = DECL_SOURCE_LOCATION (found);
      DECL_ABSTRACT_ORIGIN (result) = DECL_ABSTRACT_ORIGIN (found);
    }

but NRV runs _after_ the function was inlined and thus affects the inlined
variables copy indirectly.  We may adjust the abstract origin of
a variable only at the point we create it, not further along the path since
otherwise the (new) invariant that the abstract origin is always the ultimate
origin cannot be maintained.

The intent of what NRV does is OK I guess and it improves the debug
experience.  But I also notice we do

  SET_DECL_VALUE_EXPR (found, result);
  DECL_HAS_VALUE_EXPR_P (found) = 1;

the code is there since the merge from tree-ssa which added tree-nrv.c.

Jakub added the DECL_VALUE_EXPR in g:938650d8fddb878f623e315f0b7fd94b217efa96
and Jason added the abstract origin setting conditional in g:7716876bbd3a

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

* [Bug debug/104337] [9/10/11/12 Regression] ICE when compiling with optimize attribute and always_inline at -m32 -g3 -O0
  2022-02-01 22:52 [Bug debug/104337] New: ICE when compiling with optimize attribute at -m32 -g3 -O0 tlwang at uwaterloo dot ca
                   ` (2 preceding siblings ...)
  2022-02-02 10:20 ` rguenth at gcc dot gnu.org
@ 2022-02-02 10:20 ` rguenth at gcc dot gnu.org
  2022-02-03 15:02 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-02-02 10:20 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2

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

* [Bug debug/104337] [9/10/11/12 Regression] ICE when compiling with optimize attribute and always_inline at -m32 -g3 -O0
  2022-02-01 22:52 [Bug debug/104337] New: ICE when compiling with optimize attribute at -m32 -g3 -O0 tlwang at uwaterloo dot ca
                   ` (3 preceding siblings ...)
  2022-02-02 10:20 ` rguenth at gcc dot gnu.org
@ 2022-02-03 15:02 ` cvs-commit at gcc dot gnu.org
  2022-03-16  8:22 ` [Bug debug/104337] [9/10/11 " cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-02-03 15:02 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Richard Biener <rguenth@gcc.gnu.org>:

https://gcc.gnu.org/g:1d5c7584fd6e72bfdbede86cef5ff04ae35f9744

commit r12-7026-g1d5c7584fd6e72bfdbede86cef5ff04ae35f9744
Author: Richard Biener <rguenther@suse.de>
Date:   Thu Feb 3 11:20:59 2022 +0100

    debug/104337 - avoid messing with the abstract origin chain in NRV

    The following avoids NRV from massaging DECL_ABSTRACT_ORIGIN after
    variable creation since NRV runs _after_ the function was inlined and thus
    affects the inlined variables copy indirectly.  We may adjust the abstract
    origin of a variable only at the point we create it, not further along the
    path since otherwise the (new) invariant that the abstract origin is always
    the ultimate origin cannot be maintained.

    The intent of what NRV does is OK I guess and it may improve the debug
    experience.  But I also notice we do

      SET_DECL_VALUE_EXPR (found, result);
      DECL_HAS_VALUE_EXPR_P (found) = 1;

    the code is there since the merge from tree-ssa which added tree-nrv.c.

    Jakub added the DECL_VALUE_EXPR in
g:938650d8fddb878f623e315f0b7fd94b217efa96
    and Jason added the abstract origin setting conditional in g:7716876bbd3a

    The follwoing takes the radical approach and remove the attempt
    to "optimize" the debug info.

    The gdb testsuites show no regressions.

    2022-02-03  Richard Biener  <rguenther@suse.de>

            PR debug/104337
            * tree-nrv.cc (pass_nrv::execute): Remove tieing result and found
            together via DECL_ABSTRACT_ORIGIN.

            * gcc.dg/debug/pr104337.c: New testcase.

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

* [Bug debug/104337] [9/10/11 Regression] ICE when compiling with optimize attribute and always_inline at -m32 -g3 -O0
  2022-02-01 22:52 [Bug debug/104337] New: ICE when compiling with optimize attribute at -m32 -g3 -O0 tlwang at uwaterloo dot ca
                   ` (4 preceding siblings ...)
  2022-02-03 15:02 ` cvs-commit at gcc dot gnu.org
@ 2022-03-16  8:22 ` cvs-commit at gcc dot gnu.org
  2022-04-21 12:51 ` [Bug debug/104337] [9/10 " cvs-commit at gcc dot gnu.org
  2022-05-27  9:54 ` [Bug debug/104337] [9 " rguenth at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-03-16  8:22 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Richard Biener
<rguenth@gcc.gnu.org>:

https://gcc.gnu.org/g:24ec11aec20fd621a74c4a3bc7d61aaddf8ef8c8

commit r11-9657-g24ec11aec20fd621a74c4a3bc7d61aaddf8ef8c8
Author: Richard Biener <rguenther@suse.de>
Date:   Thu Feb 3 11:20:59 2022 +0100

    debug/104337 - avoid messing with the abstract origin chain in NRV

    The following avoids NRV from massaging DECL_ABSTRACT_ORIGIN after
    variable creation since NRV runs _after_ the function was inlined and thus
    affects the inlined variables copy indirectly.  We may adjust the abstract
    origin of a variable only at the point we create it, not further along the
    path since otherwise the (new) invariant that the abstract origin is always
    the ultimate origin cannot be maintained.

    The intent of what NRV does is OK I guess and it may improve the debug
    experience.  But I also notice we do

      SET_DECL_VALUE_EXPR (found, result);
      DECL_HAS_VALUE_EXPR_P (found) = 1;

    the code is there since the merge from tree-ssa which added tree-nrv.c.

    Jakub added the DECL_VALUE_EXPR in
g:938650d8fddb878f623e315f0b7fd94b217efa96
    and Jason added the abstract origin setting conditional in g:7716876bbd3a

    The follwoing takes the radical approach and remove the attempt
    to "optimize" the debug info.

    The gdb testsuites show no regressions.

    2022-02-03  Richard Biener  <rguenther@suse.de>

            PR debug/104337
            * tree-nrv.c (pass_nrv::execute): Remove tieing result and found
            together via DECL_ABSTRACT_ORIGIN.

            * gcc.dg/debug/pr104337.c: New testcase.

    (cherry picked from commit 1d5c7584fd6e72bfdbede86cef5ff04ae35f9744)

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

* [Bug debug/104337] [9/10 Regression] ICE when compiling with optimize attribute and always_inline at -m32 -g3 -O0
  2022-02-01 22:52 [Bug debug/104337] New: ICE when compiling with optimize attribute at -m32 -g3 -O0 tlwang at uwaterloo dot ca
                   ` (5 preceding siblings ...)
  2022-03-16  8:22 ` [Bug debug/104337] [9/10/11 " cvs-commit at gcc dot gnu.org
@ 2022-04-21 12:51 ` cvs-commit at gcc dot gnu.org
  2022-05-27  9:54 ` [Bug debug/104337] [9 " rguenth at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-04-21 12:51 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Richard Biener
<rguenth@gcc.gnu.org>:

https://gcc.gnu.org/g:f058e124350d3b19a79b3b7754b2ccab59bec7b1

commit r10-10546-gf058e124350d3b19a79b3b7754b2ccab59bec7b1
Author: Richard Biener <rguenther@suse.de>
Date:   Thu Feb 3 11:20:59 2022 +0100

    debug/104337 - avoid messing with the abstract origin chain in NRV

    The following avoids NRV from massaging DECL_ABSTRACT_ORIGIN after
    variable creation since NRV runs _after_ the function was inlined and thus
    affects the inlined variables copy indirectly.  We may adjust the abstract
    origin of a variable only at the point we create it, not further along the
    path since otherwise the (new) invariant that the abstract origin is always
    the ultimate origin cannot be maintained.

    The intent of what NRV does is OK I guess and it may improve the debug
    experience.  But I also notice we do

      SET_DECL_VALUE_EXPR (found, result);
      DECL_HAS_VALUE_EXPR_P (found) = 1;

    the code is there since the merge from tree-ssa which added tree-nrv.c.

    Jakub added the DECL_VALUE_EXPR in
g:938650d8fddb878f623e315f0b7fd94b217efa96
    and Jason added the abstract origin setting conditional in g:7716876bbd3a

    The follwoing takes the radical approach and remove the attempt
    to "optimize" the debug info.

    The gdb testsuites show no regressions.

    2022-02-03  Richard Biener  <rguenther@suse.de>

            PR debug/104337
            * tree-nrv.c (pass_nrv::execute): Remove tieing result and found
            together via DECL_ABSTRACT_ORIGIN.

            * gcc.dg/debug/pr104337.c: New testcase.

    (cherry picked from commit 1d5c7584fd6e72bfdbede86cef5ff04ae35f9744)

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

* [Bug debug/104337] [9 Regression] ICE when compiling with optimize attribute and always_inline at -m32 -g3 -O0
  2022-02-01 22:52 [Bug debug/104337] New: ICE when compiling with optimize attribute at -m32 -g3 -O0 tlwang at uwaterloo dot ca
                   ` (6 preceding siblings ...)
  2022-04-21 12:51 ` [Bug debug/104337] [9/10 " cvs-commit at gcc dot gnu.org
@ 2022-05-27  9:54 ` rguenth at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-05-27  9:54 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |9.5.0
   Target Milestone|9.0                         |10.4
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed for GCC 10.4.

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

end of thread, other threads:[~2022-05-27  9:54 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-01 22:52 [Bug debug/104337] New: ICE when compiling with optimize attribute at -m32 -g3 -O0 tlwang at uwaterloo dot ca
2022-02-02  5:11 ` [Bug debug/104337] [9/10/11/12 Regression] " pinskia at gcc dot gnu.org
2022-02-02  5:16 ` [Bug debug/104337] [9/10/11/12 Regression] ICE when compiling with optimize attribute and always_inline " pinskia at gcc dot gnu.org
2022-02-02 10:20 ` rguenth at gcc dot gnu.org
2022-02-02 10:20 ` rguenth at gcc dot gnu.org
2022-02-03 15:02 ` cvs-commit at gcc dot gnu.org
2022-03-16  8:22 ` [Bug debug/104337] [9/10/11 " cvs-commit at gcc dot gnu.org
2022-04-21 12:51 ` [Bug debug/104337] [9/10 " cvs-commit at gcc dot gnu.org
2022-05-27  9:54 ` [Bug debug/104337] [9 " rguenth 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).