public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug d/110712] New: d: ICE: verify_gimple_failed (conversion of register to a different size in 'view_convert_expr')
@ 2023-07-18 10:37 ibuclaw at gdcproject dot org
  2023-07-18 11:55 ` [Bug d/110712] " rguenth at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: ibuclaw at gdcproject dot org @ 2023-07-18 10:37 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 110712
           Summary: d: ICE: verify_gimple_failed (conversion of register
                    to a different size in 'view_convert_expr')
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: d
          Assignee: ibuclaw at gdcproject dot org
          Reporter: ibuclaw at gdcproject dot org
  Target Milestone: ---

Seen with gdc-12 with --enable-checking turned on, assume that it's going to
still be the case with mainline.

d21: error: conversion of register to a different size in ‘view_convert_expr’
VIEW_CONVERT_EXPR<struct [1]>(ap_3(D));

# .MEM_4 = VDEF <.MEM_1(D)>
this_2(D)->ap = VIEW_CONVERT_EXPR<struct [1]>(ap_3(D));
during GIMPLE pass: ssa
d21: internal compiler error: verify_gimple failed
0x11aad62 verify_gimple_in_cfg(function*, bool)
        ../../gcc/tree-cfg.cc:5561
0x1073dae execute_function_todo
        ../../gcc/passes.cc:2085
0x107431a execute_todo
        ../../gcc/passes.cc:2139

---

import gcc.builtins : va_list = __builtin_va_list;
struct S
{
    this(va_list ap)
    {
        this.ap = ap;
    }
    va_list ap;
}

---

Assigning a va_list parameter (static array saturated to a pointer on x86_64)
to a field (static array on x86_64) fails miserably to pass tree checks.

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

* [Bug d/110712] d: ICE: verify_gimple_failed (conversion of register to a different size in 'view_convert_expr')
  2023-07-18 10:37 [Bug d/110712] New: d: ICE: verify_gimple_failed (conversion of register to a different size in 'view_convert_expr') ibuclaw at gdcproject dot org
@ 2023-07-18 11:55 ` rguenth at gcc dot gnu.org
  2023-07-19 15:16 ` ibuclaw at gdcproject dot org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-07-18 11:55 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
this_2(D)->ap = VIEW_CONVERT_EXPR<struct [1]>(ap_3(D));

it looks odd since ap_3(D) is a is_gimple_reg but a struct[1] definitely
would not.  Maybe you are missing a dereference here?  In C
struct[1] would decay to a pointer so

 this.ap = ap;

wouldn't work (besides that va_list copying requires va_copy).

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

* [Bug d/110712] d: ICE: verify_gimple_failed (conversion of register to a different size in 'view_convert_expr')
  2023-07-18 10:37 [Bug d/110712] New: d: ICE: verify_gimple_failed (conversion of register to a different size in 'view_convert_expr') ibuclaw at gdcproject dot org
  2023-07-18 11:55 ` [Bug d/110712] " rguenth at gcc dot gnu.org
@ 2023-07-19 15:16 ` ibuclaw at gdcproject dot org
  2023-07-19 15:24 ` ibuclaw at gdcproject dot org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: ibuclaw at gdcproject dot org @ 2023-07-19 15:16 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Iain Buclaw <ibuclaw at gdcproject dot org> ---
(In reply to Richard Biener from comment #1)
> this_2(D)->ap = VIEW_CONVERT_EXPR<struct [1]>(ap_3(D));
> 
> it looks odd since ap_3(D) is a is_gimple_reg but a struct[1] definitely
> would not.  Maybe you are missing a dereference here?  In C
> struct[1] would decay to a pointer so
> 
>  this.ap = ap;
> 
> wouldn't work (besides that va_list copying requires va_copy).

Static arrays in D are passed around by value, rather than decaying to a
pointer. However va_list is an inconsistent type on this front.

In some D compilers, it's always a pointer type to get around the
incompatibility with C/C++ - though this requires locals and fields to be
specially initialized before being passed to va_start() or va_copy().

i.e, underneath the hood it does:
---
void va_start(T)(out va_list ap, ref T parmn,
                 va_list storage = alloca(__va_list_tag.sizeof))
{
    ap = storage;
    // initialize *ap
}

void va_copy(out va_list ap, va_list src,
             va_list storage = alloca(__va_list_tag.sizeof))
{
    ap = storage;
    // copy *src.
}
---

GDC doesn't do this, rather - in a way that mimics C/C++ - va_list static
arrays are decayed to a pointer type when used as a parameter, but semantically
it's still treated as a static array.

I think some extra errors during the D front-end codegen pass are likely the
most appropriate thing to do here, as you say, such things are rejected by
C/C++, so GDC ought to reject them too.

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

* [Bug d/110712] d: ICE: verify_gimple_failed (conversion of register to a different size in 'view_convert_expr')
  2023-07-18 10:37 [Bug d/110712] New: d: ICE: verify_gimple_failed (conversion of register to a different size in 'view_convert_expr') ibuclaw at gdcproject dot org
  2023-07-18 11:55 ` [Bug d/110712] " rguenth at gcc dot gnu.org
  2023-07-19 15:16 ` ibuclaw at gdcproject dot org
@ 2023-07-19 15:24 ` ibuclaw at gdcproject dot org
  2023-10-29 19:21 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: ibuclaw at gdcproject dot org @ 2023-07-19 15:24 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Iain Buclaw <ibuclaw at gdcproject dot org> ---
(In reply to Iain Buclaw from comment #2)
> I think some extra errors during the D front-end codegen pass are likely the
> most appropriate thing to do here, as you say, such things are rejected by
> C/C++, so GDC ought to reject them too.
This might be reviewed in future, so maybe D does define va_list as a pointer
type on targets where it's a static array.  But IIRC, this requires some care
to ensure that it doesn't start generating code inconsistently with what the
middle-end/back-end expect.

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

* [Bug d/110712] d: ICE: verify_gimple_failed (conversion of register to a different size in 'view_convert_expr')
  2023-07-18 10:37 [Bug d/110712] New: d: ICE: verify_gimple_failed (conversion of register to a different size in 'view_convert_expr') ibuclaw at gdcproject dot org
                   ` (2 preceding siblings ...)
  2023-07-19 15:24 ` ibuclaw at gdcproject dot org
@ 2023-10-29 19:21 ` cvs-commit at gcc dot gnu.org
  2023-10-29 19:23 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-10-29 19:21 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Iain Buclaw <ibuclaw@gcc.gnu.org>:

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

commit r14-4997-gea8ffdcadb388b531adf4772287e7987a82a84b7
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Sun Oct 29 20:13:14 2023 +0100

    d: Fix ICE: verify_gimple_failed (conversion of register to a different
size in 'view_convert_expr')

    Static arrays in D are passed around by value, rather than decaying to a
    pointer.  On x86_64 __builtin_va_list is an exception to this rule, but
    semantically it's still treated as a static array.

    This makes certain assignment operations fail due a mismatch in types.
    As all examples in the test program are rejected by C/C++ front-ends,
    these are now errors in D too to be consistent.

            PR d/110712

    gcc/d/ChangeLog:

            * d-codegen.cc (d_build_call): Update call to convert_for_argument.
            * d-convert.cc (is_valist_parameter_type): New function.
            (check_valist_conversion): New function.
            (convert_for_assignment): Update signature.  Add check whether
            assigning va_list is permissible.
            (convert_for_argument): Likewise.
            * d-tree.h (convert_for_assignment): Update signature.
            (convert_for_argument): Likewise.
            * expr.cc (ExprVisitor::visit (AssignExp *)): Update call to
            convert_for_assignment.

    gcc/testsuite/ChangeLog:

            * gdc.dg/pr110712.d: New test.

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

* [Bug d/110712] d: ICE: verify_gimple_failed (conversion of register to a different size in 'view_convert_expr')
  2023-07-18 10:37 [Bug d/110712] New: d: ICE: verify_gimple_failed (conversion of register to a different size in 'view_convert_expr') ibuclaw at gdcproject dot org
                   ` (3 preceding siblings ...)
  2023-10-29 19:21 ` cvs-commit at gcc dot gnu.org
@ 2023-10-29 19:23 ` cvs-commit at gcc dot gnu.org
  2023-10-29 19:23 ` cvs-commit at gcc dot gnu.org
  2023-10-29 19:25 ` ibuclaw at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-10-29 19:23 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Iain Buclaw
<ibuclaw@gcc.gnu.org>:

https://gcc.gnu.org/g:46024d05a2cbbc1c2397e5728a98f90449b20ca4

commit r13-7992-g46024d05a2cbbc1c2397e5728a98f90449b20ca4
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Sun Oct 29 20:13:14 2023 +0100

    d: Fix ICE: verify_gimple_failed (conversion of register to a different
size in 'view_convert_expr')

    Static arrays in D are passed around by value, rather than decaying to a
    pointer.  On x86_64 __builtin_va_list is an exception to this rule, but
    semantically it's still treated as a static array.

    This makes certain assignment operations fail due a mismatch in types.
    As all examples in the test program are rejected by C/C++ front-ends,
    these are now errors in D too to be consistent.

            PR d/110712

    gcc/d/ChangeLog:

            * d-codegen.cc (d_build_call): Update call to convert_for_argument.
            * d-convert.cc (is_valist_parameter_type): New function.
            (check_valist_conversion): New function.
            (convert_for_assignment): Update signature.  Add check whether
            assigning va_list is permissible.
            (convert_for_argument): Likewise.
            * d-tree.h (convert_for_assignment): Update signature.
            (convert_for_argument): Likewise.
            * expr.cc (ExprVisitor::visit (AssignExp *)): Update call to
            convert_for_assignment.

    gcc/testsuite/ChangeLog:

            * gdc.dg/pr110712.d: New test.

    (cherry picked from commit ea8ffdcadb388b531adf4772287e7987a82a84b7)

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

* [Bug d/110712] d: ICE: verify_gimple_failed (conversion of register to a different size in 'view_convert_expr')
  2023-07-18 10:37 [Bug d/110712] New: d: ICE: verify_gimple_failed (conversion of register to a different size in 'view_convert_expr') ibuclaw at gdcproject dot org
                   ` (4 preceding siblings ...)
  2023-10-29 19:23 ` cvs-commit at gcc dot gnu.org
@ 2023-10-29 19:23 ` cvs-commit at gcc dot gnu.org
  2023-10-29 19:25 ` ibuclaw at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-10-29 19:23 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Iain Buclaw
<ibuclaw@gcc.gnu.org>:

https://gcc.gnu.org/g:77f7d469e923f2bb1d21d3875290ce738262d42b

commit r12-9951-g77f7d469e923f2bb1d21d3875290ce738262d42b
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Sun Oct 29 20:13:14 2023 +0100

    d: Fix ICE: verify_gimple_failed (conversion of register to a different
size in 'view_convert_expr')

    Static arrays in D are passed around by value, rather than decaying to a
    pointer.  On x86_64 __builtin_va_list is an exception to this rule, but
    semantically it's still treated as a static array.

    This makes certain assignment operations fail due a mismatch in types.
    As all examples in the test program are rejected by C/C++ front-ends,
    these are now errors in D too to be consistent.

            PR d/110712

    gcc/d/ChangeLog:

            * d-codegen.cc (d_build_call): Update call to convert_for_argument.
            * d-convert.cc (is_valist_parameter_type): New function.
            (check_valist_conversion): New function.
            (convert_for_assignment): Update signature.  Add check whether
            assigning va_list is permissible.
            (convert_for_argument): Likewise.
            * d-tree.h (convert_for_assignment): Update signature.
            (convert_for_argument): Likewise.
            * expr.cc (ExprVisitor::visit (AssignExp *)): Update call to
            convert_for_assignment.

    gcc/testsuite/ChangeLog:

            * gdc.dg/pr110712.d: New test.

    (cherry picked from commit ea8ffdcadb388b531adf4772287e7987a82a84b7)

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

* [Bug d/110712] d: ICE: verify_gimple_failed (conversion of register to a different size in 'view_convert_expr')
  2023-07-18 10:37 [Bug d/110712] New: d: ICE: verify_gimple_failed (conversion of register to a different size in 'view_convert_expr') ibuclaw at gdcproject dot org
                   ` (5 preceding siblings ...)
  2023-10-29 19:23 ` cvs-commit at gcc dot gnu.org
@ 2023-10-29 19:25 ` ibuclaw at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: ibuclaw at gcc dot gnu.org @ 2023-10-29 19:25 UTC (permalink / raw)
  To: gcc-bugs

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

ibuclaw at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
                 CC|                            |ibuclaw at gcc dot gnu.org
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #7 from ibuclaw at gcc dot gnu.org ---
Fix committed and backported.

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

end of thread, other threads:[~2023-10-29 19:25 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-18 10:37 [Bug d/110712] New: d: ICE: verify_gimple_failed (conversion of register to a different size in 'view_convert_expr') ibuclaw at gdcproject dot org
2023-07-18 11:55 ` [Bug d/110712] " rguenth at gcc dot gnu.org
2023-07-19 15:16 ` ibuclaw at gdcproject dot org
2023-07-19 15:24 ` ibuclaw at gdcproject dot org
2023-10-29 19:21 ` cvs-commit at gcc dot gnu.org
2023-10-29 19:23 ` cvs-commit at gcc dot gnu.org
2023-10-29 19:23 ` cvs-commit at gcc dot gnu.org
2023-10-29 19:25 ` ibuclaw 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).