c++cgccattributes

Using the no_caller_saved_registers attribute in GCC


I am trying to compile some C functions, using gcc not to run over any registers. I am working on x86_64. I am trying to use no_caller_saved_registers, but all I get is this:

warning: ‘no_caller_saved_registers’ attribute directive ignored [-Wattributes]

void foo() attribute((no_caller_saved_registers));

My temporary solution was to write inline assembly prologue and epilogue to save and restore all registers, but I REALLY prefer to make the attribute work.

Did anyone have this problem?


Solution

  • No_caller_saved_registers has only been implemented in June 2016 so it's not available in any official GCC release atm.