Bug 52472 - ICE: in convert_debug_memory_address, at cfgexpand.c:2491
Summary: ICE: in convert_debug_memory_address, at cfgexpand.c:2491
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: debug (show other bugs)
Version: 4.7.0
: P3 normal
Target Milestone: 5.0
Assignee: Not yet assigned to anyone
URL:
Keywords: addr-space, ice-on-valid-code
: 56792 (view as bug list)
Depends on:
Blocks:
 
Reported: 2012-03-03 19:37 UTC by Georg-Johann Lay
Modified: 2016-10-13 21:31 UTC (History)
3 users (show)

See Also:
Host:
Target: avr
Build:
Known to work:
Known to fail: 4.7.2, 4.8.1
Last reconfirmed: 2012-05-11 00:00:00


Attachments
ice-memx.c: C source (261 bytes, text/plain)
2012-03-03 19:38 UTC, Georg-Johann Lay
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Georg-Johann Lay 2012-03-03 19:37:57 UTC
typedef unsigned long uint32_t;
typedef unsigned int uint16_t;

extern const __memx unsigned int data[320][12];

#define pgm_read_word_far(addr)                 \
    (__extension__({                            \
        uint32_t __addr32 = (uint32_t)(addr);   \
        uint16_t __result;                      \
        __asm__("; much code"                   \
            : "=r" (__result)                   \
            : "r" (__addr32));                  \
        __result;                               \
    }))

int ice (void)
{
    return pgm_read_word_far (0x20000 + (unsigned long) &data[0][0]);
}

== Command Line ==

>> avr-gcc ice-memx.c -S -Os -g3 -v

== ICE ==

ice-memx.c: In function 'ice':
ice-memx.c:18:12: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
ice-memx.c:16:5: internal compiler error: in convert_debug_memory_address, at cfgexpand.c:2491


== Configure ==

Using built-in specs.
Target: avr
Configured with: ../gcc-trunk/configure --with-gmp=/usr/local --prefix=/usr/local/avr --target=avr --enable-languages=c,c++ --with-dwarf2 --disable-shared --disable-libada --disable-libssp --disable-nls
Thread model: single
gcc version 4.7.0 20120217 (experimental) (GCC) 
GNU C (GCC) version 4.7.0 20120217 (experimental) (avr)
	compiled by GNU C version 4.6.2, GMP version 5.0.4, MPFR version 3.1.0, MPC version 0.9
Comment 1 Georg-Johann Lay 2012-03-03 19:38:56 UTC
Created attachment 26820 [details]
ice-memx.c: C source
Comment 2 Richard Biener 2012-03-05 10:22:42 UTC
The !POINTERS_EXTEND_UNSIGNED path seems to be not implemented if it would
require codegen.  I suppose instead we should have a way of saying
"not possible" here?
Comment 3 Georg-Johann Lay 2012-03-05 10:32:26 UTC
I thought about setting POINTERS_EXTEND_UNSIGNED but am unsure about other side effects of that define.

Presumably, POINTERS_EXTEND_UNSIGNED is undefined because it was never needed before?

What do you think?
Comment 4 Georg-Johann Lay 2012-03-05 14:05:36 UTC
I tried 

#define POINTERS_EXTEND_UNSIGNED 1

but this runs into ICE some lines later in cfgexpand.c:2496

mode = PSI
as = 0
x = symbol_ref:PSI ("data")

Of course PSImode is not a valid pointer mode for generic address space.
Comment 5 Jakub Jelinek 2012-03-06 12:35:09 UTC
convert_debug_memory_address can just return NULL_RTX if it can't handle it.  Can't reproduce this though.
Comment 6 Georg-Johann Lay 2012-03-07 16:09:12 UTC
(In reply to comment #5)
> Can't reproduce this though.

Strange. I still see the ICE with current trunk. It's a 32 bit build and host; might this have an impact?
Comment 7 Georg-Johann Lay 2012-03-28 15:27:42 UTC
Reduced test-case: Compile with:

$ avr-gcc ice-memx.c -S -g -Os


extern const __memx unsigned data[][10];

unsigned long ice (void)
{
    unsigned long addr32;

    return addr32 = (unsigned long) data;
}
Comment 8 Georg-Johann Lay 2013-04-13 14:33:19 UTC
*** Bug 56792 has been marked as a duplicate of this bug. ***
Comment 9 Jeffrey A. Law 2014-06-05 18:35:14 UTC
Author: law
Date: Thu Jun  5 18:34:43 2014
New Revision: 211288

URL: http://gcc.gnu.org/viewcvs?rev=211288&root=gcc&view=rev
Log:
	PR target/52472
	* cfgexpand.c (expand_debug_expr): Use address space of nested
	TREE_TYPE for ADDR_EXPR and MEM_REF.

	PR target/52472
	* gcc.target/avr/pr52472.c: New test.

Added:
    trunk/gcc/testsuite/gcc.target/avr/pr52472.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/cfgexpand.c
    trunk/gcc/testsuite/ChangeLog
Comment 10 Andrew Pinski 2016-10-13 21:31:17 UTC
Fixed over 2 years ago but forgot to close.