[clang][patch] Add builtin __arithmetic_fence and option fprotect-parens
authorMelanie Blower <melanie.blower@intel.com>
Mon, 28 Jun 2021 16:45:56 +0000 (12:45 -0400)
committerMelanie Blower <melanie.blower@intel.com>
Wed, 30 Jun 2021 13:58:06 +0000 (09:58 -0400)
commite773216f46368cd927a3c67bfa2516913acb75e7
treebfc96a0feb81cb1f3ebef1f39f1bec52b5a5bb79
parent0edb87773b1a086cb5bb960f7f4f6ca815bc8bb4
[clang][patch] Add builtin __arithmetic_fence and option fprotect-parens

This patch adds a new clang builtin, __arithmetic_fence. The purpose of the
builtin is to provide the user fine control, at the expression level, over
floating point optimization when -ffast-math (-ffp-model=fast) is enabled.
The builtin prevents the optimizer from rearranging floating point expression
evaluation. The new option fprotect-parens has the same effect on
parenthesized expressions, forcing the optimizer to respect the parentheses.

Reviewed By: aaron.ballman, kpn

Differential Revision: https://reviews.llvm.org/D100118
19 files changed:
clang/docs/UsersManual.rst
clang/include/clang/Basic/Builtins.def
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Basic/TargetInfo.h
clang/include/clang/Driver/Options.td
clang/include/clang/Sema/Sema.h
clang/lib/AST/ExprConstant.cpp
clang/lib/Basic/TargetInfo.cpp
clang/lib/Basic/Targets/X86.h
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Sema/SemaChecking.cpp
clang/lib/Sema/SemaCoroutine.cpp
clang/lib/Sema/SemaExpr.cpp
clang/test/AST/arithmetic-fence-builtin.c [new file with mode: 0644]
clang/test/CodeGen/arithmetic-fence-builtin.c [new file with mode: 0644]
clang/test/Driver/clang_f_opts.c
clang/test/Sema/arithmetic-fence-builtin.c [new file with mode: 0644]