[llvm] [Analysis] Ensure use of strict fp exceptions in ConstantFolding (PR #136139)

Simon Tatham via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 17 06:55:07 PDT 2025


================
@@ -23,6 +23,17 @@ if (DEFINED LLVM_HAVE_TF_AOT OR LLVM_HAVE_TFLITE)
   endif()
 endif()
 
+# The implementaiton of ConstantFolding.cpp relies on the use of math functions
+# from the host. In particular, it relies on the detection of floating point
+# exceptions originating from such math functions to prevent invalid cases
+# from being constant folded. Therefore, we must ensure that fp exceptions are
+# handled correctly.
+if (MSVC)
+  set_source_files_properties(ConstantFolding.cpp PROPERTIES COMPILE_OPTIONS "/fp:except")
+else()
----------------
statham-arm wrote:

I'm not sure we can assume that all the compilers in the world are either MSVC or have a GNU-style command-line syntax, can we? Should this `else()` be something more like `elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")`?

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


More information about the llvm-commits mailing list