Correct behavior for preservation of x87/MMX state in interrupt handler

I am interested in working on this issue: __attribute__((interrupt)) trashes MMX registers · Issue #26785 · llvm/llvm-project · GitHub but am unsure of what the best course of action is. The issue states that “Interrupt handler must preserve MMX and X87 states. It shouldn’t be allowed to use MMX nor x87 registers.”

It seems there are two options:

  1. Preserve the FPU/MMX state if needed by emitting fsave and frstor (or fxsave and fxrstor) instructions as indicated by the Intel software developer manual. However, my understanding is that these instructions are not particularly fast.
  2. Raise an error if an interrupt handler (or any function with its call convention) is compiled with the x87 and/or MMX features enabled. This is GCC’s current behavior.

It may be worth noting that llvm already departs from GCC behavior with SSE instructions, which are disallowed in GCC but handled by llvm. GCC docs state that interrupt handlers should be compiled with -mgeneral-regs-only, but clang does not require or warn of this to my knowledge.