public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/57586] New: ICE when expanding volatile asm using unaligned pointer
@ 2013-06-11 14:24 jgreenhalgh at gcc dot gnu.org
  2013-06-11 14:25 ` [Bug target/57586] " jgreenhalgh at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: jgreenhalgh at gcc dot gnu.org @ 2013-06-11 14:24 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57586

            Bug ID: 57586
           Summary: ICE when expanding volatile asm using unaligned
                    pointer
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jgreenhalgh at gcc dot gnu.org

Created attachment 30290
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30290&action=edit
Reduced testcase

Using built-in specs.
COLLECT_GCC=../build-arm-none-eabi/install/bin/arm-none-eabi-gcc
COLLECT_LTO_WRAPPER=/work/build-arm-none-eabi/install/libexec/gcc/arm-none-eabi/4.9.0/lto-wrapper
Target: arm-none-eabi
Configured with: /work/src/gcc/configure --target=arm-none-eabi
--prefix=/work/build-arm-none-eabi/install
--with-gmp=/work/build-arm-none-eabi/host-tools
--with-mpfr=/work/build-arm-none-eabi/host-tools
--with-mpc=/work/build-arm-none-eabi/host-tools --with-pkgversion=unknown
--disable-shared --disable-nls --disable-threads --disable-tls
--enable-checking=yes --enable-languages=c,c++ --with-newlib
Thread model: single
gcc version 4.9.0 20130326 (experimental) (unknown)

../build-arm-none-eabi/install/bin/arm-none-eabi-gcc ../testcases/pr-reduced.c
-O1
../testcases/pr-reduced.c: In function 'foo':
../testcases/pr-reduced.c:12:3: error: output number 0 not directly addressable
   __asm__ __volatile__("": "+m" (c->x) : "r" (&c->x) : );
   ^
../testcases/pr-reduced.c:12:3: internal compiler error: in
expand_asm_operands, at stmt.c:910
0x8c1be8 expand_asm_operands
    /work/oban-dev/src/gcc/gcc/stmt.c:910
0x8c28a7 expand_asm_stmt(gimple_statement_d*)
    /work/oban-dev/src/gcc/gcc/stmt.c:1151
0x5dfe5f expand_gimple_stmt_1
    /work/oban-dev/src/gcc/gcc/cfgexpand.c:2154
0x5dfe5f expand_gimple_stmt
    /work/oban-dev/src/gcc/gcc/cfgexpand.c:2309
0x5e1b69 expand_gimple_basic_block
    /work/oban-dev/src/gcc/gcc/cfgexpand.c:4143
0x5e4a33 gimple_expand_cfg
    /work/oban-dev/src/gcc/gcc/cfgexpand.c:4662
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.

No difference with -mno-unaligned-access or -maligned-access.

A manifestation of this bug prevents a Linux Kernel build.


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

* [Bug target/57586] ICE when expanding volatile asm using unaligned pointer
  2013-06-11 14:24 [Bug target/57586] New: ICE when expanding volatile asm using unaligned pointer jgreenhalgh at gcc dot gnu.org
@ 2013-06-11 14:25 ` jgreenhalgh at gcc dot gnu.org
  2013-06-11 14:53 ` jgreenhalgh at gcc dot gnu.org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jgreenhalgh at gcc dot gnu.org @ 2013-06-11 14:25 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57586

--- Comment #1 from jgreenhalgh at gcc dot gnu.org ---
A bisect shows that this bug first occurs after r197095:

    2013-03-26  Richard Biener  <rguenther@suse.de>

        * emit-rtl.c (set_mem_attributes_minus_bitpos): Remove
        alignment computations and rely on get_object_alignment_1
        for the !TYPE_P case.
        Commonize DECL/COMPONENT_REF handling in the ARRAY_REF path.


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

* [Bug target/57586] ICE when expanding volatile asm using unaligned pointer
  2013-06-11 14:24 [Bug target/57586] New: ICE when expanding volatile asm using unaligned pointer jgreenhalgh at gcc dot gnu.org
  2013-06-11 14:25 ` [Bug target/57586] " jgreenhalgh at gcc dot gnu.org
@ 2013-06-11 14:53 ` jgreenhalgh at gcc dot gnu.org
  2013-06-11 14:56 ` rguenth at gcc dot gnu.org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jgreenhalgh at gcc dot gnu.org @ 2013-06-11 14:53 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57586

jgreenhalgh at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jgreenhalgh at gcc dot gnu.org

--- Comment #2 from jgreenhalgh at gcc dot gnu.org ---
Created attachment 30292
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30292&action=edit
Working testcase

Modifying the '1' in:

  counter *c = &((counter_wrapper *)(1))->y; 

To something more aligned like a '4' as in the attached file and in:

  counter *c = &((counter_wrapper *)(4))->y; 

causes compilation to proceed as expected without an ICE.


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

* [Bug target/57586] ICE when expanding volatile asm using unaligned pointer
  2013-06-11 14:24 [Bug target/57586] New: ICE when expanding volatile asm using unaligned pointer jgreenhalgh at gcc dot gnu.org
  2013-06-11 14:25 ` [Bug target/57586] " jgreenhalgh at gcc dot gnu.org
  2013-06-11 14:53 ` jgreenhalgh at gcc dot gnu.org
@ 2013-06-11 14:56 ` rguenth at gcc dot gnu.org
  2013-06-11 15:25 ` jgreenhalgh at gcc dot gnu.org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-06-11 14:56 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57586

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING
   Last reconfirmed|                            |2013-06-11
                 CC|rguenther at suse dot de           |rguenth at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
Well, the testcase is simply invalid for a STRICT_ALIGNMENT target I suppose.

Does the same thing happen for a packed struct counter/counter_wrapper?


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

* [Bug target/57586] ICE when expanding volatile asm using unaligned pointer
  2013-06-11 14:24 [Bug target/57586] New: ICE when expanding volatile asm using unaligned pointer jgreenhalgh at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2013-06-11 14:56 ` rguenth at gcc dot gnu.org
@ 2013-06-11 15:25 ` jgreenhalgh at gcc dot gnu.org
  2013-06-11 15:28 ` rguenther at suse dot de
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jgreenhalgh at gcc dot gnu.org @ 2013-06-11 15:25 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57586

--- Comment #4 from jgreenhalgh at gcc dot gnu.org ---
Created attachment 30293
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30293&action=edit
Less reduced failing testcase

Yes, the same thing happens for packed versions of those structs. Perhaps the
attached, less-reduced, version of the testcase will make the issue more clear.
This expanded testcase fails with the same error and ICE:

../build-arm-none-eabi/install/bin/arm-none-eabi-gcc
../testcases/pr-less-reduced.c -O1 -Wall
../testcases/pr-less-reduced.c: In function 'inet_rtm_getroute':
../testcases/pr-less-reduced.c:22:3: error: output number 0 not directly
addressable
   __asm__ __volatile__(""
   ^
../testcases/pr-less-reduced.c:22:3: internal compiler error: in
expand_asm_operands, at stmt.c:910
0x8c1be8 expand_asm_operands
    /work/oban-dev/src/gcc/gcc/stmt.c:910
0x8c28a7 expand_asm_stmt(gimple_statement_d*)
    /work/oban-dev/src/gcc/gcc/stmt.c:1151
0x5dfe5f expand_gimple_stmt_1
    /work/oban-dev/src/gcc/gcc/cfgexpand.c:2154
0x5dfe5f expand_gimple_stmt
    /work/oban-dev/src/gcc/gcc/cfgexpand.c:2309
0x5e1b69 expand_gimple_basic_block
    /work/oban-dev/src/gcc/gcc/cfgexpand.c:4143
0x5e4a33 gimple_expand_cfg
    /work/oban-dev/src/gcc/gcc/cfgexpand.c:4662
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.


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

* [Bug target/57586] ICE when expanding volatile asm using unaligned pointer
  2013-06-11 14:24 [Bug target/57586] New: ICE when expanding volatile asm using unaligned pointer jgreenhalgh at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2013-06-11 15:25 ` jgreenhalgh at gcc dot gnu.org
@ 2013-06-11 15:28 ` rguenther at suse dot de
  2013-06-14  6:43 ` [Bug middle-end/57586] " amodra at gmail dot com
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenther at suse dot de @ 2013-06-11 15:28 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57586

--- Comment #5 from rguenther at suse dot de <rguenther at suse dot de> ---
On Tue, 11 Jun 2013, jgreenhalgh at gcc dot gnu.org wrote:

> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57586
> 
> --- Comment #4 from jgreenhalgh at gcc dot gnu.org ---
> Created attachment 30293
>   --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30293&action=edit
> Less reduced failing testcase
> 
> Yes, the same thing happens for packed versions of those structs. Perhaps the
> attached, less-reduced, version of the testcase will make the issue more clear.
> This expanded testcase fails with the same error and ICE:
> 
> ../build-arm-none-eabi/install/bin/arm-none-eabi-gcc
> ../testcases/pr-less-reduced.c -O1 -Wall
> ../testcases/pr-less-reduced.c: In function 'inet_rtm_getroute':
> ../testcases/pr-less-reduced.c:22:3: error: output number 0 not directly
> addressable
>    __asm__ __volatile__(""
>    ^
> ../testcases/pr-less-reduced.c:22:3: internal compiler error: in
> expand_asm_operands, at stmt.c:910
> 0x8c1be8 expand_asm_operands
>     /work/oban-dev/src/gcc/gcc/stmt.c:910
> 0x8c28a7 expand_asm_stmt(gimple_statement_d*)
>     /work/oban-dev/src/gcc/gcc/stmt.c:1151
> 0x5dfe5f expand_gimple_stmt_1
>     /work/oban-dev/src/gcc/gcc/cfgexpand.c:2154
> 0x5dfe5f expand_gimple_stmt
>     /work/oban-dev/src/gcc/gcc/cfgexpand.c:2309
> 0x5e1b69 expand_gimple_basic_block
>     /work/oban-dev/src/gcc/gcc/cfgexpand.c:4143
> 0x5e4a33 gimple_expand_cfg
>     /work/oban-dev/src/gcc/gcc/cfgexpand.c:4662
> Please submit a full bug report,
> with preprocessed source if appropriate.
> Please include the complete backtrace with any bug report.
> See <http://gcc.gnu.org/bugs.html> for instructions.

I suppose the question is why

      /* EXPAND_INITIALIZER will not generate code for valid initializer
         constants, but will still generate code for other types of 
operand.
         This is the behavior we want for constant constraints.  */
      op = expand_expr (val, NULL_RTX, VOIDmode,
                        allows_reg ? EXPAND_NORMAL
                        : allows_mem ? EXPAND_MEMORY
                        : EXPAND_INITIALIZER);

thus, EXPAND_MEMORY returns a non-MEM_P (does it?).


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

* [Bug middle-end/57586] ICE when expanding volatile asm using unaligned pointer
  2013-06-11 14:24 [Bug target/57586] New: ICE when expanding volatile asm using unaligned pointer jgreenhalgh at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2013-06-11 15:28 ` rguenther at suse dot de
@ 2013-06-14  6:43 ` amodra at gmail dot com
  2013-09-24 11:32 ` amodra at gcc dot gnu.org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: amodra at gmail dot com @ 2013-06-14  6:43 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57586

Alan Modra <amodra at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |ASSIGNED
                 CC|                            |amodra at gmail dot com
          Component|target                      |middle-end
           Assignee|unassigned at gcc dot gnu.org      |amodra at gmail dot com
           Severity|major                       |normal


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

* [Bug middle-end/57586] ICE when expanding volatile asm using unaligned pointer
  2013-06-11 14:24 [Bug target/57586] New: ICE when expanding volatile asm using unaligned pointer jgreenhalgh at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2013-06-14  6:43 ` [Bug middle-end/57586] " amodra at gmail dot com
@ 2013-09-24 11:32 ` amodra at gcc dot gnu.org
  2013-09-24 11:34 ` amodra at gmail dot com
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: amodra at gcc dot gnu.org @ 2013-09-24 11:32 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57586

--- Comment #6 from Alan Modra <amodra at gcc dot gnu.org> ---
Author: amodra
Date: Tue Sep 24 11:32:28 2013
New Revision: 202866

URL: http://gcc.gnu.org/viewcvs?rev=202866&root=gcc&view=rev
Log:
    PR middle-end/57134
    PR middle-end/57586
    * stmt.c (expand_asm_operands): Call expand_expr with
    EXPAND_MEMORY for output operands that disallow regs.  Don't
    use EXPAND_WRITE on inout operands.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/stmt.c


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

* [Bug middle-end/57586] ICE when expanding volatile asm using unaligned pointer
  2013-06-11 14:24 [Bug target/57586] New: ICE when expanding volatile asm using unaligned pointer jgreenhalgh at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2013-09-24 11:32 ` amodra at gcc dot gnu.org
@ 2013-09-24 11:34 ` amodra at gmail dot com
  2013-09-29 22:12 ` bernd.edlinger at hotmail dot de
  2013-10-01  6:40 ` amodra at gmail dot com
  9 siblings, 0 replies; 11+ messages in thread
From: amodra at gmail dot com @ 2013-09-24 11:34 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57586

Alan Modra <amodra at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED
   Target Milestone|---                         |4.9.0

--- Comment #7 from Alan Modra <amodra at gmail dot com> ---
Fixed


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

* [Bug middle-end/57586] ICE when expanding volatile asm using unaligned pointer
  2013-06-11 14:24 [Bug target/57586] New: ICE when expanding volatile asm using unaligned pointer jgreenhalgh at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2013-09-24 11:34 ` amodra at gmail dot com
@ 2013-09-29 22:12 ` bernd.edlinger at hotmail dot de
  2013-10-01  6:40 ` amodra at gmail dot com
  9 siblings, 0 replies; 11+ messages in thread
From: bernd.edlinger at hotmail dot de @ 2013-09-29 22:12 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57586

Bernd Edlinger <bernd.edlinger at hotmail dot de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bernd.edlinger at hotmail dot de

--- Comment #8 from Bernd Edlinger <bernd.edlinger at hotmail dot de> ---
(In reply to Alan Modra from comment #7)
> Fixed

Sorry, this change does not look right,
because you should not use EXPAND_NORMAL for
an output parameter, even if it is no inout.


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

* [Bug middle-end/57586] ICE when expanding volatile asm using unaligned pointer
  2013-06-11 14:24 [Bug target/57586] New: ICE when expanding volatile asm using unaligned pointer jgreenhalgh at gcc dot gnu.org
                   ` (8 preceding siblings ...)
  2013-09-29 22:12 ` bernd.edlinger at hotmail dot de
@ 2013-10-01  6:40 ` amodra at gmail dot com
  9 siblings, 0 replies; 11+ messages in thread
From: amodra at gmail dot com @ 2013-10-01  6:40 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57586

--- Comment #9 from Alan Modra <amodra at gmail dot com> ---
Once upon a time I understood this code quite well, but it's been a while since
I looked at it in detail, and I'd forgotten that inout gets split to separate
input and output operands if a register is allowed.

So the code isn't wrong, but there was no need to do anything special for
inout.  I'll commit a cleanup as obvious.


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

end of thread, other threads:[~2013-10-01  6:40 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-11 14:24 [Bug target/57586] New: ICE when expanding volatile asm using unaligned pointer jgreenhalgh at gcc dot gnu.org
2013-06-11 14:25 ` [Bug target/57586] " jgreenhalgh at gcc dot gnu.org
2013-06-11 14:53 ` jgreenhalgh at gcc dot gnu.org
2013-06-11 14:56 ` rguenth at gcc dot gnu.org
2013-06-11 15:25 ` jgreenhalgh at gcc dot gnu.org
2013-06-11 15:28 ` rguenther at suse dot de
2013-06-14  6:43 ` [Bug middle-end/57586] " amodra at gmail dot com
2013-09-24 11:32 ` amodra at gcc dot gnu.org
2013-09-24 11:34 ` amodra at gmail dot com
2013-09-29 22:12 ` bernd.edlinger at hotmail dot de
2013-10-01  6:40 ` amodra at gmail dot com

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