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

            Bug ID: 66201
           Summary: [avr] ICE in avr_print_operand: Bad address
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: senthil_kumar.selvaraj at atmel dot com
                CC: gjl at gcc dot gnu.org
  Target Milestone: ---
            Target: avr

gcc.dg/pr57134.c fails for attiny40 (and for atmega1280 with -ffixed-30) with a
bad address ICE in avr_print_operand (see stack trace below).

avr_print_operand generates the ICE if the base register is X and the RTX code
is PLUS. The testcase uses inline assembly, like so

static __inline__ __attribute__((always_inline)) int64_t
atomic64_read(const atomic64_t *v)
{
 int64_t t;
 __asm__ __volatile__("# %0, %1" : "=r"(t) : "m"(v->counter));
 return t;
}

and the RTX looks like this

(insn 16 42 43 2 (set (reg:DI 20 r20)
        (asm_operands/v:DI ("# %0, %1") ("=r") 0 [
                (mem:DI (plus:HI (reg:HI 26 r26)
                        (const_int 4 [0x4])) [1 MEM[(const struct atomic64_t
*)_5].counter+0 S8 A32])
            ]
             [
                (asm_input:DI ("m")
/home/saaadhu/code/git/gcc/gcc/testsuite/gcc.dg/pr57134.c:21)
            ]
             [] /home/saaadhu/code/git/gcc/gcc/testsuite/gcc.dg/pr57134.c:21))
/home/saaadhu/code/git/gcc/gcc/testsuite/gcc.dg/pr57134.c:21 -1
     (nil))

Even worse, AVR_TINY does not have LDD/STD at all.

Could this be be because avr_legitimate_address_p returns ok even for such
RTXes? Perhaps it should reject MEM RTXes with base + offset for AVR_TINY, and
those with base reg as X for others?

#1  0x000000000104065a in avr_print_operand (file=0x1976ab0, x=0x7ffff6a023c0,
code=0) at /home/saaadhu/code/git/gcc/gcc/config/avr/avr.c:2412
#2  0x000000000092c3d0 in output_operand (x=0x7ffff6a023c0, code=0) at
/home/saaadhu/code/git/gcc/gcc/final.c:3881
#3  0x000000000092c034 in output_asm_insn (templ=0x7ffff69f0700 "# %0, %1",
operands=0x7fffffffdf10) at /home/saaadhu/code/git/gcc/gcc/final.c:3797
#4  0x0000000000929cc0 in final_scan_insn (insn=0x7ffff69f75c0, file=0x1976ab0,
optimize_p=2, nopeepholes=0, seen=0x7fffffffe194) at
/home/saaadhu/code/git/gcc/gcc/final.c:2665
#5  0x00000000009287cb in final (first=0x7ffff69ed578, file=0x1976ab0,
optimize_p=2) at /home/saaadhu/code/git/gcc/gcc/final.c:2086
#6  0x000000000092d54e in rest_of_handle_final () at
/home/saaadhu/code/git/gcc/gcc/final.c:4479
#7  0x000000000092d821 in (anonymous namespace)::pass_final::execute
(this=0x199be90) at /home/saaadhu/code/git/gcc/gcc/final.c:4554
#8  0x0000000000c16b79 in execute_one_pass (pass=0x199be90) at
/home/saaadhu/code/git/gcc/gcc/passes.c:2317
#9  0x0000000000c16dc3 in execute_pass_list_1 (pass=0x199be90) at
/home/saaadhu/code/git/gcc/gcc/passes.c:2370
#10 0x0000000000c16df4 in execute_pass_list_1 (pass=0x199ba10) at
/home/saaadhu/code/git/gcc/gcc/passes.c:2371
#11 0x0000000000c16df4 in execute_pass_list_1 (pass=0x1999f70) at
/home/saaadhu/code/git/gcc/gcc/passes.c:2371
#12 0x0000000000c16e31 in execute_pass_list (fn=0x7ffff69f5888, pass=0x1996d90)
at /home/saaadhu/code/git/gcc/gcc/passes.c:2381
#13 0x000000000082ca10 in cgraph_node::expand (this=0x7ffff68d6900) at
/home/saaadhu/code/git/gcc/gcc/cgraphunit.c:1895
#14 0x000000000082d044 in expand_all_functions () at
/home/saaadhu/code/git/gcc/gcc/cgraphunit.c:2031
#15 0x000000000082db5c in symbol_table::compile (this=0x7ffff68d8000) at
/home/saaadhu/code/git/gcc/gcc/cgraphunit.c:2384
#16 0x000000000082dd08 in symbol_table::finalize_compilation_unit
(this=0x7ffff68d8000) at /home/saaadhu/code/git/gcc/gcc/cgraphunit.c:2461
#17 0x000000000068729f in c_write_global_declarations () at
/home/saaadhu/code/git/gcc/gcc/c/c-decl.c:10828
#18 0x0000000000ccfab2 in compile_file () at
/home/saaadhu/code/git/gcc/gcc/toplev.c:611
#19 0x0000000000cd1e13 in do_compile () at
/home/saaadhu/code/git/gcc/gcc/toplev.c:2079
#20 0x0000000000cd2061 in toplev::main (this=0x7fffffffe4b0, argc=26,
argv=0x7fffffffe5b8) at /home/saaadhu/code/git/gcc/gcc/toplev.c:2180
#21 0x000000000124fb7e in main (argc=26, argv=0x7fffffffe5b8) at
/home/saaadhu/code/git/gcc/gcc/main.c:39

Reply via email to