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

            Bug ID: 80082
           Summary: GCC incorrectly assumes Cortex-r[578] have 64-bit
                    single-copy atomic LDRD
           Product: gcc
           Version: 7.0.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: prakhar.bahuguna at arm dot com
  Target Milestone: ---

Created attachment 40992
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=40992&action=edit
Atomic load reproducer

GCC currently assumes that if your armv7* architecture has both arm and Thumb
division instructions then you have the LPAE extension. This causes the
compiler to assume that LDRD is single-copy atomic.

Cortex-R cores with ARM division are thus incorrectly treated as having LPAE.
This is a bug that leads to incorrect code that would likely to be difficult to
track down in the field (potential data corruption during contention).

Steps to reproduce:
* Compile atomic_load.c with arm-none-eabi-gcc -mcpu=cortex-r5 atomic_load.c -S
-O2 -o -
* Note that in the output, LDRD is used to load x instead of LDREXD, despite
LDRD not being single-copy atomic on Cortex-R profile. The same issue can be
reproduced for -mcpu=cortex-r7 and cortex-r8.

Reply via email to