[clang] Disable FTZ/DAZ when compiling shared libraries by default. (PR #80475)

Andy Kaylor via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 8 10:33:39 PST 2024


andykaylor wrote:

> I'm suggesting that we modify Clang so that `-ffast-math` _doesn't affect_ `denormal-fp-math`, by (as I mentioned before) removing the overload [Linux::getDefaultDenormalModeForType](https://github.com/llvm/llvm-project/blob/d4c5acac99e83ffa12d2d720c9e502a181cbd7ea/clang/lib/Driver/ToolChains/Linux.cpp#L838). This makes Clang for Linux X86 and X86-64 work the same as every other OS/CPU combo.

I don't see why the current denormal-fp-math setting behavior is a blocking issue for this change. Yes, compiling a shared library with ffast-math would lead to the "denormal-fp-math" attribute being set to a potentially misleading value, but that's already true for any file that is compiled with -ffast-math if the file containing the entry function isn't compiled with -ffast-math. I'd see fixing that as a separate issue.

I'd like to see this change land, but with the "-mdaz-ftz" option removed (because I don't think it's useful). That would fix the critical problem of fast-math infecting shared libraries with the ftz setting, and we could straighten out the other problems, which are relatively minor, afterwards.

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


More information about the cfe-commits mailing list