[clang] 0a175ad - [clang][patch][FPEnv] Fix syntax errors in pragma float_control test

2021-07-30 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2021-07-30T09:59:45-04:00
New Revision: 0a175ad445f095caf59f7175fbc035464919b7a3

URL: 
https://github.com/llvm/llvm-project/commit/0a175ad445f095caf59f7175fbc035464919b7a3
DIFF: 
https://github.com/llvm/llvm-project/commit/0a175ad445f095caf59f7175fbc035464919b7a3.diff

LOG: [clang][patch][FPEnv] Fix syntax errors in pragma float_control test

In a post-commit message to https://reviews.llvm.org/D102343
@MaskRay pointed out syntax errors in one of the test cases. This
patch fixes those problems, I had forgotten the colon after the CHECK- strings.

Added: 


Modified: 
clang/test/CodeGen/fp-floatcontrol-stack.cpp

Removed: 




diff  --git a/clang/test/CodeGen/fp-floatcontrol-stack.cpp 
b/clang/test/CodeGen/fp-floatcontrol-stack.cpp
index 35908dbc579fd..3de3af0cbad05 100644
--- a/clang/test/CodeGen/fp-floatcontrol-stack.cpp
+++ b/clang/test/CodeGen/fp-floatcontrol-stack.cpp
@@ -6,10 +6,10 @@
 #define FUN(n) \
   (float z) { return n * z + n; }
 
-// CHECK-DDEFAULT Function Attrs: noinline nounwind optnone mustprogress
-// CHECK-DEBSTRICT Function Attrs: noinline nounwind optnone strictfp 
mustprogress
-// CHECK-FAST: Function Attrs: mustprogress noinline nounwind optnone
-// CHECK-NOHONOR Function Attrs: noinline nounwind optnone mustprogress
+// CHECK-DDEFAULT: Function Attrs: mustprogress noinline nounwind optnone{{$$}}
+// CHECK-DEBSTRICT: Function Attrs: mustprogress noinline nounwind optnone 
strictfp{{$$}}
+// CHECK-FAST: Function Attrs: mustprogress noinline nounwind optnone{{$$}}
+// CHECK-NOHONOR: Function Attrs: mustprogress noinline nounwind optnone{{$$}}
 float fun_default FUN(1)
 //CHECK-LABEL: define {{.*}} @_Z11fun_defaultf{{.*}}
 #if DEFAULT
@@ -32,10 +32,10 @@ float fun_default FUN(1)
 // Rule: precise must be enabled
 #pragma float_control(except, on)
 #endif
-// CHECK-FAST: Function Attrs: mustprogress noinline nounwind optnone
-// CHECK-DDEFAULT Function Attrs: noinline nounwind optnone strictfp 
mustprogress
-// CHECK-DEBSTRICT Function Attrs: noinline nounwind optnone strictfp 
mustprogress
-// CHECK-NOHONOR Function Attrs: noinline nounwind optnone strictfp 
mustprogress
+// CHECK-FAST: Function Attrs: mustprogress noinline nounwind optnone{{$$}}
+// CHECK-DDEFAULT: Function Attrs: mustprogress noinline nounwind optnone 
strictfp{{$$}}
+// CHECK-DEBSTRICT: Function Attrs: mustprogress noinline nounwind optnone 
strictfp{{$$}}
+// CHECK-NOHONOR: Function Attrs: mustprogress noinline nounwind optnone 
strictfp{{$$}}
 float exc_on FUN(2)
 //CHECK-LABEL: define {{.*}} @_Z6exc_onf{{.*}}
 #if DEFAULT
@@ -54,10 +54,10 @@ float fun_default FUN(1)
 #endif
 
 #pragma float_control(pop)
-// CHECK-DDEFAULT Function Attrs: noinline nounwind optnone mustprogress
-// CHECK-DEBSTRICT Function Attrs: noinline nounwind optnone strictfp 
mustprogress
-// CHECK-FAST: Function Attrs: mustprogress noinline nounwind optnone
-// CHECK-NOHONOR Function Attrs: noinline nounwind optnone mustprogress
+// CHECK-DDEFAULT: Function Attrs: mustprogress noinline nounwind 
optnone{{$$}}
+// CHECK-DEBSTRICT: Function Attrs: mustprogress noinline nounwind optnone 
strictfp{{$$}}
+// CHECK-FAST: Function Attrs: mustprogress noinline nounwind optnone{{$$}}
+// CHECK-NOHONOR: Function Attrs: mustprogress noinline nounwind 
optnone{{$$}}
 float exc_pop FUN(5)
 //CHECK-LABEL: define {{.*}} @_Z7exc_popf{{.*}}
 #if DEFAULT
@@ -223,10 +223,10 @@ float fun_default FUN(1)
 #pragma float_control(except, on)
 #endif
 float y();
-// CHECK-DDEFAULT Function Attrs: noinline nounwind optnone mustprogress
-// CHECK-DEBSTRICT Function Attrs: noinline nounwind optnone strictfp 
mustprogress
-// CHECK-FAST: Function Attrs: mustprogress noinline nounwind optnone
-// CHECK-NOHONOR Function Attrs: noinline nounwind optnone mustprogress
+// CHECK-DDEFAULT: Function Attrs: mustprogress noinline nounwind optnone{{$$}}
+// CHECK-DEBSTRICT: Function Attrs: noinline nounwind optnone strictfp{{$$}}
+// CHECK-FAST: Function Attrs: mustprogress noinline nounwind optnone{{$$}}
+// CHECK-NOHONOR: Function Attrs: mustprogress noinline nounwind optnone{{$$}}
 class ON {
   // Settings for top level class initializer use program source setting.
   float z = 2 + y() * 7;
@@ -246,14 +246,14 @@ class ON {
 };
 ON on;
 #pragma float_control(except, off)
-// CHECK-DDEFAULT Function Attrs: noinline nounwind optnone
-// CHECK-DEBSTRICT Function Attrs: noinline nounwind optnone
-// CHECK-FAST: Function Attrs: noinline nounwind optnone
-// CHECK-NOHONOR Function Attrs: noinline nounwind optnone
+// CHECK-DDEFAULT: Function Attrs: noinline nounwind optnone{{$$}}
+// CHECK-DEBSTRICT: Function Attrs: noinline nounwind optnone{{$$}}
+// CHECK-FAST: Function Attrs: noinline nounwind optnone{{$$}}
+// CHECK-NOHONOR: Function Attrs: noinline 

[clang] fd251d9 - [clang][patch] Remove erroneous run line committed in D102343

2021-07-29 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2021-07-29T12:42:04-04:00
New Revision: fd251d903b9b1bc8305736fc78764521cd86f8d3

URL: 
https://github.com/llvm/llvm-project/commit/fd251d903b9b1bc8305736fc78764521cd86f8d3
DIFF: 
https://github.com/llvm/llvm-project/commit/fd251d903b9b1bc8305736fc78764521cd86f8d3.diff

LOG: [clang][patch] Remove erroneous run line committed in D102343

Added: 


Modified: 
clang/test/CodeGen/fp-floatcontrol-class.cpp

Removed: 




diff  --git a/clang/test/CodeGen/fp-floatcontrol-class.cpp 
b/clang/test/CodeGen/fp-floatcontrol-class.cpp
index 8c2e60c2a9c3..83a27cb206eb 100644
--- a/clang/test/CodeGen/fp-floatcontrol-class.cpp
+++ b/clang/test/CodeGen/fp-floatcontrol-class.cpp
@@ -1,4 +1,3 @@
-// RUN: %clang_cc1 -ffp-contract=on -triple %itanium_abi_triple -emit-llvm -o 
- %s | FileCheck %s
 // RUN: %clang_cc1 -ffp-contract=on -triple x86_64-linux-gnu -emit-llvm -o - 
%s | FileCheck %s
 // Verify that float_control does not pertain to initializer expressions
 



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] bc5b5ea - [clang][patch][FPEnv] Make initialization of C++ globals strictfp aware

2021-07-29 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2021-07-29T12:02:37-04:00
New Revision: bc5b5ea037dbadd281c59248ae9d2742b51c69ed

URL: 
https://github.com/llvm/llvm-project/commit/bc5b5ea037dbadd281c59248ae9d2742b51c69ed
DIFF: 
https://github.com/llvm/llvm-project/commit/bc5b5ea037dbadd281c59248ae9d2742b51c69ed.diff

LOG: [clang][patch][FPEnv] Make initialization of C++ globals strictfp aware

@kpn pointed out that the global variable initialization functions didn't
have the "strictfp" metadata set correctly, and @rjmccall said that there
was buggy code in SetFPModel and StartFunction, this patch is to solve
those problems. When Sema creates a FunctionDecl, it sets the
FunctionDeclBits.UsesFPIntrin to "true" if the lexical FP settings
(i.e. a combination of command line options and #pragma float_control
settings) correspond to ConstrainedFP mode. That bit is used when CodeGen
starts codegen for a llvm function, and it translates into the
"strictfp" function attribute. See bugs.llvm.org/show_bug.cgi?id=44571

Reviewed By: Aaron Ballman

Differential Revision: https://reviews.llvm.org/D102343

Added: 


Modified: 
clang/include/clang/AST/Decl.h
clang/include/clang/AST/DeclCXX.h
clang/lib/AST/ASTImporter.cpp
clang/lib/AST/Decl.cpp
clang/lib/AST/DeclCXX.cpp
clang/lib/CodeGen/CGObjC.cpp
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/lib/CodeGen/CodeGenFunction.cpp
clang/lib/CodeGen/CodeGenFunction.h
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaExprCXX.cpp
clang/lib/Sema/SemaLambda.cpp
clang/lib/Sema/SemaLookup.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/test/CodeGen/fp-floatcontrol-class.cpp
clang/test/CodeGen/fp-floatcontrol-stack.cpp
clang/unittests/Sema/ExternalSemaSourceTest.cpp

Removed: 




diff  --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h
index 510bf89789851..30923a4fa05c9 100644
--- a/clang/include/clang/AST/Decl.h
+++ b/clang/include/clang/AST/Decl.h
@@ -1990,8 +1990,8 @@ class FunctionDecl : public DeclaratorDecl,
 protected:
   FunctionDecl(Kind DK, ASTContext , DeclContext *DC, SourceLocation 
StartLoc,
const DeclarationNameInfo , QualType T,
-   TypeSourceInfo *TInfo, StorageClass S, bool isInlineSpecified,
-   ConstexprSpecKind ConstexprKind,
+   TypeSourceInfo *TInfo, StorageClass S, bool UsesFPIntrin,
+   bool isInlineSpecified, ConstexprSpecKind ConstexprKind,
Expr *TrailingRequiresClause = nullptr);
 
   using redeclarable_base = Redeclarable;
@@ -2025,23 +2025,23 @@ class FunctionDecl : public DeclaratorDecl,
   static FunctionDecl *
   Create(ASTContext , DeclContext *DC, SourceLocation StartLoc,
  SourceLocation NLoc, DeclarationName N, QualType T,
- TypeSourceInfo *TInfo, StorageClass SC, bool isInlineSpecified = 
false,
- bool hasWrittenPrototype = true,
+ TypeSourceInfo *TInfo, StorageClass SC, bool UsesFPIntrin = false,
+ bool isInlineSpecified = false, bool hasWrittenPrototype = true,
  ConstexprSpecKind ConstexprKind = ConstexprSpecKind::Unspecified,
  Expr *TrailingRequiresClause = nullptr) {
 DeclarationNameInfo NameInfo(N, NLoc);
 return FunctionDecl::Create(C, DC, StartLoc, NameInfo, T, TInfo, SC,
-isInlineSpecified, hasWrittenPrototype,
-ConstexprKind, TrailingRequiresClause);
+UsesFPIntrin, isInlineSpecified,
+hasWrittenPrototype, ConstexprKind,
+TrailingRequiresClause);
   }
 
-  static FunctionDecl *Create(ASTContext , DeclContext *DC,
-  SourceLocation StartLoc,
-  const DeclarationNameInfo , QualType T,
-  TypeSourceInfo *TInfo, StorageClass SC,
-  bool isInlineSpecified, bool hasWrittenPrototype,
-  ConstexprSpecKind ConstexprKind,
-  Expr *TrailingRequiresClause);
+  static FunctionDecl *
+  Create(ASTContext , DeclContext *DC, SourceLocation StartLoc,
+ const DeclarationNameInfo , QualType T, TypeSourceInfo 
*TInfo,
+ StorageClass SC, bool UsesFPIntrin, bool isInlineSpecified,
+ bool hasWrittenPrototype, ConstexprSpecKind ConstexprKind,
+ Expr *TrailingRequiresClause);
 
   static FunctionDecl *CreateDeserialized(ASTContext , unsigned ID);
 
@@ -2594,6 +2594,14 @@ class FunctionDecl : public DeclaratorDecl,
 FunctionDeclBits.IsInline = I;
   }
 
+  /// Determine whether the function was declared in source context
+  /// that requires constrained FP intrinsics
+  bool UsesFPIntrin() const { return 

[clang] 66ddac2 - [CLANG][PATCH][FPEnv] Add support for option -ffp-eval-method and extend #pragma float_control similarly

2021-07-28 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2021-07-28T10:50:32-04:00
New Revision: 66ddac22e2a7f268e91c26d694112970dfa607ae

URL: 
https://github.com/llvm/llvm-project/commit/66ddac22e2a7f268e91c26d694112970dfa607ae
DIFF: 
https://github.com/llvm/llvm-project/commit/66ddac22e2a7f268e91c26d694112970dfa607ae.diff

LOG: [CLANG][PATCH][FPEnv] Add support for option -ffp-eval-method and extend 
#pragma float_control similarly

The Intel compiler ICC supports the option "-fp-model=(source|double|extended)"
which causes the compiler to use a wider type for intermediate floating point
calculations. Also supported is a way to embed this effect in the source
program with #pragma float_control(source|double|extended).
This patch extends pragma float_control syntax, and also adds support
for a new floating point option "-ffp-eval-method=(source|double|extended)".
source: intermediate results use source precision
double: intermediate results use double precision
extended: intermediate results use extended precision

Reviewed By: Aaron Ballman

Differential Revision: https://reviews.llvm.org/D93769

Added: 


Modified: 
clang/docs/LanguageExtensions.rst
clang/docs/UsersManual.rst
clang/include/clang/Basic/FPOptions.def
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Basic/LangOptions.h
clang/include/clang/Basic/PragmaKinds.h
clang/include/clang/Basic/TargetInfo.h
clang/include/clang/Driver/Options.td
clang/include/clang/Lex/Preprocessor.h
clang/include/clang/Lex/PreprocessorOptions.h
clang/include/clang/Sema/Sema.h
clang/lib/Basic/Targets/OSTargets.h
clang/lib/Basic/Targets/X86.h
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Frontend/InitPreprocessor.cpp
clang/lib/Lex/PPMacroExpansion.cpp
clang/lib/Parse/ParsePragma.cpp
clang/lib/Sema/Sema.cpp
clang/lib/Sema/SemaAttr.cpp
clang/lib/Sema/SemaExpr.cpp
clang/test/CodeGen/fp-floatcontrol-pragma.cpp
clang/test/Preprocessor/init-aarch64.c
clang/test/Preprocessor/init-arm.c
clang/test/Preprocessor/init-mips.c
clang/test/Preprocessor/init-ppc.c
clang/test/Preprocessor/init-ppc64.c
clang/test/Preprocessor/init-s390x.c
clang/test/Preprocessor/init-v7k-compat.c
clang/test/Preprocessor/init-x86.c
clang/test/Preprocessor/init.c

Removed: 




diff  --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index 8090aedb573b..462aa89ea789 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -3554,7 +3554,7 @@ specification, a stack is supported so that the ``pragma 
float_control``
 settings can be pushed or popped.
 
 When ``pragma float_control(precise, on)`` is enabled, the section of code
-governed by the pragma uses precise floating point semantics, effectively
+governed by the pragma uses precise floating-point semantics, effectively
 ``-ffast-math`` is disabled and ``-ffp-contract=on``
 (fused multiply add) is enabled.
 
@@ -3565,8 +3565,29 @@ when ``pragma float_control(precise, off)`` is enabled, 
the section of code
 governed by the pragma behaves as though the command-line option
 ``-ffp-exception-behavior=ignore`` is enabled.
 
+When ``pragma float_control(source, on)`` is enabled, the section of code 
governed
+by the pragma behaves as though the command-line option
+``-ffp-eval-method=source`` is enabled. Note: The default
+floating-point evaluation method is target-specific, typically ``source``.
+
+When ``pragma float_control(double, on)`` is enabled, the section of code 
governed
+by the pragma behaves as though the command-line option
+``-ffp-eval-method=double`` is enabled.
+
+When ``pragma float_control(extended, on)`` is enabled, the section of code 
governed
+by the pragma behaves as though the command-line option
+``-ffp-eval-method=extended`` is enabled.
+
+When ``pragma float_control(source, off)`` or
+``pragma float_control(double, off)`` or
+``pragma float_control(extended, off)`` is enabled,
+the section of code governed
+by the pragma behaves as though the command-line option
+``-ffp-eval-method=source`` is enabled, returning floating-point evaluation
+method to the default setting.
+
 The full syntax this pragma supports is
-``float_control(except|precise, on|off [, push])`` and
+``float_control(except|precise|source|double|extended, on|off [, push])`` and
 ``float_control(push|pop)``.
 The ``push`` and ``pop`` forms, including using ``push`` as the optional
 third argument, can only occur at file scope.

diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index aecd28e5e12a..63056e09ac57 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -1520,6 +1520,17 @@ Note that floating-point operations performed as part of 
constant initialization
* ``maytrap`` The compiler avoids transformations that may 

[clang] 48ad446 - [clang][fpenv][patch] Change clang option -ffp-model=precise to select ffp-contract=on

2021-07-27 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2021-07-27T13:55:31-04:00
New Revision: 48ad446a0fb2c9b98cb7047e4daf8a84c29cef8f

URL: 
https://github.com/llvm/llvm-project/commit/48ad446a0fb2c9b98cb7047e4daf8a84c29cef8f
DIFF: 
https://github.com/llvm/llvm-project/commit/48ad446a0fb2c9b98cb7047e4daf8a84c29cef8f.diff

LOG: [clang][fpenv][patch] Change clang option -ffp-model=precise to select 
ffp-contract=on

Change the ffp-model=precise to enables -ffp-contract=on (previously
-ffp-model=precise enabled -ffp-contract=fast). This is a follow-up
to Andy Kaylor's comments in the llvm-dev discussion "Floating Point
semantic modes". From the same email thread, I put Andy's distillation
of floating point options and floating point modes into UsersManual.rst
Also fixes bugs.llvm.org/show_bug.cgi?id=50222

I had to revert this a few times because of failures on the x86-64
buildbot but I think we finally have that fixed by LNT/79f2b03c51.

Reviewed By: rjmccall, andrew.kaylor

Differential Revision: https://reviews.llvm.org/D74436

Added: 


Modified: 
clang/docs/UsersManual.rst
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/CodeGen/ffp-contract-option.c
clang/test/CodeGen/ppc-emmintrin.c
clang/test/CodeGen/ppc-xmmintrin.c
clang/test/Driver/fp-model.c

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 20be01a5f40ac..aecd28e5e12a6 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -1260,8 +1260,50 @@ installed.
 Controlling Floating Point Behavior
 ---
 
-Clang provides a number of ways to control floating point behavior. The options
-are listed below.
+Clang provides a number of ways to control floating point behavior, including
+with command line options and source pragmas. This section
+describes the various floating point semantic modes and the corresponding 
options.
+
+.. csv-table:: Floating Point Semantic Modes
+  :header: "Mode", "Values"
+  :widths: 15, 30, 30
+
+  "except_behavior", "{ignore, strict, may_trap}", "ffp-exception-behavior"
+  "fenv_access", "{off, on}", "(none)"
+  "rounding_mode", "{dynamic, tonearest, downward, upward, towardzero}", 
"frounding-math"
+  "contract", "{on, off, fast}", "ffp-contract"
+  "denormal_fp_math", "{IEEE, PreserveSign, PositiveZero}", "fdenormal-fp-math"
+  "denormal_fp32_math", "{IEEE, PreserveSign, PositiveZero}", 
"fdenormal-fp-math-fp32"
+  "support_math_errno", "{on, off}", "fmath-errno"
+  "no_honor_nans", "{on, off}", "fhonor-nans"
+  "no_honor_infinities", "{on, off}", "fhonor-infinities"
+  "no_signed_zeros", "{on, off}", "fsigned-zeros"
+  "allow_reciprocal", "{on, off}", "freciprocal-math"
+  "allow_approximate_fns", "{on, off}", "(none)"
+  "allow_reassociation", "{on, off}", "fassociative-math"
+
+
+This table describes the option settings that correspond to the three
+floating point semantic models: precise (the default), strict, and fast.
+
+
+.. csv-table:: Floating Point Models
+  :header: "Mode", "Precise", "Strict", "Fast"
+  :widths: 25, 15, 15, 15
+
+  "except_behavior", "ignore", "strict", "ignore"
+  "fenv_access", "off", "on", "off"
+  "rounding_mode", "tonearest", "dynamic", "tonearest"
+  "contract", "on", "off", "fast"
+  "denormal_fp_math", "IEEE", "IEEE", "PreserveSign"
+  "denormal_fp32_math", "IEEE","IEEE", "PreserveSign"
+  "support_math_errno", "on", "on", "off"
+  "no_honor_nans", "off", "off", "on"
+  "no_honor_infinities", "off", "off", "on"
+  "no_signed_zeros", "off", "off", "on"
+  "allow_reciprocal", "off", "off", "on"
+  "allow_approximate_fns", "off", "off", "on"
+  "allow_reassociation", "off", "off", "on"
 
 .. option:: -ffast-math
 
@@ -1456,7 +1498,7 @@ Note that floating-point operations performed as part of 
constant initialization
and ``fast``.
Details:
 
-   * ``precise`` Disables optimizations that are not value-safe on 
floating-point data, although FP contraction (FMA) is enabled 
(``-ffp-contract=fast``).  This is the default behavior.
+   * ``precise`` Disables optimizations that are not value-safe on 
floating-point data, although FP contraction (FMA) is enabled 
(``-ffp-contract=on``).  This is the default behavior.
* ``strict`` Enables ``-frounding-math`` and 
``-ffp-exception-behavior=strict``, and disables contractions (FMA).  All of 
the ``-ffast-math`` enablements are disabled. Enables ``STDC FENV_ACCESS``: by 
default ``FENV_ACCESS`` is disabled. This option setting behaves as though 
``#pragma STDC FENV_ACESS ON`` appeared at the top of the source file.
* ``fast`` Behaves identically to specifying both ``-ffast-math`` and 
``ffp-contract=fast``
 

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index ebdc63e249b61..a4b53a640ab5c 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2638,7 +2638,7 @@ static 

[clang] 05ae303 - [clang][patch] Remove test artifact before running test for consistent results

2021-07-24 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2021-07-24T07:55:10-04:00
New Revision: 05ae3035554aab083ea1ba721284c950cf25d158

URL: 
https://github.com/llvm/llvm-project/commit/05ae3035554aab083ea1ba721284c950cf25d158
DIFF: 
https://github.com/llvm/llvm-project/commit/05ae3035554aab083ea1ba721284c950cf25d158.diff

LOG: [clang][patch] Remove test artifact before running test for consistent 
results

Fix non-deterministic test behavior by removing previously-created
test directory, see comments in D95159

Added: 


Modified: 
clang/test/Index/preamble-reparse-changed-module.m

Removed: 




diff  --git a/clang/test/Index/preamble-reparse-changed-module.m 
b/clang/test/Index/preamble-reparse-changed-module.m
index 1c63e802ce0c0..349ed0db27d01 100644
--- a/clang/test/Index/preamble-reparse-changed-module.m
+++ b/clang/test/Index/preamble-reparse-changed-module.m
@@ -1,5 +1,6 @@
 // REQUIRES: shell
 
+// RUN: rm -rf %t
 // RUN: mkdir -p %t/mod
 // RUN: touch %t/empty.h
 // RUN: cp %S/Inputs/preamble-reparse-changed-module/module.modulemap %t/mod



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 4296d63 - Revert "[clang][fpenv][patch] Change clang option -ffp-model=precise to select ffp-contract=on"

2021-07-22 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2021-07-22T09:40:54-04:00
New Revision: 4296d633b08dcfc5bfb2df0800995df4b30ac196

URL: 
https://github.com/llvm/llvm-project/commit/4296d633b08dcfc5bfb2df0800995df4b30ac196
DIFF: 
https://github.com/llvm/llvm-project/commit/4296d633b08dcfc5bfb2df0800995df4b30ac196.diff

LOG: Revert "[clang][fpenv][patch] Change clang option -ffp-model=precise to 
select ffp-contract=on"

This reverts commit b9b696bba6702a31ac0995a494cd31c730ade5ec.
Buildbot failures see https://lab.llvm.org/buildbot#builders/118/builds/4138
and https://lab.llvm.org/buildbot#builders/110/builds/5112

Added: 


Modified: 
clang/docs/UsersManual.rst
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/CodeGen/ffp-contract-option.c
clang/test/CodeGen/ppc-emmintrin.c
clang/test/CodeGen/ppc-xmmintrin.c
clang/test/Driver/fp-model.c

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index e5c343124eb29..f7f76ed3f3e20 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -1260,50 +1260,8 @@ installed.
 Controlling Floating Point Behavior
 ---
 
-Clang provides a number of ways to control floating point behavior, including
-with command line options and source pragmas. This section
-describes the various floating point semantic modes and the corresponding 
options.
-
-.. csv-table:: Floating Point Semantic Modes
-  :header: "Mode", "Values"
-  :widths: 15, 30, 30
-
-  "except_behavior", "{ignore, strict, may_trap}", "ffp-exception-behavior"
-  "fenv_access", "{off, on}", "(none)"
-  "rounding_mode", "{dynamic, tonearest, downward, upward, towardzero}", 
"frounding-math"
-  "contract", "{on, off, fast}", "ffp-contract"
-  "denormal_fp_math", "{IEEE, PreserveSign, PositiveZero}", "fdenormal-fp-math"
-  "denormal_fp32_math", "{IEEE, PreserveSign, PositiveZero}", 
"fdenormal-fp-math-fp32"
-  "support_math_errno", "{on, off}", "fmath-errno"
-  "no_honor_nans", "{on, off}", "fhonor-nans"
-  "no_honor_infinities", "{on, off}", "fhonor-infinities"
-  "no_signed_zeros", "{on, off}", "fsigned-zeros"
-  "allow_reciprocal", "{on, off}", "freciprocal-math"
-  "allow_approximate_fns", "{on, off}", "(none)"
-  "allow_reassociation", "{on, off}", "fassociative-math"
-
-
-This table describes the option settings that correspond to the three
-floating point semantic models: precise (the default), strict, and fast.
-
-
-.. csv-table:: Floating Point Models
-  :header: "Mode", "Precise", "Strict", "Fast"
-  :widths: 25, 15, 15, 15
-
-  "except_behavior", "ignore", "strict", "ignore"
-  "fenv_access", "off", "on", "off"
-  "rounding_mode", "tonearest", "dynamic", "tonearest"
-  "contract", "on", "off", "fast"
-  "denormal_fp_math", "IEEE", "IEEE", "PreserveSign"
-  "denormal_fp32_math", "IEEE","IEEE", "PreserveSign"
-  "support_math_errno", "on", "on", "off"
-  "no_honor_nans", "off", "off", "on"
-  "no_honor_infinities", "off", "off", "on"
-  "no_signed_zeros", "off", "off", "on"
-  "allow_reciprocal", "off", "off", "on"
-  "allow_approximate_fns", "off", "off", "on"
-  "allow_reassociation", "off", "off", "on"
+Clang provides a number of ways to control floating point behavior. The options
+are listed below.
 
 .. option:: -ffast-math
 
@@ -1498,7 +1456,7 @@ Note that floating-point operations performed as part of 
constant initialization
and ``fast``.
Details:
 
-   * ``precise`` Disables optimizations that are not value-safe on 
floating-point data, although FP contraction (FMA) is enabled 
(``-ffp-contract=on``).  This is the default behavior.
+   * ``precise`` Disables optimizations that are not value-safe on 
floating-point data, although FP contraction (FMA) is enabled 
(``-ffp-contract=fast``).  This is the default behavior.
* ``strict`` Enables ``-frounding-math`` and 
``-ffp-exception-behavior=strict``, and disables contractions (FMA).  All of 
the ``-ffast-math`` enablements are disabled. Enables ``STDC FENV_ACCESS``: by 
default ``FENV_ACCESS`` is disabled. This option setting behaves as though 
``#pragma STDC FENV_ACESS ON`` appeared at the top of the source file.
* ``fast`` Behaves identically to specifying both ``-ffast-math`` and 
``ffp-contract=fast``
 

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 928fff7001b67..837ead86d6202 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2637,7 +2637,7 @@ static void RenderFloatingPointOptions(const ToolChain 
, const Driver ,
 
   llvm::DenormalMode DenormalFPMath = DefaultDenormalFPMath;
   llvm::DenormalMode DenormalFP32Math = DefaultDenormalFP32Math;
-  StringRef FPContract = "on";
+  StringRef FPContract = "";
   bool StrictFPModel = false;
 
 
@@ -2662,7 +2662,7 @@ static void RenderFloatingPointOptions(const ToolChain 
, const Driver ,
   ReciprocalMath = false;
  

[clang] b9b696b - [clang][fpenv][patch] Change clang option -ffp-model=precise to select ffp-contract=on

2021-07-22 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2021-07-22T07:59:18-04:00
New Revision: b9b696bba6702a31ac0995a494cd31c730ade5ec

URL: 
https://github.com/llvm/llvm-project/commit/b9b696bba6702a31ac0995a494cd31c730ade5ec
DIFF: 
https://github.com/llvm/llvm-project/commit/b9b696bba6702a31ac0995a494cd31c730ade5ec.diff

LOG: [clang][fpenv][patch] Change clang option -ffp-model=precise to select 
ffp-contract=on

Change the ffp-model=precise to enables -ffp-contract=on (previously
-ffp-model=precise enabled -ffp-contract=fast). This is a follow-up
to Andy Kaylor's comments in the llvm-dev discussion "Floating Point
semantic modes". From the same email thread, I put Andy's distillation
of floating point options and floating point modes into UsersManual.rst
Also fixes bugs.llvm.org/show_bug.cgi?id=50222

Reviewed By: rjmccall, andrew.kaylor

Differential Revision: https://reviews.llvm.org/D74436

Added: 


Modified: 
clang/docs/UsersManual.rst
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/CodeGen/ffp-contract-option.c
clang/test/CodeGen/ppc-emmintrin.c
clang/test/CodeGen/ppc-xmmintrin.c
clang/test/Driver/fp-model.c

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index f7f76ed3f3e20..e5c343124eb29 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -1260,8 +1260,50 @@ installed.
 Controlling Floating Point Behavior
 ---
 
-Clang provides a number of ways to control floating point behavior. The options
-are listed below.
+Clang provides a number of ways to control floating point behavior, including
+with command line options and source pragmas. This section
+describes the various floating point semantic modes and the corresponding 
options.
+
+.. csv-table:: Floating Point Semantic Modes
+  :header: "Mode", "Values"
+  :widths: 15, 30, 30
+
+  "except_behavior", "{ignore, strict, may_trap}", "ffp-exception-behavior"
+  "fenv_access", "{off, on}", "(none)"
+  "rounding_mode", "{dynamic, tonearest, downward, upward, towardzero}", 
"frounding-math"
+  "contract", "{on, off, fast}", "ffp-contract"
+  "denormal_fp_math", "{IEEE, PreserveSign, PositiveZero}", "fdenormal-fp-math"
+  "denormal_fp32_math", "{IEEE, PreserveSign, PositiveZero}", 
"fdenormal-fp-math-fp32"
+  "support_math_errno", "{on, off}", "fmath-errno"
+  "no_honor_nans", "{on, off}", "fhonor-nans"
+  "no_honor_infinities", "{on, off}", "fhonor-infinities"
+  "no_signed_zeros", "{on, off}", "fsigned-zeros"
+  "allow_reciprocal", "{on, off}", "freciprocal-math"
+  "allow_approximate_fns", "{on, off}", "(none)"
+  "allow_reassociation", "{on, off}", "fassociative-math"
+
+
+This table describes the option settings that correspond to the three
+floating point semantic models: precise (the default), strict, and fast.
+
+
+.. csv-table:: Floating Point Models
+  :header: "Mode", "Precise", "Strict", "Fast"
+  :widths: 25, 15, 15, 15
+
+  "except_behavior", "ignore", "strict", "ignore"
+  "fenv_access", "off", "on", "off"
+  "rounding_mode", "tonearest", "dynamic", "tonearest"
+  "contract", "on", "off", "fast"
+  "denormal_fp_math", "IEEE", "IEEE", "PreserveSign"
+  "denormal_fp32_math", "IEEE","IEEE", "PreserveSign"
+  "support_math_errno", "on", "on", "off"
+  "no_honor_nans", "off", "off", "on"
+  "no_honor_infinities", "off", "off", "on"
+  "no_signed_zeros", "off", "off", "on"
+  "allow_reciprocal", "off", "off", "on"
+  "allow_approximate_fns", "off", "off", "on"
+  "allow_reassociation", "off", "off", "on"
 
 .. option:: -ffast-math
 
@@ -1456,7 +1498,7 @@ Note that floating-point operations performed as part of 
constant initialization
and ``fast``.
Details:
 
-   * ``precise`` Disables optimizations that are not value-safe on 
floating-point data, although FP contraction (FMA) is enabled 
(``-ffp-contract=fast``).  This is the default behavior.
+   * ``precise`` Disables optimizations that are not value-safe on 
floating-point data, although FP contraction (FMA) is enabled 
(``-ffp-contract=on``).  This is the default behavior.
* ``strict`` Enables ``-frounding-math`` and 
``-ffp-exception-behavior=strict``, and disables contractions (FMA).  All of 
the ``-ffast-math`` enablements are disabled. Enables ``STDC FENV_ACCESS``: by 
default ``FENV_ACCESS`` is disabled. This option setting behaves as though 
``#pragma STDC FENV_ACESS ON`` appeared at the top of the source file.
* ``fast`` Behaves identically to specifying both ``-ffast-math`` and 
``ffp-contract=fast``
 

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 837ead86d6202..928fff7001b67 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2637,7 +2637,7 @@ static void RenderFloatingPointOptions(const ToolChain 
, const Driver ,
 
   llvm::DenormalMode DenormalFPMath = DefaultDenormalFPMath;
   

[clang] d48ad35 - Revert "[CLANG][PATCH][FPEnv] Add support for option -ffp-eval-method and extend #pragma float_control similarly"

2021-07-20 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2021-07-20T16:40:55-04:00
New Revision: d48ad358b1e84698f1070cec50c7586b78865265

URL: 
https://github.com/llvm/llvm-project/commit/d48ad358b1e84698f1070cec50c7586b78865265
DIFF: 
https://github.com/llvm/llvm-project/commit/d48ad358b1e84698f1070cec50c7586b78865265.diff

LOG: Revert "[CLANG][PATCH][FPEnv] Add support for option -ffp-eval-method and 
extend #pragma float_control similarly"

This reverts commit ce8024e8ff76e7be8b9ffa1a39d1dc9310bf74c7.
There are a couple buildbot problems

Added: 


Modified: 
clang/docs/LanguageExtensions.rst
clang/docs/UsersManual.rst
clang/include/clang/Basic/FPOptions.def
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Basic/LangOptions.h
clang/include/clang/Basic/PragmaKinds.h
clang/include/clang/Basic/TargetInfo.h
clang/include/clang/Driver/Options.td
clang/include/clang/Lex/Preprocessor.h
clang/include/clang/Lex/PreprocessorOptions.h
clang/include/clang/Sema/Sema.h
clang/lib/Basic/Targets/OSTargets.h
clang/lib/Basic/Targets/X86.h
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Frontend/InitPreprocessor.cpp
clang/lib/Lex/PPMacroExpansion.cpp
clang/lib/Parse/ParsePragma.cpp
clang/lib/Sema/Sema.cpp
clang/lib/Sema/SemaAttr.cpp
clang/lib/Sema/SemaExpr.cpp
clang/test/CodeGen/fp-floatcontrol-pragma.cpp
clang/test/Preprocessor/init-aarch64.c
clang/test/Preprocessor/init-arm.c
clang/test/Preprocessor/init-mips.c
clang/test/Preprocessor/init-ppc.c
clang/test/Preprocessor/init-ppc64.c
clang/test/Preprocessor/init-s390x.c
clang/test/Preprocessor/init-v7k-compat.c
clang/test/Preprocessor/init-x86.c
clang/test/Preprocessor/init.c

Removed: 
clang/test/Preprocessor/predefined-flteval-macro.c



diff  --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index 93805b65689ca..f14f986c646a4 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -3552,7 +3552,7 @@ same spelling and syntax.  For pragmas specified at file 
scope, a stack
 is supported so that the ``pragma float_control`` settings can be pushed or 
popped.
 
 When ``pragma float_control(precise, on)`` is enabled, the section of code
-governed by the pragma uses precise floating-point semantics, effectively
+governed by the pragma uses precise floating point semantics, effectively
 ``-ffast-math`` is disabled and ``-ffp-contract=on``
 (fused multiply add) is enabled.
 
@@ -3563,29 +3563,8 @@ when ``pragma float_control(precise, off)`` is enabled, 
the section of code
 governed by the pragma behaves as though the command-line option
 ``-ffp-exception-behavior=ignore`` is enabled.
 
-When ``pragma float_control(source, on)`` is enabled, the section of code 
governed
-by the pragma behaves as though the command-line option
-``-ffp-eval-method=source`` is enabled. Note: The default
-floating-point evaluation method is target-specific, typically ``source``.
-
-When ``pragma float_control(double, on)`` is enabled, the section of code 
governed
-by the pragma behaves as though the command-line option
-``-ffp-eval-method=double`` is enabled.
-
-When ``pragma float_control(extended, on)`` is enabled, the section of code 
governed
-by the pragma behaves as though the command-line option
-``-ffp-eval-method=extended`` is enabled.
-
-When ``pragma float_control(source, off)`` or
-``pragma float_control(double, off)`` or
-``pragma float_control(extended, off)`` is enabled,
-the section of code governed
-by the pragma behaves as though the command-line option
-``-ffp-eval-method=source`` is enabled, returning floating-point evaluation
-method to the default setting.
-
 The full syntax this pragma supports is
-``float_control(except|precise|source|double|extended, on|off [, push])`` and
+``float_control(except|precise, on|off [, push])`` and
 ``float_control(push|pop)``.
 The ``push`` and ``pop`` forms, including using ``push`` as the optional
 third argument, can only occur at file scope.

diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index c47c3cdb4207f..f7f76ed3f3e20 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -1478,17 +1478,6 @@ Note that floating-point operations performed as part of 
constant initialization
* ``maytrap`` The compiler avoids transformations that may raise exceptions 
that would not have been raised by the original code. Constant folding 
performed by the compiler is exempt from this option.
* ``strict`` The compiler ensures that all transformations strictly 
preserve the floating point exception semantics of the original code.
 
-.. option:: -ffp-eval-method=
-
-   Specify the floating-point evaluation method.
-
-   Valid values are: ``source``, ``double``, and ``extended``.
-   The default value is 

[clang] ce8024e - [CLANG][PATCH][FPEnv] Add support for option -ffp-eval-method and extend #pragma float_control similarly

2021-07-20 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2021-07-20T16:02:09-04:00
New Revision: ce8024e8ff76e7be8b9ffa1a39d1dc9310bf74c7

URL: 
https://github.com/llvm/llvm-project/commit/ce8024e8ff76e7be8b9ffa1a39d1dc9310bf74c7
DIFF: 
https://github.com/llvm/llvm-project/commit/ce8024e8ff76e7be8b9ffa1a39d1dc9310bf74c7.diff

LOG: [CLANG][PATCH][FPEnv] Add support for option -ffp-eval-method and extend 
#pragma float_control similarly

The Intel compiler ICC supports the option "-fp-model=(source|double|extended)"
which causes the compiler to use a wider type for intermediate floating point
calculations. Also supported is a way to embed this effect in the source
program with #pragma float_control(source|double|extended).
This patch extends pragma float_control syntax, and also adds support
for a new floating point option "-ffp-eval-method=(source|double|extended)".
source: intermediate results use source precision
double: intermediate results use double precision
extended: intermediate results use extended precision

Reviewed By: Aaron Ballman

Differential Revision: https://reviews.llvm.org/D93769

Added: 
clang/test/Preprocessor/predefined-flteval-macro.c

Modified: 
clang/docs/LanguageExtensions.rst
clang/docs/UsersManual.rst
clang/include/clang/Basic/FPOptions.def
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Basic/LangOptions.h
clang/include/clang/Basic/PragmaKinds.h
clang/include/clang/Basic/TargetInfo.h
clang/include/clang/Driver/Options.td
clang/include/clang/Lex/Preprocessor.h
clang/include/clang/Lex/PreprocessorOptions.h
clang/include/clang/Sema/Sema.h
clang/lib/Basic/Targets/OSTargets.h
clang/lib/Basic/Targets/X86.h
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Frontend/InitPreprocessor.cpp
clang/lib/Lex/PPMacroExpansion.cpp
clang/lib/Parse/ParsePragma.cpp
clang/lib/Sema/Sema.cpp
clang/lib/Sema/SemaAttr.cpp
clang/lib/Sema/SemaExpr.cpp
clang/test/CodeGen/fp-floatcontrol-pragma.cpp
clang/test/Preprocessor/init-aarch64.c
clang/test/Preprocessor/init-arm.c
clang/test/Preprocessor/init-mips.c
clang/test/Preprocessor/init-ppc.c
clang/test/Preprocessor/init-ppc64.c
clang/test/Preprocessor/init-s390x.c
clang/test/Preprocessor/init-v7k-compat.c
clang/test/Preprocessor/init-x86.c
clang/test/Preprocessor/init.c

Removed: 




diff  --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index f14f986c646a4..93805b65689ca 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -3552,7 +3552,7 @@ same spelling and syntax.  For pragmas specified at file 
scope, a stack
 is supported so that the ``pragma float_control`` settings can be pushed or 
popped.
 
 When ``pragma float_control(precise, on)`` is enabled, the section of code
-governed by the pragma uses precise floating point semantics, effectively
+governed by the pragma uses precise floating-point semantics, effectively
 ``-ffast-math`` is disabled and ``-ffp-contract=on``
 (fused multiply add) is enabled.
 
@@ -3563,8 +3563,29 @@ when ``pragma float_control(precise, off)`` is enabled, 
the section of code
 governed by the pragma behaves as though the command-line option
 ``-ffp-exception-behavior=ignore`` is enabled.
 
+When ``pragma float_control(source, on)`` is enabled, the section of code 
governed
+by the pragma behaves as though the command-line option
+``-ffp-eval-method=source`` is enabled. Note: The default
+floating-point evaluation method is target-specific, typically ``source``.
+
+When ``pragma float_control(double, on)`` is enabled, the section of code 
governed
+by the pragma behaves as though the command-line option
+``-ffp-eval-method=double`` is enabled.
+
+When ``pragma float_control(extended, on)`` is enabled, the section of code 
governed
+by the pragma behaves as though the command-line option
+``-ffp-eval-method=extended`` is enabled.
+
+When ``pragma float_control(source, off)`` or
+``pragma float_control(double, off)`` or
+``pragma float_control(extended, off)`` is enabled,
+the section of code governed
+by the pragma behaves as though the command-line option
+``-ffp-eval-method=source`` is enabled, returning floating-point evaluation
+method to the default setting.
+
 The full syntax this pragma supports is
-``float_control(except|precise, on|off [, push])`` and
+``float_control(except|precise|source|double|extended, on|off [, push])`` and
 ``float_control(push|pop)``.
 The ``push`` and ``pop`` forms, including using ``push`` as the optional
 third argument, can only occur at file scope.

diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index f7f76ed3f3e20..c47c3cdb4207f 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -1478,6 +1478,17 @@ Note that floating-point operations 

[clang] ea864c9 - [clang][patch][NFC] Refactor calculation of FunctionDecl to avoid duplicate code

2021-07-20 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2021-07-20T11:01:22-04:00
New Revision: ea864c9933021030e33411da79b5155a78b33325

URL: 
https://github.com/llvm/llvm-project/commit/ea864c9933021030e33411da79b5155a78b33325
DIFF: 
https://github.com/llvm/llvm-project/commit/ea864c9933021030e33411da79b5155a78b33325.diff

LOG: [clang][patch][NFC] Refactor calculation of FunctionDecl to avoid 
duplicate code

Added: 


Modified: 
clang/lib/CodeGen/CodeGenFunction.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenFunction.cpp 
b/clang/lib/CodeGen/CodeGenFunction.cpp
index 91480b0824a2..a2384456ea94 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -710,9 +710,9 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType 
RetTy,
 
   DidCallStackSave = false;
   CurCodeDecl = D;
-  if (const auto *FD = dyn_cast_or_null(D))
-if (FD->usesSEHTry())
-  CurSEHParent = FD;
+  const FunctionDecl *FD = dyn_cast_or_null(D);
+  if (FD && FD->usesSEHTry())
+CurSEHParent = FD;
   CurFuncDecl = (D ? D->getNonClosureContext() : nullptr);
   FnRetTy = RetTy;
   CurFn = Fn;
@@ -803,10 +803,9 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, 
QualType RetTy,
   // are not aware of how to move the extra UBSan instructions across the split
   // coroutine boundaries.
   if (D && SanOpts.has(SanitizerKind::Null))
-if (const auto *FD = dyn_cast(D))
-  if (FD->getBody() &&
-  FD->getBody()->getStmtClass() == Stmt::CoroutineBodyStmtClass)
-SanOpts.Mask &= ~SanitizerKind::Null;
+if (FD && FD->getBody() &&
+FD->getBody()->getStmtClass() == Stmt::CoroutineBodyStmtClass)
+  SanOpts.Mask &= ~SanitizerKind::Null;
 
   // Apply xray attributes to the function (as a string, for now)
   bool AlwaysXRayAttr = false;
@@ -896,32 +895,27 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, 
QualType RetTy,
   if (D && D->hasAttr())
 Fn->addFnAttr(llvm::Attribute::NoProfile);
 
-  if (getLangOpts().OpenCL) {
+  if (FD && getLangOpts().OpenCL) {
 // Add metadata for a kernel function.
-if (const FunctionDecl *FD = dyn_cast_or_null(D))
-  EmitOpenCLKernelMetadata(FD, Fn);
+EmitOpenCLKernelMetadata(FD, Fn);
   }
 
   // If we are checking function types, emit a function type signature as
   // prologue data.
-  if (getLangOpts().CPlusPlus && SanOpts.has(SanitizerKind::Function)) {
-if (const FunctionDecl *FD = dyn_cast_or_null(D)) {
-  if (llvm::Constant *PrologueSig = getPrologueSignature(CGM, FD)) {
-// Remove any (C++17) exception specifications, to allow calling e.g. a
-// noexcept function through a non-noexcept pointer.
-auto ProtoTy =
-  getContext().getFunctionTypeWithExceptionSpec(FD->getType(),
-EST_None);
-llvm::Constant *FTRTTIConst =
-CGM.GetAddrOfRTTIDescriptor(ProtoTy, /*ForEH=*/true);
-llvm::Constant *FTRTTIConstEncoded =
-EncodeAddrForUseInPrologue(Fn, FTRTTIConst);
-llvm::Constant *PrologueStructElems[] = {PrologueSig,
- FTRTTIConstEncoded};
-llvm::Constant *PrologueStructConst =
-llvm::ConstantStruct::getAnon(PrologueStructElems, 
/*Packed=*/true);
-Fn->setPrologueData(PrologueStructConst);
-  }
+  if (FD && getLangOpts().CPlusPlus && SanOpts.has(SanitizerKind::Function)) {
+if (llvm::Constant *PrologueSig = getPrologueSignature(CGM, FD)) {
+  // Remove any (C++17) exception specifications, to allow calling e.g. a
+  // noexcept function through a non-noexcept pointer.
+  auto ProtoTy = getContext().getFunctionTypeWithExceptionSpec(
+  FD->getType(), EST_None);
+  llvm::Constant *FTRTTIConst =
+  CGM.GetAddrOfRTTIDescriptor(ProtoTy, /*ForEH=*/true);
+  llvm::Constant *FTRTTIConstEncoded =
+  EncodeAddrForUseInPrologue(Fn, FTRTTIConst);
+  llvm::Constant *PrologueStructElems[] = {PrologueSig, 
FTRTTIConstEncoded};
+  llvm::Constant *PrologueStructConst =
+  llvm::ConstantStruct::getAnon(PrologueStructElems, /*Packed=*/true);
+  Fn->setPrologueData(PrologueStructConst);
 }
   }
 
@@ -948,14 +942,12 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, 
QualType RetTy,
   // kernels cannot include RTTI information, exception classes,
   // recursive code, virtual functions or make use of C++ libraries that
   // are not compiled for the device.
-  if (const FunctionDecl *FD = dyn_cast_or_null(D)) {
-if ((getLangOpts().CPlusPlus && FD->isMain()) || getLangOpts().OpenCL ||
-getLangOpts().SYCLIsDevice ||
-(getLangOpts().CUDA && FD->hasAttr()))
-  Fn->addFnAttr(llvm::Attribute::NoRecurse);
-  }
+  if (FD && ((getLangOpts().CPlusPlus && FD->isMain()) ||
+ getLangOpts().OpenCL || 

[clang] e773216 - [clang][patch] Add builtin __arithmetic_fence and option fprotect-parens

2021-06-30 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2021-06-30T09:58:06-04:00
New Revision: e773216f46368cd927a3c67bfa2516913acb75e7

URL: 
https://github.com/llvm/llvm-project/commit/e773216f46368cd927a3c67bfa2516913acb75e7
DIFF: 
https://github.com/llvm/llvm-project/commit/e773216f46368cd927a3c67bfa2516913acb75e7.diff

LOG: [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

Added: 
clang/test/AST/arithmetic-fence-builtin.c
clang/test/CodeGen/arithmetic-fence-builtin.c
clang/test/Sema/arithmetic-fence-builtin.c

Modified: 
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/Driver/clang_f_opts.c

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 244212a1336db..9e8bac635337e 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -1478,6 +1478,26 @@ Note that floating-point operations performed as part of 
constant initialization
* ``maytrap`` The compiler avoids transformations that may raise exceptions 
that would not have been raised by the original code. Constant folding 
performed by the compiler is exempt from this option.
* ``strict`` The compiler ensures that all transformations strictly 
preserve the floating point exception semantics of the original code.
 
+.. option:: -f[no-]protect-parens:
+
+   This option pertains to floating-point types, complex types with
+   floating-point components, and vectors of these types. Some arithmetic
+   expression transformations that are mathematically correct and permissible
+   according to the C and C++ language standards may be incorrect when dealing
+   with floating-point types, such as reassociation and distribution. Further,
+   the optimizer may ignore parentheses when computing arithmetic expressions
+   in circumstances where the parenthesized and unparenthesized expression
+   express the same mathematical value. For example (a+b)+c is the same
+   mathematical value as a+(b+c), but the optimizer is free to evaluate the 
+   additions in any order regardless of the parentheses. When enabled, this
+   option forces the optimizer to honor the order of operations with respect
+   to parentheses in all circumstances.
+
+   Note that floating-point contraction (option `-ffp-contract=`) is disabled
+   when `-fprotect-parens` is enabled.  Also note that in safe floating-point
+   modes, such as `-ffp-model=precise` or `-ffp-model=strict`, this option
+   has no effect because the optimizer is prohibited from making unsafe
+   transformations.
 
 .. _fp-constant-eval:
 

diff  --git a/clang/include/clang/Basic/Builtins.def 
b/clang/include/clang/Basic/Builtins.def
index 5a9d0a0018292..33d3e6dc4e7db 100644
--- a/clang/include/clang/Basic/Builtins.def
+++ b/clang/include/clang/Basic/Builtins.def
@@ -1657,6 +1657,9 @@ BUILTIN(__builtin_ms_va_start, "vc*&.", "nt")
 BUILTIN(__builtin_ms_va_end, "vc*&", "n")
 BUILTIN(__builtin_ms_va_copy, "vc**&", "n")
 
+// Arithmetic Fence: to prevent FP reordering and reassociation optimizations
+LANGBUILTIN(__arithmetic_fence, "v.", "t", ALL_LANGUAGES)
+
 #undef BUILTIN
 #undef LIBBUILTIN
 #undef LANGBUILTIN

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 70a22fd2506a3..22c2a1a39ea13 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -8530,6 +8530,9 @@ def err_typecheck_expect_scalar_operand : Error<
   "operand of type %0 where arithmetic or pointer type is required">;
 def err_typecheck_cond_incompatible_operands : Error<
   "incompatible operand types%
diff { ($ and $)|}0,1">;
+def err_typecheck_expect_flt_or_vector : Error<
+  "invalid operand of type %0 where floating, complex or "
+  "a vector of such types is required">;
 def err_cast_selector_expr : 

[clang] aaba371 - [clang][PATCH][nfc] Refactor TargetInfo::adjust to pass DiagnosticsEngine to allow diagnostics on target-unsupported options

2021-06-29 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2021-06-29T13:26:23-04:00
New Revision: aaba37187fda7f5a7fdc4c1e6129cbaaa1bbf709

URL: 
https://github.com/llvm/llvm-project/commit/aaba37187fda7f5a7fdc4c1e6129cbaaa1bbf709
DIFF: 
https://github.com/llvm/llvm-project/commit/aaba37187fda7f5a7fdc4c1e6129cbaaa1bbf709.diff

LOG: [clang][PATCH][nfc] Refactor TargetInfo::adjust to pass DiagnosticsEngine 
to allow diagnostics on target-unsupported options

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D104729

Added: 


Modified: 
clang/include/clang/Basic/TargetInfo.h
clang/lib/Basic/TargetInfo.cpp
clang/lib/Basic/Targets/AMDGPU.cpp
clang/lib/Basic/Targets/AMDGPU.h
clang/lib/Basic/Targets/PPC.cpp
clang/lib/Basic/Targets/PPC.h
clang/lib/Basic/Targets/SPIR.h
clang/lib/Basic/Targets/WebAssembly.cpp
clang/lib/Basic/Targets/WebAssembly.h
clang/lib/Frontend/ASTUnit.cpp
clang/lib/Frontend/CompilerInstance.cpp
clang/lib/Interpreter/Interpreter.cpp
clang/tools/clang-import-test/clang-import-test.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index d59bad30e7428..20f6afa76cbb3 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -1162,7 +1162,7 @@ class TargetInfo : public virtual TransferrableTargetInfo,
   /// Apply changes to the target information with respect to certain
   /// language options which change the target configuration and adjust
   /// the language based on the target options where applicable.
-  virtual void adjust(LangOptions );
+  virtual void adjust(DiagnosticsEngine , LangOptions );
 
   /// Adjust target options based on codegen options.
   virtual void adjustTargetOptions(const CodeGenOptions ,

diff  --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp
index e73b4a3a40c74..4c2859e5eda7f 100644
--- a/clang/lib/Basic/TargetInfo.cpp
+++ b/clang/lib/Basic/TargetInfo.cpp
@@ -346,7 +346,7 @@ bool TargetInfo::isTypeSigned(IntType T) {
 /// Apply changes to the target information with respect to certain
 /// language options which change the target configuration and adjust
 /// the language based on the target options where applicable.
-void TargetInfo::adjust(LangOptions ) {
+void TargetInfo::adjust(DiagnosticsEngine , LangOptions ) {
   if (Opts.NoBitFieldTypeAlign)
 UseBitFieldTypeAlignment = false;
 

diff  --git a/clang/lib/Basic/Targets/AMDGPU.cpp 
b/clang/lib/Basic/Targets/AMDGPU.cpp
index 595132e2e70ba..fac786dbcf9e2 100644
--- a/clang/lib/Basic/Targets/AMDGPU.cpp
+++ b/clang/lib/Basic/Targets/AMDGPU.cpp
@@ -358,8 +358,8 @@ AMDGPUTargetInfo::AMDGPUTargetInfo(const llvm::Triple 
,
   MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
 }
 
-void AMDGPUTargetInfo::adjust(LangOptions ) {
-  TargetInfo::adjust(Opts);
+void AMDGPUTargetInfo::adjust(DiagnosticsEngine , LangOptions ) {
+  TargetInfo::adjust(Diags, Opts);
   // ToDo: There are still a few places using default address space as private
   // address space in OpenCL, which needs to be cleaned up, then Opts.OpenCL
   // can be removed from the following line.

diff  --git a/clang/lib/Basic/Targets/AMDGPU.h 
b/clang/lib/Basic/Targets/AMDGPU.h
index fe5c61c6ba2bb..244a6e0446905 100644
--- a/clang/lib/Basic/Targets/AMDGPU.h
+++ b/clang/lib/Basic/Targets/AMDGPU.h
@@ -93,7 +93,7 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public 
TargetInfo {
 
   void setAddressSpaceMap(bool DefaultIsPrivate);
 
-  void adjust(LangOptions ) override;
+  void adjust(DiagnosticsEngine , LangOptions ) override;
 
   uint64_t getPointerWidthV(unsigned AddrSpace) const override {
 if (isR600(getTriple()))

diff  --git a/clang/lib/Basic/Targets/PPC.cpp b/clang/lib/Basic/Targets/PPC.cpp
index 6860b5e5d02fa..d431dda970222 100644
--- a/clang/lib/Basic/Targets/PPC.cpp
+++ b/clang/lib/Basic/Targets/PPC.cpp
@@ -614,10 +614,10 @@ void 
PPCTargetInfo::fillValidCPUList(SmallVectorImpl ) const {
   Values.append(std::begin(ValidCPUNames), std::end(ValidCPUNames));
 }
 
-void PPCTargetInfo::adjust(LangOptions ) {
+void PPCTargetInfo::adjust(DiagnosticsEngine , LangOptions ) {
   if (HasAltivec)
 Opts.AltiVec = 1;
-  TargetInfo::adjust(Opts);
+  TargetInfo::adjust(Diags, Opts);
   if (LongDoubleFormat != ::APFloat::IEEEdouble())
 LongDoubleFormat = Opts.PPCIEEELongDouble
? ::APFloat::IEEEquad()

diff  --git a/clang/lib/Basic/Targets/PPC.h b/clang/lib/Basic/Targets/PPC.h
index 554f2174fee00..18ee1194c759d 100644
--- a/clang/lib/Basic/Targets/PPC.h
+++ b/clang/lib/Basic/Targets/PPC.h
@@ -89,7 +89,7 @@ class LLVM_LIBRARY_VISIBILITY PPCTargetInfo : public 
TargetInfo {
   }
 
   // Set the language option 

[clang] 1d85d08 - Revert "[clang][PATCH][nfc] Refactor TargetInfo::adjust to pass DiagnosticsEngine to allow diagnostics on target-unsupported options"

2021-06-28 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2021-06-28T15:47:21-04:00
New Revision: 1d85d0879a75b9556b10f55739437af8233c0b64

URL: 
https://github.com/llvm/llvm-project/commit/1d85d0879a75b9556b10f55739437af8233c0b64
DIFF: 
https://github.com/llvm/llvm-project/commit/1d85d0879a75b9556b10f55739437af8233c0b64.diff

LOG: Revert "[clang][PATCH][nfc] Refactor TargetInfo::adjust to pass 
DiagnosticsEngine to allow diagnostics on target-unsupported options"

This reverts commit 2dbe1c675fe94eeb7973dcc25b049d25f4ca4fa0.
More buildbot failures

Added: 


Modified: 
clang/include/clang/Basic/TargetInfo.h
clang/lib/Basic/TargetInfo.cpp
clang/lib/Basic/Targets/AMDGPU.cpp
clang/lib/Basic/Targets/AMDGPU.h
clang/lib/Basic/Targets/PPC.cpp
clang/lib/Basic/Targets/PPC.h
clang/lib/Basic/Targets/SPIR.h
clang/lib/Basic/Targets/WebAssembly.cpp
clang/lib/Basic/Targets/WebAssembly.h
clang/lib/Frontend/ASTUnit.cpp
clang/lib/Frontend/CompilerInstance.cpp
clang/lib/Interpreter/Interpreter.cpp
clang/tools/clang-import-test/clang-import-test.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index 20f6afa76cbb3..d59bad30e7428 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -1162,7 +1162,7 @@ class TargetInfo : public virtual TransferrableTargetInfo,
   /// Apply changes to the target information with respect to certain
   /// language options which change the target configuration and adjust
   /// the language based on the target options where applicable.
-  virtual void adjust(DiagnosticsEngine , LangOptions );
+  virtual void adjust(LangOptions );
 
   /// Adjust target options based on codegen options.
   virtual void adjustTargetOptions(const CodeGenOptions ,

diff  --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp
index 4c2859e5eda7f..e73b4a3a40c74 100644
--- a/clang/lib/Basic/TargetInfo.cpp
+++ b/clang/lib/Basic/TargetInfo.cpp
@@ -346,7 +346,7 @@ bool TargetInfo::isTypeSigned(IntType T) {
 /// Apply changes to the target information with respect to certain
 /// language options which change the target configuration and adjust
 /// the language based on the target options where applicable.
-void TargetInfo::adjust(DiagnosticsEngine , LangOptions ) {
+void TargetInfo::adjust(LangOptions ) {
   if (Opts.NoBitFieldTypeAlign)
 UseBitFieldTypeAlignment = false;
 

diff  --git a/clang/lib/Basic/Targets/AMDGPU.cpp 
b/clang/lib/Basic/Targets/AMDGPU.cpp
index fac786dbcf9e2..595132e2e70ba 100644
--- a/clang/lib/Basic/Targets/AMDGPU.cpp
+++ b/clang/lib/Basic/Targets/AMDGPU.cpp
@@ -358,8 +358,8 @@ AMDGPUTargetInfo::AMDGPUTargetInfo(const llvm::Triple 
,
   MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
 }
 
-void AMDGPUTargetInfo::adjust(DiagnosticsEngine , LangOptions ) {
-  TargetInfo::adjust(Diags, Opts);
+void AMDGPUTargetInfo::adjust(LangOptions ) {
+  TargetInfo::adjust(Opts);
   // ToDo: There are still a few places using default address space as private
   // address space in OpenCL, which needs to be cleaned up, then Opts.OpenCL
   // can be removed from the following line.

diff  --git a/clang/lib/Basic/Targets/AMDGPU.h 
b/clang/lib/Basic/Targets/AMDGPU.h
index 244a6e0446905..fe5c61c6ba2bb 100644
--- a/clang/lib/Basic/Targets/AMDGPU.h
+++ b/clang/lib/Basic/Targets/AMDGPU.h
@@ -93,7 +93,7 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public 
TargetInfo {
 
   void setAddressSpaceMap(bool DefaultIsPrivate);
 
-  void adjust(DiagnosticsEngine , LangOptions ) override;
+  void adjust(LangOptions ) override;
 
   uint64_t getPointerWidthV(unsigned AddrSpace) const override {
 if (isR600(getTriple()))

diff  --git a/clang/lib/Basic/Targets/PPC.cpp b/clang/lib/Basic/Targets/PPC.cpp
index d431dda970222..6860b5e5d02fa 100644
--- a/clang/lib/Basic/Targets/PPC.cpp
+++ b/clang/lib/Basic/Targets/PPC.cpp
@@ -614,10 +614,10 @@ void 
PPCTargetInfo::fillValidCPUList(SmallVectorImpl ) const {
   Values.append(std::begin(ValidCPUNames), std::end(ValidCPUNames));
 }
 
-void PPCTargetInfo::adjust(DiagnosticsEngine , LangOptions ) {
+void PPCTargetInfo::adjust(LangOptions ) {
   if (HasAltivec)
 Opts.AltiVec = 1;
-  TargetInfo::adjust(Diags, Opts);
+  TargetInfo::adjust(Opts);
   if (LongDoubleFormat != ::APFloat::IEEEdouble())
 LongDoubleFormat = Opts.PPCIEEELongDouble
? ::APFloat::IEEEquad()

diff  --git a/clang/lib/Basic/Targets/PPC.h b/clang/lib/Basic/Targets/PPC.h
index 18ee1194c759d..554f2174fee00 100644
--- a/clang/lib/Basic/Targets/PPC.h
+++ b/clang/lib/Basic/Targets/PPC.h
@@ -89,7 +89,7 @@ class LLVM_LIBRARY_VISIBILITY PPCTargetInfo : public 
TargetInfo {
   }
 
   // Set the 

[clang] 2dbe1c6 - [clang][PATCH][nfc] Refactor TargetInfo::adjust to pass DiagnosticsEngine to allow diagnostics on target-unsupported options

2021-06-28 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2021-06-28T15:09:53-04:00
New Revision: 2dbe1c675fe94eeb7973dcc25b049d25f4ca4fa0

URL: 
https://github.com/llvm/llvm-project/commit/2dbe1c675fe94eeb7973dcc25b049d25f4ca4fa0
DIFF: 
https://github.com/llvm/llvm-project/commit/2dbe1c675fe94eeb7973dcc25b049d25f4ca4fa0.diff

LOG: [clang][PATCH][nfc] Refactor TargetInfo::adjust to pass DiagnosticsEngine 
to allow diagnostics on target-unsupported options

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D104729

Added: 


Modified: 
clang/include/clang/Basic/TargetInfo.h
clang/lib/Basic/TargetInfo.cpp
clang/lib/Basic/Targets/AMDGPU.cpp
clang/lib/Basic/Targets/AMDGPU.h
clang/lib/Basic/Targets/PPC.cpp
clang/lib/Basic/Targets/PPC.h
clang/lib/Basic/Targets/SPIR.h
clang/lib/Basic/Targets/WebAssembly.cpp
clang/lib/Basic/Targets/WebAssembly.h
clang/lib/Frontend/ASTUnit.cpp
clang/lib/Frontend/CompilerInstance.cpp
clang/lib/Interpreter/Interpreter.cpp
clang/tools/clang-import-test/clang-import-test.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index d59bad30e7428..20f6afa76cbb3 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -1162,7 +1162,7 @@ class TargetInfo : public virtual TransferrableTargetInfo,
   /// Apply changes to the target information with respect to certain
   /// language options which change the target configuration and adjust
   /// the language based on the target options where applicable.
-  virtual void adjust(LangOptions );
+  virtual void adjust(DiagnosticsEngine , LangOptions );
 
   /// Adjust target options based on codegen options.
   virtual void adjustTargetOptions(const CodeGenOptions ,

diff  --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp
index e73b4a3a40c74..4c2859e5eda7f 100644
--- a/clang/lib/Basic/TargetInfo.cpp
+++ b/clang/lib/Basic/TargetInfo.cpp
@@ -346,7 +346,7 @@ bool TargetInfo::isTypeSigned(IntType T) {
 /// Apply changes to the target information with respect to certain
 /// language options which change the target configuration and adjust
 /// the language based on the target options where applicable.
-void TargetInfo::adjust(LangOptions ) {
+void TargetInfo::adjust(DiagnosticsEngine , LangOptions ) {
   if (Opts.NoBitFieldTypeAlign)
 UseBitFieldTypeAlignment = false;
 

diff  --git a/clang/lib/Basic/Targets/AMDGPU.cpp 
b/clang/lib/Basic/Targets/AMDGPU.cpp
index 595132e2e70ba..fac786dbcf9e2 100644
--- a/clang/lib/Basic/Targets/AMDGPU.cpp
+++ b/clang/lib/Basic/Targets/AMDGPU.cpp
@@ -358,8 +358,8 @@ AMDGPUTargetInfo::AMDGPUTargetInfo(const llvm::Triple 
,
   MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
 }
 
-void AMDGPUTargetInfo::adjust(LangOptions ) {
-  TargetInfo::adjust(Opts);
+void AMDGPUTargetInfo::adjust(DiagnosticsEngine , LangOptions ) {
+  TargetInfo::adjust(Diags, Opts);
   // ToDo: There are still a few places using default address space as private
   // address space in OpenCL, which needs to be cleaned up, then Opts.OpenCL
   // can be removed from the following line.

diff  --git a/clang/lib/Basic/Targets/AMDGPU.h 
b/clang/lib/Basic/Targets/AMDGPU.h
index fe5c61c6ba2bb..244a6e0446905 100644
--- a/clang/lib/Basic/Targets/AMDGPU.h
+++ b/clang/lib/Basic/Targets/AMDGPU.h
@@ -93,7 +93,7 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public 
TargetInfo {
 
   void setAddressSpaceMap(bool DefaultIsPrivate);
 
-  void adjust(LangOptions ) override;
+  void adjust(DiagnosticsEngine , LangOptions ) override;
 
   uint64_t getPointerWidthV(unsigned AddrSpace) const override {
 if (isR600(getTriple()))

diff  --git a/clang/lib/Basic/Targets/PPC.cpp b/clang/lib/Basic/Targets/PPC.cpp
index 6860b5e5d02fa..d431dda970222 100644
--- a/clang/lib/Basic/Targets/PPC.cpp
+++ b/clang/lib/Basic/Targets/PPC.cpp
@@ -614,10 +614,10 @@ void 
PPCTargetInfo::fillValidCPUList(SmallVectorImpl ) const {
   Values.append(std::begin(ValidCPUNames), std::end(ValidCPUNames));
 }
 
-void PPCTargetInfo::adjust(LangOptions ) {
+void PPCTargetInfo::adjust(DiagnosticsEngine , LangOptions ) {
   if (HasAltivec)
 Opts.AltiVec = 1;
-  TargetInfo::adjust(Opts);
+  TargetInfo::adjust(Diags, Opts);
   if (LongDoubleFormat != ::APFloat::IEEEdouble())
 LongDoubleFormat = Opts.PPCIEEELongDouble
? ::APFloat::IEEEquad()

diff  --git a/clang/lib/Basic/Targets/PPC.h b/clang/lib/Basic/Targets/PPC.h
index 554f2174fee00..18ee1194c759d 100644
--- a/clang/lib/Basic/Targets/PPC.h
+++ b/clang/lib/Basic/Targets/PPC.h
@@ -89,7 +89,7 @@ class LLVM_LIBRARY_VISIBILITY PPCTargetInfo : public 
TargetInfo {
   }
 
   // Set the language option 

[clang] c27e5a2 - Revert "[clang][patch][fpenv] Add builtin __arithmetic_fence and option fprotect-parens"

2021-06-28 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2021-06-28T12:42:59-04:00
New Revision: c27e5a2a8e34aaa4c6037498cd8d21df0a8e8e70

URL: 
https://github.com/llvm/llvm-project/commit/c27e5a2a8e34aaa4c6037498cd8d21df0a8e8e70
DIFF: 
https://github.com/llvm/llvm-project/commit/c27e5a2a8e34aaa4c6037498cd8d21df0a8e8e70.diff

LOG: Revert "[clang][patch][fpenv] Add builtin __arithmetic_fence and option 
fprotect-parens"

This reverts commit 4f1238e44d803b145997fa984677a6c5cdf1f417.
Buildbot fails on predecessor patch

Added: 


Modified: 
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/Driver/clang_f_opts.c

Removed: 
clang/test/AST/arithmetic-fence-builtin.c
clang/test/CodeGen/arithmetic-fence-builtin.c
clang/test/Sema/arithmetic-fence-builtin.c



diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 9e8bac635337..244212a1336d 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -1478,26 +1478,6 @@ Note that floating-point operations performed as part of 
constant initialization
* ``maytrap`` The compiler avoids transformations that may raise exceptions 
that would not have been raised by the original code. Constant folding 
performed by the compiler is exempt from this option.
* ``strict`` The compiler ensures that all transformations strictly 
preserve the floating point exception semantics of the original code.
 
-.. option:: -f[no-]protect-parens:
-
-   This option pertains to floating-point types, complex types with
-   floating-point components, and vectors of these types. Some arithmetic
-   expression transformations that are mathematically correct and permissible
-   according to the C and C++ language standards may be incorrect when dealing
-   with floating-point types, such as reassociation and distribution. Further,
-   the optimizer may ignore parentheses when computing arithmetic expressions
-   in circumstances where the parenthesized and unparenthesized expression
-   express the same mathematical value. For example (a+b)+c is the same
-   mathematical value as a+(b+c), but the optimizer is free to evaluate the 
-   additions in any order regardless of the parentheses. When enabled, this
-   option forces the optimizer to honor the order of operations with respect
-   to parentheses in all circumstances.
-
-   Note that floating-point contraction (option `-ffp-contract=`) is disabled
-   when `-fprotect-parens` is enabled.  Also note that in safe floating-point
-   modes, such as `-ffp-model=precise` or `-ffp-model=strict`, this option
-   has no effect because the optimizer is prohibited from making unsafe
-   transformations.
 
 .. _fp-constant-eval:
 

diff  --git a/clang/include/clang/Basic/Builtins.def 
b/clang/include/clang/Basic/Builtins.def
index 33d3e6dc4e7d..5a9d0a001829 100644
--- a/clang/include/clang/Basic/Builtins.def
+++ b/clang/include/clang/Basic/Builtins.def
@@ -1657,9 +1657,6 @@ BUILTIN(__builtin_ms_va_start, "vc*&.", "nt")
 BUILTIN(__builtin_ms_va_end, "vc*&", "n")
 BUILTIN(__builtin_ms_va_copy, "vc**&", "n")
 
-// Arithmetic Fence: to prevent FP reordering and reassociation optimizations
-LANGBUILTIN(__arithmetic_fence, "v.", "t", ALL_LANGUAGES)
-
 #undef BUILTIN
 #undef LIBBUILTIN
 #undef LANGBUILTIN

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 22c2a1a39ea1..70a22fd2506a 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -8530,9 +8530,6 @@ def err_typecheck_expect_scalar_operand : Error<
   "operand of type %0 where arithmetic or pointer type is required">;
 def err_typecheck_cond_incompatible_operands : Error<
   "incompatible operand types%
diff { ($ and $)|}0,1">;
-def err_typecheck_expect_flt_or_vector : Error<
-  "invalid operand of type %0 where floating, complex or "
-  "a vector of such types is required">;
 def err_cast_selector_expr : Error<
   "cannot type cast @selector expression">;
 def ext_typecheck_cond_incompatible_pointers : ExtWarn<

diff  --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index b18e957a58f4..465bad8d7d11 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -199,8 +199,6 @@ COMPATIBLE_LANGOPT(Deprecated, 1, 0, "__DEPRECATED 

[clang] 8815ef8 - Revert "[clang][PATCH][nfc] Refactor TargetInfo::adjust to pass DiagnosticsEngine to allow diagnostics on target-unsupported options"

2021-06-28 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2021-06-28T12:42:59-04:00
New Revision: 8815ef823c803e98f328068d1abde255296de9c3

URL: 
https://github.com/llvm/llvm-project/commit/8815ef823c803e98f328068d1abde255296de9c3
DIFF: 
https://github.com/llvm/llvm-project/commit/8815ef823c803e98f328068d1abde255296de9c3.diff

LOG: Revert "[clang][PATCH][nfc] Refactor TargetInfo::adjust to pass 
DiagnosticsEngine to allow diagnostics on target-unsupported options"

This reverts commit 2c02b0c3f45414ac6c64583e006a26113c028304.
buildbot fails

Added: 


Modified: 
clang/include/clang/Basic/TargetInfo.h
clang/lib/Basic/TargetInfo.cpp
clang/lib/Basic/Targets/AMDGPU.cpp
clang/lib/Basic/Targets/AMDGPU.h
clang/lib/Basic/Targets/PPC.cpp
clang/lib/Basic/Targets/PPC.h
clang/lib/Basic/Targets/SPIR.h
clang/lib/Basic/Targets/WebAssembly.cpp
clang/lib/Basic/Targets/WebAssembly.h
clang/lib/Frontend/ASTUnit.cpp
clang/lib/Frontend/CompilerInstance.cpp
clang/lib/Interpreter/Interpreter.cpp
clang/tools/clang-import-test/clang-import-test.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index 4f0cbf986b31..0e984eb29b81 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -1162,7 +1162,7 @@ class TargetInfo : public virtual TransferrableTargetInfo,
   /// Apply changes to the target information with respect to certain
   /// language options which change the target configuration and adjust
   /// the language based on the target options where applicable.
-  virtual void adjust(DiagnosticsEngine , LangOptions );
+  virtual void adjust(LangOptions );
 
   /// Adjust target options based on codegen options.
   virtual void adjustTargetOptions(const CodeGenOptions ,

diff  --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp
index 88086fa2fed7..ffd88dc75dba 100644
--- a/clang/lib/Basic/TargetInfo.cpp
+++ b/clang/lib/Basic/TargetInfo.cpp
@@ -346,7 +346,7 @@ bool TargetInfo::isTypeSigned(IntType T) {
 /// Apply changes to the target information with respect to certain
 /// language options which change the target configuration and adjust
 /// the language based on the target options where applicable.
-void TargetInfo::adjust(DiagnosticsEngine , LangOptions ) {
+void TargetInfo::adjust(LangOptions ) {
   if (Opts.NoBitFieldTypeAlign)
 UseBitFieldTypeAlignment = false;
 

diff  --git a/clang/lib/Basic/Targets/AMDGPU.cpp 
b/clang/lib/Basic/Targets/AMDGPU.cpp
index fac786dbcf9e..595132e2e70b 100644
--- a/clang/lib/Basic/Targets/AMDGPU.cpp
+++ b/clang/lib/Basic/Targets/AMDGPU.cpp
@@ -358,8 +358,8 @@ AMDGPUTargetInfo::AMDGPUTargetInfo(const llvm::Triple 
,
   MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
 }
 
-void AMDGPUTargetInfo::adjust(DiagnosticsEngine , LangOptions ) {
-  TargetInfo::adjust(Diags, Opts);
+void AMDGPUTargetInfo::adjust(LangOptions ) {
+  TargetInfo::adjust(Opts);
   // ToDo: There are still a few places using default address space as private
   // address space in OpenCL, which needs to be cleaned up, then Opts.OpenCL
   // can be removed from the following line.

diff  --git a/clang/lib/Basic/Targets/AMDGPU.h 
b/clang/lib/Basic/Targets/AMDGPU.h
index 244a6e044690..fe5c61c6ba2b 100644
--- a/clang/lib/Basic/Targets/AMDGPU.h
+++ b/clang/lib/Basic/Targets/AMDGPU.h
@@ -93,7 +93,7 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public 
TargetInfo {
 
   void setAddressSpaceMap(bool DefaultIsPrivate);
 
-  void adjust(DiagnosticsEngine , LangOptions ) override;
+  void adjust(LangOptions ) override;
 
   uint64_t getPointerWidthV(unsigned AddrSpace) const override {
 if (isR600(getTriple()))

diff  --git a/clang/lib/Basic/Targets/PPC.cpp b/clang/lib/Basic/Targets/PPC.cpp
index d431dda97022..6860b5e5d02f 100644
--- a/clang/lib/Basic/Targets/PPC.cpp
+++ b/clang/lib/Basic/Targets/PPC.cpp
@@ -614,10 +614,10 @@ void 
PPCTargetInfo::fillValidCPUList(SmallVectorImpl ) const {
   Values.append(std::begin(ValidCPUNames), std::end(ValidCPUNames));
 }
 
-void PPCTargetInfo::adjust(DiagnosticsEngine , LangOptions ) {
+void PPCTargetInfo::adjust(LangOptions ) {
   if (HasAltivec)
 Opts.AltiVec = 1;
-  TargetInfo::adjust(Diags, Opts);
+  TargetInfo::adjust(Opts);
   if (LongDoubleFormat != ::APFloat::IEEEdouble())
 LongDoubleFormat = Opts.PPCIEEELongDouble
? ::APFloat::IEEEquad()

diff  --git a/clang/lib/Basic/Targets/PPC.h b/clang/lib/Basic/Targets/PPC.h
index 18ee1194c759..554f2174fee0 100644
--- a/clang/lib/Basic/Targets/PPC.h
+++ b/clang/lib/Basic/Targets/PPC.h
@@ -89,7 +89,7 @@ class LLVM_LIBRARY_VISIBILITY PPCTargetInfo : public 
TargetInfo {
   }
 
   // Set the language option for altivec based on our value.
-  void adjust(DiagnosticsEngine , LangOptions ) override;
+  void adjust(LangOptions ) override;
 
   // Note: GCC 

[clang] 4f1238e - [clang][patch][fpenv] Add builtin __arithmetic_fence and option fprotect-parens

2021-06-28 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2021-06-28T12:26:53-04:00
New Revision: 4f1238e44d803b145997fa984677a6c5cdf1f417

URL: 
https://github.com/llvm/llvm-project/commit/4f1238e44d803b145997fa984677a6c5cdf1f417
DIFF: 
https://github.com/llvm/llvm-project/commit/4f1238e44d803b145997fa984677a6c5cdf1f417.diff

LOG: [clang][patch][fpenv] 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

Added: 
clang/test/AST/arithmetic-fence-builtin.c
clang/test/CodeGen/arithmetic-fence-builtin.c
clang/test/Sema/arithmetic-fence-builtin.c

Modified: 
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/Driver/clang_f_opts.c

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 244212a1336d..9e8bac635337 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -1478,6 +1478,26 @@ Note that floating-point operations performed as part of 
constant initialization
* ``maytrap`` The compiler avoids transformations that may raise exceptions 
that would not have been raised by the original code. Constant folding 
performed by the compiler is exempt from this option.
* ``strict`` The compiler ensures that all transformations strictly 
preserve the floating point exception semantics of the original code.
 
+.. option:: -f[no-]protect-parens:
+
+   This option pertains to floating-point types, complex types with
+   floating-point components, and vectors of these types. Some arithmetic
+   expression transformations that are mathematically correct and permissible
+   according to the C and C++ language standards may be incorrect when dealing
+   with floating-point types, such as reassociation and distribution. Further,
+   the optimizer may ignore parentheses when computing arithmetic expressions
+   in circumstances where the parenthesized and unparenthesized expression
+   express the same mathematical value. For example (a+b)+c is the same
+   mathematical value as a+(b+c), but the optimizer is free to evaluate the 
+   additions in any order regardless of the parentheses. When enabled, this
+   option forces the optimizer to honor the order of operations with respect
+   to parentheses in all circumstances.
+
+   Note that floating-point contraction (option `-ffp-contract=`) is disabled
+   when `-fprotect-parens` is enabled.  Also note that in safe floating-point
+   modes, such as `-ffp-model=precise` or `-ffp-model=strict`, this option
+   has no effect because the optimizer is prohibited from making unsafe
+   transformations.
 
 .. _fp-constant-eval:
 

diff  --git a/clang/include/clang/Basic/Builtins.def 
b/clang/include/clang/Basic/Builtins.def
index 5a9d0a001829..33d3e6dc4e7d 100644
--- a/clang/include/clang/Basic/Builtins.def
+++ b/clang/include/clang/Basic/Builtins.def
@@ -1657,6 +1657,9 @@ BUILTIN(__builtin_ms_va_start, "vc*&.", "nt")
 BUILTIN(__builtin_ms_va_end, "vc*&", "n")
 BUILTIN(__builtin_ms_va_copy, "vc**&", "n")
 
+// Arithmetic Fence: to prevent FP reordering and reassociation optimizations
+LANGBUILTIN(__arithmetic_fence, "v.", "t", ALL_LANGUAGES)
+
 #undef BUILTIN
 #undef LIBBUILTIN
 #undef LANGBUILTIN

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 70a22fd2506a..22c2a1a39ea1 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -8530,6 +8530,9 @@ def err_typecheck_expect_scalar_operand : Error<
   "operand of type %0 where arithmetic or pointer type is required">;
 def err_typecheck_cond_incompatible_operands : Error<
   "incompatible operand types%
diff { ($ and $)|}0,1">;
+def err_typecheck_expect_flt_or_vector : Error<
+  "invalid operand of type %0 where floating, complex or "
+  "a vector of such types is required">;
 def err_cast_selector_expr : 

[clang] 2c02b0c - [clang][PATCH][nfc] Refactor TargetInfo::adjust to pass DiagnosticsEngine to allow diagnostics on target-unsupported options

2021-06-28 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2021-06-28T12:26:53-04:00
New Revision: 2c02b0c3f45414ac6c64583e006a26113c028304

URL: 
https://github.com/llvm/llvm-project/commit/2c02b0c3f45414ac6c64583e006a26113c028304
DIFF: 
https://github.com/llvm/llvm-project/commit/2c02b0c3f45414ac6c64583e006a26113c028304.diff

LOG: [clang][PATCH][nfc] Refactor TargetInfo::adjust to pass DiagnosticsEngine 
to allow diagnostics on target-unsupported options

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D104729

Added: 


Modified: 
clang/include/clang/Basic/TargetInfo.h
clang/lib/Basic/TargetInfo.cpp
clang/lib/Basic/Targets/AMDGPU.cpp
clang/lib/Basic/Targets/AMDGPU.h
clang/lib/Basic/Targets/PPC.cpp
clang/lib/Basic/Targets/PPC.h
clang/lib/Basic/Targets/SPIR.h
clang/lib/Basic/Targets/WebAssembly.cpp
clang/lib/Basic/Targets/WebAssembly.h
clang/lib/Frontend/ASTUnit.cpp
clang/lib/Frontend/CompilerInstance.cpp
clang/lib/Interpreter/Interpreter.cpp
clang/tools/clang-import-test/clang-import-test.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index d59bad30e742..20f6afa76cbb 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -1162,7 +1162,7 @@ class TargetInfo : public virtual TransferrableTargetInfo,
   /// Apply changes to the target information with respect to certain
   /// language options which change the target configuration and adjust
   /// the language based on the target options where applicable.
-  virtual void adjust(LangOptions );
+  virtual void adjust(DiagnosticsEngine , LangOptions );
 
   /// Adjust target options based on codegen options.
   virtual void adjustTargetOptions(const CodeGenOptions ,

diff  --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp
index e73b4a3a40c7..4c2859e5eda7 100644
--- a/clang/lib/Basic/TargetInfo.cpp
+++ b/clang/lib/Basic/TargetInfo.cpp
@@ -346,7 +346,7 @@ bool TargetInfo::isTypeSigned(IntType T) {
 /// Apply changes to the target information with respect to certain
 /// language options which change the target configuration and adjust
 /// the language based on the target options where applicable.
-void TargetInfo::adjust(LangOptions ) {
+void TargetInfo::adjust(DiagnosticsEngine , LangOptions ) {
   if (Opts.NoBitFieldTypeAlign)
 UseBitFieldTypeAlignment = false;
 

diff  --git a/clang/lib/Basic/Targets/AMDGPU.cpp 
b/clang/lib/Basic/Targets/AMDGPU.cpp
index 595132e2e70b..fac786dbcf9e 100644
--- a/clang/lib/Basic/Targets/AMDGPU.cpp
+++ b/clang/lib/Basic/Targets/AMDGPU.cpp
@@ -358,8 +358,8 @@ AMDGPUTargetInfo::AMDGPUTargetInfo(const llvm::Triple 
,
   MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
 }
 
-void AMDGPUTargetInfo::adjust(LangOptions ) {
-  TargetInfo::adjust(Opts);
+void AMDGPUTargetInfo::adjust(DiagnosticsEngine , LangOptions ) {
+  TargetInfo::adjust(Diags, Opts);
   // ToDo: There are still a few places using default address space as private
   // address space in OpenCL, which needs to be cleaned up, then Opts.OpenCL
   // can be removed from the following line.

diff  --git a/clang/lib/Basic/Targets/AMDGPU.h 
b/clang/lib/Basic/Targets/AMDGPU.h
index fe5c61c6ba2b..244a6e044690 100644
--- a/clang/lib/Basic/Targets/AMDGPU.h
+++ b/clang/lib/Basic/Targets/AMDGPU.h
@@ -93,7 +93,7 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public 
TargetInfo {
 
   void setAddressSpaceMap(bool DefaultIsPrivate);
 
-  void adjust(LangOptions ) override;
+  void adjust(DiagnosticsEngine , LangOptions ) override;
 
   uint64_t getPointerWidthV(unsigned AddrSpace) const override {
 if (isR600(getTriple()))

diff  --git a/clang/lib/Basic/Targets/PPC.cpp b/clang/lib/Basic/Targets/PPC.cpp
index 6860b5e5d02f..d431dda97022 100644
--- a/clang/lib/Basic/Targets/PPC.cpp
+++ b/clang/lib/Basic/Targets/PPC.cpp
@@ -614,10 +614,10 @@ void 
PPCTargetInfo::fillValidCPUList(SmallVectorImpl ) const {
   Values.append(std::begin(ValidCPUNames), std::end(ValidCPUNames));
 }
 
-void PPCTargetInfo::adjust(LangOptions ) {
+void PPCTargetInfo::adjust(DiagnosticsEngine , LangOptions ) {
   if (HasAltivec)
 Opts.AltiVec = 1;
-  TargetInfo::adjust(Opts);
+  TargetInfo::adjust(Diags, Opts);
   if (LongDoubleFormat != ::APFloat::IEEEdouble())
 LongDoubleFormat = Opts.PPCIEEELongDouble
? ::APFloat::IEEEquad()

diff  --git a/clang/lib/Basic/Targets/PPC.h b/clang/lib/Basic/Targets/PPC.h
index 554f2174fee0..18ee1194c759 100644
--- a/clang/lib/Basic/Targets/PPC.h
+++ b/clang/lib/Basic/Targets/PPC.h
@@ -89,7 +89,7 @@ class LLVM_LIBRARY_VISIBILITY PPCTargetInfo : public 
TargetInfo {
   }
 
   // Set the language option for altivec based on our value.
-  void adjust(LangOptions ) override;
+  void adjust(DiagnosticsEngine , LangOptions ) override;
 
   // Note: GCC recognizes 

[clang] 9abaf5c - Revert "[clang][FPEnv] Clang floatng point model ffp-model=precise enables ffp-contract=on"

2021-06-19 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2021-06-19T08:01:22-04:00
New Revision: 9abaf5c359ca29fcdd4f42b72ae0a62f18626180

URL: 
https://github.com/llvm/llvm-project/commit/9abaf5c359ca29fcdd4f42b72ae0a62f18626180
DIFF: 
https://github.com/llvm/llvm-project/commit/9abaf5c359ca29fcdd4f42b72ae0a62f18626180.diff

LOG: Revert "[clang][FPEnv] Clang floatng point model ffp-model=precise enables 
ffp-contract=on"

This reverts commit a1449a10dbcfcf353f4f761281c4e572b4ce9308.
Seems like my changes to LNT had no effect -- puzzled.
The 21 tests pass on my sandbox with the clang patch but are
failing in exec time in the bot

Added: 


Modified: 
clang/docs/UsersManual.rst
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/CodeGen/ffp-contract-option.c
clang/test/CodeGen/ppc-emmintrin.c
clang/test/CodeGen/ppc-xmmintrin.c
clang/test/Driver/fp-model.c

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 96512f7514b3e..244212a1336db 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -1260,50 +1260,8 @@ installed.
 Controlling Floating Point Behavior
 ---
 
-Clang provides a number of ways to control floating point behavior, including
-with command line options and source pragmas. This section
-describes the various floating point semantic modes and the corresponding 
options.
-
-.. csv-table:: Floating Point Semantic Modes
-  :header: "Mode", "Values"
-  :widths: 15, 30, 30
-
-  "except_behavior", "{ignore, strict, may_trap}", "ffp-exception-behavior"
-  "fenv_access", "{off, on}", "(none)"
-  "rounding_mode", "{dynamic, tonearest, downward, upward, towardzero}", 
"frounding-math"
-  "contract", "{on, off, fast}", "ffp-contract"
-  "denormal_fp_math", "{IEEE, PreserveSign, PositiveZero}", "fdenormal-fp-math"
-  "denormal_fp32_math", "{IEEE, PreserveSign, PositiveZero}", 
"fdenormal-fp-math-fp32"
-  "support_math_errno", "{on, off}", "fmath-errno"
-  "no_honor_nans", "{on, off}", "fhonor-nans"
-  "no_honor_infinities", "{on, off}", "fhonor-infinities"
-  "no_signed_zeros", "{on, off}", "fsigned-zeros"
-  "allow_reciprocal", "{on, off}", "freciprocal-math"
-  "allow_approximate_fns", "{on, off}", "(none)"
-  "allow_reassociation", "{on, off}", "fassociative-math"
-
-
-This table describes the option settings that correspond to the three
-floating point semantic models: precise (the default), strict, and fast.
-
-
-.. csv-table:: Floating Point Models
-  :header: "Mode", "Precise", "Strict", "Fast"
-  :widths: 25, 15, 15, 15
-
-  "except_behavior", "ignore", "strict", "ignore"
-  "fenv_access", "off", "on", "off"
-  "rounding_mode", "tonearest", "dynamic", "tonearest"
-  "contract", "on", "off", "fast"
-  "denormal_fp_math", "IEEE", "IEEE", "PreserveSign"
-  "denormal_fp32_math", "IEEE","IEEE", "PreserveSign"
-  "support_math_errno", "on", "on", "off"
-  "no_honor_nans", "off", "off", "on"
-  "no_honor_infinities", "off", "off", "on"
-  "no_signed_zeros", "off", "off", "on"
-  "allow_reciprocal", "off", "off", "on"
-  "allow_approximate_fns", "off", "off", "on"
-  "allow_reassociation", "off", "off", "on"
+Clang provides a number of ways to control floating point behavior. The options
+are listed below.
 
 .. option:: -ffast-math
 
@@ -1498,7 +1456,7 @@ Note that floating-point operations performed as part of 
constant initialization
and ``fast``.
Details:
 
-   * ``precise`` Disables optimizations that are not value-safe on 
floating-point data, although FP contraction (FMA) is enabled 
(``-ffp-contract=on``).  This is the default behavior.
+   * ``precise`` Disables optimizations that are not value-safe on 
floating-point data, although FP contraction (FMA) is enabled 
(``-ffp-contract=fast``).  This is the default behavior.
* ``strict`` Enables ``-frounding-math`` and 
``-ffp-exception-behavior=strict``, and disables contractions (FMA).  All of 
the ``-ffast-math`` enablements are disabled. Enables ``STDC FENV_ACCESS``: by 
default ``FENV_ACCESS`` is disabled. This option setting behaves as though 
``#pragma STDC FENV_ACESS ON`` appeared at the top of the source file.
* ``fast`` Behaves identically to specifying both ``-ffast-math`` and 
``ffp-contract=fast``
 

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 1fc395cdda0bc..f6e3447eccb02 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2631,7 +2631,7 @@ static void RenderFloatingPointOptions(const ToolChain 
, const Driver ,
 
   llvm::DenormalMode DenormalFPMath = DefaultDenormalFPMath;
   llvm::DenormalMode DenormalFP32Math = DefaultDenormalFP32Math;
-  StringRef FPContract = "on";
+  StringRef FPContract = "";
   bool StrictFPModel = false;
 
 
@@ -2656,7 +2656,7 @@ static void RenderFloatingPointOptions(const ToolChain 
, const Driver ,
   ReciprocalMath = 

[clang] a1449a1 - [clang][FPEnv] Clang floatng point model ffp-model=precise enables ffp-contract=on

2021-06-19 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2021-06-19T06:49:27-04:00
New Revision: a1449a10dbcfcf353f4f761281c4e572b4ce9308

URL: 
https://github.com/llvm/llvm-project/commit/a1449a10dbcfcf353f4f761281c4e572b4ce9308
DIFF: 
https://github.com/llvm/llvm-project/commit/a1449a10dbcfcf353f4f761281c4e572b4ce9308.diff

LOG: [clang][FPEnv] Clang floatng point model ffp-model=precise enables 
ffp-contract=on

This patch changes the ffp-model=precise to enables -ffp-contract=on
(previously -ffp-model=precise enabled -ffp-contract=fast). This is a
follow-up to Andy Kaylor's comments in the llvm-dev discussion
"Floating Point semantic modes". From the same email thread, I put
Andy's distillation of floating point options and floating point modes
into UsersManual.rst

Differential Revision: https://reviews.llvm.org/D74436

Added: 


Modified: 
clang/docs/UsersManual.rst
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/CodeGen/ffp-contract-option.c
clang/test/CodeGen/ppc-emmintrin.c
clang/test/CodeGen/ppc-xmmintrin.c
clang/test/Driver/fp-model.c

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 244212a1336db..96512f7514b3e 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -1260,8 +1260,50 @@ installed.
 Controlling Floating Point Behavior
 ---
 
-Clang provides a number of ways to control floating point behavior. The options
-are listed below.
+Clang provides a number of ways to control floating point behavior, including
+with command line options and source pragmas. This section
+describes the various floating point semantic modes and the corresponding 
options.
+
+.. csv-table:: Floating Point Semantic Modes
+  :header: "Mode", "Values"
+  :widths: 15, 30, 30
+
+  "except_behavior", "{ignore, strict, may_trap}", "ffp-exception-behavior"
+  "fenv_access", "{off, on}", "(none)"
+  "rounding_mode", "{dynamic, tonearest, downward, upward, towardzero}", 
"frounding-math"
+  "contract", "{on, off, fast}", "ffp-contract"
+  "denormal_fp_math", "{IEEE, PreserveSign, PositiveZero}", "fdenormal-fp-math"
+  "denormal_fp32_math", "{IEEE, PreserveSign, PositiveZero}", 
"fdenormal-fp-math-fp32"
+  "support_math_errno", "{on, off}", "fmath-errno"
+  "no_honor_nans", "{on, off}", "fhonor-nans"
+  "no_honor_infinities", "{on, off}", "fhonor-infinities"
+  "no_signed_zeros", "{on, off}", "fsigned-zeros"
+  "allow_reciprocal", "{on, off}", "freciprocal-math"
+  "allow_approximate_fns", "{on, off}", "(none)"
+  "allow_reassociation", "{on, off}", "fassociative-math"
+
+
+This table describes the option settings that correspond to the three
+floating point semantic models: precise (the default), strict, and fast.
+
+
+.. csv-table:: Floating Point Models
+  :header: "Mode", "Precise", "Strict", "Fast"
+  :widths: 25, 15, 15, 15
+
+  "except_behavior", "ignore", "strict", "ignore"
+  "fenv_access", "off", "on", "off"
+  "rounding_mode", "tonearest", "dynamic", "tonearest"
+  "contract", "on", "off", "fast"
+  "denormal_fp_math", "IEEE", "IEEE", "PreserveSign"
+  "denormal_fp32_math", "IEEE","IEEE", "PreserveSign"
+  "support_math_errno", "on", "on", "off"
+  "no_honor_nans", "off", "off", "on"
+  "no_honor_infinities", "off", "off", "on"
+  "no_signed_zeros", "off", "off", "on"
+  "allow_reciprocal", "off", "off", "on"
+  "allow_approximate_fns", "off", "off", "on"
+  "allow_reassociation", "off", "off", "on"
 
 .. option:: -ffast-math
 
@@ -1456,7 +1498,7 @@ Note that floating-point operations performed as part of 
constant initialization
and ``fast``.
Details:
 
-   * ``precise`` Disables optimizations that are not value-safe on 
floating-point data, although FP contraction (FMA) is enabled 
(``-ffp-contract=fast``).  This is the default behavior.
+   * ``precise`` Disables optimizations that are not value-safe on 
floating-point data, although FP contraction (FMA) is enabled 
(``-ffp-contract=on``).  This is the default behavior.
* ``strict`` Enables ``-frounding-math`` and 
``-ffp-exception-behavior=strict``, and disables contractions (FMA).  All of 
the ``-ffast-math`` enablements are disabled. Enables ``STDC FENV_ACCESS``: by 
default ``FENV_ACCESS`` is disabled. This option setting behaves as though 
``#pragma STDC FENV_ACESS ON`` appeared at the top of the source file.
* ``fast`` Behaves identically to specifying both ``-ffast-math`` and 
``ffp-contract=fast``
 

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index f6e3447eccb02..1fc395cdda0bc 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2631,7 +2631,7 @@ static void RenderFloatingPointOptions(const ToolChain 
, const Driver ,
 
   llvm::DenormalMode DenormalFPMath = DefaultDenormalFPMath;
   llvm::DenormalMode DenormalFP32Math = DefaultDenormalFP32Math;
-  StringRef 

[clang] c3cc14f - Revert "[clang][FPEnv] Clang floatng point model ffp-model=precise enables ffp-contract=on"

2021-06-10 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2021-06-10T12:19:02-04:00
New Revision: c3cc14f87f78f8172b74175bbd2557cfb9384900

URL: 
https://github.com/llvm/llvm-project/commit/c3cc14f87f78f8172b74175bbd2557cfb9384900
DIFF: 
https://github.com/llvm/llvm-project/commit/c3cc14f87f78f8172b74175bbd2557cfb9384900.diff

LOG: Revert "[clang][FPEnv] Clang floatng point model ffp-model=precise enables 
ffp-contract=on"

This reverts commit 8daac3714083aa5507622dba858344051f6b5574.
The build bots are showing some fails on broadwell and arm.
Fix to LNT test suite needs work.

Added: 


Modified: 
clang/docs/UsersManual.rst
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/CodeGen/ffp-contract-option.c
clang/test/CodeGen/ppc-emmintrin.c
clang/test/CodeGen/ppc-xmmintrin.c
clang/test/Driver/fp-model.c

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 96512f7514b3e..244212a1336db 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -1260,50 +1260,8 @@ installed.
 Controlling Floating Point Behavior
 ---
 
-Clang provides a number of ways to control floating point behavior, including
-with command line options and source pragmas. This section
-describes the various floating point semantic modes and the corresponding 
options.
-
-.. csv-table:: Floating Point Semantic Modes
-  :header: "Mode", "Values"
-  :widths: 15, 30, 30
-
-  "except_behavior", "{ignore, strict, may_trap}", "ffp-exception-behavior"
-  "fenv_access", "{off, on}", "(none)"
-  "rounding_mode", "{dynamic, tonearest, downward, upward, towardzero}", 
"frounding-math"
-  "contract", "{on, off, fast}", "ffp-contract"
-  "denormal_fp_math", "{IEEE, PreserveSign, PositiveZero}", "fdenormal-fp-math"
-  "denormal_fp32_math", "{IEEE, PreserveSign, PositiveZero}", 
"fdenormal-fp-math-fp32"
-  "support_math_errno", "{on, off}", "fmath-errno"
-  "no_honor_nans", "{on, off}", "fhonor-nans"
-  "no_honor_infinities", "{on, off}", "fhonor-infinities"
-  "no_signed_zeros", "{on, off}", "fsigned-zeros"
-  "allow_reciprocal", "{on, off}", "freciprocal-math"
-  "allow_approximate_fns", "{on, off}", "(none)"
-  "allow_reassociation", "{on, off}", "fassociative-math"
-
-
-This table describes the option settings that correspond to the three
-floating point semantic models: precise (the default), strict, and fast.
-
-
-.. csv-table:: Floating Point Models
-  :header: "Mode", "Precise", "Strict", "Fast"
-  :widths: 25, 15, 15, 15
-
-  "except_behavior", "ignore", "strict", "ignore"
-  "fenv_access", "off", "on", "off"
-  "rounding_mode", "tonearest", "dynamic", "tonearest"
-  "contract", "on", "off", "fast"
-  "denormal_fp_math", "IEEE", "IEEE", "PreserveSign"
-  "denormal_fp32_math", "IEEE","IEEE", "PreserveSign"
-  "support_math_errno", "on", "on", "off"
-  "no_honor_nans", "off", "off", "on"
-  "no_honor_infinities", "off", "off", "on"
-  "no_signed_zeros", "off", "off", "on"
-  "allow_reciprocal", "off", "off", "on"
-  "allow_approximate_fns", "off", "off", "on"
-  "allow_reassociation", "off", "off", "on"
+Clang provides a number of ways to control floating point behavior. The options
+are listed below.
 
 .. option:: -ffast-math
 
@@ -1498,7 +1456,7 @@ Note that floating-point operations performed as part of 
constant initialization
and ``fast``.
Details:
 
-   * ``precise`` Disables optimizations that are not value-safe on 
floating-point data, although FP contraction (FMA) is enabled 
(``-ffp-contract=on``).  This is the default behavior.
+   * ``precise`` Disables optimizations that are not value-safe on 
floating-point data, although FP contraction (FMA) is enabled 
(``-ffp-contract=fast``).  This is the default behavior.
* ``strict`` Enables ``-frounding-math`` and 
``-ffp-exception-behavior=strict``, and disables contractions (FMA).  All of 
the ``-ffast-math`` enablements are disabled. Enables ``STDC FENV_ACCESS``: by 
default ``FENV_ACCESS`` is disabled. This option setting behaves as though 
``#pragma STDC FENV_ACESS ON`` appeared at the top of the source file.
* ``fast`` Behaves identically to specifying both ``-ffast-math`` and 
``ffp-contract=fast``
 

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 3163c26e44723..bcbb35f07d407 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2631,7 +2631,7 @@ static void RenderFloatingPointOptions(const ToolChain 
, const Driver ,
 
   llvm::DenormalMode DenormalFPMath = DefaultDenormalFPMath;
   llvm::DenormalMode DenormalFP32Math = DefaultDenormalFP32Math;
-  StringRef FPContract = "on";
+  StringRef FPContract = "";
   bool StrictFPModel = false;
 
 
@@ -2656,7 +2656,7 @@ static void RenderFloatingPointOptions(const ToolChain 
, const Driver ,
   ReciprocalMath = false;
   SignedZeros = true;
   // 

[clang] 8daac37 - [clang][FPEnv] Clang floatng point model ffp-model=precise enables ffp-contract=on

2021-06-10 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2021-06-10T09:30:41-04:00
New Revision: 8daac3714083aa5507622dba858344051f6b5574

URL: 
https://github.com/llvm/llvm-project/commit/8daac3714083aa5507622dba858344051f6b5574
DIFF: 
https://github.com/llvm/llvm-project/commit/8daac3714083aa5507622dba858344051f6b5574.diff

LOG: [clang][FPEnv] Clang floatng point model ffp-model=precise enables 
ffp-contract=on

This patch changes the ffp-model=precise to enables -ffp-contract=on
(previously -ffp-model=precise enabled -ffp-contract=fast). This is a
follow-up to Andy Kaylor's comments in the llvm-dev discussion
"Floating Point semantic modes". From the same email thread, I put
Andy's distillation of floating point options and floating point modes
into UsersManual.rst

Differential Revision: https://reviews.llvm.org/D74436

Added: 


Modified: 
clang/docs/UsersManual.rst
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/CodeGen/ffp-contract-option.c
clang/test/CodeGen/ppc-emmintrin.c
clang/test/CodeGen/ppc-xmmintrin.c
clang/test/Driver/fp-model.c

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 244212a1336db..96512f7514b3e 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -1260,8 +1260,50 @@ installed.
 Controlling Floating Point Behavior
 ---
 
-Clang provides a number of ways to control floating point behavior. The options
-are listed below.
+Clang provides a number of ways to control floating point behavior, including
+with command line options and source pragmas. This section
+describes the various floating point semantic modes and the corresponding 
options.
+
+.. csv-table:: Floating Point Semantic Modes
+  :header: "Mode", "Values"
+  :widths: 15, 30, 30
+
+  "except_behavior", "{ignore, strict, may_trap}", "ffp-exception-behavior"
+  "fenv_access", "{off, on}", "(none)"
+  "rounding_mode", "{dynamic, tonearest, downward, upward, towardzero}", 
"frounding-math"
+  "contract", "{on, off, fast}", "ffp-contract"
+  "denormal_fp_math", "{IEEE, PreserveSign, PositiveZero}", "fdenormal-fp-math"
+  "denormal_fp32_math", "{IEEE, PreserveSign, PositiveZero}", 
"fdenormal-fp-math-fp32"
+  "support_math_errno", "{on, off}", "fmath-errno"
+  "no_honor_nans", "{on, off}", "fhonor-nans"
+  "no_honor_infinities", "{on, off}", "fhonor-infinities"
+  "no_signed_zeros", "{on, off}", "fsigned-zeros"
+  "allow_reciprocal", "{on, off}", "freciprocal-math"
+  "allow_approximate_fns", "{on, off}", "(none)"
+  "allow_reassociation", "{on, off}", "fassociative-math"
+
+
+This table describes the option settings that correspond to the three
+floating point semantic models: precise (the default), strict, and fast.
+
+
+.. csv-table:: Floating Point Models
+  :header: "Mode", "Precise", "Strict", "Fast"
+  :widths: 25, 15, 15, 15
+
+  "except_behavior", "ignore", "strict", "ignore"
+  "fenv_access", "off", "on", "off"
+  "rounding_mode", "tonearest", "dynamic", "tonearest"
+  "contract", "on", "off", "fast"
+  "denormal_fp_math", "IEEE", "IEEE", "PreserveSign"
+  "denormal_fp32_math", "IEEE","IEEE", "PreserveSign"
+  "support_math_errno", "on", "on", "off"
+  "no_honor_nans", "off", "off", "on"
+  "no_honor_infinities", "off", "off", "on"
+  "no_signed_zeros", "off", "off", "on"
+  "allow_reciprocal", "off", "off", "on"
+  "allow_approximate_fns", "off", "off", "on"
+  "allow_reassociation", "off", "off", "on"
 
 .. option:: -ffast-math
 
@@ -1456,7 +1498,7 @@ Note that floating-point operations performed as part of 
constant initialization
and ``fast``.
Details:
 
-   * ``precise`` Disables optimizations that are not value-safe on 
floating-point data, although FP contraction (FMA) is enabled 
(``-ffp-contract=fast``).  This is the default behavior.
+   * ``precise`` Disables optimizations that are not value-safe on 
floating-point data, although FP contraction (FMA) is enabled 
(``-ffp-contract=on``).  This is the default behavior.
* ``strict`` Enables ``-frounding-math`` and 
``-ffp-exception-behavior=strict``, and disables contractions (FMA).  All of 
the ``-ffast-math`` enablements are disabled. Enables ``STDC FENV_ACCESS``: by 
default ``FENV_ACCESS`` is disabled. This option setting behaves as though 
``#pragma STDC FENV_ACESS ON`` appeared at the top of the source file.
* ``fast`` Behaves identically to specifying both ``-ffast-math`` and 
``ffp-contract=fast``
 

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index a0e1208fd709c..6eaa8938a8d24 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2631,7 +2631,7 @@ static void RenderFloatingPointOptions(const ToolChain 
, const Driver ,
 
   llvm::DenormalMode DenormalFPMath = DefaultDenormalFPMath;
   llvm::DenormalMode DenormalFP32Math = DefaultDenormalFP32Math;
-  StringRef 

[clang] d30dfa8 - [clang][patch] Add support for option -fextend-arguments={32,64}: widen integer arguments to int64 in unprototyped function calls

2021-05-19 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2021-05-19T10:59:56-04:00
New Revision: d30dfa86760ced9ac57f676340b34f2247898102

URL: 
https://github.com/llvm/llvm-project/commit/d30dfa86760ced9ac57f676340b34f2247898102
DIFF: 
https://github.com/llvm/llvm-project/commit/d30dfa86760ced9ac57f676340b34f2247898102.diff

LOG: [clang][patch] Add support for option -fextend-arguments={32,64}: widen 
integer arguments to int64 in unprototyped function calls

Reviewed By: Aaron Ballman

Differential Revision: https://reviews.llvm.org/D101640

Added: 
clang/test/CodeGen/extend-arg-64.c
clang/test/Driver/fextend-args.c

Modified: 
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Basic/LangOptions.h
clang/include/clang/Basic/TargetInfo.h
clang/include/clang/Driver/Options.td
clang/lib/Basic/Targets/X86.h
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Sema/SemaExpr.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index 20c03987bd02..fff5fe23dc80 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -415,6 +415,10 @@ LANGOPT(RelativeCXXABIVTables, 1, 0,
 
 LANGOPT(ArmSveVectorBits, 32, 0, "SVE vector size in bits")
 
+ENUM_LANGOPT(ExtendIntArgs, ExtendArgsKind, 1, ExtendArgsKind::ExtendTo32, 
+ "Controls how scalar integer arguments are extended in calls "
+ "to unprototyped and varargs functions")
+
 #undef LANGOPT
 #undef COMPATIBLE_LANGOPT
 #undef BENIGN_LANGOPT

diff  --git a/clang/include/clang/Basic/LangOptions.h 
b/clang/include/clang/Basic/LangOptions.h
index 454c101b2142..7fd4bf0eb206 100644
--- a/clang/include/clang/Basic/LangOptions.h
+++ b/clang/include/clang/Basic/LangOptions.h
@@ -267,6 +267,13 @@ class LangOptions : public LangOptionsBase {
 Single
   };
 
+  enum class ExtendArgsKind {
+/// Integer arguments are sign or zero extended to 32/64 bits
+/// during default argument promotions.
+ExtendTo32,
+ExtendTo64
+  };
+
 public:
   /// The used language standard.
   LangStandard::Kind LangStd;

diff  --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index b55a99051cfb..29b957607f3e 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -1415,6 +1415,9 @@ class TargetInfo : public virtual TransferrableTargetInfo,
   bool isBigEndian() const { return BigEndian; }
   bool isLittleEndian() const { return !BigEndian; }
 
+  /// Whether the option -fextend-arguments={32,64} is supported on the target.
+  virtual bool supportsExtendIntArgs() const { return false; }
+
   /// Gets the default calling convention for the given target and
   /// declaration context.
   virtual CallingConv getDefaultCallingConv() const {

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index a876f48c5596..1b78810bf352 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1451,6 +1451,14 @@ defm math_errno : BoolFOption<"math-errno",
   PosFlag,
   NegFlag>,
   ShouldParseIf;
+def fextend_args_EQ : Joined<["-"], "fextend-arguments=">, Group,
+  Flags<[CC1Option, NoArgumentUnused]>,
+  HelpText<"Controls how scalar integer arguments are extended in calls "
+   "to unprototyped and varargs functions">,
+  Values<"32,64">,
+  NormalizedValues<["ExtendTo32", "ExtendTo64"]>,
+  NormalizedValuesScope<"LangOptions::ExtendArgsKind">,
+  MarshallingInfoEnum,"ExtendTo32">;
 def fbracket_depth_EQ : Joined<["-"], "fbracket-depth=">, Group, 
Flags<[CoreOption]>;
 def fsignaling_math : Flag<["-"], "fsignaling-math">, Group;
 def fno_signaling_math : Flag<["-"], "fno-signaling-math">, Group;

diff  --git a/clang/lib/Basic/Targets/X86.h b/clang/lib/Basic/Targets/X86.h
index 58b48ffd6328..0ba2fd6ba024 100644
--- a/clang/lib/Basic/Targets/X86.h
+++ b/clang/lib/Basic/Targets/X86.h
@@ -338,6 +338,10 @@ class LLVM_LIBRARY_VISIBILITY X86TargetInfo : public 
TargetInfo {
 
   bool setFPMath(StringRef Name) override;
 
+  bool supportsExtendIntArgs() const override {
+return getTriple().getArch() != llvm::Triple::x86;
+  }
+
   CallingConvCheckResult checkCallingConvention(CallingConv CC) const override 
{
 // Most of the non-ARM calling conventions are i386 conventions.
 switch (CC) {

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 47552dcb6fdf..add62e3ab4ab 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -4903,6 +4903,20 @@ void Clang::ConstructJob(Compilation , const JobAction 
,
 
   RenderFloatingPointOptions(TC, D, OFastEnabled, Args, CmdArgs, JA);
 
+  if (Arg *A = Args.getLastArg(options::OPT_fextend_args_EQ)) {
+const llvm::Triple::ArchType Arch = TC.getArch();
+if (Arch 

[clang] 938b863 - [clang][patch] Modify diagnostic level from err to warn: anyx86_interrupt_regsave

2021-04-15 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2021-04-15T13:11:33-04:00
New Revision: 938b863bb53f033c916d4e8d9a18cbd063656011

URL: 
https://github.com/llvm/llvm-project/commit/938b863bb53f033c916d4e8d9a18cbd063656011
DIFF: 
https://github.com/llvm/llvm-project/commit/938b863bb53f033c916d4e8d9a18cbd063656011.diff

LOG: [clang][patch] Modify diagnostic level from err to warn: 
anyx86_interrupt_regsave

Reviewed By: Aaron Ballman

Differential Revision: https://reviews.llvm.org/D100511

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaExpr.cpp
clang/test/Sema/attr-x86-interrupt.c

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index afef86ab5890..c84fd4da0fd4 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -293,9 +293,10 @@ def err_anyx86_interrupt_attribute : Error<
   "a pointer as the first parameter|a %2 type as the second parameter}1">;
 def err_anyx86_interrupt_called : Error<
   "interrupt service routine cannot be called directly">;
-def err_anyx86_interrupt_regsave : Error<
-  "interrupt service routine may only call a function"
-  " with attribute 'no_caller_saved_registers'">;
+def warn_anyx86_interrupt_regsave : Warning<
+  "interrupt service routine should only call a function"
+  " with attribute 'no_caller_saved_registers'">,
+  InGroup>;
 def warn_arm_interrupt_calling_convention : Warning<
"call to function without interrupt attribute could clobber interruptee's 
VFP registers">,
InGroup;

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 2ea5775eaaa0..38c25ca65374 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -6607,7 +6607,7 @@ ExprResult Sema::BuildResolvedCallExpr(Expr *Fn, 
NamedDecl *NDecl,
 }
 if (Caller->hasAttr() &&
 ((!FDecl || !FDecl->hasAttr( {
-  Diag(Fn->getExprLoc(), diag::err_anyx86_interrupt_regsave);
+  Diag(Fn->getExprLoc(), diag::warn_anyx86_interrupt_regsave);
   if (FDecl)
 Diag(FDecl->getLocation(), diag::note_callee_decl) << FDecl;
 }

diff  --git a/clang/test/Sema/attr-x86-interrupt.c 
b/clang/test/Sema/attr-x86-interrupt.c
index 952433e2cb8a..564704a56477 100644
--- a/clang/test/Sema/attr-x86-interrupt.c
+++ b/clang/test/Sema/attr-x86-interrupt.c
@@ -51,7 +51,7 @@ typedef unsigned int Arg2Type;
 __attribute__((no_caller_saved_registers))
 #else
 // expected-note@+3 {{'foo9' declared here}}
-// expected-error@+4 {{interrupt service routine may only call a function with 
attribute 'no_caller_saved_registers'}}
+// expected-warning@+4 {{interrupt service routine should only call a function 
with attribute 'no_caller_saved_registers'}}
 #endif
 void foo9(int *a, Arg2Type b) {}
 __attribute__((interrupt)) void fooA(int *a, Arg2Type b) {



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 33b1f3f - [clang][patch] Solve PR49479, File scope fp pragma should propagate to functions nested in struct, and initialization expressions

2021-03-15 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2021-03-15T12:15:20-04:00
New Revision: 33b1f3f42cb9fc4fed9501ed49e4805f134e7a1b

URL: 
https://github.com/llvm/llvm-project/commit/33b1f3f42cb9fc4fed9501ed49e4805f134e7a1b
DIFF: 
https://github.com/llvm/llvm-project/commit/33b1f3f42cb9fc4fed9501ed49e4805f134e7a1b.diff

LOG: [clang][patch] Solve PR49479, File scope fp pragma should propagate to 
functions nested in struct, and initialization expressions

Previously, the CurFPFeatures state was set to command line settings before
semantic analysis of the nested member functions and initialization
expressions, that's not correct, it should use the pragma state which
is in effect at the lexical position.

Reviewed By: Erich Keane, Aaron Ballman

Differential Revision: https://reviews.llvm.org/D98211

Added: 


Modified: 
clang/lib/Parse/ParseDeclCXX.cpp
clang/test/CodeGen/fp-floatcontrol-stack.cpp

Removed: 




diff  --git a/clang/lib/Parse/ParseDeclCXX.cpp 
b/clang/lib/Parse/ParseDeclCXX.cpp
index df71ba34cdd9..dd1cccf72668 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -3417,15 +3417,6 @@ void Parser::ParseCXXMemberSpecification(SourceLocation 
RecordLoc,
 // declarations and the lexed inline method definitions, along with any
 // delayed attributes.
 
-// Save the state of Sema.FPFeatures, and change the setting
-// to the levels specified on the command line.  Previous level
-// will be restored when the RAII object is destroyed.
-Sema::FPFeaturesStateRAII SaveFPFeaturesState(Actions);
-FPOptionsOverride NewOverrides;
-Actions.CurFPFeatures = NewOverrides.applyOverrides(getLangOpts());
-Actions.FpPragmaStack.Act(Tok.getLocation(), Sema::PSK_Reset, StringRef(),
-  {} /*unused*/);
-
 SourceLocation SavedPrevTokLocation = PrevTokLocation;
 ParseLexedPragmas(getCurrentClass());
 ParseLexedAttributes(getCurrentClass());

diff  --git a/clang/test/CodeGen/fp-floatcontrol-stack.cpp 
b/clang/test/CodeGen/fp-floatcontrol-stack.cpp
index f49b5088641c..122c621b4cbc 100644
--- a/clang/test/CodeGen/fp-floatcontrol-stack.cpp
+++ b/clang/test/CodeGen/fp-floatcontrol-stack.cpp
@@ -212,8 +212,7 @@ float fun_default FUN(1)
 #endif
 float y();
 class ON {
-  // Settings for top level class initializer revert to command line
-  // source pragma's do not pertain.
+  // Settings for top level class initializer use program source setting.
   float z = 2 + y() * 7;
 //CHECK-LABEL: define {{.*}} void @_ZN2ONC2Ev{{.*}}
 #if DEFAULT
@@ -224,11 +223,10 @@ class ON {
 //CHECK-DEBSTRICT: call float {{.*}}llvm.fmuladd
 #endif
 #if NOHONOR
-//CHECK-NOHONOR: call nnan ninf float @llvm.fmuladd{{.*}}
+//CHECK-NOHONOR: call float {{.*}}llvm.fmuladd
 #endif
 #if FAST
-//CHECK-FAST: fmul fast float
-//CHECK-FAST: fadd fast float
+//CHECK-FAST: float {{.*}}llvm.fmuladd{{.*}}
 #endif
 };
 ON on;
@@ -236,18 +234,28 @@ ON on;
 class OFF {
   float w = 2 + y() * 7;
 //CHECK-LABEL: define {{.*}} void @_ZN3OFFC2Ev{{.*}}
-#if DEFAULT
-//CHECK-DDEFAULT: call float {{.*}}llvm.fmuladd
-#endif
-#if EBSTRICT
-//CHECK-DEBSTRICT: call float {{.*}}llvm.fmuladd
-#endif
-#if NOHONOR
-//CHECK-NOHONOR: call nnan ninf float @llvm.fmuladd{{.*}}
-#endif
-#if FAST
-//CHECK-FAST: fmul fast float
-//CHECK-FAST: fadd fast float
-#endif
+//CHECK: call float {{.*}}llvm.fmuladd
 };
 OFF off;
+
+#pragma clang fp reassociate(on)
+struct MyComplex {
+  float xx;
+  float yy;
+  MyComplex(float x, float y) {
+xx = x;
+yy = y;
+  }
+  MyComplex() {}
+  const MyComplex operator+(const MyComplex other) const {
+//CHECK-LABEL: define {{.*}} @_ZNK9MyComplexplES_
+//CHECK: fadd reassoc float
+//CHECK: fadd reassoc float
+return MyComplex(xx + other.xx, yy + other.yy);
+  }
+};
+MyComplex useAdd() {
+  MyComplex a (1, 3);
+  MyComplex b (2, 4);
+   return a + b;
+}



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] cc3d25b - [clang][patch] To solve PR26413, x86 interrupt routines may only call routines with no_saved_reg

2021-03-03 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2021-03-03T10:11:13-05:00
New Revision: cc3d25be0116fc3cc41a08f8bf9eef73d6dc5d62

URL: 
https://github.com/llvm/llvm-project/commit/cc3d25be0116fc3cc41a08f8bf9eef73d6dc5d62
DIFF: 
https://github.com/llvm/llvm-project/commit/cc3d25be0116fc3cc41a08f8bf9eef73d6dc5d62.diff

LOG: [clang][patch] To solve PR26413, x86 interrupt routines may only call 
routines with no_saved_reg

Reviewed By: Aaron Ballman

Differential Revision: https://reviews.llvm.org/D97764

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaExpr.cpp
clang/test/Sema/arm-interrupt-attr.c
clang/test/Sema/attr-x86-interrupt.c

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 481ed57c0b58..1ffc9884013d 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -293,6 +293,9 @@ def err_anyx86_interrupt_attribute : Error<
   "a pointer as the first parameter|a %2 type as the second parameter}1">;
 def err_anyx86_interrupt_called : Error<
   "interrupt service routine cannot be called directly">;
+def err_anyx86_interrupt_regsave : Error<
+  "interrupt service routine may only call a function"
+  " with attribute 'no_caller_saved_registers'">;
 def warn_arm_interrupt_calling_convention : Warning<
"call to function without interrupt attribute could clobber interruptee's 
VFP registers">,
InGroup;

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 98097b6fb381..79dd3c0c1184 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -6552,12 +6552,25 @@ ExprResult Sema::BuildResolvedCallExpr(Expr *Fn, 
NamedDecl *NDecl,
   // so there's some risk when calling out to non-interrupt handler functions
   // that the callee might not preserve them. This is easy to diagnose here,
   // but can be very challenging to debug.
-  if (auto *Caller = getCurFunctionDecl())
+  // Likewise, X86 interrupt handlers may only call routines with attribute
+  // no_caller_saved_registers since there is no efficient way to
+  // save and restore the non-GPR state.
+  if (auto *Caller = getCurFunctionDecl()) {
 if (Caller->hasAttr()) {
   bool VFP = Context.getTargetInfo().hasFeature("vfp");
-  if (VFP && (!FDecl || !FDecl->hasAttr()))
+  if (VFP && (!FDecl || !FDecl->hasAttr())) {
 Diag(Fn->getExprLoc(), diag::warn_arm_interrupt_calling_convention);
+if (FDecl)
+  Diag(FDecl->getLocation(), diag::note_callee_decl) << FDecl;
+  }
+}
+if (Caller->hasAttr() &&
+((!FDecl || !FDecl->hasAttr( {
+  Diag(Fn->getExprLoc(), diag::err_anyx86_interrupt_regsave);
+  if (FDecl)
+Diag(FDecl->getLocation(), diag::note_callee_decl) << FDecl;
 }
+  }
 
   // Promote the function operand.
   // We special-case function promotion here because we only allow promoting

diff  --git a/clang/test/Sema/arm-interrupt-attr.c 
b/clang/test/Sema/arm-interrupt-attr.c
index 60691ab7f8e8..5a844d0e2d79 100644
--- a/clang/test/Sema/arm-interrupt-attr.c
+++ b/clang/test/Sema/arm-interrupt-attr.c
@@ -19,6 +19,9 @@ __attribute__((interrupt)) void foo8() {}
 __attribute__((interrupt())) void foo9() {}
 __attribute__((interrupt(""))) void foo10() {}
 
+#ifndef SOFT
+// expected-note@+2 {{'callee1' declared here}}
+#endif
 void callee1();
 __attribute__((interrupt("IRQ"))) void callee2();
 void caller1() {

diff  --git a/clang/test/Sema/attr-x86-interrupt.c 
b/clang/test/Sema/attr-x86-interrupt.c
index 0785fdfcb1b3..952433e2cb8a 100644
--- a/clang/test/Sema/attr-x86-interrupt.c
+++ b/clang/test/Sema/attr-x86-interrupt.c
@@ -3,6 +3,7 @@
 // RUN: %clang_cc1 -triple x86_64-pc-win32  -fsyntax-only -verify %s
 // RUN: %clang_cc1 -triple i386-pc-win32  -fsyntax-only -verify %s
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnux32  -fsyntax-only -verify 
%s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu  -fsyntax-only -verify %s 
-DNOCALLERSAVE=1
 
 struct a {
   int b;
@@ -39,6 +40,23 @@ __attribute__((interrupt)) void foo6(float *a, int b) {}
 __attribute__((interrupt)) void foo7(int *a, unsigned b) {}
 __attribute__((interrupt)) void foo8(int *a) {}
 
+#ifdef _LP64
+typedef unsigned long Arg2Type;
+#elif defined(__x86_64__)
+typedef unsigned long long Arg2Type;
+#else
+typedef unsigned int Arg2Type;
+#endif
+#ifndef NOCALLERSAVE
+__attribute__((no_caller_saved_registers))
+#else
+// expected-note@+3 {{'foo9' declared here}}
+// expected-error@+4 {{interrupt service routine may only call a function with 
attribute 'no_caller_saved_registers'}}
+#endif
+void foo9(int *a, Arg2Type b) {}
+__attribute__((interrupt)) void fooA(int *a, Arg2Type b) {
+  foo9(a, b);
+}
 void g(void (*fp)(int *));
 int main(int argc, char **argv) {
   void *ptr = (void *)




[clang] e64fcdf - [clang][patch] Inclusive language, modify filename SanitizerBlacklist.h to NoSanitizeList.h

2021-02-22 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2021-02-22T15:11:37-05:00
New Revision: e64fcdf8d53c1d2ab709394c39743fa11d270181

URL: 
https://github.com/llvm/llvm-project/commit/e64fcdf8d53c1d2ab709394c39743fa11d270181
DIFF: 
https://github.com/llvm/llvm-project/commit/e64fcdf8d53c1d2ab709394c39743fa11d270181.diff

LOG: [clang][patch] Inclusive language, modify filename SanitizerBlacklist.h to 
NoSanitizeList.h

This patch responds to a comment from @vitalybuka in D96203: suggestion to
do the change incrementally, and start by modifying this file name. I modified
the file name and made the other changes that follow from that rename.

Reviewers: vitalybuka, echristo, MaskRay, jansvoboda11, aaron.ballman

Differential Revision: https://reviews.llvm.org/D96974

Added: 
clang/include/clang/Basic/NoSanitizeList.h
clang/lib/Basic/NoSanitizeList.cpp

Modified: 
clang/include/clang/AST/ASTContext.h
clang/include/clang/Basic/LangOptions.h
clang/lib/AST/ASTContext.cpp
clang/lib/AST/Decl.cpp
clang/lib/Basic/CMakeLists.txt
clang/lib/Basic/LangOptions.cpp
clang/lib/CodeGen/BackendUtil.cpp
clang/lib/CodeGen/CGClass.cpp
clang/lib/CodeGen/CGDeclCXX.cpp
clang/lib/CodeGen/CGExpr.cpp
clang/lib/CodeGen/CodeGenFunction.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/CodeGen/CodeGenModule.h
clang/lib/CodeGen/SanitizerMetadata.cpp
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 
clang/include/clang/Basic/SanitizerBlacklist.h
clang/lib/Basic/SanitizerBlacklist.cpp



diff  --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index f256f9762b50..8ba4c41aac70 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -34,10 +34,10 @@
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/Linkage.h"
+#include "clang/Basic/NoSanitizeList.h"
 #include "clang/Basic/OperatorKinds.h"
 #include "clang/Basic/PartialDiagnostic.h"
 #include "clang/Basic/ProfileList.h"
-#include "clang/Basic/SanitizerBlacklist.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/Specifiers.h"
 #include "clang/Basic/XRayLists.h"
@@ -562,9 +562,9 @@ class ASTContext : public RefCountedBase {
   ///  this ASTContext object.
   LangOptions 
 
-  /// Blacklist object that is used by sanitizers to decide which
+  /// NoSanitizeList object that is used by sanitizers to decide which
   /// entities should not be instrumented.
-  std::unique_ptr SanitizerBL;
+  std::unique_ptr NoSanitizeL;
 
   /// Function filtering mechanism to determine whether a given function
   /// should be imbued with the XRay "always" or "never" attributes.
@@ -691,9 +691,7 @@ class ASTContext : public RefCountedBase {
 return LangOpts.CPlusPlus || LangOpts.RecoveryAST;
   }
 
-  const SanitizerBlacklist () const {
-return *SanitizerBL;
-  }
+  const NoSanitizeList () const { return *NoSanitizeL; }
 
   const XRayFunctionFilter () const {
 return *XRayFilter;

diff  --git a/clang/include/clang/Basic/LangOptions.h 
b/clang/include/clang/Basic/LangOptions.h
index 0d14121bac7a..c797167f8fd2 100644
--- a/clang/include/clang/Basic/LangOptions.h
+++ b/clang/include/clang/Basic/LangOptions.h
@@ -264,9 +264,9 @@ class LangOptions : public LangOptionsBase {
   /// Set of enabled sanitizers.
   SanitizerSet Sanitize;
 
-  /// Paths to blacklist files specifying which objects
+  /// Paths to files specifying which objects
   /// (files, functions, variables) should not be instrumented.
-  std::vector SanitizerBlacklistFiles;
+  std::vector NoSanitizeFiles;
 
   /// Paths to the XRay "always instrument" files specifying which
   /// objects (files, functions, variables) should be imbued with the XRay

diff  --git a/clang/include/clang/Basic/NoSanitizeList.h 
b/clang/include/clang/Basic/NoSanitizeList.h
new file mode 100644
index ..3f80e0fdedda
--- /dev/null
+++ b/clang/include/clang/Basic/NoSanitizeList.h
@@ -0,0 +1,50 @@
+//===--- NoSanitizeList.h - List of ignored entities for sanitizers --*- C++
+//-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// User-provided list of ignored entities used to disable/alter
+// instrumentation done in sanitizers.
+//
+//===--===//
+#ifndef LLVM_CLANG_BASIC_NOSANITIZELIST_H
+#define LLVM_CLANG_BASIC_NOSANITIZELIST_H
+
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/SourceLocation.h"
+#include "llvm/ADT/StringRef.h"
+#include 
+#include 
+
+namespace clang {
+
+class SanitizerMask;
+class SourceManager;
+class SanitizerSpecialCaseList;
+
+class 

[clang] 9a5dc01 - [clang][PATCH][NFC] Correct test case related to review D95482

2021-02-02 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2021-02-02T07:06:43-08:00
New Revision: 9a5dc01e4b65b15c73751f5b3d9273ea73533b5d

URL: 
https://github.com/llvm/llvm-project/commit/9a5dc01e4b65b15c73751f5b3d9273ea73533b5d
DIFF: 
https://github.com/llvm/llvm-project/commit/9a5dc01e4b65b15c73751f5b3d9273ea73533b5d.diff

LOG: [clang][PATCH][NFC] Correct test case related to review D95482

Added: 
clang/test/SemaCXX/pr48848.cpp

Modified: 
clang/test/SemaCXX/lambda-expressions.cpp

Removed: 




diff  --git a/clang/test/SemaCXX/lambda-expressions.cpp 
b/clang/test/SemaCXX/lambda-expressions.cpp
index 03bf13733d7b..22e0939379f5 100644
--- a/clang/test/SemaCXX/lambda-expressions.cpp
+++ b/clang/test/SemaCXX/lambda-expressions.cpp
@@ -1,8 +1,6 @@
 // RUN: %clang_cc1 -std=c++14 -Wno-unused-value -fsyntax-only -verify 
-verify=expected-cxx14 -fblocks %s
 // RUN: %clang_cc1 -std=c++17 -Wno-unused-value -fsyntax-only -verify -fblocks 
%s
-// RUN: %clang_cc1 -std=c++17 -fblocks -DSHOW_MS -Wno-unused-value 
-fms-compatibility -fdelayed-template-parsing -fsyntax-only -verify %s
 
-#ifndef SHOW_MS
 namespace std { class type_info; };
 
 namespace ExplicitCapture {
@@ -666,22 +664,3 @@ void Test() {
 
 }
 };
-
-#else
-template 
-void Decider(const RT , ET ) {
-  [=](auto i) { ep[i] = sp[i + j]; };
-// expected-error@-1 {{use of undeclared identifier 'j'}}
-}
-
-template  void LS() {
-  int *ep;
-  Decider(5, ep);
-}
-
-void runChapter4()
-{
-  LS(); // expected-note {{in instantiation of}}
-}
-
-#endif

diff  --git a/clang/test/SemaCXX/pr48848.cpp b/clang/test/SemaCXX/pr48848.cpp
new file mode 100644
index ..064dbb137082
--- /dev/null
+++ b/clang/test/SemaCXX/pr48848.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -std=c++17 -fblocks -DSHOW_MS -Wno-unused-value 
-fms-compatibility -fdelayed-template-parsing -fsyntax-only -verify %s
+template 
+void Decider(const RT , ET ) {
+  [=](auto i) { ep[i] = sp[i + j]; };
+  // expected-error@-1 {{use of undeclared identifier 'j'}}
+}
+
+template  void LS() {
+  int *ep;
+  Decider(5, ep);
+}
+
+void runChapter4() {
+  LS(); // expected-note {{in instantiation of}}
+}



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 08d46d5 - [clang][PATCH] Fix bug 48848 assertion related to recoverFromMSUnqualifiedLookup

2021-02-01 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2021-02-01T10:56:47-08:00
New Revision: 08d46d50599a7005380e1a9eebb276ceb2b0ad93

URL: 
https://github.com/llvm/llvm-project/commit/08d46d50599a7005380e1a9eebb276ceb2b0ad93
DIFF: 
https://github.com/llvm/llvm-project/commit/08d46d50599a7005380e1a9eebb276ceb2b0ad93.diff

LOG: [clang][PATCH] Fix bug 48848 assertion related to 
recoverFromMSUnqualifiedLookup

Reviewed By: rnk

Differential Revision: https://reviews.llvm.org/D95482

Added: 


Modified: 
clang/lib/Sema/SemaExprCXX.cpp
clang/test/SemaCXX/lambda-expressions.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index d91db60f17a0..a708ccd58dd4 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -1176,15 +1176,11 @@ QualType Sema::getCurrentThisType() {
   }
 
   if (ThisTy.isNull() && isLambdaCallOperator(CurContext) &&
-  inTemplateInstantiation()) {
-
-assert(isa(DC) &&
-   "Trying to get 'this' type from static method?");
+  inTemplateInstantiation() && isa(DC)) {
 
 // This is a lambda call operator that is being instantiated as a default
 // initializer. DC must point to the enclosing class type, so we can 
recover
 // the 'this' type from it.
-
 QualType ClassTy = Context.getTypeDeclType(cast(DC));
 // There are no cv-qualifiers for 'this' within default initializers,
 // per [expr.prim.general]p4.

diff  --git a/clang/test/SemaCXX/lambda-expressions.cpp 
b/clang/test/SemaCXX/lambda-expressions.cpp
index 22e0939379f5..03bf13733d7b 100644
--- a/clang/test/SemaCXX/lambda-expressions.cpp
+++ b/clang/test/SemaCXX/lambda-expressions.cpp
@@ -1,6 +1,8 @@
 // RUN: %clang_cc1 -std=c++14 -Wno-unused-value -fsyntax-only -verify 
-verify=expected-cxx14 -fblocks %s
 // RUN: %clang_cc1 -std=c++17 -Wno-unused-value -fsyntax-only -verify -fblocks 
%s
+// RUN: %clang_cc1 -std=c++17 -fblocks -DSHOW_MS -Wno-unused-value 
-fms-compatibility -fdelayed-template-parsing -fsyntax-only -verify %s
 
+#ifndef SHOW_MS
 namespace std { class type_info; };
 
 namespace ExplicitCapture {
@@ -664,3 +666,22 @@ void Test() {
 
 }
 };
+
+#else
+template 
+void Decider(const RT , ET ) {
+  [=](auto i) { ep[i] = sp[i + j]; };
+// expected-error@-1 {{use of undeclared identifier 'j'}}
+}
+
+template  void LS() {
+  int *ep;
+  Decider(5, ep);
+}
+
+void runChapter4()
+{
+  LS(); // expected-note {{in instantiation of}}
+}
+
+#endif



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 320af6b - Create SPIRABIInfo to enable SPIR_FUNC calling convention.

2020-12-12 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2020-12-12T05:48:20-08:00
New Revision: 320af6b138391d289fe70db39c51da92e8d3d9df

URL: 
https://github.com/llvm/llvm-project/commit/320af6b138391d289fe70db39c51da92e8d3d9df
DIFF: 
https://github.com/llvm/llvm-project/commit/320af6b138391d289fe70db39c51da92e8d3d9df.diff

LOG: Create SPIRABIInfo to enable SPIR_FUNC calling convention.

Background: Call to library arithmetic functions for div is emitted by the
compiler and it set wrong “C” calling convention for calls to these functions,
whereas library functions are declared with `spir_function` calling convention.
InstCombine optimization replaces such calls with “unreachable” instruction.
It looks like clang lacks SPIRABIInfo class which should specify default
calling conventions for “system” function calls. SPIR supports only
SPIR_FUNC and SPIR_KERNEL calling convention.

Reviewers: Erich Keane, Anastasia

Differential Revision: https://reviews.llvm.org/D92721

Added: 


Modified: 
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/CodeGen/TargetInfo.cpp
clang/test/CodeGen/complex-math.c
clang/test/CodeGenOpenCL/builtins.cl
clang/test/CodeGenOpenCL/cl20-device-side-enqueue.cl
clang/test/CodeGenOpenCL/to_addr_builtin.cl
clang/test/CodeGenOpenCLCXX/atexit.cl

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index db7ae582b1d6..316a60c31fd4 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -4313,8 +4313,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
   Int32Ty, llvm::ArrayRef(ArgTys), false);
   Value *BCast = Builder.CreatePointerCast(Arg1, I8PTy);
   return RValue::get(
-  Builder.CreateCall(CGM.CreateRuntimeFunction(FTy, Name),
- {Arg0, BCast, PacketSize, PacketAlign}));
+  EmitRuntimeCall(CGM.CreateRuntimeFunction(FTy, Name),
+  {Arg0, BCast, PacketSize, PacketAlign}));
 } else {
   assert(4 == E->getNumArgs() &&
  "Illegal number of parameters to pipe function");
@@ -4332,9 +4332,9 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
   // it to i32.
   if (Arg2->getType() != Int32Ty)
 Arg2 = Builder.CreateZExtOrTrunc(Arg2, Int32Ty);
-  return RValue::get(Builder.CreateCall(
-  CGM.CreateRuntimeFunction(FTy, Name),
-  {Arg0, Arg1, Arg2, BCast, PacketSize, PacketAlign}));
+  return RValue::get(
+  EmitRuntimeCall(CGM.CreateRuntimeFunction(FTy, Name),
+  {Arg0, Arg1, Arg2, BCast, PacketSize, PacketAlign}));
 }
   }
   // OpenCL v2.0 s6.13.16 ,s9.17.3.5 - Built-in pipe reserve read and write
@@ -4375,9 +4375,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
 // it to i32.
 if (Arg1->getType() != Int32Ty)
   Arg1 = Builder.CreateZExtOrTrunc(Arg1, Int32Ty);
-return RValue::get(
-Builder.CreateCall(CGM.CreateRuntimeFunction(FTy, Name),
-   {Arg0, Arg1, PacketSize, PacketAlign}));
+return RValue::get(EmitRuntimeCall(CGM.CreateRuntimeFunction(FTy, Name),
+   {Arg0, Arg1, PacketSize, PacketAlign}));
   }
   // OpenCL v2.0 s6.13.16, s9.17.3.5 - Built-in pipe commit read and write
   // functions
@@ -4413,9 +4412,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
 llvm::FunctionType::get(llvm::Type::getVoidTy(getLLVMContext()),
 llvm::ArrayRef(ArgTys), false);
 
-return RValue::get(
-Builder.CreateCall(CGM.CreateRuntimeFunction(FTy, Name),
-   {Arg0, Arg1, PacketSize, PacketAlign}));
+return RValue::get(EmitRuntimeCall(CGM.CreateRuntimeFunction(FTy, Name),
+   {Arg0, Arg1, PacketSize, PacketAlign}));
   }
   // OpenCL v2.0 s6.13.16.4 Built-in pipe query functions
   case Builtin::BIget_pipe_num_packets:
@@ -4438,8 +4436,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
 llvm::FunctionType *FTy = llvm::FunctionType::get(
 Int32Ty, llvm::ArrayRef(ArgTys), false);
 
-return RValue::get(Builder.CreateCall(CGM.CreateRuntimeFunction(FTy, Name),
-  {Arg0, PacketSize, PacketAlign}));
+return RValue::get(EmitRuntimeCall(CGM.CreateRuntimeFunction(FTy, Name),
+   {Arg0, PacketSize, PacketAlign}));
   }
 
   // OpenCL v2.0 s6.13.9 - Address space qualifier functions.
@@ -4461,7 +4459,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
   NewArg = Builder.CreateBitOrPointerCast(Arg0, NewArgT);
 auto NewName = std::string("__") + E->getDirectCallee()->getName().str();

[clang] c511963 - [clang] Fix length threshold for MicrosoftMangle md5 hash

2020-11-07 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2020-11-07T07:40:24-08:00
New Revision: c511963d5adb1a8ca16adabf4b49f8d013a66785

URL: 
https://github.com/llvm/llvm-project/commit/c511963d5adb1a8ca16adabf4b49f8d013a66785
DIFF: 
https://github.com/llvm/llvm-project/commit/c511963d5adb1a8ca16adabf4b49f8d013a66785.diff

LOG: [clang] Fix length threshold for MicrosoftMangle md5 hash

Reviewers: rnk, dblaikie

Differential Revision: https://reviews.llvm.org/D90714

Added: 


Modified: 
clang/lib/AST/MicrosoftMangle.cpp
clang/test/CodeGenCXX/mangle-ms-md5.cpp

Removed: 




diff  --git a/clang/lib/AST/MicrosoftMangle.cpp 
b/clang/lib/AST/MicrosoftMangle.cpp
index 3a263d487b75..de03a88d7612 100644
--- a/clang/lib/AST/MicrosoftMangle.cpp
+++ b/clang/lib/AST/MicrosoftMangle.cpp
@@ -50,7 +50,7 @@ struct msvc_hashing_ostream : public 
llvm::raw_svector_ostream {
 bool StartsWithEscape = MangledName.startswith("\01");
 if (StartsWithEscape)
   MangledName = MangledName.drop_front(1);
-if (MangledName.size() <= 4096) {
+if (MangledName.size() < 4096) {
   OS << str();
   return;
 }

diff  --git a/clang/test/CodeGenCXX/mangle-ms-md5.cpp 
b/clang/test/CodeGenCXX/mangle-ms-md5.cpp
index 52a29324af05..bd7cef2f099b 100644
--- a/clang/test/CodeGenCXX/mangle-ms-md5.cpp
+++ b/clang/test/CodeGenCXX/mangle-ms-md5.cpp
@@ -49,3 +49,25 @@ void g() {
 // HAVECTOR: 
"_CT??@c14087f0ec22b387aea7c59083f4f546@??@4ef4f8979c81f9d2224b32bf327e6bdf@4"
 }
 #endif
+
+// Verify the threshold where md5 mangling kicks in
+// Test an ident with 4088 characters, pre-hash, MangleName.size() is 4095
+#define X4088(X)\
+C2(C2(  \
+  C4(X,   X4(X),   X4(X),X8(X)),\
+  C4(X8(X),   X32(X),  X64(X),   X128(X))), \
+  C4(X256(X), X512(X), X1024(X), X2048(X)))
+#define Z4088 X4088(z)
+// Use initialization to verify mangled name association in the il
+int X4088(z) = 1515;
+// CHECK-DAG: @"?{{z+}}@@3HA" = dso_local global i32 1515, align 4
+
+// Test an ident with 4089 characters, pre-hash, MangleName.size() is 4096
+#define X4089(X)\
+C2(C2(  \
+  C4(X2(X),   X4(X),   X4(X),X8(X)),\
+  C4(X8(X),   X32(X),  X64(X),   X128(X))), \
+  C4(X256(X), X512(X), X1024(X), X2048(X)))
+// Use initialization to verify mangled name association in the il
+int X4089(z) = 1717;
+// CHECK-DAG: @"??@0269945400a3474730d6880df0967d8f@" = dso_local global i32 
1717, align 4



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] b0de3f6 - [clang] Improve Microsoft mangling lit test with dblaikie's suggestions

2020-11-07 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2020-11-07T07:32:34-08:00
New Revision: b0de3f67874ac3eff465cb2ef8ab6081292625c3

URL: 
https://github.com/llvm/llvm-project/commit/b0de3f67874ac3eff465cb2ef8ab6081292625c3
DIFF: 
https://github.com/llvm/llvm-project/commit/b0de3f67874ac3eff465cb2ef8ab6081292625c3.diff

LOG: [clang] Improve Microsoft mangling lit test with dblaikie's suggestions

Added: 


Modified: 
clang/test/CodeGenCXX/mangle-ms-md5.cpp

Removed: 




diff  --git a/clang/test/CodeGenCXX/mangle-ms-md5.cpp 
b/clang/test/CodeGenCXX/mangle-ms-md5.cpp
index 1492984d3fed..52a29324af05 100644
--- a/clang/test/CodeGenCXX/mangle-ms-md5.cpp
+++ b/clang/test/CodeGenCXX/mangle-ms-md5.cpp
@@ -1,12 +1,37 @@
 // RUN: %clang_cc1 -emit-llvm -o - -triple i686-pc-win32 %s | FileCheck %s
-int 
xxx;
+// Define macros, using 

[clang] 71bf9f0 - [clang] add fexperimental-strict-floating-point to test cases that fail on arm and aarch not sure this will work due to commit rG13bfd89c4962

2020-10-30 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2020-10-30T07:30:06-07:00
New Revision: 71bf9f07d514e160ff130eced53248667021829d

URL: 
https://github.com/llvm/llvm-project/commit/71bf9f07d514e160ff130eced53248667021829d
DIFF: 
https://github.com/llvm/llvm-project/commit/71bf9f07d514e160ff130eced53248667021829d.diff

LOG: [clang] add fexperimental-strict-floating-point to test cases that fail on 
arm and aarch not sure this will work due to commit rG13bfd89c4962

Added: 


Modified: 
clang/test/AST/const-fpfeatures.c
clang/test/CodeGen/fp-floatcontrol-pragma.cpp
clang/test/CodeGen/pragma-fenv_access.c
clang/test/CodeGen/rounding-math.c
clang/test/PCH/pragma-floatcontrol.c
clang/test/Parser/pragma-fenv_round.c

Removed: 




diff  --git a/clang/test/AST/const-fpfeatures.c 
b/clang/test/AST/const-fpfeatures.c
index bf512ff70658..c29afe680999 100644
--- a/clang/test/AST/const-fpfeatures.c
+++ b/clang/test/AST/const-fpfeatures.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -S -emit-llvm -Wno-unknown-pragmas %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fexperimental-strict-floating-point -S -emit-llvm -triple 
i386-linux -Wno-unknown-pragmas %s -o - | FileCheck %s
 
 // nextUp(1.F) == 0x1.02p0F
 

diff  --git a/clang/test/CodeGen/fp-floatcontrol-pragma.cpp 
b/clang/test/CodeGen/fp-floatcontrol-pragma.cpp
index 45eb14bccc06..539ad86d6bb8 100644
--- a/clang/test/CodeGen/fp-floatcontrol-pragma.cpp
+++ b/clang/test/CodeGen/fp-floatcontrol-pragma.cpp
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -DEXCEPT=1 -fcxx-exceptions -triple x86_64-linux-gnu 
-emit-llvm -o - %s | FileCheck -check-prefix=CHECK-NS %s
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck %s
-// RUN: %clang_cc1 -DFENV_ON=1 -triple x86_64-linux-gnu -emit-llvm -o - %s | 
FileCheck -check-prefix=CHECK-FENV %s
-// RUN: %clang_cc1 -triple %itanium_abi_triple -O3 -emit-llvm -o - %s | 
FileCheck -check-prefix=CHECK-O3 %s
+// RUN: %clang_cc1 -fexperimental-strict-floating-point -DEXCEPT=1 
-fcxx-exceptions -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck 
-check-prefix=CHECK-NS %s
+// RUN: %clang_cc1 -fexperimental-strict-floating-point -triple 
x86_64-linux-gnu -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -fexperimental-strict-floating-point -DFENV_ON=1 -triple 
x86_64-linux-gnu -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-FENV %s
+// RUN: %clang_cc1 -fexperimental-strict-floating-point -triple 
%itanium_abi_triple -O3 -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-O3 %s
 
 // Verify float_control(precise, off) enables fast math flags on fp operations.
 float fp_precise_1(float a, float b, float c) {

diff  --git a/clang/test/CodeGen/pragma-fenv_access.c 
b/clang/test/CodeGen/pragma-fenv_access.c
index 87d12a3a7ab1..fb7b8b2af61d 100644
--- a/clang/test/CodeGen/pragma-fenv_access.c
+++ b/clang/test/CodeGen/pragma-fenv_access.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -ffp-exception-behavior=strict -triple %itanium_abi_triple 
-emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fexperimental-strict-floating-point 
-ffp-exception-behavior=strict -triple %itanium_abi_triple -emit-llvm %s -o - | 
FileCheck %s
 
 #pragma STDC FENV_ACCESS ON
 

diff  --git a/clang/test/CodeGen/rounding-math.c 
b/clang/test/CodeGen/rounding-math.c
index b2671db0efc8..13ec2fdcaa2e 100644
--- a/clang/test/CodeGen/rounding-math.c
+++ b/clang/test/CodeGen/rounding-math.c
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -S -emit-llvm -ffp-exception-behavior=strict 
-Wno-unknown-pragmas %s -o - | FileCheck %s
-// RUN: %clang_cc1 -S -emit-llvm -frounding-math -Wno-unknown-pragmas %s -o - 
| FileCheck %s
+// RUN: %clang_cc1 -fexperimental-strict-floating-point -S -emit-llvm 
-ffp-exception-behavior=strict -Wno-unknown-pragmas %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fexperimental-strict-floating-point -S -emit-llvm 
-frounding-math -Wno-unknown-pragmas %s -o - | FileCheck %s
 
 float PR47807 = -8.6563630030e-03;
 

diff  --git a/clang/test/PCH/pragma-floatcontrol.c 
b/clang/test/PCH/pragma-floatcontrol.c
index 8be46dbd1655..95f587a7b52b 100644
--- a/clang/test/PCH/pragma-floatcontrol.c
+++ b/clang/test/PCH/pragma-floatcontrol.c
@@ -1,27 +1,27 @@
 // Test this without pch.
-// RUN: %clang_cc1 %s -include %s -verify -fsyntax-only -DSET
-// RUN: %clang_cc1 %s -include %s -verify -fsyntax-only -DPUSH
-// RUN: %clang_cc1 %s -include %s -verify -fsyntax-only -DPUSH_POP
+// RUN: %clang_cc1 -fexperimental-strict-floating-point  %s -include %s 
-verify -fsyntax-only -DSET
+// RUN: %clang_cc1 -fexperimental-strict-floating-point  %s -include %s 
-verify -fsyntax-only -DPUSH
+// RUN: %clang_cc1 -fexperimental-strict-floating-point  %s -include %s 
-verify -fsyntax-only -DPUSH_POP
 
 // Test with pch.
-// RUN: %clang_cc1 %s -DSET -emit-pch -o %t
-// RUN: %clang_cc1 %s -DSET -include-pch %t -emit-llvm -o - | FileCheck 
--check-prefix=CHECK-EBSTRICT %s
-// RUN: %clang_cc1 %s 

[clang] 13bfd89 - [clang][FPEnv] Diagnose Strict FP pragmas if target does not support StrictFP

2020-10-30 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2020-10-30T06:11:25-07:00
New Revision: 13bfd89c4962e738cbe50662013267b33a678b8f

URL: 
https://github.com/llvm/llvm-project/commit/13bfd89c4962e738cbe50662013267b33a678b8f
DIFF: 
https://github.com/llvm/llvm-project/commit/13bfd89c4962e738cbe50662013267b33a678b8f.diff

LOG: [clang][FPEnv] Diagnose Strict FP pragmas if target does not support 
StrictFP

Reviewers: sepavloff, kpn, aaron.ballman

Differential Revision: https://reviews.llvm.org/D90316

Added: 
clang/test/Parser/pragma-fp-warn.c

Modified: 
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/lib/Parse/ParsePragma.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 24ca8340ef6f..0fd4eb5323de 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1147,6 +1147,9 @@ def warn_stdc_fenv_round_not_supported :
 def warn_stdc_unknown_rounding_mode : Warning<
   "invalid or unsupported rounding mode in '#pragma STDC FENV_ROUND' - 
ignored">,
   InGroup;
+def warn_pragma_fp_ignored : Warning<
+  "'#pragma %0' is not supported on this target - ignored">,
+  InGroup;
 // - #pragma comment
 def err_pragma_comment_malformed : Error<
   "pragma comment requires parenthesized identifier and optional string">;

diff  --git a/clang/lib/Parse/ParsePragma.cpp b/clang/lib/Parse/ParsePragma.cpp
index 36bfeeebfef3..278e6f50deba 100644
--- a/clang/lib/Parse/ParsePragma.cpp
+++ b/clang/lib/Parse/ParsePragma.cpp
@@ -103,6 +103,12 @@ struct PragmaSTDC_FENV_ACCESSHandler : public 
PragmaHandler {
 
   void HandlePragma(Preprocessor , PragmaIntroducer Introducer,
 Token ) override {
+Token PragmaName = Tok;
+if (!PP.getTargetInfo().hasStrictFP() && !PP.getLangOpts().ExpStrictFP) {
+  PP.Diag(Tok.getLocation(), diag::warn_pragma_fp_ignored)
+  << PragmaName.getIdentifierInfo()->getName();
+  return;
+}
 tok::OnOffSwitch OOS;
 if (PP.LexOnOffSwitch(OOS))
  return;
@@ -2553,6 +2559,12 @@ void 
PragmaFloatControlHandler::HandlePragma(Preprocessor ,
  Token ) {
   Sema::PragmaMsStackAction Action = Sema::PSK_Set;
   SourceLocation FloatControlLoc = Tok.getLocation();
+  Token PragmaName = Tok;
+  if (!PP.getTargetInfo().hasStrictFP() && !PP.getLangOpts().ExpStrictFP) {
+PP.Diag(Tok.getLocation(), diag::warn_pragma_fp_ignored)
+<< PragmaName.getIdentifierInfo()->getName();
+return;
+  }
   PP.Lex(Tok);
   if (Tok.isNot(tok::l_paren)) {
 PP.Diag(FloatControlLoc, diag::err_expected) << tok::l_paren;
@@ -2952,6 +2964,11 @@ void 
PragmaSTDC_FENV_ROUNDHandler::HandlePragma(Preprocessor ,
 Token ) {
   Token PragmaName = Tok;
   SmallVector TokenList;
+  if (!PP.getTargetInfo().hasStrictFP() && !PP.getLangOpts().ExpStrictFP) {
+PP.Diag(Tok.getLocation(), diag::warn_pragma_fp_ignored)
+<< PragmaName.getIdentifierInfo()->getName();
+return;
+  }
 
   PP.Lex(Tok);
   if (Tok.isNot(tok::identifier)) {

diff  --git a/clang/test/Parser/pragma-fp-warn.c 
b/clang/test/Parser/pragma-fp-warn.c
new file mode 100644
index ..21a2cccf4d8f
--- /dev/null
+++ b/clang/test/Parser/pragma-fp-warn.c
@@ -0,0 +1,19 @@
+
+// RUN: %clang_cc1 -triple wasm32 -fsyntax-only -Wno-unknown-pragmas 
-Wignored-pragmas -verify %s
+// RUN: %clang_cc1 -triple thumbv7 -fsyntax-only -Wno-unknown-pragmas 
-Wignored-pragmas -verify %s
+// RUN: %clang_cc1 -triple aarch64 -fsyntax-only -Wno-unknown-pragmas 
-Wignored-pragmas -verify %s
+// RUN: %clang_cc1 -DEXPOK -triple x86_64 -fsyntax-only -Wno-unknown-pragmas 
-Wignored-pragmas -verify %s
+// RUN: %clang_cc1 -DEXPOK -triple systemz -fsyntax-only -Wno-unknown-pragmas 
-Wignored-pragmas -verify %s
+// RUN: %clang_cc1 -DEXPOK -triple powerpc -fsyntax-only -Wno-unknown-pragmas 
-Wignored-pragmas -verify %s
+#ifdef EXPOK
+// expected-no-diagnostics
+#else
+// expected-warning@+4 {{'#pragma float_control' is not supported on this 
target - ignored}}
+// expected-warning@+5 {{'#pragma FENV_ACCESS' is not supported on this target 
- ignored}}
+// expected-warning@+6 {{'#pragma FENV_ROUND' is not supported on this target 
- ignored}}
+#endif
+#pragma float_control(precise, on)
+
+#pragma STDC FENV_ACCESS OFF
+
+#pragma STDC FENV_ROUND FE_DOWNWARD



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 576d436 - Correct LIT test failure detected on buildbot after mibintc committed rG2e204e23911b: [clang] Enable support for #pragma STDC FENV_ACCESS D87528

2020-10-25 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2020-10-25T08:10:34-07:00
New Revision: 576d436c828f84f18277e4675e6e5337d2b77fde

URL: 
https://github.com/llvm/llvm-project/commit/576d436c828f84f18277e4675e6e5337d2b77fde
DIFF: 
https://github.com/llvm/llvm-project/commit/576d436c828f84f18277e4675e6e5337d2b77fde.diff

LOG: Correct LIT test failure detected on buildbot after mibintc committed 
rG2e204e23911b: [clang] Enable support for #pragma STDC FENV_ACCESS D87528

Added: 


Modified: 
clang/test/Parser/pragma-fenv_access.c

Removed: 




diff  --git a/clang/test/Parser/pragma-fenv_access.c 
b/clang/test/Parser/pragma-fenv_access.c
index c789f3313132..3c003d124286 100644
--- a/clang/test/Parser/pragma-fenv_access.c
+++ b/clang/test/Parser/pragma-fenv_access.c
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
-// RUN: %clang_cc1 -ffp-exception-behavior=strict -DSTRICT -fsyntax-only 
-verify %s
-// RUN: %clang_cc1 -x c++ -DCPP -DSTRICT -ffp-exception-behavior=strict 
-fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -ffp-exception-behavior=strict 
-DSTRICT -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -x c++ -DCPP -DSTRICT 
-ffp-exception-behavior=strict -fsyntax-only -verify %s
 #ifdef CPP
 #define CONST constexpr
 #else



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 2e204e2 - [clang] Enable support for #pragma STDC FENV_ACCESS

2020-10-25 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2020-10-25T06:46:25-07:00
New Revision: 2e204e23911b1f8bd1463535da40c6e48747a138

URL: 
https://github.com/llvm/llvm-project/commit/2e204e23911b1f8bd1463535da40c6e48747a138
DIFF: 
https://github.com/llvm/llvm-project/commit/2e204e23911b1f8bd1463535da40c6e48747a138.diff

LOG: [clang] Enable support for #pragma STDC FENV_ACCESS

Reviewers: rjmccall, rsmith, sepavloff

Differential Revision: https://reviews.llvm.org/D87528

Added: 
clang/test/CodeGen/pragma-fenv_access.c
clang/test/Parser/pragma-fenv_access.c

Modified: 
clang/docs/UsersManual.rst
clang/include/clang/AST/Decl.h
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/DiagnosticASTKinds.td
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/include/clang/Basic/LangOptions.h
clang/include/clang/Sema/ScopeInfo.h
clang/include/clang/Sema/Sema.h
clang/lib/AST/ExprConstant.cpp
clang/lib/CodeGen/CGCall.cpp
clang/lib/CodeGen/CodeGenFunction.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/CodeGen/CodeGenModule.h
clang/lib/Parse/ParsePragma.cpp
clang/lib/Parse/ParseStmt.cpp
clang/lib/Sema/ScopeInfo.cpp
clang/lib/Sema/SemaAttr.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaStmt.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/lib/Serialization/ASTReaderDecl.cpp
clang/lib/Serialization/ASTWriterDecl.cpp
clang/test/CXX/expr/expr.const/p2-0x.cpp
clang/test/CodeGen/fp-floatcontrol-pragma.cpp
clang/test/Parser/fp-floatcontrol-syntax.cpp
clang/test/Preprocessor/pragma_unknown.c

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 9726a25f7f63..5d18435aab6c 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -1386,7 +1386,7 @@ Note that floating-point operations performed as part of 
constant initialization
Details:
 
* ``precise`` Disables optimizations that are not value-safe on 
floating-point data, although FP contraction (FMA) is enabled 
(``-ffp-contract=fast``).  This is the default behavior.
-   * ``strict`` Enables ``-frounding-math`` and 
``-ffp-exception-behavior=strict``, and disables contractions (FMA).  All of 
the ``-ffast-math`` enablements are disabled.
+   * ``strict`` Enables ``-frounding-math`` and 
``-ffp-exception-behavior=strict``, and disables contractions (FMA).  All of 
the ``-ffast-math`` enablements are disabled. Enables ``STDC FENV_ACCESS``: by 
default ``FENV_ACCESS`` is disabled. This option setting behaves as though 
``#pragma STDC FENV_ACESS ON`` appeared at the top of the source file.
* ``fast`` Behaves identically to specifying both ``-ffast-math`` and 
``ffp-contract=fast``
 
Note: If your command line specifies multiple instances
@@ -1408,6 +1408,44 @@ Note that floating-point operations performed as part of 
constant initialization
* ``strict`` The compiler ensures that all transformations strictly 
preserve the floating point exception semantics of the original code.
 
 
+.. _fp-constant-eval:
+
+A note about Floating Point Constant Evaluation
+^^^
+
+In C, the only place floating point operations are guaranteed to be evaluated
+during translation is in the initializers of variables of static storage
+duration, which are all notionally initialized before the program begins
+executing (and thus before a non-default floating point environment can be
+entered).  But C++ has many more contexts where floating point constant
+evaluation occurs.  Specifically: for static/thread-local variables,
+first try evaluating the initializer in a constant context, including in the
+constant floating point environment (just like in C), and then, if that fails,
+fall back to emitting runtime code to perform the initialization (which might
+in general be in a 
diff erent floating point environment).
+
+Consider this example when compiled with ``-frounding-math``
+
+   .. code-block:: console
+
+constexpr float func_01(float x, float y) {
+  return x + y;
+}
+float V1 = func_01(1.0F, 0x0.01p0F);
+
+The C++ rule is that initializers for static storage duration variables are
+first evaluated during translation (therefore, in the default rounding mode),
+and only evaluated at runtime (and therefore in the runtime rounding mode) if
+the compile-time evaluation fails. This is in line with the C rules;
+C11 F.8.5 says: *All computation for automatic initialization is done (as if)
+at execution time; thus, it is affected by any operative modes and raises
+floating-point exceptions as required by IEC 60559 (provided the state for the
+FENV_ACCESS pragma is ‘‘on’’). All computation for initialization of objects
+that have static or thread storage duration is done (as if) at translation
+time.* C++ generalizes this by adding another phase of initialization
+(at runtime) if the 

[clang] 467ba4c - More corrections to documented spelling of ffinite-math to ffinite-math-only

2020-06-26 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2020-06-26T13:17:55-07:00
New Revision: 467ba4c92f5bfafd88e154c1657d6ac11dfb34df

URL: 
https://github.com/llvm/llvm-project/commit/467ba4c92f5bfafd88e154c1657d6ac11dfb34df
DIFF: 
https://github.com/llvm/llvm-project/commit/467ba4c92f5bfafd88e154c1657d6ac11dfb34df.diff

LOG: More corrections to documented spelling of ffinite-math to 
ffinite-math-only

Added: 


Modified: 
clang/docs/UsersManual.rst

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 855cf1e8d8b0..4b4e28a8b65c 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -1353,7 +1353,7 @@ are listed below.
 
 .. _opt_ffinite-math-only:
 
-**-f[no-]finite-math**
+**-f[no-]finite-math-only**
 
Allow floating-point optimizations that assume arguments and results are
not NaNs or +-Inf.  This defines the ``__FINITE_MATH_ONLY__`` preprocessor 
macro.
@@ -1362,7 +1362,7 @@ are listed below.
* ``-fno-honor-infinities``
* ``-fno-honor-nans``
 
-   Defaults to ``-fno-finite-math``.
+   Defaults to ``-fno-finite-math-only``.
 
 .. _opt_frounding-math:
 



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 7cc5307 - Correct documented spelling of ffinite-math to ffinite-math-only

2020-06-26 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2020-06-26T12:50:45-07:00
New Revision: 7cc5307c73caa72f22edd4208b175e3c36eec46e

URL: 
https://github.com/llvm/llvm-project/commit/7cc5307c73caa72f22edd4208b175e3c36eec46e
DIFF: 
https://github.com/llvm/llvm-project/commit/7cc5307c73caa72f22edd4208b175e3c36eec46e.diff

LOG: Correct documented spelling of ffinite-math to ffinite-math-only

This is to correct bugs.llvm.org/show_bug.cgi?id=46444
ffinite-math-only is a gcc option.  That is the correct spelling.
File modified is clang/docs/UsersManual.rst

Added: 


Modified: 
clang/docs/UsersManual.rst

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index d13d4180a112..855cf1e8d8b0 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -1220,7 +1220,7 @@ are listed below.
 
* ``-fno-math-errno``
 
-   * ``-ffinite-math``
+   * ``-ffinite-math-only``
 
* ``-fassociative-math``
 
@@ -1306,14 +1306,14 @@ are listed below.
 **-f[no-]honor-infinities**
 
If both ``-fno-honor-infinities`` and ``-fno-honor-nans`` are used,
-   has the same effect as specifying ``-ffinite-math``.
+   has the same effect as specifying ``-ffinite-math-only``.
 
 .. _opt_fhonor-nans:
 
 **-f[no-]honor-nans**
 
If both ``-fno-honor-infinities`` and ``-fno-honor-nans`` are used,
-   has the same effect as specifying ``-ffinite-math``.
+   has the same effect as specifying ``-ffinite-math-only``.
 
 .. _opt_fsigned-zeros:
 
@@ -1351,7 +1351,7 @@ are listed below.
 
Defaults to ``-fno-unsafe-math-optimizations``.
 
-.. _opt_ffinite-math:
+.. _opt_ffinite-math-only:
 
 **-f[no-]finite-math**
 



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 827be69 - [clang] FastMathFlags.allowContract should be initialized only from FPFeatures.allowFPContractAcrossStatement

2020-05-20 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2020-05-20T06:19:10-07:00
New Revision: 827be690dce158924924a70fda79b35a9d7ad1cc

URL: 
https://github.com/llvm/llvm-project/commit/827be690dce158924924a70fda79b35a9d7ad1cc
DIFF: 
https://github.com/llvm/llvm-project/commit/827be690dce158924924a70fda79b35a9d7ad1cc.diff

LOG: [clang] FastMathFlags.allowContract should be initialized only from 
FPFeatures.allowFPContractAcrossStatement

Summary: Fix bug introduced in D72841 adding support for pragma float_control

Reviewers: rjmccall, Anastasia

Differential Revision: https://reviews.llvm.org/D79903

Added: 


Modified: 
clang/lib/CodeGen/CGExprScalar.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/CodeGen/constrained-math-builtins.c
clang/test/CodeGen/fp-contract-on-pragma.cpp
clang/test/CodeGen/fp-contract-pragma.cpp
clang/test/CodeGen/fp-floatcontrol-class.cpp
clang/test/CodeGen/fp-floatcontrol-pragma.cpp
clang/test/CodeGen/fp-floatcontrol-stack.cpp
clang/test/CodeGenOpenCL/relaxed-fpmath.cl
clang/test/CodeGenOpenCL/single-precision-constant.cl

Removed: 




diff  --git a/clang/lib/CodeGen/CGExprScalar.cpp 
b/clang/lib/CodeGen/CGExprScalar.cpp
index 76f58b284eeb..346c429f663e 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -223,8 +223,7 @@ static void updateFastMathFlags(llvm::FastMathFlags ,
   FMF.setNoSignedZeros(FPFeatures.noSignedZeros());
   FMF.setAllowReciprocal(FPFeatures.allowReciprocalMath());
   FMF.setApproxFunc(FPFeatures.allowApproximateFunctions());
-  FMF.setAllowContract(FPFeatures.allowFPContractAcrossStatement() ||
-   FPFeatures.allowFPContractWithinStatement());
+  FMF.setAllowContract(FPFeatures.allowFPContractAcrossStatement());
 }
 
 /// Propagate fast-math flags from \p Op to the instruction in \p V.

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 94ba0dd8e598..b4bc027e832b 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -2944,6 +2944,8 @@ static void ParseLangArgs(LangOptions , ArgList 
, InputKind IK,
   Opts.NoBitFieldTypeAlign = Args.hasArg(OPT_fno_bitfield_type_align);
   Opts.SinglePrecisionConstants = 
Args.hasArg(OPT_cl_single_precision_constant);
   Opts.FastRelaxedMath = Args.hasArg(OPT_cl_fast_relaxed_math);
+  if (Opts.FastRelaxedMath)
+Opts.setDefaultFPContractMode(LangOptions::FPM_Fast);
   Opts.HexagonQdsp6Compat = Args.hasArg(OPT_mqdsp6_compat);
   Opts.FakeAddressSpaceMap = Args.hasArg(OPT_ffake_address_space_map);
   Opts.ParseUnknownAnytype = Args.hasArg(OPT_funknown_anytype);

diff  --git a/clang/test/CodeGen/constrained-math-builtins.c 
b/clang/test/CodeGen/constrained-math-builtins.c
index fe303eb0d5c2..a2feae903d30 100644
--- a/clang/test/CodeGen/constrained-math-builtins.c
+++ b/clang/test/CodeGen/constrained-math-builtins.c
@@ -154,9 +154,9 @@ void bar(float f) {
   (double)f * f - f;
   (long double)-f * f + f;
 
-  // CHECK: call contract float @llvm.experimental.constrained.fmuladd.f32
+  // CHECK: call float @llvm.experimental.constrained.fmuladd.f32
   // CHECK: fneg
-  // CHECK: call contract double @llvm.experimental.constrained.fmuladd.f64
+  // CHECK: call double @llvm.experimental.constrained.fmuladd.f64
   // CHECK: fneg
-  // CHECK: call contract x86_fp80 @llvm.experimental.constrained.fmuladd.f80
+  // CHECK: call x86_fp80 @llvm.experimental.constrained.fmuladd.f80
 };

diff  --git a/clang/test/CodeGen/fp-contract-on-pragma.cpp 
b/clang/test/CodeGen/fp-contract-on-pragma.cpp
index 5f7463608660..812a7176b515 100644
--- a/clang/test/CodeGen/fp-contract-on-pragma.cpp
+++ b/clang/test/CodeGen/fp-contract-on-pragma.cpp
@@ -3,7 +3,7 @@
 // Is FP_CONTRACT honored in a simple case?
 float fp_contract_1(float a, float b, float c) {
 // CHECK: _Z13fp_contract_1fff
-// CHECK: tail call contract float @llvm.fmuladd
+// CHECK: tail call float @llvm.fmuladd
 #pragma clang fp contract(on)
   return a * b + c;
 }
@@ -31,7 +31,7 @@ T template_muladd(T a, T b, T c) {
 
 float fp_contract_3(float a, float b, float c) {
   // CHECK: _Z13fp_contract_3fff
-  // CHECK: tail call contract float @llvm.fmuladd
+  // CHECK: tail call float @llvm.fmuladd
   return template_muladd(a, b, c);
 }
 
@@ -45,13 +45,13 @@ class fp_contract_4 {
 
 template class fp_contract_4;
 // CHECK: _ZN13fp_contract_4IiE6methodEfff
-// CHECK: tail call contract float @llvm.fmuladd
+// CHECK: tail call float @llvm.fmuladd
 
 // Check file-scoped FP_CONTRACT
 #pragma clang fp contract(on)
 float fp_contract_5(float a, float b, float c) {
   // CHECK: _Z13fp_contract_5fff
-  // CHECK: tail call contract float @llvm.fmuladd
+  // CHECK: tail call float @llvm.fmuladd
   return a * b + c;
 }
 
@@ -69,8 +69,8 @@ float fp_contract_6(float a, float b, float c) {
 
 float fp_contract_7(float a, float 

[clang] 7b8e306 - [clang] Fix bug in #pragma float_control(push/pop)

2020-05-14 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2020-05-14T05:58:11-07:00
New Revision: 7b8e3065606cb555e7528e3b59d5e164ecf008fa

URL: 
https://github.com/llvm/llvm-project/commit/7b8e3065606cb555e7528e3b59d5e164ecf008fa
DIFF: 
https://github.com/llvm/llvm-project/commit/7b8e3065606cb555e7528e3b59d5e164ecf008fa.diff

LOG: [clang] Fix bug in #pragma float_control(push/pop)

Summary: #pragma float_control(pop) was failing to restore the expected
floating point settings because the settings were not correctly preserved
at #pragma float_control(push).

Added: 


Modified: 
clang/lib/Sema/SemaAttr.cpp
clang/test/CodeGen/fp-floatcontrol-pragma.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaAttr.cpp b/clang/lib/Sema/SemaAttr.cpp
index 222aaf3049ae..977e92475182 100644
--- a/clang/lib/Sema/SemaAttr.cpp
+++ b/clang/lib/Sema/SemaAttr.cpp
@@ -457,8 +457,12 @@ void Sema::ActOnPragmaFloatControl(SourceLocation Loc,
 FpPragmaStack.Act(Loc, Action, StringRef(), NewValue);
 break;
   case PFC_Push:
-Action = Sema::PSK_Push_Set;
-FpPragmaStack.Act(Loc, Action, StringRef(), 
NewFPFeatures.getAsOpaqueInt());
+if (FpPragmaStack.Stack.empty()) {
+  FpPragmaStack.Act(Loc, Sema::PSK_Set, StringRef(),
+CurFPFeatures.getAsOpaqueInt());
+}
+FpPragmaStack.Act(Loc, Sema::PSK_Push_Set, StringRef(),
+  NewFPFeatures.getAsOpaqueInt());
 break;
   case PFC_Pop:
 if (FpPragmaStack.Stack.empty()) {

diff  --git a/clang/test/CodeGen/fp-floatcontrol-pragma.cpp 
b/clang/test/CodeGen/fp-floatcontrol-pragma.cpp
index a80a4d377660..ca3a3a46aab2 100644
--- a/clang/test/CodeGen/fp-floatcontrol-pragma.cpp
+++ b/clang/test/CodeGen/fp-floatcontrol-pragma.cpp
@@ -1,6 +1,68 @@
 // RUN: %clang_cc1 -DEXCEPT=1 -fcxx-exceptions -triple x86_64-linux-gnu 
-emit-llvm -o - %s | FileCheck -check-prefix=CHECK-NS %s
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck %s
 // RUN: %clang_cc1 -verify -DFENV_ON=1 -triple x86_64-linux-gnu -emit-llvm -o 
- %s | FileCheck %s
+// RUN: %clang_cc1 -triple %itanium_abi_triple -O3 -emit-llvm -o - %s | 
FileCheck -check-prefix=CHECK-O3 %s
+
+// Verify float_control(precise, off) enables fast math flags on fp operations.
+float fp_precise_1(float a, float b, float c) {
+// CHECK-O3: _Z12fp_precise_1fff
+// CHECK-O3: %[[M:.+]] = fmul fast float{{.*}}
+// CHECK-O3: fadd fast float %[[M]], %c
+#pragma float_control(precise, off)
+  return a * b + c;
+}
+
+// Is float_control state cleared on exiting compound statements?
+float fp_precise_2(float a, float b, float c) {
+  // CHECK-O3: _Z12fp_precise_2fff
+  // CHECK-O3: %[[M:.+]] = fmul float{{.*}}
+  // CHECK-O3: fadd float %[[M]], %c
+  {
+#pragma float_control(precise, off)
+  }
+  return a * b + c;
+}
+
+// Does float_control survive template instantiation?
+class Foo {};
+Foo operator+(Foo, Foo);
+
+template 
+T template_muladd(T a, T b, T c) {
+#pragma float_control(precise, off)
+  return a * b + c;
+}
+
+float fp_precise_3(float a, float b, float c) {
+  // CHECK-O3: _Z12fp_precise_3fff
+  // CHECK-O3: %[[M:.+]] = fmul fast float{{.*}}
+  // CHECK-O3: fadd fast float %[[M]], %c
+  return template_muladd(a, b, c);
+}
+
+template 
+class fp_precise_4 {
+  float method(float a, float b, float c) {
+#pragma float_control(precise, off)
+return a * b + c;
+  }
+};
+
+template class fp_precise_4;
+// CHECK-O3: _ZN12fp_precise_4IiE6methodEfff
+// CHECK-O3: %[[M:.+]] = fmul fast float{{.*}}
+// CHECK-O3: fadd fast float %[[M]], %c
+
+// Check file-scoped float_control
+#pragma float_control(push)
+#pragma float_control(precise, off)
+float fp_precise_5(float a, float b, float c) {
+  // CHECK-O3: _Z12fp_precise_5fff
+  // CHECK-O3: %[[M:.+]] = fmul fast float{{.*}}
+  // CHECK-O3: fadd fast float %[[M]], %c
+  return a * b + c;
+}
+#pragma float_control(pop)
 
 float fff(float x, float y) {
 // CHECK-LABEL: define float @_Z3f{{.*}}
@@ -41,6 +103,14 @@ float check_precise(float x, float y) {
   return z;
 }
 
+float fma_test2(float a, float b, float c) {
+// CHECK-LABEL define float @_Z9fma_test2fff{{.*}}
+#pragma float_control(precise, off)
+  float x = a * b + c;
+  //CHECK: fmuladd
+  return x;
+}
+
 float fma_test1(float a, float b, float c) {
 // CHECK-LABEL define float @_Z9fma_test1fff{{.*}}
 #pragma float_control(precise, on)



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 7f2db99 - [PATCH] #pragma float_control should be permitted in namespace scope.

2020-05-12 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2020-05-12T06:10:19-07:00
New Revision: 7f2db993500923a51c0b0aed650a3e0d4241205b

URL: 
https://github.com/llvm/llvm-project/commit/7f2db993500923a51c0b0aed650a3e0d4241205b
DIFF: 
https://github.com/llvm/llvm-project/commit/7f2db993500923a51c0b0aed650a3e0d4241205b.diff

LOG: [PATCH] #pragma float_control should be permitted in namespace scope.

Summary: Erroneous error diagnostic observed in VS2017  header
Also correction to propagate usesFPIntrin from template func to instantiation.

Reviewers: rjmccall, erichkeane (no feedback received)

Differential Revision: https://reviews.llvm.org/D79631

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaAttr.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/test/CodeGen/fp-floatcontrol-pragma.cpp
clang/test/Parser/fp-floatcontrol-syntax.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 44a34080b239..371e20183e1e 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -860,7 +860,7 @@ def warn_pragma_pack_pop_identifier_and_alignment : Warning<
 def warn_pragma_pop_failed : Warning<"#pragma %0(pop, ...) failed: %1">,
   InGroup;
 def err_pragma_fc_pp_scope : Error<
-  "'#pragma float_control push/pop' can only appear at file scope">;
+  "'#pragma float_control push/pop' can only appear at file scope or namespace 
scope">;
 def err_pragma_fc_noprecise_requires_nofenv : Error<
   "'#pragma float_control(precise, off)' is illegal when fenv_access is 
enabled">;
 def err_pragma_fc_except_requires_precise : Error<

diff  --git a/clang/lib/Sema/SemaAttr.cpp b/clang/lib/Sema/SemaAttr.cpp
index 01f30a985935..222aaf3049ae 100644
--- a/clang/lib/Sema/SemaAttr.cpp
+++ b/clang/lib/Sema/SemaAttr.cpp
@@ -420,8 +420,8 @@ void Sema::ActOnPragmaFloatControl(SourceLocation Loc,
   auto NewValue = FpPragmaStack.CurrentValue;
   FPOptions NewFPFeatures(NewValue);
   if ((Action == PSK_Push_Set || Action == PSK_Push || Action == PSK_Pop) &&
-  !CurContext->isTranslationUnit()) {
-// Push and pop can only occur at file scope.
+  !(CurContext->isTranslationUnit()) && !CurContext->isNamespace()) {
+// Push and pop can only occur at file or namespace scope.
 Diag(Loc, diag::err_pragma_fc_pp_scope);
 return;
   }

diff  --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp 
b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index a6541dabe6b2..327022218e01 100755
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -1911,6 +1911,7 @@ Decl *TemplateDeclInstantiator::VisitFunctionDecl(
 D->hasWrittenPrototype(), D->getConstexprKind(),
 TrailingRequiresClause);
 Function->setRangeEnd(D->getSourceRange().getEnd());
+Function->setUsesFPIntrin(D->usesFPIntrin());
   }
 
   if (D->isInlined())

diff  --git a/clang/test/CodeGen/fp-floatcontrol-pragma.cpp 
b/clang/test/CodeGen/fp-floatcontrol-pragma.cpp
index 773cfcdd2829..a80a4d377660 100644
--- a/clang/test/CodeGen/fp-floatcontrol-pragma.cpp
+++ b/clang/test/CodeGen/fp-floatcontrol-pragma.cpp
@@ -1,3 +1,4 @@
+// RUN: %clang_cc1 -DEXCEPT=1 -fcxx-exceptions -triple x86_64-linux-gnu 
-emit-llvm -o - %s | FileCheck -check-prefix=CHECK-NS %s
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck %s
 // RUN: %clang_cc1 -verify -DFENV_ON=1 -triple x86_64-linux-gnu -emit-llvm -o 
- %s | FileCheck %s
 
@@ -59,3 +60,56 @@ void callt() {
   z = z * z;
 //CHECK: = fmul float
 }
+
+#if EXCEPT
+namespace ns {
+// Check that pragma float_control can appear in namespace.
+#pragma float_control(except, on, push)
+float exc_on(double x, float zero) {
+// CHECK-NS: define {{.*}}exc_on{{.*}}
+  {} try {
+x = 1.0 / zero; /* division by zero, the result unused */
+//CHECK-NS: llvm.experimental.constrained.fdiv{{.*}}
+  } catch (...) {}
+  return zero;
+}
+}
+
+// Check pragma is still effective after namespace closes
+float exc_still_on(double x, float zero) {
+// CHECK-NS: define {{.*}}exc_still_on{{.*}}
+  {} try {
+x = 1.0 / zero; /* division by zero, the result unused */
+//CHECK-NS: llvm.experimental.constrained.fdiv{{.*}}
+  } catch (...) {}
+  return zero;
+}
+
+#pragma float_control(pop)
+float exc_off(double x, float zero) {
+// CHECK-NS: define {{.*}}exc_off{{.*}}
+  {} try {
+x = 1.0 / zero; /* division by zero, the result unused */
+//CHECK-NS: fdiv contract double
+  } catch (...) {}
+  return zero;
+}
+
+namespace fc_template_namespace {
+#pragma float_control(except, on, push)
+template 
+T exc_on(double x, T zero) {
+// CHECK-NS: define {{.*}}fc_template_namespace{{.*}}
+  {} try {
+x = 1.0 / zero; /* division by zero, the result unused */
+//CHECK-NS: 

[clang] 01dc694 - FP LangOpts should not be dependent on CGOpt

2020-05-11 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2020-05-11T12:32:35-07:00
New Revision: 01dc694ccb8689a4b4a180da67ed042f85bbcfd5

URL: 
https://github.com/llvm/llvm-project/commit/01dc694ccb8689a4b4a180da67ed042f85bbcfd5
DIFF: 
https://github.com/llvm/llvm-project/commit/01dc694ccb8689a4b4a180da67ed042f85bbcfd5.diff

LOG: FP LangOpts should not be dependent on CGOpt
This bug was observed by Apple since their compiler processes LangOpts and 
CGOpts in a different order.

Reviewed By: rjmccall

Differential Revision: https://reviews.llvm.org/D79735

Added: 


Modified: 
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index ec415472ea3c..2d6f4be6885e 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -2454,7 +2454,7 @@ static const StringRef GetInputKindName(InputKind IK) {
 
 static void ParseLangArgs(LangOptions , ArgList , InputKind IK,
   const TargetOptions ,
-  PreprocessorOptions , CodeGenOptions ,
+  PreprocessorOptions ,
   DiagnosticsEngine ) {
   // FIXME: Cleanup per-file based stuff.
   LangStandard::Kind LangStd = LangStandard::lang_unspecified;
@@ -3188,13 +3188,21 @@ static void ParseLangArgs(LangOptions , ArgList 
, InputKind IK,
   Opts.UnsafeFPMath = Args.hasArg(OPT_menable_unsafe_fp_math) ||
   Args.hasArg(OPT_cl_unsafe_math_optimizations) ||
   Args.hasArg(OPT_cl_fast_relaxed_math);
-  Opts.AllowFPReassoc = Opts.FastMath || CGOpts.Reassociate;
-  Opts.NoHonorNaNs =
-  Opts.FastMath || CGOpts.NoNaNsFPMath || Opts.FiniteMathOnly;
-  Opts.NoHonorInfs =
-  Opts.FastMath || CGOpts.NoInfsFPMath || Opts.FiniteMathOnly;
-  Opts.NoSignedZero = Opts.FastMath || CGOpts.NoSignedZeros;
-  Opts.AllowRecip = Opts.FastMath || CGOpts.ReciprocalMath;
+  Opts.AllowFPReassoc = Opts.FastMath || Args.hasArg(OPT_mreassociate);
+  Opts.NoHonorNaNs = Opts.FastMath || Opts.FiniteMathOnly ||
+ Args.hasArg(OPT_menable_no_nans) ||
+ Args.hasArg(OPT_cl_unsafe_math_optimizations) ||
+ Args.hasArg(OPT_cl_finite_math_only) ||
+ Args.hasArg(OPT_cl_fast_relaxed_math);
+  Opts.NoHonorInfs = Opts.FastMath || Opts.FiniteMathOnly ||
+ Args.hasArg(OPT_menable_no_infinities) ||
+ Args.hasArg(OPT_cl_finite_math_only) ||
+ Args.hasArg(OPT_cl_fast_relaxed_math);
+  Opts.NoSignedZero = Opts.FastMath || (Args.hasArg(OPT_fno_signed_zeros) ||
+  Args.hasArg(OPT_cl_no_signed_zeros) ||
+  Args.hasArg(OPT_cl_unsafe_math_optimizations) ||
+  Args.hasArg(OPT_cl_fast_relaxed_math));
+  Opts.AllowRecip = Opts.FastMath || Args.hasArg(OPT_freciprocal_math);
   // Currently there's no clang option to enable this individually
   Opts.ApproxFunc = Opts.FastMath;
 
@@ -3652,7 +3660,7 @@ bool 
CompilerInvocation::CreateFromArgs(CompilerInvocation ,
 // Other LangOpts are only initialized when the input is not AST or LLVM 
IR.
 // FIXME: Should we really be calling this for an Language::Asm input?
 ParseLangArgs(LangOpts, Args, DashX, Res.getTargetOpts(),
-  Res.getPreprocessorOpts(), Res.getCodeGenOpts(), Diags);
+  Res.getPreprocessorOpts(), Diags);
 if (Res.getFrontendOpts().ProgramAction == frontend::RewriteObjC)
   LangOpts.ObjCExceptions = 1;
 if (T.isOSDarwin() && DashX.isPreprocessed()) {



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] e557801 - When pragma FENV_ACCESS is ignored do not modify Sema.CurFPFeatures

2020-05-06 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2020-05-06T13:18:59-07:00
New Revision: e5578013b199e142864cbf374b4a143e5d0c184a

URL: 
https://github.com/llvm/llvm-project/commit/e5578013b199e142864cbf374b4a143e5d0c184a
DIFF: 
https://github.com/llvm/llvm-project/commit/e5578013b199e142864cbf374b4a143e5d0c184a.diff

LOG: When pragma FENV_ACCESS is ignored do not modify Sema.CurFPFeatures
Bug reported by @uabelho against reviews.llvm.org/D72841

Reviewers: rjmccall

Differential Revision: https://reviews.llvm.org/D79510

Added: 


Modified: 
clang/lib/Parse/ParsePragma.cpp
clang/test/CodeGen/fp-floatcontrol-pragma.cpp
clang/test/Parser/fp-floatcontrol-syntax.cpp

Removed: 




diff  --git a/clang/lib/Parse/ParsePragma.cpp b/clang/lib/Parse/ParsePragma.cpp
index 8adf978a8e13..828d429e6969 100644
--- a/clang/lib/Parse/ParsePragma.cpp
+++ b/clang/lib/Parse/ParsePragma.cpp
@@ -108,6 +108,7 @@ struct PragmaSTDC_FENV_ACCESSHandler : public PragmaHandler 
{
  return;
 if (OOS == tok::OOS_ON) {
   PP.Diag(Tok, diag::warn_stdc_fenv_access_not_supported);
+  return;
 }
 
 MutableArrayRef 
Toks(PP.getPreprocessorAllocator().Allocate(1),

diff  --git a/clang/test/CodeGen/fp-floatcontrol-pragma.cpp 
b/clang/test/CodeGen/fp-floatcontrol-pragma.cpp
index caaab3ca4f84..773cfcdd2829 100644
--- a/clang/test/CodeGen/fp-floatcontrol-pragma.cpp
+++ b/clang/test/CodeGen/fp-floatcontrol-pragma.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -verify -DFENV_ON=1 -triple x86_64-linux-gnu -emit-llvm -o 
- %s | FileCheck %s
 
 float fff(float x, float y) {
 // CHECK-LABEL: define float @_Z3f{{.*}}
@@ -38,6 +39,7 @@ float check_precise(float x, float y) {
   }
   return z;
 }
+
 float fma_test1(float a, float b, float c) {
 // CHECK-LABEL define float @_Z9fma_test1fff{{.*}}
 #pragma float_control(precise, on)
@@ -45,3 +47,15 @@ float fma_test1(float a, float b, float c) {
   //CHECK: fmuladd
   return x;
 }
+
+#if FENV_ON
+// expected-warning@+1{{pragma STDC FENV_ACCESS ON is not supported, ignoring 
pragma}}
+#pragma STDC FENV_ACCESS ON
+#endif
+// CHECK-LABEL: define {{.*}}callt{{.*}}
+
+void callt() {
+  volatile float z;
+  z = z * z;
+//CHECK: = fmul float
+}

diff  --git a/clang/test/Parser/fp-floatcontrol-syntax.cpp 
b/clang/test/Parser/fp-floatcontrol-syntax.cpp
index a7303720e6c4..4bdc34dd5ee0 100644
--- a/clang/test/Parser/fp-floatcontrol-syntax.cpp
+++ b/clang/test/Parser/fp-floatcontrol-syntax.cpp
@@ -30,14 +30,15 @@ double b = 1.0;
 //  document the warning
 #ifdef FAST
 // expected-warning@+1{{pragma STDC FENV_ACCESS ON is not supported, ignoring 
pragma}}
-#pragma STDC FENV_ACCESS ON // expected-error{{'#pragma STDC FENV_ACCESS ON' 
is illegal when precise is disabled}}
+#pragma STDC FENV_ACCESS ON
 #else
 #pragma STDC FENV_ACCESS ON // expected-warning{{pragma STDC FENV_ACCESS ON is 
not supported, ignoring pragma}}
 #endif
 #ifdef STRICT
 #pragma float_control(precise, off) // expected-error {{'#pragma 
float_control(precise, off)' is illegal when except is enabled}}
 #else
-#pragma float_control(precise, off) // expected-error {{'#pragma 
float_control(precise, off)' is illegal when fenv_access is enabled}}
+// Currently FENV_ACCESS cannot be enabled by pragma, skip error check
+#pragma float_control(precise, off) // not-expected-error {{'#pragma 
float_control(precise, off)' is illegal when fenv_access is enabled}}
 #endif
 
 #pragma float_control(precise, on)



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] c355bec - Add support for #pragma clang fp reassociate(on|off)

2020-05-06 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2020-05-06T08:05:44-07:00
New Revision: c355bec749e94c601a42e435f6c98b956f3965ac

URL: 
https://github.com/llvm/llvm-project/commit/c355bec749e94c601a42e435f6c98b956f3965ac
DIFF: 
https://github.com/llvm/llvm-project/commit/c355bec749e94c601a42e435f6c98b956f3965ac.diff

LOG: Add support for #pragma clang fp reassociate(on|off)

Reviewers: rjmccall, erichkeane, sepavloff

Differential Revision: https://reviews.llvm.org/D78827

Added: 
clang/test/CodeGen/fp-reassoc-pragma.cpp

Modified: 
clang/docs/LanguageExtensions.rst
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Basic/LangOptions.h
clang/include/clang/Sema/Sema.h
clang/lib/CodeGen/BackendUtil.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Parse/ParsePragma.cpp
clang/lib/Sema/SemaAttr.cpp
clang/test/Parser/pragma-fp-contract.c
clang/test/Parser/pragma-fp.cpp

Removed: 




diff  --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index 1c753ea0e569..2fbf5ea5eb01 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -3173,16 +3173,36 @@ at the start of a compound statement (excluding 
comments). When using within a
 compound statement, the pragma is active within the scope of the compound
 statement.
 
-Currently, only FP contraction can be controlled with the pragma. ``#pragma
-clang fp contract`` specifies whether the compiler should contract a multiply
-and an addition (or subtraction) into a fused FMA operation when supported by
-the target.
+Currently, the following settings can be controlled with this pragma:
+
+``#pragma clang fp reassociate`` allows control over the reassociation
+of floating point expressions. When enabled, this pragma allows the expression
+``x + (y + z)`` to be reassociated as ``(x + y) + z``.
+Reassociation can also occur across multiple statements.
+This pragma can be used to disable reassociation when it is otherwise
+enabled for the translation unit with the ``-fassociative-math`` flag.
+The pragma can take two values: ``on`` and ``off``.
+
+.. code-block:: c++
+
+  float f(float x, float y, float z)
+  {
+// Enable floating point reassociation across statements
+#pragma fp reassociate(on)
+float t = x + y;
+float v = t + z;
+  }
+
+
+``#pragma clang fp contract`` specifies whether the compiler should
+contract a multiply and an addition (or subtraction) into a fused FMA
+operation when supported by the target.
 
 The pragma can take three values: ``on``, ``fast`` and ``off``.  The ``on``
 option is identical to using ``#pragma STDC FP_CONTRACT(ON)`` and it allows
-fusion as specified the language standard.  The ``fast`` option allows fusiong
+fusion as specified the language standard.  The ``fast`` option allows fusion
 in cases when the language standard does not make this possible (e.g. across
-statements in C)
+statements in C).
 
 .. code-block:: c++
 

diff  --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 9400a87c0ef3..552c9187e705 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1332,10 +1332,12 @@ def err_pragma_loop_invalid_option : Error<
   "pipeline, pipeline_initiation_interval, vectorize_predicate, or 
distribute">;
 
 def err_pragma_fp_invalid_option : Error<
-  "%select{invalid|missing}0 option%select{ %1|}0; expected contract">;
+  "%select{invalid|missing}0 option%select{ %1|}0; expected 'contract' or 
'reassociate'">;
 def err_pragma_fp_invalid_argument : Error<
   "unexpected argument '%0' to '#pragma clang fp %1'; "
-  "expected 'on', 'fast' or 'off'">;
+  "%select{"
+  "expected 'fast' or 'on' or 'off'|"
+  "expected 'on' or 'off'}2">;
 
 def err_pragma_invalid_keyword : Error<
   "invalid argument; expected 'enable'%select{|, 'full'}0%select{|, 
'assume_safety'}1 or 'disable'">;

diff  --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index 289f9c3f50e2..02f67636d03d 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -268,7 +268,7 @@ BENIGN_LANGOPT(SpellChecking , 1, 1, "spell-checking")
 LANGOPT(SinglePrecisionConstants , 1, 0, "treating double-precision floating 
point constants as single precision constants")
 LANGOPT(FastRelaxedMath , 1, 0, "OpenCL fast relaxed math")
 /// FP_CONTRACT mode (on/off/fast).
-ENUM_LANGOPT(DefaultFPContractMode, FPContractModeKind, 2, FPC_Off, "FP 
contraction type")
+ENUM_LANGOPT(DefaultFPContractMode, FPModeKind, 2, FPM_Off, "FP contraction 
type")
 ENUM_LANGOPT(FPRoundingMode, RoundingMode, 3, RoundingMode::NearestTiesToEven, 
"FP Rounding Mode type")
 ENUM_LANGOPT(FPExceptionMode, FPExceptionModeKind, 2, FPE_Ignore, 

[clang] 7cbb495 - Fix LABEL match for test case for D72841 #pragma float_control

2020-05-04 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2020-05-04T07:27:40-07:00
New Revision: 7cbb495ab452877496df270678f9b0a8d57ab7e7

URL: 
https://github.com/llvm/llvm-project/commit/7cbb495ab452877496df270678f9b0a8d57ab7e7
DIFF: 
https://github.com/llvm/llvm-project/commit/7cbb495ab452877496df270678f9b0a8d57ab7e7.diff

LOG: Fix LABEL match for test case for D72841 #pragma float_control

Added: 


Modified: 
clang/test/CodeGen/fp-floatcontrol-class.cpp

Removed: 




diff  --git a/clang/test/CodeGen/fp-floatcontrol-class.cpp 
b/clang/test/CodeGen/fp-floatcontrol-class.cpp
index ce4e0eb01390..324c3cc14f6f 100644
--- a/clang/test/CodeGen/fp-floatcontrol-class.cpp
+++ b/clang/test/CodeGen/fp-floatcontrol-class.cpp
@@ -1,6 +1,5 @@
 // RUN: %clang_cc1 -ffp-contract=on -triple %itanium_abi_triple -emit-llvm -o 
- %s | FileCheck %s
 // RUN: %clang_cc1 -ffp-contract=on -triple x86_64-linux-gnu -emit-llvm -o - 
%s | FileCheck %s
-// RUN: %clang_cc1 -ffp-contract=on -triple x86_64-unknown-unknown -emit-llvm 
-o - %s | FileCheck %s
 // Verify that float_control does not pertain to initializer expressions
 
 float y();
@@ -8,14 +7,14 @@ float z();
 #pragma float_control(except, on)
 class ON {
   float w = 2 + y() * z();
-  // CHECK-LABEL: define {{.*}} void @_ZN2ONC2Ev{{.*}}
+  // CHECK-LABEL: define {{.*}} @_ZN2ONC2Ev{{.*}}
   //CHECK: call contract float {{.*}}llvm.fmuladd
 };
 ON on;
 #pragma float_control(except, off)
 class OFF {
   float w = 2 + y() * z();
-  // CHECK-LABEL: define {{.*}} void @_ZN3OFFC2Ev{{.*}}
+  // CHECK-LABEL: define {{.*}} @_ZN3OFFC2Ev{{.*}}
   //CHECK: call contract float {{.*}}llvm.fmuladd
 };
 OFF off;



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 8812b0c - [NFC] Rename Sema.FPFeatures to CurFPFeatures and accessor to getCurFPFeatures

2020-04-16 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2020-04-16T08:50:14-07:00
New Revision: 8812b0cc5cc09f350d8e89bff99f185c5e1a5d4d

URL: 
https://github.com/llvm/llvm-project/commit/8812b0cc5cc09f350d8e89bff99f185c5e1a5d4d
DIFF: 
https://github.com/llvm/llvm-project/commit/8812b0cc5cc09f350d8e89bff99f185c5e1a5d4d.diff

LOG: [NFC] Rename Sema.FPFeatures to CurFPFeatures and accessor to 
getCurFPFeatures

Added: 


Modified: 
clang/include/clang/Sema/Sema.h
clang/lib/Sema/Sema.cpp
clang/lib/Sema/SemaAttr.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaOverload.cpp
clang/lib/Sema/SemaPseudoObject.cpp
clang/lib/Sema/TreeTransform.h
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 889f4ee9031e..a1a0b854a85b 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -392,7 +392,7 @@ class Sema final {
   typedef OpaquePtr TypeTy;
 
   OpenCLOptions OpenCLFeatures;
-  FPOptions FPFeatures;
+  FPOptions CurFPFeatures;
 
   const LangOptions 
   Preprocessor 
@@ -1354,8 +1354,8 @@ class Sema final {
   /// statements.
   class FPFeaturesStateRAII {
   public:
-FPFeaturesStateRAII(Sema ) : S(S), OldFPFeaturesState(S.FPFeatures) {}
-~FPFeaturesStateRAII() { S.FPFeatures = OldFPFeaturesState; }
+FPFeaturesStateRAII(Sema ) : S(S), OldFPFeaturesState(S.CurFPFeatures) {}
+~FPFeaturesStateRAII() { S.CurFPFeatures = OldFPFeaturesState; }
 
   private:
 Sema& S;
@@ -1378,7 +1378,7 @@ class Sema final {
 
   const LangOptions () const { return LangOpts; }
   OpenCLOptions () { return OpenCLFeatures; }
-  FPOptions () { return FPFeatures; }
+  FPOptions () { return CurFPFeatures; }
 
   DiagnosticsEngine () const { return Diags; }
   SourceManager () const { return SourceMgr; }

diff  --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index 5e5a90ad0143..405b6c33d280 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -150,7 +150,7 @@ const unsigned Sema::MaximumAlignment;
 Sema::Sema(Preprocessor , ASTContext , ASTConsumer ,
TranslationUnitKind TUKind, CodeCompleteConsumer *CodeCompleter)
 : ExternalSource(nullptr), isMultiplexExternalSource(false),
-  FPFeatures(pp.getLangOpts()), LangOpts(pp.getLangOpts()), PP(pp),
+  CurFPFeatures(pp.getLangOpts()), LangOpts(pp.getLangOpts()), PP(pp),
   Context(ctxt), Consumer(consumer), Diags(PP.getDiagnostics()),
   SourceMgr(PP.getSourceManager()), CollectStats(false),
   CodeCompleter(CodeCompleter), CurContext(nullptr),

diff  --git a/clang/lib/Sema/SemaAttr.cpp b/clang/lib/Sema/SemaAttr.cpp
index 9141a28381ad..8633581b6880 100644
--- a/clang/lib/Sema/SemaAttr.cpp
+++ b/clang/lib/Sema/SemaAttr.cpp
@@ -929,32 +929,32 @@ void Sema::ActOnPragmaVisibility(const IdentifierInfo* 
VisType,
 void Sema::ActOnPragmaFPContract(LangOptions::FPContractModeKind FPC) {
   switch (FPC) {
   case LangOptions::FPC_On:
-FPFeatures.setAllowFPContractWithinStatement();
+CurFPFeatures.setAllowFPContractWithinStatement();
 break;
   case LangOptions::FPC_Fast:
-FPFeatures.setAllowFPContractAcrossStatement();
+CurFPFeatures.setAllowFPContractAcrossStatement();
 break;
   case LangOptions::FPC_Off:
-FPFeatures.setDisallowFPContract();
+CurFPFeatures.setDisallowFPContract();
 break;
   }
 }
 
 void Sema::setRoundingMode(llvm::RoundingMode FPR) {
-  FPFeatures.setRoundingMode(FPR);
+  CurFPFeatures.setRoundingMode(FPR);
 }
 
 void Sema::setExceptionMode(LangOptions::FPExceptionModeKind FPE) {
-  FPFeatures.setExceptionMode(FPE);
+  CurFPFeatures.setExceptionMode(FPE);
 }
 
 void Sema::ActOnPragmaFEnvAccess(LangOptions::FEnvAccessModeKind FPC) {
   switch (FPC) {
   case LangOptions::FEA_On:
-FPFeatures.setAllowFEnvAccess();
+CurFPFeatures.setAllowFEnvAccess();
 break;
   case LangOptions::FEA_Off:
-FPFeatures.setDisallowFEnvAccess();
+CurFPFeatures.setDisallowFEnvAccess();
 break;
   }
 }

diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 381db055afae..8f04f5ae5dea 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -13698,7 +13698,7 @@ buildSingleCopyAssignRecursively(Sema , 
SourceLocation Loc, QualType T,
   Expr *Comparison = BinaryOperator::Create(
   S.Context, IterationVarRefRVal.build(S, Loc),
   IntegerLiteral::Create(S.Context, Upper, SizeType, Loc), BO_NE,
-  S.Context.BoolTy, VK_RValue, OK_Ordinary, Loc, S.FPFeatures);
+  S.Context.BoolTy, VK_RValue, OK_Ordinary, Loc, S.CurFPFeatures);
 
   // Create the pre-increment of the iteration variable. We can determine
   // whether the increment will overflow based on the value of the array

diff  --git a/clang/lib/Sema/SemaExpr.cpp 

[clang] 2ba4e3a - Move BinaryOperators.FPOptions to trailing storage

2020-04-15 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2020-04-15T12:57:31-07:00
New Revision: 2ba4e3a4598b165245c581c506a813cd4a7dce33

URL: 
https://github.com/llvm/llvm-project/commit/2ba4e3a4598b165245c581c506a813cd4a7dce33
DIFF: 
https://github.com/llvm/llvm-project/commit/2ba4e3a4598b165245c581c506a813cd4a7dce33.diff

LOG: Move BinaryOperators.FPOptions to trailing storage

Reviewers: rjmccall

Differential Revision: https://reviews.llvm.org/D76384

Added: 


Modified: 
clang/include/clang/AST/Expr.h
clang/include/clang/AST/ExprCXX.h
clang/include/clang/AST/Stmt.h
clang/include/clang/Basic/LangOptions.h
clang/lib/AST/ASTImporter.cpp
clang/lib/AST/Expr.cpp
clang/lib/AST/ExprCXX.cpp
clang/lib/Analysis/BodyFarm.cpp
clang/lib/Basic/LangOptions.cpp
clang/lib/CodeGen/CGExprScalar.cpp
clang/lib/CodeGen/CGObjC.cpp
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
clang/lib/Frontend/Rewrite/RewriteObjC.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaExprCXX.cpp
clang/lib/Sema/SemaOverload.cpp
clang/lib/Sema/SemaPseudoObject.cpp
clang/lib/Sema/TreeTransform.h
clang/lib/Serialization/ASTReaderStmt.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/lib/Serialization/ASTWriterStmt.cpp

Removed: 




diff  --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index c1ef6ed09ce8..1fdfe926eb71 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -3475,17 +3475,36 @@ class BinaryOperator : public Expr {
 public:
   typedef BinaryOperatorKind Opcode;
 
-  BinaryOperator(Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy,
- ExprValueKind VK, ExprObjectKind OK, SourceLocation opLoc,
- FPOptions FPFeatures)
+protected:
+  size_t offsetOfTrailingStorage() const;
+
+  /// Return a pointer to the trailing FPOptions
+  FPOptions *getTrailingFPFeatures() {
+assert(BinaryOperatorBits.HasFPFeatures);
+return reinterpret_cast(reinterpret_cast(this) +
+ offsetOfTrailingStorage());
+  }
+  const FPOptions *getTrailingFPFeatures() const {
+assert(BinaryOperatorBits.HasFPFeatures);
+return reinterpret_cast(
+reinterpret_cast(this) + offsetOfTrailingStorage());
+  }
+
+  /// Build a binary operator, assuming that appropriate storage has been
+  /// allocated for the trailing objects when needed.
+  BinaryOperator(const ASTContext , Expr *lhs, Expr *rhs, Opcode opc,
+ QualType ResTy, ExprValueKind VK, ExprObjectKind OK,
+ SourceLocation opLoc, FPOptions FPFeatures)
   : Expr(BinaryOperatorClass, ResTy, VK, OK) {
 BinaryOperatorBits.Opc = opc;
-BinaryOperatorBits.FPFeatures = FPFeatures.getInt();
+assert(!isCompoundAssignmentOp() &&
+   "Use CompoundAssignOperator for compound assignments");
 BinaryOperatorBits.OpLoc = opLoc;
 SubExprs[LHS] = lhs;
 SubExprs[RHS] = rhs;
-assert(!isCompoundAssignmentOp() &&
-   "Use CompoundAssignOperator for compound assignments");
+BinaryOperatorBits.HasFPFeatures = FPFeatures.requiresTrailingStorage(Ctx);
+if (BinaryOperatorBits.HasFPFeatures)
+  *getTrailingFPFeatures() = FPFeatures;
 setDependence(computeDependence(this));
   }
 
@@ -3494,6 +3513,13 @@ class BinaryOperator : public Expr {
 BinaryOperatorBits.Opc = BO_Comma;
   }
 
+public:
+  static BinaryOperator *CreateEmpty(const ASTContext , bool hasFPFeatures);
+
+  static BinaryOperator *Create(const ASTContext , Expr *lhs, Expr *rhs,
+Opcode opc, QualType ResTy, ExprValueKind VK,
+ExprObjectKind OK, SourceLocation opLoc,
+FPOptions FPFeatures);
   SourceLocation getExprLoc() const { return getOperatorLoc(); }
   SourceLocation getOperatorLoc() const { return BinaryOperatorBits.OpLoc; }
   void setOperatorLoc(SourceLocation L) { BinaryOperatorBits.OpLoc = L; }
@@ -3634,42 +3660,69 @@ class BinaryOperator : public Expr {
 return const_child_range([0], [0] + END_EXPR);
   }
 
-  // Set the FP contractability status of this operator. Only meaningful for
-  // operations on floating point types.
-  void setFPFeatures(FPOptions F) {
-BinaryOperatorBits.FPFeatures = F.getInt();
+  /// Set and fetch the bit that shows whether FPFeatures needs to be
+  /// allocated in Trailing Storage
+  void setHasStoredFPFeatures(bool B) { BinaryOperatorBits.HasFPFeatures = B; }
+  bool hasStoredFPFeatures() const { return BinaryOperatorBits.HasFPFeatures; }
+
+  /// Get FPFeatures from trailing storage
+  FPOptions getStoredFPFeatures() const {
+assert(hasStoredFPFeatures());
+return *getTrailingFPFeatures();
+  }
+  /// Set FPFeatures in trailing storage, used only by Serialization
+  void 

[clang] c8dadac - add release notes for ffp-model and ffp-exception-behavior

2020-02-24 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2020-02-24T06:42:05-08:00
New Revision: c8dadac228b7dd3a71d5fc25489d1b884a2b0f5e

URL: 
https://github.com/llvm/llvm-project/commit/c8dadac228b7dd3a71d5fc25489d1b884a2b0f5e
DIFF: 
https://github.com/llvm/llvm-project/commit/c8dadac228b7dd3a71d5fc25489d1b884a2b0f5e.diff

LOG: add release notes for ffp-model and ffp-exception-behavior

Added: 


Modified: 
clang/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index ba3937dd83ed..831ef32c6b8a 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -66,6 +66,13 @@ New Compiler Flags
   attack for x86 architecture through automatic probing of each page of
   allocated stack.
 
+- -ffp-exception-behavior={ignore,maytrap,strict} allows the user to specify
+  the floating-point exception behavior.  The default setting is ``ignore``.
+
+- -ffp-model={precise,strict,fast} provides the user an umbrella option to
+  simplify access to the many single purpose floating point options. The 
default
+  setting is ``precise``.
+
 Deprecated Compiler Flags
 -
 



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] cd2c5af - Reland D74436 "Change clang option -ffp-model=precise to select ffp-contract=on""

2020-02-18 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2020-02-18T06:55:36-08:00
New Revision: cd2c5af6dfd6e32ee7043894bcb42981ce99e8ac

URL: 
https://github.com/llvm/llvm-project/commit/cd2c5af6dfd6e32ee7043894bcb42981ce99e8ac
DIFF: 
https://github.com/llvm/llvm-project/commit/cd2c5af6dfd6e32ee7043894bcb42981ce99e8ac.diff

LOG: Reland D74436 "Change clang option -ffp-model=precise to select 
ffp-contract=on""
Change clang option -ffp-model=precise, the default, to select 
ffp-contract=on
The patch caused some problems for PowerPC but ibm has made
adjustments so I am resubmitting this patch.  Additionally, Andy looked
at the performance regressions on LNT and it looks like a loop
unrolling decision that could be adjusted.

Reviewers: rjmccall, Andy Kaylor

Differential Revision: https://reviews.llvm.org/D74436

Added: 


Modified: 
clang/docs/UsersManual.rst
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/CodeGen/ppc-emmintrin.c
clang/test/CodeGen/ppc-xmmintrin.c
clang/test/Driver/fp-model.c

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 856d5e34bbcc..6c8c9f802082 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -1190,8 +1190,50 @@ installed.
 Controlling Floating Point Behavior
 ---
 
-Clang provides a number of ways to control floating point behavior. The options
-are listed below.
+Clang provides a number of ways to control floating point behavior, including
+with command line options and source pragmas. This section
+describes the various floating point semantic modes and the corresponding 
options.
+
+.. csv-table:: Floating Point Semantic Modes
+  :header: "Mode", "Values"
+  :widths: 15, 30, 30
+
+  "except_behavior", "{ignore, strict, may_trap}", "ffp-exception-behavior"
+  "fenv_access", "{off, on}", "(none)"
+  "rounding_mode", "{dynamic, tonearest, downward, upward, towardzero}", 
"frounding-math"
+  "contract", "{on, off, fast}", "ffp-contract"
+  "denormal_fp_math", "{IEEE, PreserveSign, PositiveZero}", "fdenormal-fp-math"
+  "denormal_fp32_math", "{IEEE, PreserveSign, PositiveZero}", 
"fdenormal-fp-math-fp32"
+  "support_math_errno", "{on, off}", "fmath-errno"
+  "no_honor_nans", "{on, off}", "fhonor-nans"
+  "no_honor_infinities", "{on, off}", "fhonor-infinities"
+  "no_signed_zeros", "{on, off}", "fsigned-zeros"
+  "allow_reciprocal", "{on, off}", "freciprocal-math"
+  "allow_approximate_fns", "{on, off}", "(none)"
+  "allow_reassociation", "{on, off}", "fassociative-math"
+
+
+This table describes the option settings that correspond to the three
+floating point semantic models: precise (the default), strict, and fast.
+
+
+.. csv-table:: Floating Point Models
+  :header: "Mode", "Precise", "Strict", "Fast"
+  :widths: 25, 15, 15, 15
+
+  "except_behavior", "ignore", "strict", "ignore"
+  "fenv_access", "off", "on", "off"
+  "rounding_mode", "tonearest", "dynamic", "tonearest"
+  "contract", "on", "off", "fast"
+  "denormal_fp_math", "IEEE", "IEEE", "PreserveSign"
+  "denormal_fp32_math", "IEEE","IEEE", "PreserveSign"
+  "support_math_errno", "on", "on", "off"
+  "no_honor_nans", "off", "off", "on"
+  "no_honor_infinities", "off", "off", "on"
+  "no_signed_zeros", "off", "off", "on"
+  "allow_reciprocal", "off", "off", "on"
+  "allow_approximate_fns", "off", "off", "on"
+  "allow_reassociation", "off", "off", "on"
 
 .. option:: -ffast-math
 
@@ -1385,7 +1427,7 @@ Note that floating-point operations performed as part of 
constant initialization
and ``fast``.
Details:
 
-   * ``precise`` Disables optimizations that are not value-safe on 
floating-point data, although FP contraction (FMA) is enabled 
(``-ffp-contract=fast``).  This is the default behavior.
+   * ``precise`` Disables optimizations that are not value-safe on 
floating-point data, although FP contraction (FMA) is enabled 
(``-ffp-contract=on``).  This is the default behavior.
* ``strict`` Enables ``-frounding-math`` and 
``-ffp-exception-behavior=strict``, and disables contractions (FMA).  All of 
the ``-ffast-math`` enablements are disabled.
* ``fast`` Behaves identically to specifying both ``-ffast-math`` and 
``ffp-contract=fast``
 

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 2585a5fa05da..d1197556aeef 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2525,10 +2525,9 @@ static void RenderFloatingPointOptions(const ToolChain 
, const Driver ,
 
   llvm::DenormalMode DenormalFPMath = DefaultDenormalFPMath;
   llvm::DenormalMode DenormalFP32Math = DefaultDenormalFP32Math;
-  StringRef FPContract = "";
+  StringRef FPContract = "on";
   bool StrictFPModel = false;
 
-
   if (const Arg *A = Args.getLastArg(options::OPT_flimited_precision_EQ)) {
 CmdArgs.push_back("-mlimit-float-precision");
 

[clang] 9122b92 - Revert "Reland D74436 "Change clang option -ffp-model=precise to select ffp-contract=on""

2020-02-14 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2020-02-14T07:32:09-08:00
New Revision: 9122b92f8e046bfeabdc503d978cf098c86f6e49

URL: 
https://github.com/llvm/llvm-project/commit/9122b92f8e046bfeabdc503d978cf098c86f6e49
DIFF: 
https://github.com/llvm/llvm-project/commit/9122b92f8e046bfeabdc503d978cf098c86f6e49.diff

LOG: Revert "Reland D74436 "Change clang option -ffp-model=precise to select 
ffp-contract=on""

This reverts commit 0a1123eb43f945593b26dd037490e0c909fa3c4f.
Want to revert this because it's causing trouble for PowerPC
I also fixed test fp-model.c which was looking for an incorrect error message

Added: 


Modified: 
clang/docs/UsersManual.rst
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/CodeGen/ppc-emmintrin.c
clang/test/CodeGen/ppc-xmmintrin.c
clang/test/Driver/fp-model.c

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 6c8c9f802082..856d5e34bbcc 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -1190,50 +1190,8 @@ installed.
 Controlling Floating Point Behavior
 ---
 
-Clang provides a number of ways to control floating point behavior, including
-with command line options and source pragmas. This section
-describes the various floating point semantic modes and the corresponding 
options.
-
-.. csv-table:: Floating Point Semantic Modes
-  :header: "Mode", "Values"
-  :widths: 15, 30, 30
-
-  "except_behavior", "{ignore, strict, may_trap}", "ffp-exception-behavior"
-  "fenv_access", "{off, on}", "(none)"
-  "rounding_mode", "{dynamic, tonearest, downward, upward, towardzero}", 
"frounding-math"
-  "contract", "{on, off, fast}", "ffp-contract"
-  "denormal_fp_math", "{IEEE, PreserveSign, PositiveZero}", "fdenormal-fp-math"
-  "denormal_fp32_math", "{IEEE, PreserveSign, PositiveZero}", 
"fdenormal-fp-math-fp32"
-  "support_math_errno", "{on, off}", "fmath-errno"
-  "no_honor_nans", "{on, off}", "fhonor-nans"
-  "no_honor_infinities", "{on, off}", "fhonor-infinities"
-  "no_signed_zeros", "{on, off}", "fsigned-zeros"
-  "allow_reciprocal", "{on, off}", "freciprocal-math"
-  "allow_approximate_fns", "{on, off}", "(none)"
-  "allow_reassociation", "{on, off}", "fassociative-math"
-
-
-This table describes the option settings that correspond to the three
-floating point semantic models: precise (the default), strict, and fast.
-
-
-.. csv-table:: Floating Point Models
-  :header: "Mode", "Precise", "Strict", "Fast"
-  :widths: 25, 15, 15, 15
-
-  "except_behavior", "ignore", "strict", "ignore"
-  "fenv_access", "off", "on", "off"
-  "rounding_mode", "tonearest", "dynamic", "tonearest"
-  "contract", "on", "off", "fast"
-  "denormal_fp_math", "IEEE", "IEEE", "PreserveSign"
-  "denormal_fp32_math", "IEEE","IEEE", "PreserveSign"
-  "support_math_errno", "on", "on", "off"
-  "no_honor_nans", "off", "off", "on"
-  "no_honor_infinities", "off", "off", "on"
-  "no_signed_zeros", "off", "off", "on"
-  "allow_reciprocal", "off", "off", "on"
-  "allow_approximate_fns", "off", "off", "on"
-  "allow_reassociation", "off", "off", "on"
+Clang provides a number of ways to control floating point behavior. The options
+are listed below.
 
 .. option:: -ffast-math
 
@@ -1427,7 +1385,7 @@ Note that floating-point operations performed as part of 
constant initialization
and ``fast``.
Details:
 
-   * ``precise`` Disables optimizations that are not value-safe on 
floating-point data, although FP contraction (FMA) is enabled 
(``-ffp-contract=on``).  This is the default behavior.
+   * ``precise`` Disables optimizations that are not value-safe on 
floating-point data, although FP contraction (FMA) is enabled 
(``-ffp-contract=fast``).  This is the default behavior.
* ``strict`` Enables ``-frounding-math`` and 
``-ffp-exception-behavior=strict``, and disables contractions (FMA).  All of 
the ``-ffast-math`` enablements are disabled.
* ``fast`` Behaves identically to specifying both ``-ffast-math`` and 
``ffp-contract=fast``
 

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index d1197556aeef..2585a5fa05da 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2525,9 +2525,10 @@ static void RenderFloatingPointOptions(const ToolChain 
, const Driver ,
 
   llvm::DenormalMode DenormalFPMath = DefaultDenormalFPMath;
   llvm::DenormalMode DenormalFP32Math = DefaultDenormalFP32Math;
-  StringRef FPContract = "on";
+  StringRef FPContract = "";
   bool StrictFPModel = false;
 
+
   if (const Arg *A = Args.getLastArg(options::OPT_flimited_precision_EQ)) {
 CmdArgs.push_back("-mlimit-float-precision");
 CmdArgs.push_back(A->getValue());
@@ -2550,6 +2551,7 @@ static void RenderFloatingPointOptions(const ToolChain 
, const Driver ,
   SignedZeros = true;
   // -fno_fast_math restores default denormal and fpcontract 

[clang] 88ec01c - Revert "Revert "Revert "Change clang option -ffp-model=precise to select ffp-contract=on"""

2020-02-13 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2020-02-13T15:06:12-08:00
New Revision: 88ec01ca1bfa4c3a29225db93d36e6d32278190d

URL: 
https://github.com/llvm/llvm-project/commit/88ec01ca1bfa4c3a29225db93d36e6d32278190d
DIFF: 
https://github.com/llvm/llvm-project/commit/88ec01ca1bfa4c3a29225db93d36e6d32278190d.diff

LOG: Revert "Revert "Revert "Change clang option -ffp-model=precise to select 
ffp-contract=on"""

This reverts commit abd09053bc7aa6144873c196a7d50aa6ce6ca430.
It's causing internal buildbot fails on ppc

Conflicts:
clang/lib/Driver/ToolChains/Clang.cpp

Added: 


Modified: 
clang/docs/UsersManual.rst
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/CodeGen/ppc-emmintrin.c
clang/test/CodeGen/ppc-xmmintrin.c
clang/test/Driver/fp-model.c

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 6c8c9f802082..856d5e34bbcc 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -1190,50 +1190,8 @@ installed.
 Controlling Floating Point Behavior
 ---
 
-Clang provides a number of ways to control floating point behavior, including
-with command line options and source pragmas. This section
-describes the various floating point semantic modes and the corresponding 
options.
-
-.. csv-table:: Floating Point Semantic Modes
-  :header: "Mode", "Values"
-  :widths: 15, 30, 30
-
-  "except_behavior", "{ignore, strict, may_trap}", "ffp-exception-behavior"
-  "fenv_access", "{off, on}", "(none)"
-  "rounding_mode", "{dynamic, tonearest, downward, upward, towardzero}", 
"frounding-math"
-  "contract", "{on, off, fast}", "ffp-contract"
-  "denormal_fp_math", "{IEEE, PreserveSign, PositiveZero}", "fdenormal-fp-math"
-  "denormal_fp32_math", "{IEEE, PreserveSign, PositiveZero}", 
"fdenormal-fp-math-fp32"
-  "support_math_errno", "{on, off}", "fmath-errno"
-  "no_honor_nans", "{on, off}", "fhonor-nans"
-  "no_honor_infinities", "{on, off}", "fhonor-infinities"
-  "no_signed_zeros", "{on, off}", "fsigned-zeros"
-  "allow_reciprocal", "{on, off}", "freciprocal-math"
-  "allow_approximate_fns", "{on, off}", "(none)"
-  "allow_reassociation", "{on, off}", "fassociative-math"
-
-
-This table describes the option settings that correspond to the three
-floating point semantic models: precise (the default), strict, and fast.
-
-
-.. csv-table:: Floating Point Models
-  :header: "Mode", "Precise", "Strict", "Fast"
-  :widths: 25, 15, 15, 15
-
-  "except_behavior", "ignore", "strict", "ignore"
-  "fenv_access", "off", "on", "off"
-  "rounding_mode", "tonearest", "dynamic", "tonearest"
-  "contract", "on", "off", "fast"
-  "denormal_fp_math", "IEEE", "IEEE", "PreserveSign"
-  "denormal_fp32_math", "IEEE","IEEE", "PreserveSign"
-  "support_math_errno", "on", "on", "off"
-  "no_honor_nans", "off", "off", "on"
-  "no_honor_infinities", "off", "off", "on"
-  "no_signed_zeros", "off", "off", "on"
-  "allow_reciprocal", "off", "off", "on"
-  "allow_approximate_fns", "off", "off", "on"
-  "allow_reassociation", "off", "off", "on"
+Clang provides a number of ways to control floating point behavior. The options
+are listed below.
 
 .. option:: -ffast-math
 
@@ -1427,7 +1385,7 @@ Note that floating-point operations performed as part of 
constant initialization
and ``fast``.
Details:
 
-   * ``precise`` Disables optimizations that are not value-safe on 
floating-point data, although FP contraction (FMA) is enabled 
(``-ffp-contract=on``).  This is the default behavior.
+   * ``precise`` Disables optimizations that are not value-safe on 
floating-point data, although FP contraction (FMA) is enabled 
(``-ffp-contract=fast``).  This is the default behavior.
* ``strict`` Enables ``-frounding-math`` and 
``-ffp-exception-behavior=strict``, and disables contractions (FMA).  All of 
the ``-ffast-math`` enablements are disabled.
* ``fast`` Behaves identically to specifying both ``-ffast-math`` and 
``ffp-contract=fast``
 

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index d1197556aeef..5a207f3ca9f7 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2525,9 +2525,10 @@ static void RenderFloatingPointOptions(const ToolChain 
, const Driver ,
 
   llvm::DenormalMode DenormalFPMath = DefaultDenormalFPMath;
   llvm::DenormalMode DenormalFP32Math = DefaultDenormalFP32Math;
-  StringRef FPContract = "on";
+  StringRef FPContract = "";
   bool StrictFPModel = false;
 
+
   if (const Arg *A = Args.getLastArg(options::OPT_flimited_precision_EQ)) {
 CmdArgs.push_back("-mlimit-float-precision");
 CmdArgs.push_back(A->getValue());
@@ -2550,6 +2551,7 @@ static void RenderFloatingPointOptions(const ToolChain 
, const Driver ,
   SignedZeros = true;
   // -fno_fast_math restores default denormal and fpcontract handling
   DenormalFPMath = 

[clang] abd0905 - Revert "Revert "Change clang option -ffp-model=precise to select ffp-contract=on""

2020-02-12 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2020-02-12T07:30:43-08:00
New Revision: abd09053bc7aa6144873c196a7d50aa6ce6ca430

URL: 
https://github.com/llvm/llvm-project/commit/abd09053bc7aa6144873c196a7d50aa6ce6ca430
DIFF: 
https://github.com/llvm/llvm-project/commit/abd09053bc7aa6144873c196a7d50aa6ce6ca430.diff

LOG: Revert "Revert "Change clang option -ffp-model=precise to select 
ffp-contract=on""

This reverts commit 99c5bcbce89f07e68ccd89891a0300346705d013.
Change clang option -ffp-model=precise to select ffp-contract=on
Including some small touch-ups to the original commit

Reviewers: rjmccall, Andy Kaylor

Differential Revision: https://reviews.llvm.org/D74436

Added: 


Modified: 
clang/docs/UsersManual.rst
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/CodeGen/ppc-emmintrin.c
clang/test/CodeGen/ppc-xmmintrin.c
clang/test/Driver/fp-model.c

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 856d5e34bbcc..6c8c9f802082 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -1190,8 +1190,50 @@ installed.
 Controlling Floating Point Behavior
 ---
 
-Clang provides a number of ways to control floating point behavior. The options
-are listed below.
+Clang provides a number of ways to control floating point behavior, including
+with command line options and source pragmas. This section
+describes the various floating point semantic modes and the corresponding 
options.
+
+.. csv-table:: Floating Point Semantic Modes
+  :header: "Mode", "Values"
+  :widths: 15, 30, 30
+
+  "except_behavior", "{ignore, strict, may_trap}", "ffp-exception-behavior"
+  "fenv_access", "{off, on}", "(none)"
+  "rounding_mode", "{dynamic, tonearest, downward, upward, towardzero}", 
"frounding-math"
+  "contract", "{on, off, fast}", "ffp-contract"
+  "denormal_fp_math", "{IEEE, PreserveSign, PositiveZero}", "fdenormal-fp-math"
+  "denormal_fp32_math", "{IEEE, PreserveSign, PositiveZero}", 
"fdenormal-fp-math-fp32"
+  "support_math_errno", "{on, off}", "fmath-errno"
+  "no_honor_nans", "{on, off}", "fhonor-nans"
+  "no_honor_infinities", "{on, off}", "fhonor-infinities"
+  "no_signed_zeros", "{on, off}", "fsigned-zeros"
+  "allow_reciprocal", "{on, off}", "freciprocal-math"
+  "allow_approximate_fns", "{on, off}", "(none)"
+  "allow_reassociation", "{on, off}", "fassociative-math"
+
+
+This table describes the option settings that correspond to the three
+floating point semantic models: precise (the default), strict, and fast.
+
+
+.. csv-table:: Floating Point Models
+  :header: "Mode", "Precise", "Strict", "Fast"
+  :widths: 25, 15, 15, 15
+
+  "except_behavior", "ignore", "strict", "ignore"
+  "fenv_access", "off", "on", "off"
+  "rounding_mode", "tonearest", "dynamic", "tonearest"
+  "contract", "on", "off", "fast"
+  "denormal_fp_math", "IEEE", "IEEE", "PreserveSign"
+  "denormal_fp32_math", "IEEE","IEEE", "PreserveSign"
+  "support_math_errno", "on", "on", "off"
+  "no_honor_nans", "off", "off", "on"
+  "no_honor_infinities", "off", "off", "on"
+  "no_signed_zeros", "off", "off", "on"
+  "allow_reciprocal", "off", "off", "on"
+  "allow_approximate_fns", "off", "off", "on"
+  "allow_reassociation", "off", "off", "on"
 
 .. option:: -ffast-math
 
@@ -1385,7 +1427,7 @@ Note that floating-point operations performed as part of 
constant initialization
and ``fast``.
Details:
 
-   * ``precise`` Disables optimizations that are not value-safe on 
floating-point data, although FP contraction (FMA) is enabled 
(``-ffp-contract=fast``).  This is the default behavior.
+   * ``precise`` Disables optimizations that are not value-safe on 
floating-point data, although FP contraction (FMA) is enabled 
(``-ffp-contract=on``).  This is the default behavior.
* ``strict`` Enables ``-frounding-math`` and 
``-ffp-exception-behavior=strict``, and disables contractions (FMA).  All of 
the ``-ffast-math`` enablements are disabled.
* ``fast`` Behaves identically to specifying both ``-ffast-math`` and 
``ffp-contract=fast``
 

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 4424d8e6f72c..a11a5423b0b9 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2525,10 +2525,9 @@ static void RenderFloatingPointOptions(const ToolChain 
, const Driver ,
 
   llvm::DenormalMode DenormalFPMath = DefaultDenormalFPMath;
   llvm::DenormalMode DenormalFP32Math = DefaultDenormalFP32Math;
-  StringRef FPContract = "";
+  StringRef FPContract = "on";
   bool StrictFPModel = false;
 
-
   if (const Arg *A = Args.getLastArg(options::OPT_flimited_precision_EQ)) {
 CmdArgs.push_back("-mlimit-float-precision");
 CmdArgs.push_back(A->getValue());
@@ -2551,7 +2550,6 @@ static void RenderFloatingPointOptions(const ToolChain 
, const Driver ,
   SignedZeros = true;
   

[clang] 99c5bcb - Revert "Change clang option -ffp-model=precise to select ffp-contract=on"

2020-02-11 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2020-02-11T14:20:00-08:00
New Revision: 99c5bcbce89f07e68ccd89891a0300346705d013

URL: 
https://github.com/llvm/llvm-project/commit/99c5bcbce89f07e68ccd89891a0300346705d013
DIFF: 
https://github.com/llvm/llvm-project/commit/99c5bcbce89f07e68ccd89891a0300346705d013.diff

LOG: Revert "Change clang option -ffp-model=precise to select ffp-contract=on"

This reverts commit 3fcdf2fa945aca5849c5587c55de4186c7d81b8a.
Sorry I was too hasty with my commit, I will review Andy's comments
and resubmit.

Added: 


Modified: 
clang/docs/UsersManual.rst
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/CodeGen/ppc-emmintrin.c
clang/test/CodeGen/ppc-xmmintrin.c
clang/test/Driver/fp-model.c

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 6c8c9f802082..856d5e34bbcc 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -1190,50 +1190,8 @@ installed.
 Controlling Floating Point Behavior
 ---
 
-Clang provides a number of ways to control floating point behavior, including
-with command line options and source pragmas. This section
-describes the various floating point semantic modes and the corresponding 
options.
-
-.. csv-table:: Floating Point Semantic Modes
-  :header: "Mode", "Values"
-  :widths: 15, 30, 30
-
-  "except_behavior", "{ignore, strict, may_trap}", "ffp-exception-behavior"
-  "fenv_access", "{off, on}", "(none)"
-  "rounding_mode", "{dynamic, tonearest, downward, upward, towardzero}", 
"frounding-math"
-  "contract", "{on, off, fast}", "ffp-contract"
-  "denormal_fp_math", "{IEEE, PreserveSign, PositiveZero}", "fdenormal-fp-math"
-  "denormal_fp32_math", "{IEEE, PreserveSign, PositiveZero}", 
"fdenormal-fp-math-fp32"
-  "support_math_errno", "{on, off}", "fmath-errno"
-  "no_honor_nans", "{on, off}", "fhonor-nans"
-  "no_honor_infinities", "{on, off}", "fhonor-infinities"
-  "no_signed_zeros", "{on, off}", "fsigned-zeros"
-  "allow_reciprocal", "{on, off}", "freciprocal-math"
-  "allow_approximate_fns", "{on, off}", "(none)"
-  "allow_reassociation", "{on, off}", "fassociative-math"
-
-
-This table describes the option settings that correspond to the three
-floating point semantic models: precise (the default), strict, and fast.
-
-
-.. csv-table:: Floating Point Models
-  :header: "Mode", "Precise", "Strict", "Fast"
-  :widths: 25, 15, 15, 15
-
-  "except_behavior", "ignore", "strict", "ignore"
-  "fenv_access", "off", "on", "off"
-  "rounding_mode", "tonearest", "dynamic", "tonearest"
-  "contract", "on", "off", "fast"
-  "denormal_fp_math", "IEEE", "IEEE", "PreserveSign"
-  "denormal_fp32_math", "IEEE","IEEE", "PreserveSign"
-  "support_math_errno", "on", "on", "off"
-  "no_honor_nans", "off", "off", "on"
-  "no_honor_infinities", "off", "off", "on"
-  "no_signed_zeros", "off", "off", "on"
-  "allow_reciprocal", "off", "off", "on"
-  "allow_approximate_fns", "off", "off", "on"
-  "allow_reassociation", "off", "off", "on"
+Clang provides a number of ways to control floating point behavior. The options
+are listed below.
 
 .. option:: -ffast-math
 
@@ -1427,7 +1385,7 @@ Note that floating-point operations performed as part of 
constant initialization
and ``fast``.
Details:
 
-   * ``precise`` Disables optimizations that are not value-safe on 
floating-point data, although FP contraction (FMA) is enabled 
(``-ffp-contract=on``).  This is the default behavior.
+   * ``precise`` Disables optimizations that are not value-safe on 
floating-point data, although FP contraction (FMA) is enabled 
(``-ffp-contract=fast``).  This is the default behavior.
* ``strict`` Enables ``-frounding-math`` and 
``-ffp-exception-behavior=strict``, and disables contractions (FMA).  All of 
the ``-ffast-math`` enablements are disabled.
* ``fast`` Behaves identically to specifying both ``-ffast-math`` and 
``ffp-contract=fast``
 

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index c70659bf1485..7901f8a48f5f 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2520,9 +2520,10 @@ static void RenderFloatingPointOptions(const ToolChain 
, const Driver ,
 
   llvm::DenormalMode DenormalFPMath = DefaultDenormalFPMath;
   llvm::DenormalMode DenormalFP32Math = DefaultDenormalFP32Math;
-  StringRef FPContract = "on";
+  StringRef FPContract = "";
   bool StrictFPModel = false;
 
+
   if (const Arg *A = Args.getLastArg(options::OPT_flimited_precision_EQ)) {
 CmdArgs.push_back("-mlimit-float-precision");
 CmdArgs.push_back(A->getValue());
@@ -2559,10 +2560,12 @@ static void RenderFloatingPointOptions(const ToolChain 
, const Driver ,
   // ffp-model= is a Driver option, it is entirely rewritten into more
   // granular options before being passed into cc1.
   // Use the gcc option in the 

[clang] 3fcdf2f - Change clang option -ffp-model=precise to select ffp-contract=on

2020-02-11 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2020-02-11T14:07:10-08:00
New Revision: 3fcdf2fa945aca5849c5587c55de4186c7d81b8a

URL: 
https://github.com/llvm/llvm-project/commit/3fcdf2fa945aca5849c5587c55de4186c7d81b8a
DIFF: 
https://github.com/llvm/llvm-project/commit/3fcdf2fa945aca5849c5587c55de4186c7d81b8a.diff

LOG: Change clang option -ffp-model=precise to select ffp-contract=on

Reviewers: rjmccall

Differential Revision: https://reviews.llvm.org/D74436

Added: 


Modified: 
clang/docs/UsersManual.rst
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/CodeGen/ppc-emmintrin.c
clang/test/CodeGen/ppc-xmmintrin.c
clang/test/Driver/fp-model.c

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 856d5e34bbcc..6c8c9f802082 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -1190,8 +1190,50 @@ installed.
 Controlling Floating Point Behavior
 ---
 
-Clang provides a number of ways to control floating point behavior. The options
-are listed below.
+Clang provides a number of ways to control floating point behavior, including
+with command line options and source pragmas. This section
+describes the various floating point semantic modes and the corresponding 
options.
+
+.. csv-table:: Floating Point Semantic Modes
+  :header: "Mode", "Values"
+  :widths: 15, 30, 30
+
+  "except_behavior", "{ignore, strict, may_trap}", "ffp-exception-behavior"
+  "fenv_access", "{off, on}", "(none)"
+  "rounding_mode", "{dynamic, tonearest, downward, upward, towardzero}", 
"frounding-math"
+  "contract", "{on, off, fast}", "ffp-contract"
+  "denormal_fp_math", "{IEEE, PreserveSign, PositiveZero}", "fdenormal-fp-math"
+  "denormal_fp32_math", "{IEEE, PreserveSign, PositiveZero}", 
"fdenormal-fp-math-fp32"
+  "support_math_errno", "{on, off}", "fmath-errno"
+  "no_honor_nans", "{on, off}", "fhonor-nans"
+  "no_honor_infinities", "{on, off}", "fhonor-infinities"
+  "no_signed_zeros", "{on, off}", "fsigned-zeros"
+  "allow_reciprocal", "{on, off}", "freciprocal-math"
+  "allow_approximate_fns", "{on, off}", "(none)"
+  "allow_reassociation", "{on, off}", "fassociative-math"
+
+
+This table describes the option settings that correspond to the three
+floating point semantic models: precise (the default), strict, and fast.
+
+
+.. csv-table:: Floating Point Models
+  :header: "Mode", "Precise", "Strict", "Fast"
+  :widths: 25, 15, 15, 15
+
+  "except_behavior", "ignore", "strict", "ignore"
+  "fenv_access", "off", "on", "off"
+  "rounding_mode", "tonearest", "dynamic", "tonearest"
+  "contract", "on", "off", "fast"
+  "denormal_fp_math", "IEEE", "IEEE", "PreserveSign"
+  "denormal_fp32_math", "IEEE","IEEE", "PreserveSign"
+  "support_math_errno", "on", "on", "off"
+  "no_honor_nans", "off", "off", "on"
+  "no_honor_infinities", "off", "off", "on"
+  "no_signed_zeros", "off", "off", "on"
+  "allow_reciprocal", "off", "off", "on"
+  "allow_approximate_fns", "off", "off", "on"
+  "allow_reassociation", "off", "off", "on"
 
 .. option:: -ffast-math
 
@@ -1385,7 +1427,7 @@ Note that floating-point operations performed as part of 
constant initialization
and ``fast``.
Details:
 
-   * ``precise`` Disables optimizations that are not value-safe on 
floating-point data, although FP contraction (FMA) is enabled 
(``-ffp-contract=fast``).  This is the default behavior.
+   * ``precise`` Disables optimizations that are not value-safe on 
floating-point data, although FP contraction (FMA) is enabled 
(``-ffp-contract=on``).  This is the default behavior.
* ``strict`` Enables ``-frounding-math`` and 
``-ffp-exception-behavior=strict``, and disables contractions (FMA).  All of 
the ``-ffast-math`` enablements are disabled.
* ``fast`` Behaves identically to specifying both ``-ffast-math`` and 
``ffp-contract=fast``
 

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 7901f8a48f5f..c70659bf1485 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2520,10 +2520,9 @@ static void RenderFloatingPointOptions(const ToolChain 
, const Driver ,
 
   llvm::DenormalMode DenormalFPMath = DefaultDenormalFPMath;
   llvm::DenormalMode DenormalFP32Math = DefaultDenormalFP32Math;
-  StringRef FPContract = "";
+  StringRef FPContract = "on";
   bool StrictFPModel = false;
 
-
   if (const Arg *A = Args.getLastArg(options::OPT_flimited_precision_EQ)) {
 CmdArgs.push_back("-mlimit-float-precision");
 CmdArgs.push_back(A->getValue());
@@ -2560,12 +2559,10 @@ static void RenderFloatingPointOptions(const ToolChain 
, const Driver ,
   // ffp-model= is a Driver option, it is entirely rewritten into more
   // granular options before being passed into cc1.
   // Use the gcc option in the switch below.
-  if (!FPModel.empty() && !FPModel.equals(Val)) {
+  

[clang] 7f9b513 - Reapply af57dbf12e54 "Add support for options -frounding-math, ftrapping-math, -ffp-model=, and -ffp-exception-behavior="

2019-12-05 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2019-12-05T03:48:04-08:00
New Revision: 7f9b5138470db1dc58f3bc05631284c653c9ed7a

URL: 
https://github.com/llvm/llvm-project/commit/7f9b5138470db1dc58f3bc05631284c653c9ed7a
DIFF: 
https://github.com/llvm/llvm-project/commit/7f9b5138470db1dc58f3bc05631284c653c9ed7a.diff

LOG: Reapply af57dbf12e54 "Add support for options -frounding-math, 
ftrapping-math, -ffp-model=, and -ffp-exception-behavior="

Patch was reverted because https://bugs.llvm.org/show_bug.cgi?id=44048
The original patch is modified to set the strictfp IR attribute
explicitly in CodeGen instead of as a side effect of IRBuilder.
In the 2nd attempt to reapply there was a windows lit test fail, the
tests were fixed to use wildcard matching.

Differential Revision: https://reviews.llvm.org/D62731

Added: 
clang/test/CodeGen/fpconstrained.c
clang/test/CodeGen/fpconstrained.cpp
clang/test/Driver/fp-model.c

Modified: 
clang/docs/UsersManual.rst
clang/include/clang/AST/Decl.h
clang/include/clang/AST/DeclBase.h
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Basic/LangOptions.h
clang/include/clang/Driver/Options.td
clang/lib/AST/Decl.cpp
clang/lib/CodeGen/CGCall.cpp
clang/lib/CodeGen/CodeGenFunction.cpp
clang/lib/CodeGen/CodeGenFunction.h
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Serialization/ASTReaderDecl.cpp
clang/lib/Serialization/ASTWriterDecl.cpp
clang/test/Driver/clang_f_opts.c
clang/test/Driver/fast-math.c
llvm/include/llvm/IR/IRBuilder.h
llvm/include/llvm/Target/TargetOptions.h
llvm/unittests/IR/IRBuilderTest.cpp

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 714681d7f4ce..62e2575c6b26 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -1231,10 +1231,10 @@ are listed below.
 
 **-f[no-]trapping-math**
 
-   ``-fno-trapping-math`` allows optimizations that assume that
-   floating point operations cannot generate traps such as divide-by-zero,
-   overflow and underflow. Defaults to ``-ftrapping-math``.
-   Currently this option has no effect.
+   Control floating point exception behavior. ``-fno-trapping-math`` allows 
optimizations that assume that floating point operations cannot generate traps 
such as divide-by-zero, overflow and underflow.
+
+- The option ``-ftrapping-math`` behaves identically to 
``-ffp-exception-behavior=strict``.
+- The option ``-fno-trapping-math`` behaves identically to 
``-ffp-exception-behavior=ignore``.   This is the default.
 
 .. option:: -ffp-contract=
 
@@ -1319,6 +1319,52 @@ are listed below.
 
Defaults to ``-fno-finite-math``.
 
+.. _opt_frounding-math:
+
+**-f[no-]rounding-math**
+
+Force floating-point operations to honor the dynamically-set rounding mode by 
default.
+
+The result of a floating-point operation often cannot be exactly represented 
in the result type and therefore must be rounded.  IEEE 754 describes 
diff erent rounding modes that control how to perform this rounding, not all of 
which are supported by all implementations.  C provides interfaces 
(``fesetround`` and ``fesetenv``) for dynamically controlling the rounding 
mode, and while it also recommends certain conventions for changing the 
rounding mode, these conventions are not typically enforced in the ABI.  Since 
the rounding mode changes the numerical result of operations, the compiler must 
understand something about it in order to optimize floating point operations.
+
+Note that floating-point operations performed as part of constant 
initialization are formally performed prior to the start of the program and are 
therefore not subject to the current rounding mode.  This includes the 
initialization of global variables and local ``static`` variables.  
Floating-point operations in these contexts will be rounded using 
``FE_TONEAREST``.
+
+- The option ``-fno-rounding-math`` allows the compiler to assume that the 
rounding mode is set to ``FE_TONEAREST``.  This is the default.
+- The option ``-frounding-math`` forces the compiler to honor the 
dynamically-set rounding mode.  This prevents optimizations which might affect 
results if the rounding mode changes or is 
diff erent from the default; for example, it prevents floating-point operations 
from being reordered across most calls and prevents constant-folding when the 
result is not exactly representable.
+
+.. option:: -ffp-model=
+
+   Specify floating point behavior. ``-ffp-model`` is an umbrella
+   option that encompasses functionality provided by other, single
+   purpose, floating point options.  Valid values are: ``precise``, ``strict``,
+   and 

[clang] 5412913 - Revert " Reapply af57dbf12e54 "Add support for options -frounding-math, ftrapping-math, -ffp-model=, and -ffp-exception-behavior=""

2019-12-04 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2019-12-04T12:21:23-08:00
New Revision: 5412913631feef74f7d52c092e947227c1cc7b04

URL: 
https://github.com/llvm/llvm-project/commit/5412913631feef74f7d52c092e947227c1cc7b04
DIFF: 
https://github.com/llvm/llvm-project/commit/5412913631feef74f7d52c092e947227c1cc7b04.diff

LOG: Revert "Reapply af57dbf12e54 "Add support for options 
-frounding-math, ftrapping-math, -ffp-model=, and -ffp-exception-behavior=""

This reverts commit cdbed2dd856c14687efd741c2d8321686102acb8.
Build break on Windows (lit fail)

Added: 


Modified: 
clang/docs/UsersManual.rst
clang/include/clang/AST/Decl.h
clang/include/clang/AST/DeclBase.h
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Basic/LangOptions.h
clang/include/clang/Driver/Options.td
clang/lib/AST/Decl.cpp
clang/lib/CodeGen/CGCall.cpp
clang/lib/CodeGen/CodeGenFunction.cpp
clang/lib/CodeGen/CodeGenFunction.h
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Serialization/ASTReaderDecl.cpp
clang/lib/Serialization/ASTWriterDecl.cpp
clang/test/Driver/clang_f_opts.c
clang/test/Driver/fast-math.c
llvm/include/llvm/IR/IRBuilder.h
llvm/include/llvm/Target/TargetOptions.h
llvm/unittests/IR/IRBuilderTest.cpp

Removed: 
clang/test/CodeGen/fpconstrained.c
clang/test/CodeGen/fpconstrained.cpp
clang/test/Driver/fp-model.c



diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 62e2575c6b26..714681d7f4ce 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -1231,10 +1231,10 @@ are listed below.
 
 **-f[no-]trapping-math**
 
-   Control floating point exception behavior. ``-fno-trapping-math`` allows 
optimizations that assume that floating point operations cannot generate traps 
such as divide-by-zero, overflow and underflow.
-
-- The option ``-ftrapping-math`` behaves identically to 
``-ffp-exception-behavior=strict``.
-- The option ``-fno-trapping-math`` behaves identically to 
``-ffp-exception-behavior=ignore``.   This is the default.
+   ``-fno-trapping-math`` allows optimizations that assume that
+   floating point operations cannot generate traps such as divide-by-zero,
+   overflow and underflow. Defaults to ``-ftrapping-math``.
+   Currently this option has no effect.
 
 .. option:: -ffp-contract=
 
@@ -1319,52 +1319,6 @@ are listed below.
 
Defaults to ``-fno-finite-math``.
 
-.. _opt_frounding-math:
-
-**-f[no-]rounding-math**
-
-Force floating-point operations to honor the dynamically-set rounding mode by 
default.
-
-The result of a floating-point operation often cannot be exactly represented 
in the result type and therefore must be rounded.  IEEE 754 describes 
diff erent rounding modes that control how to perform this rounding, not all of 
which are supported by all implementations.  C provides interfaces 
(``fesetround`` and ``fesetenv``) for dynamically controlling the rounding 
mode, and while it also recommends certain conventions for changing the 
rounding mode, these conventions are not typically enforced in the ABI.  Since 
the rounding mode changes the numerical result of operations, the compiler must 
understand something about it in order to optimize floating point operations.
-
-Note that floating-point operations performed as part of constant 
initialization are formally performed prior to the start of the program and are 
therefore not subject to the current rounding mode.  This includes the 
initialization of global variables and local ``static`` variables.  
Floating-point operations in these contexts will be rounded using 
``FE_TONEAREST``.
-
-- The option ``-fno-rounding-math`` allows the compiler to assume that the 
rounding mode is set to ``FE_TONEAREST``.  This is the default.
-- The option ``-frounding-math`` forces the compiler to honor the 
dynamically-set rounding mode.  This prevents optimizations which might affect 
results if the rounding mode changes or is 
diff erent from the default; for example, it prevents floating-point operations 
from being reordered across most calls and prevents constant-folding when the 
result is not exactly representable.
-
-.. option:: -ffp-model=
-
-   Specify floating point behavior. ``-ffp-model`` is an umbrella
-   option that encompasses functionality provided by other, single
-   purpose, floating point options.  Valid values are: ``precise``, ``strict``,
-   and ``fast``.
-   Details:
-
-   * ``precise`` Disables optimizations that are not value-safe on 
floating-point data, although FP contraction (FMA) is enabled 
(``-ffp-contract=fast``).  This is the default behavior.
-   * ``strict`` Enables ``-frounding-math`` and 
``-ffp-exception-behavior=strict``, and 

[clang] cdbed2d - Reapply af57dbf12e54 "Add support for options -frounding-math, ftrapping-math, -ffp-model=, and -ffp-exception-behavior="

2019-12-04 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2019-12-04T11:32:33-08:00
New Revision: cdbed2dd856c14687efd741c2d8321686102acb8

URL: 
https://github.com/llvm/llvm-project/commit/cdbed2dd856c14687efd741c2d8321686102acb8
DIFF: 
https://github.com/llvm/llvm-project/commit/cdbed2dd856c14687efd741c2d8321686102acb8.diff

LOG: Reapply af57dbf12e54 "Add support for options -frounding-math, 
ftrapping-math, -ffp-model=, and -ffp-exception-behavior="

Patch was reverted because https://bugs.llvm.org/show_bug.cgi?id=44048
The original patch is modified to set the strictfp IR attribute
explicitly in CodeGen instead of as a side effect of IRBuilder

Differential Revision: https://reviews.llvm.org/D62731

Added: 
clang/test/CodeGen/fpconstrained.c
clang/test/CodeGen/fpconstrained.cpp
clang/test/Driver/fp-model.c

Modified: 
clang/docs/UsersManual.rst
clang/include/clang/AST/Decl.h
clang/include/clang/AST/DeclBase.h
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Basic/LangOptions.h
clang/include/clang/Driver/Options.td
clang/lib/AST/Decl.cpp
clang/lib/CodeGen/CGCall.cpp
clang/lib/CodeGen/CodeGenFunction.cpp
clang/lib/CodeGen/CodeGenFunction.h
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Serialization/ASTReaderDecl.cpp
clang/lib/Serialization/ASTWriterDecl.cpp
clang/test/Driver/clang_f_opts.c
clang/test/Driver/fast-math.c
llvm/include/llvm/IR/IRBuilder.h
llvm/include/llvm/Target/TargetOptions.h
llvm/unittests/IR/IRBuilderTest.cpp

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 714681d7f4ce..62e2575c6b26 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -1231,10 +1231,10 @@ are listed below.
 
 **-f[no-]trapping-math**
 
-   ``-fno-trapping-math`` allows optimizations that assume that
-   floating point operations cannot generate traps such as divide-by-zero,
-   overflow and underflow. Defaults to ``-ftrapping-math``.
-   Currently this option has no effect.
+   Control floating point exception behavior. ``-fno-trapping-math`` allows 
optimizations that assume that floating point operations cannot generate traps 
such as divide-by-zero, overflow and underflow.
+
+- The option ``-ftrapping-math`` behaves identically to 
``-ffp-exception-behavior=strict``.
+- The option ``-fno-trapping-math`` behaves identically to 
``-ffp-exception-behavior=ignore``.   This is the default.
 
 .. option:: -ffp-contract=
 
@@ -1319,6 +1319,52 @@ are listed below.
 
Defaults to ``-fno-finite-math``.
 
+.. _opt_frounding-math:
+
+**-f[no-]rounding-math**
+
+Force floating-point operations to honor the dynamically-set rounding mode by 
default.
+
+The result of a floating-point operation often cannot be exactly represented 
in the result type and therefore must be rounded.  IEEE 754 describes 
diff erent rounding modes that control how to perform this rounding, not all of 
which are supported by all implementations.  C provides interfaces 
(``fesetround`` and ``fesetenv``) for dynamically controlling the rounding 
mode, and while it also recommends certain conventions for changing the 
rounding mode, these conventions are not typically enforced in the ABI.  Since 
the rounding mode changes the numerical result of operations, the compiler must 
understand something about it in order to optimize floating point operations.
+
+Note that floating-point operations performed as part of constant 
initialization are formally performed prior to the start of the program and are 
therefore not subject to the current rounding mode.  This includes the 
initialization of global variables and local ``static`` variables.  
Floating-point operations in these contexts will be rounded using 
``FE_TONEAREST``.
+
+- The option ``-fno-rounding-math`` allows the compiler to assume that the 
rounding mode is set to ``FE_TONEAREST``.  This is the default.
+- The option ``-frounding-math`` forces the compiler to honor the 
dynamically-set rounding mode.  This prevents optimizations which might affect 
results if the rounding mode changes or is 
diff erent from the default; for example, it prevents floating-point operations 
from being reordered across most calls and prevents constant-folding when the 
result is not exactly representable.
+
+.. option:: -ffp-model=
+
+   Specify floating point behavior. ``-ffp-model`` is an umbrella
+   option that encompasses functionality provided by other, single
+   purpose, floating point options.  Valid values are: ``precise``, ``strict``,
+   and ``fast``.
+   Details:
+
+   * ``precise`` Disables optimizations that are not value-safe on 
floating-point data, although FP 

[clang-tools-extra] d0b3e73 - Revert "Reapply "Fix crash on switch conditions of non-integer types in templates""

2019-11-08 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2019-11-08T14:18:15-08:00
New Revision: d0b3e73175041306474bfb1914ef565e042fb50a

URL: 
https://github.com/llvm/llvm-project/commit/d0b3e73175041306474bfb1914ef565e042fb50a
DIFF: 
https://github.com/llvm/llvm-project/commit/d0b3e73175041306474bfb1914ef565e042fb50a.diff

LOG: Revert "Reapply "Fix crash on switch conditions of non-integer types in 
templates""

This reverts commit 759948467ea3181615d44d80f74ffeb260180fd0.
There were build bot failures in clang-tidy

Added: 


Modified: 

clang-tools-extra/test/clang-tidy/checkers/bugprone-string-integer-assignment.cpp
clang-tools-extra/test/clang-tidy/checkers/misc-unused-parameters.cpp
clang/lib/AST/Expr.cpp
clang/lib/Sema/SemaChecking.cpp
clang/test/SemaCXX/constant-expression-cxx2a.cpp
clang/test/SemaTemplate/dependent-names.cpp
clang/test/SemaTemplate/enum-argument.cpp
clang/test/SemaTemplate/member-access-expr.cpp

Removed: 
clang/test/SemaTemplate/non-integral-switch-cond.cpp



diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone-string-integer-assignment.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone-string-integer-assignment.cpp
index 79d41ef77c80..18fe5ef4e5c2 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone-string-integer-assignment.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone-string-integer-assignment.cpp
@@ -103,8 +103,6 @@ struct S {
   static constexpr T t = 0x8000;
   std::string s;
   void f(char c) { s += c | static_cast(t); }
-  // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: an integer is interpreted as a 
chara
-  // CHECK-FIXES: {{^}}  void f(char c) { s += std::to_string(c | 
static_cast(t)); } 
 };
 
 template S;

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/misc-unused-parameters.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/misc-unused-parameters.cpp
index 8e546b44ab74..119eff67318e 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/misc-unused-parameters.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/misc-unused-parameters.cpp
@@ -233,7 +233,7 @@ struct a {
 template 
 class d {
   a e;
-  void f() { e.b(0); }
+  void f() { e.b(); }
 };
 }  // namespace
 }  // namespace PR38055

diff  --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index 00ba329642c8..3438c3aadc6b 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -1675,15 +1675,6 @@ MemberExpr *MemberExpr::Create(
   MemberExpr *E = new (Mem) MemberExpr(Base, IsArrow, OperatorLoc, MemberDecl,
NameInfo, T, VK, OK, NOUR);
 
-  if (FieldDecl *Field = dyn_cast(MemberDecl)) {
-DeclContext *DC = MemberDecl->getDeclContext();
-// dyn_cast_or_null is used to handle objC variables which do not
-// have a declaration context.
-CXXRecordDecl *RD = dyn_cast_or_null(DC);
-if (RD && RD->isDependentContext() && RD->isCurrentInstantiation(DC))
-  E->setTypeDependent(T->isDependentType());
-  }
-
   if (HasQualOrFound) {
 // FIXME: Wrong. We should be looking at the member declaration we found.
 if (QualifierLoc && QualifierLoc.getNestedNameSpecifier()->isDependent()) {

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 45a3a7f5b00d..8322a9bf1477 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -14682,8 +14682,6 @@ void Sema::RefersToMemberWithReducedAlignment(
   bool AnyIsPacked = false;
   do {
 QualType BaseType = ME->getBase()->getType();
-if (BaseType->isDependentType())
-  return;
 if (ME->isArrow())
   BaseType = BaseType->getPointeeType();
 RecordDecl *RD = BaseType->castAs()->getDecl();

diff  --git a/clang/test/SemaCXX/constant-expression-cxx2a.cpp 
b/clang/test/SemaCXX/constant-expression-cxx2a.cpp
index c2e443b9bec1..8db705dcdc67 100644
--- a/clang/test/SemaCXX/constant-expression-cxx2a.cpp
+++ b/clang/test/SemaCXX/constant-expression-cxx2a.cpp
@@ -18,7 +18,6 @@ namespace std {
 [[nodiscard]] void *operator new(std::size_t, std::align_val_t, const 
std::nothrow_t&) noexcept;
 [[nodiscard]] void *operator new[](std::size_t, const std::nothrow_t&) 
noexcept;
 [[nodiscard]] void *operator new[](std::size_t, std::align_val_t, const 
std::nothrow_t&) noexcept;
-[[nodiscard]] void *operator new[](std::size_t, std::align_val_t);
 void operator delete(void*, const std::nothrow_t&) noexcept;
 void operator delete(void*, std::align_val_t, const std::nothrow_t&) noexcept;
 void operator delete[](void*, const std::nothrow_t&) noexcept;
@@ -1051,7 +1050,7 @@ namespace dynamic_alloc {
 // Ensure that we don't try to evaluate these for overflow and crash. These
 // are all value-dependent expressions.
 p = new char[n];
-p = new ((std::align_val_t)n) char[n];
+p = new (n) char[n];
 p = new char(n);
   }
 }

diff  --git 

[clang] 7599484 - Reapply "Fix crash on switch conditions of non-integer types in templates"

2019-11-08 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2019-11-08T10:17:06-08:00
New Revision: 759948467ea3181615d44d80f74ffeb260180fd0

URL: 
https://github.com/llvm/llvm-project/commit/759948467ea3181615d44d80f74ffeb260180fd0
DIFF: 
https://github.com/llvm/llvm-project/commit/759948467ea3181615d44d80f74ffeb260180fd0.diff

LOG: Reapply "Fix crash on switch conditions of non-integer types in templates"

This patch reapplies commit 76945821b9cad3. The first version broke
buildbots due to clang-tidy test fails. The fails are because some
errors in templates are now diagnosed earlier (does not wait till
instantiation). I have modified the tests to add checks for these
diagnostics/prevent these diagnostics. There are no additional code
changes.

Summary of code changes:

Clang currently crashes for switch statements inside a template when the
condition is a non-integer field member because contextual implicit
conversion is skipped when parsing the condition. This conversion is
however later checked in an assert when the case statement is handled.
The conversion is skipped when parsing the condition because
the field member is set as type-dependent based on its containing class.
This patch sets the type dependency based on the field's type instead.

This patch fixes Bug 40982.

Reviewers: rnk, gribozavr2

Patch by: Elizabeth Andrews (eandrews)

Differential revision: https://reviews.llvm.org/D69950

Added: 
clang/test/SemaTemplate/non-integral-switch-cond.cpp

Modified: 

clang-tools-extra/test/clang-tidy/checkers/bugprone-string-integer-assignment.cpp
clang-tools-extra/test/clang-tidy/checkers/misc-unused-parameters.cpp
clang/lib/AST/Expr.cpp
clang/lib/Sema/SemaChecking.cpp
clang/test/SemaCXX/constant-expression-cxx2a.cpp
clang/test/SemaTemplate/dependent-names.cpp
clang/test/SemaTemplate/enum-argument.cpp
clang/test/SemaTemplate/member-access-expr.cpp

Removed: 




diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone-string-integer-assignment.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone-string-integer-assignment.cpp
index 18fe5ef4e5c2..79d41ef77c80 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone-string-integer-assignment.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone-string-integer-assignment.cpp
@@ -103,6 +103,8 @@ struct S {
   static constexpr T t = 0x8000;
   std::string s;
   void f(char c) { s += c | static_cast(t); }
+  // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: an integer is interpreted as a 
chara
+  // CHECK-FIXES: {{^}}  void f(char c) { s += std::to_string(c | 
static_cast(t)); } 
 };
 
 template S;

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/misc-unused-parameters.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/misc-unused-parameters.cpp
index 119eff67318e..8e546b44ab74 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/misc-unused-parameters.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/misc-unused-parameters.cpp
@@ -233,7 +233,7 @@ struct a {
 template 
 class d {
   a e;
-  void f() { e.b(); }
+  void f() { e.b(0); }
 };
 }  // namespace
 }  // namespace PR38055

diff  --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index 3438c3aadc6b..00ba329642c8 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -1675,6 +1675,15 @@ MemberExpr *MemberExpr::Create(
   MemberExpr *E = new (Mem) MemberExpr(Base, IsArrow, OperatorLoc, MemberDecl,
NameInfo, T, VK, OK, NOUR);
 
+  if (FieldDecl *Field = dyn_cast(MemberDecl)) {
+DeclContext *DC = MemberDecl->getDeclContext();
+// dyn_cast_or_null is used to handle objC variables which do not
+// have a declaration context.
+CXXRecordDecl *RD = dyn_cast_or_null(DC);
+if (RD && RD->isDependentContext() && RD->isCurrentInstantiation(DC))
+  E->setTypeDependent(T->isDependentType());
+  }
+
   if (HasQualOrFound) {
 // FIXME: Wrong. We should be looking at the member declaration we found.
 if (QualifierLoc && QualifierLoc.getNestedNameSpecifier()->isDependent()) {

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 8322a9bf1477..45a3a7f5b00d 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -14682,6 +14682,8 @@ void Sema::RefersToMemberWithReducedAlignment(
   bool AnyIsPacked = false;
   do {
 QualType BaseType = ME->getBase()->getType();
+if (BaseType->isDependentType())
+  return;
 if (ME->isArrow())
   BaseType = BaseType->getPointeeType();
 RecordDecl *RD = BaseType->castAs()->getDecl();

diff  --git a/clang/test/SemaCXX/constant-expression-cxx2a.cpp 
b/clang/test/SemaCXX/constant-expression-cxx2a.cpp
index 8db705dcdc67..c2e443b9bec1 100644
--- a/clang/test/SemaCXX/constant-expression-cxx2a.cpp
+++ b/clang/test/SemaCXX/constant-expression-cxx2a.cpp
@@ -18,6 +18,7 @@ namespace std {
 

[clang] af57dbf - Add support for options -frounding-math, ftrapping-math, -ffp-model=, and -ffp-exception-behavior=

2019-11-07 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2019-11-07T07:22:45-08:00
New Revision: af57dbf12e54f3a8ff48534bf1078f4de104c1cd

URL: 
https://github.com/llvm/llvm-project/commit/af57dbf12e54f3a8ff48534bf1078f4de104c1cd
DIFF: 
https://github.com/llvm/llvm-project/commit/af57dbf12e54f3a8ff48534bf1078f4de104c1cd.diff

LOG: Add support for options -frounding-math, ftrapping-math, -ffp-model=, and 
-ffp-exception-behavior=

Add options to control floating point behavior: trapping and
exception behavior, rounding, and control of optimizations that affect
floating point calculations. More details in UsersManual.rst.

Reviewers: rjmccall

Differential Revision: https://reviews.llvm.org/D62731

Added: 
clang/test/CodeGen/fpconstrained.c
clang/test/Driver/fp-model.c

Modified: 
clang/docs/UsersManual.rst
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Basic/LangOptions.h
clang/include/clang/Driver/Options.td
clang/lib/CodeGen/CodeGenFunction.cpp
clang/lib/CodeGen/CodeGenFunction.h
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/Driver/clang_f_opts.c
clang/test/Driver/fast-math.c
llvm/include/llvm/Target/TargetOptions.h

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 714681d7f4ce..62e2575c6b26 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -1231,10 +1231,10 @@ are listed below.
 
 **-f[no-]trapping-math**
 
-   ``-fno-trapping-math`` allows optimizations that assume that
-   floating point operations cannot generate traps such as divide-by-zero,
-   overflow and underflow. Defaults to ``-ftrapping-math``.
-   Currently this option has no effect.
+   Control floating point exception behavior. ``-fno-trapping-math`` allows 
optimizations that assume that floating point operations cannot generate traps 
such as divide-by-zero, overflow and underflow.
+
+- The option ``-ftrapping-math`` behaves identically to 
``-ffp-exception-behavior=strict``.
+- The option ``-fno-trapping-math`` behaves identically to 
``-ffp-exception-behavior=ignore``.   This is the default.
 
 .. option:: -ffp-contract=
 
@@ -1319,6 +1319,52 @@ are listed below.
 
Defaults to ``-fno-finite-math``.
 
+.. _opt_frounding-math:
+
+**-f[no-]rounding-math**
+
+Force floating-point operations to honor the dynamically-set rounding mode by 
default.
+
+The result of a floating-point operation often cannot be exactly represented 
in the result type and therefore must be rounded.  IEEE 754 describes 
diff erent rounding modes that control how to perform this rounding, not all of 
which are supported by all implementations.  C provides interfaces 
(``fesetround`` and ``fesetenv``) for dynamically controlling the rounding 
mode, and while it also recommends certain conventions for changing the 
rounding mode, these conventions are not typically enforced in the ABI.  Since 
the rounding mode changes the numerical result of operations, the compiler must 
understand something about it in order to optimize floating point operations.
+
+Note that floating-point operations performed as part of constant 
initialization are formally performed prior to the start of the program and are 
therefore not subject to the current rounding mode.  This includes the 
initialization of global variables and local ``static`` variables.  
Floating-point operations in these contexts will be rounded using 
``FE_TONEAREST``.
+
+- The option ``-fno-rounding-math`` allows the compiler to assume that the 
rounding mode is set to ``FE_TONEAREST``.  This is the default.
+- The option ``-frounding-math`` forces the compiler to honor the 
dynamically-set rounding mode.  This prevents optimizations which might affect 
results if the rounding mode changes or is 
diff erent from the default; for example, it prevents floating-point operations 
from being reordered across most calls and prevents constant-folding when the 
result is not exactly representable.
+
+.. option:: -ffp-model=
+
+   Specify floating point behavior. ``-ffp-model`` is an umbrella
+   option that encompasses functionality provided by other, single
+   purpose, floating point options.  Valid values are: ``precise``, ``strict``,
+   and ``fast``.
+   Details:
+
+   * ``precise`` Disables optimizations that are not value-safe on 
floating-point data, although FP contraction (FMA) is enabled 
(``-ffp-contract=fast``).  This is the default behavior.
+   * ``strict`` Enables ``-frounding-math`` and 
``-ffp-exception-behavior=strict``, and disables contractions (FMA).  All of 
the ``-ffast-math`` enablements are disabled.
+   * ``fast`` Behaves identically to specifying both ``-ffast-math`` and 
``ffp-contract=fast``
+
+   Note: If your command line specifies multiple instances
+   of the ``-ffp-model`` option, or if your command line option specifies
+   

[PATCH] D26636: patch for llvm/clang bug 25965, suppress warning diagnostic on float-to-bool conversion when in condition context

2016-11-22 Thread Melanie Blower via cfe-commits
mibintc added a comment.

BTW I tried a couple different approaches to suppress the message.

One of them was to call IgnoreParenImpCasts().  This worked great to suppress 
the unwanted diagnostic but the call also inhibited constant folding and dead 
code elimination, so there were many test failures.  I couldn't find any 
documentation about when and where a call to IgnoreParenImpCasts is 
appropriate.  Use with care.


https://reviews.llvm.org/D26636



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26636: patch for llvm/clang bug 25965, suppress warning diagnostic on float-to-bool conversion when in condition context

2016-11-21 Thread Melanie Blower via cfe-commits
mibintc added a comment.

Does anyone have time to do a code review for this patch?


https://reviews.llvm.org/D26636



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26636: patch for llvm/clang bug 25965, suppress warning diagnostic on float-to-bool conversion when in condition context

2016-11-18 Thread Melanie Blower via cfe-commits
mibintc removed rL LLVM as the repository for this revision.
mibintc updated this revision to Diff 78518.
mibintc added a comment.

I regenerated the diff using diff -x -U99


https://reviews.llvm.org/D26636

Files:
  include/clang/AST/Expr.h
  include/clang/AST/Stmt.h
  lib/Parse/ParseExpr.cpp
  lib/Sema/SemaChecking.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaStmt.cpp
  test/SemaCXX/warn-float-conversion.cpp

Index: test/SemaCXX/warn-float-conversion.cpp
===
--- test/SemaCXX/warn-float-conversion.cpp
+++ test/SemaCXX/warn-float-conversion.cpp
@@ -87,3 +87,29 @@
   char e = 1.0 / 0.0;  // expected-warning{{implicit conversion of out of range value from 'double' to 'char' changes value from +Inf to 127}}
 }
 #endif  // OVERFLOW
+
+int m(int argc)
+{
+  float f = argc;
+  // Test that float-to-bool conversion warnings are not issued
+  // for conditions.
+ 
+
+  if (f)  	
+return 1;
+  else  
+return f
+   ? 1 
+   : 0;
+
+  if (f+1)  	//Question: also suppress for this expresson?
+return 1;
+
+  while (f) ;
+
+  do ; while (f) ;
+
+  for (; f ; ) ;
+
+  return 0;
+}
Index: lib/Sema/SemaStmt.cpp
===
--- lib/Sema/SemaStmt.cpp
+++ lib/Sema/SemaStmt.cpp
@@ -1264,6 +1264,7 @@
   if (CondResult.isInvalid())
 return StmtError();
   Cond = CondResult.get();
+  Cond->setIsCondition();
 
   CondResult = ActOnFinishFullExpr(Cond, DoLoc);
   if (CondResult.isInvalid())
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -14607,10 +14607,12 @@
   ExprResult Cond;
   switch (CK) {
   case ConditionKind::Boolean:
+SubExpr->setIsCondition();
 Cond = CheckBooleanCondition(Loc, SubExpr);
 break;
 
   case ConditionKind::ConstexprIf:
+SubExpr->setIsCondition();
 Cond = CheckBooleanCondition(Loc, SubExpr, true);
 break;
 
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -9020,6 +9020,10 @@
   if (S.SourceMgr.isInSystemMacro(CC))
 return;
 
+  // Suppress float-to-bool diagnostic in conditions.
+  if (TargetBT->isBooleanType() && E->isCondition())
+return;
+
   DiagnoseFloatingImpCast(S, E, T, CC);
 }
 
@@ -9222,7 +9226,10 @@
 /// of competing diagnostics here, -Wconversion and -Wsign-compare.
 void AnalyzeImplicitConversions(Sema , Expr *OrigE, SourceLocation CC) {
   QualType T = OrigE->getType();
+  bool isCondition = OrigE->isCondition();
   Expr *E = OrigE->IgnoreParenImpCasts();
+  if (isCondition)
+E->setIsCondition(isCondition);
 
   if (E->isTypeDependent() || E->isValueDependent())
 return;
Index: lib/Parse/ParseExpr.cpp
===
--- lib/Parse/ParseExpr.cpp
+++ lib/Parse/ParseExpr.cpp
@@ -309,6 +309,8 @@
 TernaryMiddle = nullptr;
 Diag(Tok, diag::ext_gnu_conditional_expr);
   }
+  if (!LHS.isInvalid()) 
+LHS.get()->setIsCondition();
 
   if (!TryConsumeToken(tok::colon, ColonLoc)) {
 // Otherwise, we're missing a ':'.  Assume that this was a typo that
Index: include/clang/AST/Stmt.h
===
--- include/clang/AST/Stmt.h
+++ include/clang/AST/Stmt.h
@@ -131,8 +131,9 @@
 unsigned ValueDependent : 1;
 unsigned InstantiationDependent : 1;
 unsigned ContainsUnexpandedParameterPack : 1;
+unsigned IsCondition : 1;
   };
-  enum { NumExprBits = 16 };
+  enum { NumExprBits = 17 };
 
   class CharacterLiteralBitfields {
 friend class CharacterLiteral;
Index: include/clang/AST/Expr.h
===
--- include/clang/AST/Expr.h
+++ include/clang/AST/Expr.h
@@ -116,6 +116,7 @@
 ExprBits.ValueKind = VK;
 ExprBits.ObjectKind = OK;
 ExprBits.ContainsUnexpandedParameterPack = ContainsUnexpandedParameterPack;
+ExprBits.IsCondition = 0;
 setType(T);
   }
 
@@ -219,6 +220,17 @@
 ExprBits.ContainsUnexpandedParameterPack = PP;
   }
 
+  /// \brief Whether this expression appears in condition expression context.
+  bool isCondition() const {
+return ExprBits.IsCondition;
+  }
+
+  /// \brief Set the bit that describes whether this expression
+  /// appears in condition context e.g.: if(expr) while(expr) ?: etc.
+  void setIsCondition(bool PP = true) {
+ExprBits.IsCondition = PP;
+  }
+
   /// getExprLoc - Return the preferred location for the arrow when diagnosing
   /// a problem with a generic expression.
   SourceLocation getExprLoc() const LLVM_READONLY;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits