Created attachment 43054 [details] Preprocessed file gcc version 8.0.0 20180107 (experimental) (GCC) gcc svn r256323 Target: avr Configured with: ../configure --target=avr --prefix=/usr/local/avr --disable-nls --enable-languages=c --disable-bootstrap --disable-libssp Cross compiled on host using x86_64-pc-linux-gnu v7.2.0 ICE while compiling avr-libc svn r2546 Command: avr-gcc -save-temps -DHAVE_CONFIG_H -I. -I../../.. -I../../../common -I../../../include -I../../../include -Wall -W -Wstrict-prototypes -mmcu=avr2 -D__COMPILING_AVR_LIBC__ -mcall-prologues -Os -MT asctime_r.o -MD -MP -MF .deps/asctime_r.Tpo -c -o asctime_r.o ../../../libc/time/asctime_r.c -Wextra during RTL pass: expand ../../../libc/time/asctime_r.c: In function 'asctime_r': ../../../libc/time/asctime_r.c:57:16: internal compiler error: in convert_memory_address_addr_space_1, at explow.c:300 buffer[i] = ascdays[d++]; ~~~~~~~~~~^~~~~~~~~~~~~~ 0x51b973 convert_memory_address_addr_space_1(scalar_int_mode, rtx_def*, unsigned char, bool, bool) ../../gcc/explow.c:300 0x7ab83a convert_memory_address_addr_space_1(scalar_int_mode, rtx_def*, unsigned char, bool, bool) ../../gcc/explow.c:474 0x7ab83a convert_memory_address_addr_space(scalar_int_mode, rtx_def*, unsigned char) ../../gcc/explow.c:402 0x7ab83a memory_address_addr_space(machine_mode, rtx_def*, unsigned char) ../../gcc/explow.c:416 0x791824 change_address_1 ../../gcc/emit-rtl.c:2288 0x7c200f expand_expr_real_1(tree_node*, rtx_def*, machine_mode, expand_modifier, rtx_def**, bool) ../../gcc/expr.c:10185 0x7c1a6c expand_expr_real_1(tree_node*, rtx_def*, machine_mode, expand_modifier, rtx_def**, bool) ../../gcc/expr.c:10586 0x7c492f expand_expr_real_1(tree_node*, rtx_def*, machine_mode, expand_modifier, rtx_def**, bool) ../../gcc/expr.c:9923 0x7cf6d3 store_expr_with_bounds(tree_node*, rtx_def*, int, bool, bool, tree_node*) ../../gcc/expr.c:5632 0x7d0f87 expand_assignment(tree_node*, tree_node*, bool) ../../gcc/expr.c:5400 0x6ad998 expand_gimple_stmt_1 ../../gcc/cfgexpand.c:3692 0x6ad998 expand_gimple_stmt ../../gcc/cfgexpand.c:3790 0x6afdf7 expand_gimple_basic_block ../../gcc/cfgexpand.c:5810 0x6b52ae execute ../../gcc/cfgexpand.c:6416
Confirmed for v8 with a reduced test case and -O for: const __memx char ascdays[] = "SunMonTueWedThuFriSat"; void asctime_r (int a, char *buffer) { buffer[0] = ascdays[a]; } v7 and v6 are ok.
...and this is a middle-end flaw because POINTERS_EXTEND_UNSIGNED states: [...] You need not define this macro [which is the case for avr] if the ptr_mode, Pmode and word_mode are all the same width [which is also true for avr]. https://gcc.gnu.org/onlinedocs/gcc-7.2.0/gccint/Storage-Layout.html#index-POINTERS_005fEXTEND_005fUNSIGNED Actually I don't see any readon for why an extension should be needed here as both targetm.addr_space.pointer_mode (__memx) and targetm.addr_space.address_mode (__memx) are PSImode.
Another regression test case (compile with -O): void code_to_ascii(char buf[1], unsigned int code) { __attribute__((used)) static const char __flash test[5]="ABCDE"; static const char __flash code_tab[32]="0123456789ABCDEFGHJKLMNPRSTUWXYZ"; buf[0]=code_tab[code]; } Variable "test" is correctly placed in section .progmem.data. Variable "code_tab" is incorrectly placed in section .rodata. This causes a problem for programs that are larger than 64KB in size. In my case, "code_to_ascii" is one of the last functions in my .c file, and therefore it is at the very end of the executable. Since "code_tab" appears next to "code_to_ascii" after the 64KB boundary, __flash no longer references the correct area in program memory. GCC 7.2 correctly places both variables in .progmem.data.
(In reply to gandalf from comment #3) > Another regression test case (compile with -O): > > void code_to_ascii(char buf[1], unsigned int code) > { > __attribute__((used)) > static const char __flash test[5]="ABCDE"; > > static const char __flash code_tab[32]="0123456789ABCDEFGHJKLMNPRSTUWXYZ"; > > buf[0]=code_tab[code]; > } > > Variable "code_tab" is incorrectly placed in section .rodata. Different issue, likely a target thing. Filed as PR83801.
Fixed by 256608. *** This bug has been marked as a duplicate of bug 83801 ***
Author: gjl Date: Mon Jan 15 10:04:32 2018 New Revision: 256687 URL: https://gcc.gnu.org/viewcvs?rev=256687&root=gcc&view=rev Log: PR c/83801 PR c/83729 * gcc.target/avr/torture/pr83729.c: New test. * gcc.target/avr/torture/pr83801.c: New test. Added: trunk/gcc/testsuite/gcc.target/avr/torture/pr83729.c trunk/gcc/testsuite/gcc.target/avr/torture/pr83801.c Modified: trunk/gcc/testsuite/ChangeLog