Bug 78554 - Internal Compiler Error in msp430 target with -mlarge, -O{s123}
Summary: Internal Compiler Error in msp430 target with -mlarge, -O{s123}
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 6.2.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-11-28 05:18 UTC by Andrew Wygle
Modified: 2020-05-18 13:07 UTC (History)
1 user (show)

See Also:
Host:
Target: msp430
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Wygle 2016-11-28 05:18:24 UTC
When compiling code for an MSP430 using large model (-mlarge) and any optimization above 0, assigning the address of a global variable to an __int20 unsigned (__UINTPTR_TYPE__) which is part of a structure causes an internal compiler error, as in the following .i file:

# 1 "test.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "test.c"
unsigned char test_val = 0;

typedef __int20 unsigned reg_t;

struct holds_reg {
  reg_t r0;
};

struct holds_reg ex = { 0 };

int main() {
  ex.r0 = (reg_t)(&test_val);
  return 0;
}


The invocation of msp430-elf-gcc:


msp430-elf-gcc -mmcu=msp430fr5969 -mlarge -O1 -save-temps test.c
test.c: In function ‘main’:
test.c:14:1: error: unrecognizable insn:
 }
 ^
(insn 6 5 8 2 (set (mem/c:HI (reg/f:PSI 25) [2 ex.r0+0 S2 A16])
        (subreg:HI (symbol_ref:PSI ("test_val") [flags 0x2] <var_decl 0x7fb37aa82090 test_val>) 0)) test.c:12 -1
     (nil))
test.c:14:1: internal compiler error: in extract_insn, at recog.c:2287
0x8aa29a _fatal_insn(char const*, rtx_def const*, char const*, int, char const*)
        ../../gcc-6.2.0/gcc/rtl-error.c:108
0x8aa2c9 _fatal_insn_not_found(rtx_def const*, char const*, int, char const*)
        ../../gcc-6.2.0/gcc/rtl-error.c:116
0x882087 extract_insn(rtx_insn*)
        ../../gcc-6.2.0/gcc/recog.c:2287
0x6e1ba5 instantiate_virtual_regs_in_insn
        ../../gcc-6.2.0/gcc/function.c:1582
0x6e1ba5 instantiate_virtual_regs
        ../../gcc-6.2.0/gcc/function.c:1950
0x6e1ba5 execute
        ../../gcc-6.2.0/gcc/function.c:1999
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.


Some things which don't cause this error include assigning the address of a variable which is local to main or assigning the address directly to a __int20 unsigned which is not part of a struct. The error does not occur on -msmall or on -O0.
Comment 1 Jozef Lawrynowicz 2019-02-05 23:39:10 UTC
The test case no longer ICEs on trunk, can someone please close this.

Thanks,
Jozef
Comment 2 Jozef Lawrynowicz 2020-05-18 13:07:41 UTC
Fixed.