Skip to content

[Analysis] Ensure use of strict fp exceptions in ConstantFolding #136139

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions llvm/lib/Analysis/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# The implementaiton of ConstantFolding.cpp relies on the use of math functions
# The implementation 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")
elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
set_source_files_properties(ConstantFolding.cpp PROPERTIES COMPILE_OPTIONS "-ffp-exception-behavior=strict")
endif()

add_llvm_component_library(LLVMAnalysis
AliasAnalysis.cpp
AliasAnalysisEvaluator.cpp
Expand Down
Loading