4.9 series reproducibly corrupts register R7
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
GNU Arm Embedded Toolchain |
Confirmed
|
Undecided
|
Unassigned |
Bug Description
Host OS is windows 8.1 64 bit. Toolchains were all prebuilt
Target processor is an Arm Cortex M0, specifically a Nordic Semiconductor NRF51422_xxAC.
Language is C.
Bug is reproducible on all three of the 2015 4.9.3 series. Does not occur on 4.8 2014q3.
Here is a minimal test case the demonstrates the issue:
Begin cut and paste of "r7lost.c"
//This is a minimal test case to demonstrate a believed bug.
//Host platform is Windows 8.1 x64.
//Target is a Cortex M0.
//tested with 4 different toolchains, all binary downloads from GCC ARM Launchpad site.
//Code below does not exhibit problem when compiled with 4.8 2014q3
//Code trashes register R7 with 4.9 2015q1, q2, or q3 and the flagged braces are uncommented.
//Commenting out the flagged braces removes the problem with the 4.9 series.
//Compile with arm-none-eabi-gcc -fverbose-asm -Wa,-adhln=
#include <inttypes.h>
#include <string.h>
#define RING_SIZE 64
int16_t readingBuffer[
uint8_t readingGetIndex;
extern _Bool TryEstimate(
inline uint8_t incrementRingIn
{
++old;
if (old >= RING_SIZE) old = 0;
return old;
}
void process()
{
const uint32_t data_size = 3;
//if braces uncommented, bug is triggered.
{
uint8_t flash_buffer[
memcpy(
uint16_t n;
if (TryEstimate(&n))
{
memcpy(
}
}
readingGetIndex = incrementRingIn
}
End cut and paste of "r7lost.c"
On my system, I see the following results:
If the flagged braces are commented out, the register assignments are such that R7 is not used for any of the 4 compilers mentioned.
If the flagged braces are present, the 4.8 series compiler correctly preserves R7 but none of the three 4.9 series versions do.
Thanks for your attention, let me know if I need to provide more info.
Hi David,
Thank you for reporting this. I can confirm this occurs on 4.9 q3 release. I checked with the 5.0 q4 release and the bug doesn't seem to be present there. At least not with the code you provided even when using '-fno-omit- frame-pointer' . If possible I suggest you use that release.
I will try to look into why this code was generated for 4.9.
Cheers,
Andre