I found a issue when compiling this code with GCC for Renesas v4.8.4.201701-GNURX .

extern void f(int a, int b, int *p);
typedef struct {
int* p;
} R;

extern R* r;

void test(void)
f(1, 1, r->p);

f() is called with invalid parameter b.

./rx-elf-gcc -O -fpeephole2 test.c -S -o –
.file “test.c”
.section P,”ax”
.global _test
.type _test,@function
mov.L #_r, r5
mov.L [r5], r5
mov.L r1, r2                             ; param b is undefined.     <—————-
mov.L [r5], r3                           ; param p = r->p
mov.L #1, r1                            ; param a = 1
bsr _f
.size _test, .-_test
.ident “GCC: (GNU)”

This issue isn’t occur when compiling with -fno-peephole2 nor with gnu original version gcc.


Erika Molnar commented
    • Hello,

      Thank you for reaching out to us!

      Based on the information you provided, we have managed to reproduce the problem.
      Our development team is analyzing the issue, after which a fix will be considered for a future release of GCC for Renesas RX Toolchain. Until then, please use -fno-peephole2 as a workaround.

      Please let us know if we can be of further assistance.

      Best regards,
      The GNU Tools Team