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

            Bug ID: 101422
           Summary: register variable uninitialised before passing to asm
           Product: gcc
           Version: 10.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: simon.willcocks at gmx dot de
  Target Milestone: ---

Created attachment 51132
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51132&action=edit
Source code fragment

The attached program fragment sets up multiple register variables associated
with specific ARM registers and runs some assembly code that makes use of them.
With -Os (and a generated memset to initialise a local array), some registers
are not correctly initialised, notably r0, which is corrupted by the address of
the array, and r3 which is not initialised at all before the asm instruction.
r4, however, is correctly initialised.

Affects arm-linux-gnueabi-gcc-10, arm-linux-gnueabi-gcc-9, and
arm-linux-gnueabi-gcc-8.

for opt in 1 2 3 4 s ; do for vers in 8 9 10 ; do arm-linux-gnueabi-gcc-$vers
problem.c -S -O$opt -Wall -Wextra -o problem-$vers-$opt.s ; done ; done

To see the problem (the most obvious feature, at least):

for i in problem*.s ; do echo ; echo $i ; grep r3 $i ; done

In all three versions with -Os, the first mention of r3 is the asm code.

Reply via email to