[llvm] [FPEnv][X86] Correct strictfp tests. (PR #87791)

Andy Kaylor via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 5 16:02:11 PDT 2024


https://github.com/andykaylor approved this pull request.

This looks right to me.

You may know this, but I'll comment here to have the explanation with your patch. The x87 exception handling is a bit arcane. When an exception occurs, there are few guarantees about when it will be reported, but a wait instruction acts as a barrier to ensure that nothing else happens until any pending exceptions are processed. I believe the C language standard allows a bit of leeway about the timing of exceptions, but it requires them to be handled before making a function call or returning from a function. It seems that's the model that LLVM is following.

FWIW, the Intel Classic Compiler (icc) inserts waits all over the place, more or less after every x87 instruction, when strict exception semantics are enabled. That seems like overkill as you'd pretty much need to block all optimizations to maintain that level of granularity in the exception handling.

It's a bit disturbing that LLVM doesn't insert the wait instructions without the strictfp attribute, but I suppose once you've finished the work to enforce the rules for this that will be ok.

https://github.com/llvm/llvm-project/pull/87791


More information about the llvm-commits mailing list