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

            Bug ID: 102076
           Summary: powerpc: mflr called twice when using
                    __builtin_return_address(0)
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: christophe.leroy at csgroup dot eu
  Target Milestone: ---

Fonction:

long f(void *);

long g(void)
{
        return 3 + f(__builtin_return_address(0));
}


Builds into:

00000000 <g>:
   0:   7c 08 02 a6     mflr    r0
   4:   7c 68 02 a6     mflr    r3
   8:   94 21 ff f0     stwu    r1,-16(r1)
   c:   90 01 00 14     stw     r0,20(r1)
  10:   48 00 00 01     bl      10 <g+0x10>
  14:   80 01 00 14     lwz     r0,20(r1)
  18:   38 63 00 03     addi    r3,r3,3
  1c:   7c 08 03 a6     mtlr    r0
  20:   38 21 00 10     addi    r1,r1,16
  24:   4e 80 00 20     blr



The 'mflr r0' should be avoided by using the value in r3
  • [Bug target/102076] New: p... christophe.leroy at csgroup dot eu via Gcc-bugs

Reply via email to