[llvm] [FPEnv] Add strictfp attribute to the FP environment manipulation intrinsics (PR #96093)

Kevin P. Neal via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 28 10:09:44 PDT 2024


kpneal wrote:

> Strictfp set on a function call means, according to the documentation, that the context requires strictfp semantics, that is all FP operations, that normally look as pure functions, are required expose their interaction with FP environment. 
> It is OK for a functions that modify FP environment, like `fesetround`. If a function temporarily sets a non-default rounding mode to makes some calculation, it does not need the strict floating-point semantics in the context where it is called. In the latter case `strictfp` is implementation detail which does not need to be known outside the function body.

> Unconditional propagation of strictfp from function declaration to function call does not look correct.

The API for checking for attributes at call sites looks through to function declarations always. It would be asking for trouble to have one attribute behave differently. Plus, a number of places will emit a function call and then immediately replace all the attributes for the call. If propagation isn't done for the strictfp attribute then in these cases the attribute that was added by the IRBuilder will be lost at the call site. So the propagation both decreases the cognitive load on developers by having the attribute checks all behave the same, and it helps avoid bugs by keeping the attribute from being accidentally lost. The harm is... what?

@arsenm, having the constrained intrinsics have strictfp specified in tablegen was your idea. Any thoughts? 

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


More information about the llvm-commits mailing list