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

            Bug ID: 122527
           Summary: [avr] Wrong code when reading from __flash1 without
                    ELPMx
           Product: gcc
           Version: 15.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gjl at gcc dot gnu.org
  Target Milestone: ---

long test4 (const __flash1 long *p)
{
    return *p;
}

$ avr-gcc -Os -mmcu=atmega103 -S -dp

generates:

test4:
        mov r30,r24      ;  25  [c=4 l=1]  movqi_insn/0
        mov r31,r25      ;  26  [c=4 l=1]  movqi_insn/0
        call __load_4    ;  20  [c=16 l=2]  *load_si_libgcc
        ...

which is wrong since __load_4 loads from __flash, not __flash1.

This issue only occurs on devices that have ELPM but no ELPMx, which is avr31:
ATmega103 and AT43USB320.

The problem is that avr.cc::avr_load_libgcc_p() returns true in that case, but
shouldn't.

Reply via email to