public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/103038] New: ICE in set_mem_attributes_minus_bitpos, at emit-rtl.c:2092 since r12-4829-g429e3b7d8bf6609d
@ 2021-11-02  7:58 marxin at gcc dot gnu.org
  2021-11-02  7:58 ` [Bug tree-optimization/103038] " marxin at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-11-02  7:58 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 103038
           Summary: ICE in set_mem_attributes_minus_bitpos, at
                    emit-rtl.c:2092 since r12-4829-g429e3b7d8bf6609d
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: marxin at gcc dot gnu.org
                CC: qinzhao at gcc dot gnu.org
  Target Milestone: ---

The following fails:

$ cat warn.cpp
struct S;
void test() { int(S::*PtrMem); }

$ g++ warn.cpp -ftrivial-auto-var-init=pattern -c
during RTL pass: expand
warn.cpp: In function ‘void test()’:
warn.cpp:2:23: internal compiler error: in set_mem_attributes_minus_bitpos, at
emit-rtl.c:2092
    2 | void test() { int(S::*PtrMem); }
      |                       ^~~~~~
0x7ca0cb set_mem_attributes_minus_bitpos(rtx_def*, tree_node*, int,
poly_int<1u, long>)
        /home/marxin/Programming/gcc/gcc/emit-rtl.c:2092
0xe71a0c expand_assignment(tree_node*, tree_node*, bool)
        /home/marxin/Programming/gcc/gcc/expr.c:5658
0xd31b47 expand_call_stmt
        /home/marxin/Programming/gcc/gcc/cfgexpand.c:2749
0xd31b47 expand_gimple_stmt_1
        /home/marxin/Programming/gcc/gcc/cfgexpand.c:3876
0xd31b47 expand_gimple_stmt
        /home/marxin/Programming/gcc/gcc/cfgexpand.c:4040
0xd37a84 expand_gimple_basic_block
        /home/marxin/Programming/gcc/gcc/cfgexpand.c:6085
0xd39ca7 execute
        /home/marxin/Programming/gcc/gcc/cfgexpand.c:6811
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

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

* [Bug tree-optimization/103038] ICE in set_mem_attributes_minus_bitpos, at emit-rtl.c:2092 since r12-4829-g429e3b7d8bf6609d
  2021-11-02  7:58 [Bug tree-optimization/103038] New: ICE in set_mem_attributes_minus_bitpos, at emit-rtl.c:2092 since r12-4829-g429e3b7d8bf6609d marxin at gcc dot gnu.org
@ 2021-11-02  7:58 ` marxin at gcc dot gnu.org
  2021-11-02  8:51 ` pinskia at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-11-02  7:58 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P1
   Target Milestone|---                         |12.0
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2021-11-02

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

* [Bug tree-optimization/103038] ICE in set_mem_attributes_minus_bitpos, at emit-rtl.c:2092 since r12-4829-g429e3b7d8bf6609d
  2021-11-02  7:58 [Bug tree-optimization/103038] New: ICE in set_mem_attributes_minus_bitpos, at emit-rtl.c:2092 since r12-4829-g429e3b7d8bf6609d marxin at gcc dot gnu.org
  2021-11-02  7:58 ` [Bug tree-optimization/103038] " marxin at gcc dot gnu.org
@ 2021-11-02  8:51 ` pinskia at gcc dot gnu.org
  2021-11-02  8:52 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-02  8:51 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I think this patch which fix the problem:
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 54f91f0149c..2d3ba07e541 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -8791,6 +8791,7 @@ native_interpret_expr (tree type, const unsigned char
*ptr, int len)
     case BOOLEAN_TYPE:
     case POINTER_TYPE:
     case REFERENCE_TYPE:
+    case OFFSET_TYPE:
       return native_interpret_int (type, ptr, len);

     case REAL_TYPE:
@@ -8827,6 +8828,7 @@ can_native_interpret_type_p (tree type)
     case REAL_TYPE:
     case COMPLEX_TYPE:
     case VECTOR_TYPE:
+    case OFFSET_TYPE:
       return true;
     default:
       return false;


-----------
I have not tested it.

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

* [Bug tree-optimization/103038] ICE in set_mem_attributes_minus_bitpos, at emit-rtl.c:2092 since r12-4829-g429e3b7d8bf6609d
  2021-11-02  7:58 [Bug tree-optimization/103038] New: ICE in set_mem_attributes_minus_bitpos, at emit-rtl.c:2092 since r12-4829-g429e3b7d8bf6609d marxin at gcc dot gnu.org
  2021-11-02  7:58 ` [Bug tree-optimization/103038] " marxin at gcc dot gnu.org
  2021-11-02  8:51 ` pinskia at gcc dot gnu.org
@ 2021-11-02  8:52 ` rguenth at gcc dot gnu.org
  2021-11-02  8:53 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-11-02  8:52 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
#3  0x000000000140112e in expand_DEFERRED_INIT (stmt=0x7ffff65728e8)
    at /home/rguenther/src/gcc3/gcc/internal-fn.c:3101
3101          expand_assignment (lhs, init, false);
(gdb) p lhs
$3 = <view_convert_expr 0x7ffff66a49a0>
(gdb) p debug_generic_expr ($3)
VIEW_CONVERT_EXPR<unsigned long>(PtrMem_1)
(gdb) p debug_tree ($3)
 <view_convert_expr 0x7ffff66a49a0
    type <integer_type 0x7ffff656b1f8 public unsigned DI
        size <integer_cst 0x7ffff6543f30 constant 64>
        unit-size <integer_cst 0x7ffff6543f48 constant 8>
        align:64 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7ffff656b1f8 precision:64 min <integer_cst 0x7ffff6565360 0> max <integer_cst
0x7ffff65446a0 18446744073709551615>>

    arg:0 <ssa_name 0x7ffff654ee58
        type <offset_type 0x7ffff66acc78 type <integer_type 0x7ffff65635e8 int>
            sizes-gimplified DI size <integer_cst 0x7ffff6543f30 64> unit-size
<integer_cst 0x7ffff6543f48 8>
            align:64 warn_if_not_align:0 symtab:0 alias-set 1 canonical-type
0x7ffff66acc78 basetype <record_type 0x7ffff66acb28 S>>
        var <var_decl 0x7ffff7ff5cf0 PtrMem>
        def_stmt PtrMem_1 = .DEFERRED_INIT (8, 1, 0);
        version:1>>

and we ended up putting the LHS to the stack.  We have to avoid using
a V_C_E on a SSA name on the LHS.

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

* [Bug tree-optimization/103038] ICE in set_mem_attributes_minus_bitpos, at emit-rtl.c:2092 since r12-4829-g429e3b7d8bf6609d
  2021-11-02  7:58 [Bug tree-optimization/103038] New: ICE in set_mem_attributes_minus_bitpos, at emit-rtl.c:2092 since r12-4829-g429e3b7d8bf6609d marxin at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2021-11-02  8:52 ` rguenth at gcc dot gnu.org
@ 2021-11-02  8:53 ` rguenth at gcc dot gnu.org
  2021-11-02 13:17 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-11-02  8:53 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
But yes, Andrews patch is also an improvement and avoids the issue.

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

* [Bug tree-optimization/103038] ICE in set_mem_attributes_minus_bitpos, at emit-rtl.c:2092 since r12-4829-g429e3b7d8bf6609d
  2021-11-02  7:58 [Bug tree-optimization/103038] New: ICE in set_mem_attributes_minus_bitpos, at emit-rtl.c:2092 since r12-4829-g429e3b7d8bf6609d marxin at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2021-11-02  8:53 ` rguenth at gcc dot gnu.org
@ 2021-11-02 13:17 ` rguenth at gcc dot gnu.org
  2021-11-02 13:17 ` cvs-commit at gcc dot gnu.org
  2021-11-02 15:52 ` qinzhao at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-11-02 13:17 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed.

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

* [Bug tree-optimization/103038] ICE in set_mem_attributes_minus_bitpos, at emit-rtl.c:2092 since r12-4829-g429e3b7d8bf6609d
  2021-11-02  7:58 [Bug tree-optimization/103038] New: ICE in set_mem_attributes_minus_bitpos, at emit-rtl.c:2092 since r12-4829-g429e3b7d8bf6609d marxin at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2021-11-02 13:17 ` rguenth at gcc dot gnu.org
@ 2021-11-02 13:17 ` cvs-commit at gcc dot gnu.org
  2021-11-02 15:52 ` qinzhao at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-11-02 13:17 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 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:268b43d2592c196ea101946d7063156a914b2713

commit r12-4845-g268b43d2592c196ea101946d7063156a914b2713
Author: Richard Biener <rguenther@suse.de>
Date:   Tue Nov 2 09:58:00 2021 +0100

    middle-end/103038 - avoid ICE with -ftrivial-auto-var-init=pattern

    This avoids ICEing with expanding a VIEW_CONVERT_EXRP of a SSA name
    on the LHS by making sure we can native-interpret OFFSET_TYPE and
    by never building such a LHS but instead view-converting the RHS
    for SSA LHS.

    2021-11-02  Richard Biener  <rguenther@suse.de>

            PR middle-end/103038
            * fold-const.c (native_interpret_expr): Handle OFFSET_TYPE.
            (can_native_interpret_type_p): Likewise.
            * internal-fn.c (expand_DEFERRED_INIT): View-convert the
            RHS if the LHS is an SSA name.

            * g++.dg/pr103038.C: New testcase.

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

* [Bug tree-optimization/103038] ICE in set_mem_attributes_minus_bitpos, at emit-rtl.c:2092 since r12-4829-g429e3b7d8bf6609d
  2021-11-02  7:58 [Bug tree-optimization/103038] New: ICE in set_mem_attributes_minus_bitpos, at emit-rtl.c:2092 since r12-4829-g429e3b7d8bf6609d marxin at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2021-11-02 13:17 ` cvs-commit at gcc dot gnu.org
@ 2021-11-02 15:52 ` qinzhao at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: qinzhao at gcc dot gnu.org @ 2021-11-02 15:52 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from qinzhao at gcc dot gnu.org ---
just wondering why the ICE after my fix to PR102281. and found the reason:

Before the fix to PR102281, the IR before expansion phase is:

void test ()
{
  <<< Unknown tree: offset_type >>> PtrMem;

  <bb 2> :
  PtrMem = .DEFERRED_INIT (8, 1, 0);
  GIMPLE_NOP
  PtrMem ={v} {CLOBBER};
  return;

}

After the fix to PR102281, the IR before expansion phase is:
void test ()
{
  <<< Unknown tree: offset_type >>> PtrMem;

  <bb 2> :
  PtrMem_1 = .DEFERRED_INIT (8, 1, 0);
  return;

}

the key difference is, 

Before the PR102281 Fix, the LHS of the call to .DEFERRED_INIT is a
VAR_DECL(due to the additional call to __builtin_clear_padding (&PtrMem, ...),
and folded to GIMPLE_NOP later).  as a result, the RTL expansion for this call
went through the MEMSET expansion and succeed.

After the PR102281 Fix, the LHS of the call is a SSA name. as a result, the RTL
expansion for this call went thought the ASSIGN expansion and exposed the
issues for OFFSET_TYPE.

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

end of thread, other threads:[~2021-11-02 15:52 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-02  7:58 [Bug tree-optimization/103038] New: ICE in set_mem_attributes_minus_bitpos, at emit-rtl.c:2092 since r12-4829-g429e3b7d8bf6609d marxin at gcc dot gnu.org
2021-11-02  7:58 ` [Bug tree-optimization/103038] " marxin at gcc dot gnu.org
2021-11-02  8:51 ` pinskia at gcc dot gnu.org
2021-11-02  8:52 ` rguenth at gcc dot gnu.org
2021-11-02  8:53 ` rguenth at gcc dot gnu.org
2021-11-02 13:17 ` rguenth at gcc dot gnu.org
2021-11-02 13:17 ` cvs-commit at gcc dot gnu.org
2021-11-02 15:52 ` qinzhao 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).