Skip to content

ARM NLR with gcc 9 should save FP registers #4844

@dpgeorge

Description

@dpgeorge

ARM CPUs with hardware floating point (VFP) have additional registers, s0-s31 (also labelled by d0-d15). Of these, s16-s31 are callee save and so in principle should be saved and restored by the NLR code.

Currently they are not saved. This has not been an issue so far because gcc (up to v8) only uses these s16-s31 registers when doing floating point calculations and MicroPython doesn't call into NLR-sensitive code during a floating point calculation (eg no NLR push/pop during sin(x) or during binary ops between two complex numbers). (At least this has never been observed, no problems related to this have been reported so far.)

But gcc 9 uses more aggressive optimisation and may use s16-s31 to save normal integer values instead of using the stack, and these values may be corrupted by NLR not restoring them correctly. Compiling stm32 with gcc 9.1.0 does lead to such issues (eg test suit run on PYBv1.0 fails on multiple tests).

The workaround for now would be to only use gcc 8.x or below.

Probably the only proper fix is to save registers s16-s31 (or maybe just s16-s23 since gcc 9 doesn't seem to use registers above these) in the NLR context.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy