ARM - Unwanted local variable stored in VFP register

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

we are found that GCC >= 9 uses ARM VFP registers to store local function
variables instead of stack. It looks like a smart idea, because access to
the VFP register is faster than access to stack, but there is one serious
problem. We need to disable this optimization and we don't know how to do
it.
Problem is simple. We have MCU with VFP unit and real-time operating
system. Problem is that save/restore complete VFP unit state on every
context switch is very time expensive (33 DWORDs on stack). And most
processes don't need VFP operations. Therefore we enable/disable VFP unit
depending on the process setting. In other words we need to have VFP
operations only on functions where there are float point operations.

And GCC9 produce code like this for ANY more complex function with more
local variables:

    stmdb sp!, {r4, r5, r6, r7, r8, r9, sl, fp, lr}
    vpush {d8}
    ... do something
   vmov s16, r3 ; store local varible to VFP register temporary
    ... do something
  vmov r1, s16 ; restore local varible from temporary VFP register
    ... do something
   vpop {d8}
   ldmia.w sp!, {r4, r5, r6, r7, r8, r9, sl, fp, pc}

Code like this must throw an Undefined Instruction exception on runtime,
because VFP unit is disabled.

How to manage(block) this optimization?

Jiri Dobry



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux