[PATCH] D74436: Change clang option -ffp-model=precise to select ffp-contract=on

2021-08-04 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a subscriber: kbsmith1.
mibintc added a comment.

There was a long discussion on cfe-dev about this issue approximately 
January-February 2020 including @scanon @andrew.w.kaylor and many others.  
While there wasn't 100% consensus to move to ffp-contract=on there are many 
reasons to do it including better numerical results and debuggability.  I'm 
hoping that @andrew.w.kaylor @kbsmith1 @rjmccall and others will join in here.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74436/new/

https://reviews.llvm.org/D74436

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


[PATCH] D74436: Change clang option -ffp-model=precise to select ffp-contract=on

2021-07-30 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

In D74436#2917357 , @haowei wrote:

> We are seeing float related unit tests failing in Fuchsia after this patch. 
> What flags should we add to our build to match llvm's previous float point 
> behavior?

This option: ffp-contract=off


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74436/new/

https://reviews.llvm.org/D74436

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


[PATCH] D102343: [clang][patch][FPEnv] Make Initialization of C++ globals strictfp aware

2021-07-29 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

@MaskRay Thanks a lot -- yes!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102343/new/

https://reviews.llvm.org/D102343

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


[PATCH] D102343: [clang][patch][FPEnv} Initialization of C++ globals not strictfp aware

2021-07-29 Thread Melanie Blower via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbc5b5ea037db: [clang][patch][FPEnv] Make initialization of 
C++ globals strictfp aware (authored by mibintc).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102343/new/

https://reviews.llvm.org/D102343

Files:
  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

Index: clang/unittests/Sema/ExternalSemaSourceTest.cpp
===
--- clang/unittests/Sema/ExternalSemaSourceTest.cpp
+++ clang/unittests/Sema/ExternalSemaSourceTest.cpp
@@ -163,7 +163,8 @@
   CurrentSema->getPreprocessor().getIdentifierInfo(CorrectTo);
   auto *NewFunction = FunctionDecl::Create(
   Context, DestContext, SourceLocation(), SourceLocation(), ToIdent,
-  Context.getFunctionType(Context.VoidTy, {}, {}), nullptr, SC_Static);
+  Context.getFunctionType(Context.VoidTy, {}, {}), nullptr, SC_Static,
+  /*UsesFPIntrin*/ false);
   DestContext->addDecl(NewFunction);
   TypoCorrection Correction(ToIdent);
   Correction.addCorrectionDecl(NewFunction);
Index: clang/test/CodeGen/fp-floatcontrol-stack.cpp
===
--- clang/test/CodeGen/fp-floatcontrol-stack.cpp
+++ clang/test/CodeGen/fp-floatcontrol-stack.cpp
@@ -6,6 +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
 float fun_default FUN(1)
 //CHECK-LABEL: define {{.*}} @_Z11fun_defaultf{{.*}}
 #if DEFAULT
@@ -28,6 +32,10 @@
 // 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
 float exc_on FUN(2)
 //CHECK-LABEL: define {{.*}} @_Z6exc_onf{{.*}}
 #if DEFAULT
@@ -46,7 +54,11 @@
 #endif
 
 #pragma float_control(pop)
-float exc_pop FUN(5)
+// 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
+float exc_pop FUN(5)
 //CHECK-LABEL: define {{.*}} @_Z7exc_popf{{.*}}
 #if DEFAULT
 //CHECK-DDEFAULT: call float @llvm.fmuladd{{.*}}
@@ -63,7 +75,7 @@
 #endif
 
 #pragma float_control(except, off)
-float exc_off FUN(5)
+float exc_off FUN(5)
 //CHECK-LABEL: define {{.*}} @_Z7exc_offf{{.*}}
 #if DEFAULT
 //CHECK-DDEFAULT: call float @llvm.fmuladd{{.*}}
@@ -80,7 +92,7 @@
 #endif
 
 #pragma float_control(precise, on, push)
-float precise_on FUN(3)
+float precise_on FUN(3)
 //CHECK-LABEL: define {{.*}} @_Z10precise_onf{{.*}}
 #if DEFAULT
 //CHECK-DDEFAULT: float {{.*}}llvm.fmuladd{{.*}}
@@ -97,7 +109,7 @@
 #endif
 
 #pragma float_control(pop)
-float precise_pop FUN(3)
+float precise_pop FUN(3)
 //CHECK-LABEL: define {{.*}} @_Z11precise_popf{{.*}}
 #if DEFAULT
 //CHECK-DDEFAULT: float {{.*}}llvm.fmuladd{{.*}}
@@ -113,7 +125,7 @@
 //CHECK-FAST: fadd fast float
 #endif
 #pragma float_control(precise, off)
-float precise_off FUN(4)
+float precise_off FUN(4)
 //CHECK-LABEL: define {{.*}} @_Z11precise_offf{{.*}}
 #if DEFAULT
 // Note: precise_off enables fp_contract=fast and the instructions
@@ -137,7 +149,7 @@
 #endif
 
 #pragma float_control(precise, on)
-float precise_on2 FUN(3)
+float precise_on2 FUN(3)
 //CHECK-LABEL: define {{.*}} @_Z11precise_on2f{{.*}}
 #if DEFAULT
 //CHECK-DDEFAULT: l

[PATCH] D93769: [clang] Add support for option -ffp-eval-method and extend #pragma float_control similarly

2021-07-28 Thread Melanie Blower via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG66ddac22e2a7: [CLANG][PATCH][FPEnv] Add support for option 
-ffp-eval-method and extend… (authored by mibintc).

Changed prior to commit:
  https://reviews.llvm.org/D93769?vs=360247&id=362385#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93769/new/

https://reviews.llvm.org/D93769

Files:
  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

Index: clang/test/Preprocessor/init.c
===
--- clang/test/Preprocessor/init.c
+++ clang/test/Preprocessor/init.c
@@ -323,7 +323,6 @@
 // MSP430:#define __FLT_DENORM_MIN__ 1.40129846e-45F
 // MSP430:#define __FLT_DIG__ 6
 // MSP430:#define __FLT_EPSILON__ 1.19209290e-7F
-// MSP430:#define __FLT_EVAL_METHOD__ 0
 // MSP430:#define __FLT_HAS_DENORM__ 1
 // MSP430:#define __FLT_HAS_INFINITY__ 1
 // MSP430:#define __FLT_HAS_QUIET_NAN__ 1
@@ -511,7 +510,6 @@
 // NVPTX32:#define __FLT_DENORM_MIN__ 1.40129846e-45F
 // NVPTX32:#define __FLT_DIG__ 6
 // NVPTX32:#define __FLT_EPSILON__ 1.19209290e-7F
-// NVPTX32:#define __FLT_EVAL_METHOD__ 0
 // NVPTX32:#define __FLT_HAS_DENORM__ 1
 // NVPTX32:#define __FLT_HAS_INFINITY__ 1
 // NVPTX32:#define __FLT_HAS_QUIET_NAN__ 1
@@ -700,7 +698,6 @@
 // NVPTX64:#define __FLT_DENORM_MIN__ 1.40129846e-45F
 // NVPTX64:#define __FLT_DIG__ 6
 // NVPTX64:#define __FLT_EPSILON__ 1.19209290e-7F
-// NVPTX64:#define __FLT_EVAL_METHOD__ 0
 // NVPTX64:#define __FLT_HAS_DENORM__ 1
 // NVPTX64:#define __FLT_HAS_INFINITY__ 1
 // NVPTX64:#define __FLT_HAS_QUIET_NAN__ 1
@@ -904,7 +901,6 @@
 // SPARC:#define __FLT_DENORM_MIN__ 1.40129846e-45F
 // SPARC:#define __FLT_DIG__ 6
 // SPARC:#define __FLT_EPSILON__ 1.19209290e-7F
-// SPARC:#define __FLT_EVAL_METHOD__ 0
 // SPARC:#define __FLT_HAS_DENORM__ 1
 // SPARC:#define __FLT_HAS_INFINITY__ 1
 // SPARC:#define __FLT_HAS_QUIET_NAN__ 1
@@ -1105,7 +1101,6 @@
 // TCE:#define __FLT_DENORM_MIN__ 1.40129846e-45F
 // TCE:#define __FLT_DIG__ 6
 // TCE:#define __FLT_EPSILON__ 1.19209290e-7F
-// TCE:#define __FLT_EVAL_METHOD__ 0
 // TCE:#define __FLT_HAS_DENORM__ 1
 // TCE:#define __FLT_HAS_INFINITY__ 1
 // TCE:#define __FLT_HAS_QUIET_NAN__ 1
@@ -1272,7 +1267,6 @@
 // PS4:#define __FLT_DENORM_MIN__ 1.40129846e-45F
 // PS4:#define __FLT_DIG__ 6
 // PS4:#define __FLT_EPSILON__ 1.19209290e-7F
-// PS4:#define __FLT_EVAL_METHOD__ 0
 // PS4:#define __FLT_HAS_DENORM__ 1
 // PS4:#define __FLT_HAS_INFINITY__ 1
 // PS4:#define __FLT_HAS_QUIET_NAN__ 1
@@ -1564,7 +1558,6 @@
 // WEBASSEMBLY-NEXT:#define __FLT_DENORM_MIN__ 1.40129846e-45F
 // WEBASSEMBLY-NEXT:#define __FLT_DIG__ 6
 // WEBASSEMBLY-NEXT:#define __FLT_EPSILON__ 1.19209290e-7F
-// WEBASSEMBLY-NEXT:#define __FLT_EVAL_METHOD__ 0
 // WEBASSEMBLY-NEXT:#define __FLT_HAS_DENORM__ 1
 // WEBASSEMBLY-NEXT:#define __FLT_HAS_INFINITY__ 1
 // WEBASSEMBLY-NEXT:#define __FLT_HAS_QUIET_NAN__ 1
@@ -1916,7 +1909,6 @@
 // AVR:#define __FLT_DENORM_MIN__ 1.40129846e-45F
 // AVR:#define __FLT_DIG__ 6
 // AVR:#define __FLT_EPSILON__ 1.19209290e-7F
-// AVR:#define __FLT_EVAL_METHOD__ 0
 // AVR:#define __FLT_HAS_DENORM__ 1
 // AVR:#define __FLT_HAS_INFINITY__ 1
 // AVR:#define __FLT_HAS_QUIET_NAN__ 1
@@ -2199,7 +2191,6 @@
 // RISCV32: #define __FLT_DENORM_MIN__ 1.40129846e-45F
 // RISCV32: #define __FLT_DIG__ 6
 // RISCV32: #define __FLT_EPSILON__ 1.19209290e-7F
-// RISCV32: #define __FLT_EVAL_METHOD__ 0
 // RISCV32: #define __FLT_HAS_DENORM__ 1
 // RISCV32: #define __FLT_HAS_INFINITY__ 1
 // RISCV32: #define __FLT_HAS_QUIET_NAN__ 1
@@ -2407,7 +2398,6 @@
 // RISCV64: #define __FLT_DENORM_MIN__ 1.40129846e-45F
 // RISCV64: #define __FLT_DIG__ 6
 // RISCV64: #define __FLT_EPSILON__ 1.19209290e-7F
-// RISCV64: #define __FLT_EVAL_METHOD__ 0
 // RISCV64: #define __FLT_HAS_DENORM__ 1
 // RIS

[PATCH] D74436: Change clang option -ffp-model=precise to select ffp-contract=on

2021-07-27 Thread Melanie Blower via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG48ad446a0fb2: [clang][fpenv][patch] Change clang option 
-ffp-model=precise to select ffp… (authored by mibintc).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74436/new/

https://reviews.llvm.org/D74436

Files:
  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

Index: clang/test/Driver/fp-model.c
===
--- clang/test/Driver/fp-model.c
+++ clang/test/Driver/fp-model.c
@@ -1,88 +1,90 @@
 // Test that incompatible combinations of -ffp-model= options
 // and other floating point options get a warning diagnostic.
-//
-// REQUIRES: clang-driver
 
-// RUN: %clang -### -ffp-model=fast -ffp-contract=off -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=fast -ffp-contract=off -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARN %s
 // WARN: warning: overriding '-ffp-model=fast' option with '-ffp-contract=off' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=fast -ffp-contract=on -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=fast -ffp-contract=on -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARN1 %s
 // WARN1: warning: overriding '-ffp-model=fast' option with '-ffp-contract=on' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -fassociative-math -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict -fassociative-math -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARN2 %s
 // WARN2: warning: overriding '-ffp-model=strict' option with '-fassociative-math' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -ffast-math -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict -ffast-math -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARN3 %s
 // WARN3: warning: overriding '-ffp-model=strict' option with '-ffast-math' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -ffinite-math-only -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict -ffinite-math-only -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARN4 %s
 // WARN4: warning: overriding '-ffp-model=strict' option with '-ffinite-math-only' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -ffp-contract=fast -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict -ffp-contract=fast -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARN5 %s
 // WARN5: warning: overriding '-ffp-model=strict' option with '-ffp-contract=fast' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -ffp-contract=on -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict -ffp-contract=fast -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN6 %s
+// WARN6: warning: overriding '-ffp-model=strict' option with '-ffp-contract=fast' [-Woverriding-t-option]
+
+// RUN: %clang -target x86_64 -### -ffp-model=strict -ffp-contract=on -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARN7 %s
 // WARN7: warning: overriding '-ffp-model=strict' option with '-ffp-contract=on' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -fno-honor-infinities -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict -fno-honor-infinities -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARN8 %s
 // WARN8: warning: overriding '-ffp-model=strict' option with '-fno-honor-infinities' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -fno-honor-nans -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict -fno-honor-nans -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARN9 %s
 // WARN9: warning: overriding '-ffp-model=strict' option with '-fno-honor-nans' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -fno-rounding-math -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict -fno-rounding-math -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARNa %s
 // WARNa: warning: overriding '-ffp-model=strict' option with '-fno-rounding-math' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -fno-signed-zeros -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict -fno-signed-zeros -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARNb %s
 // WARNb: warning: overriding '-ffp-model=strict' option with '-fno-signed-zeros' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -fno-trapping-math -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict -fno-trapping-math -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARNc %s
 // WARNc: warning: overriding '-ffp-model=strict' option with '-fno-trapping-math' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -freciprocal-math -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict

[PATCH] D106863: Allow #pragma float_control(push|pop) within a language linkage specification

2021-07-27 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a reviewer: zahiraam.
mibintc added a subscriber: zahiraam.
mibintc added a comment.

Adding @zahiraam FYI


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106863/new/

https://reviews.llvm.org/D106863

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


[PATCH] D106863: Allow #pragma float_control(push|pop) within a language linkage specification

2021-07-27 Thread Melanie Blower via Phabricator via cfe-commits
mibintc accepted this revision.
mibintc added a comment.

Thanks for fixing this Aaron, just curious was there a bug report?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106863/new/

https://reviews.llvm.org/D106863

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


[PATCH] D105951: [clang] P2266 implicit moves STL workaround

2021-07-26 Thread Melanie Blower via Phabricator via cfe-commits
mibintc accepted this revision.
mibintc added a comment.
This revision is now accepted and ready to land.

I tested this patch downstream on Windows with Microsoft (R) C/C++ Optimizing 
Compiler Version 19.28.29334 for x64

I used c++20, x++latest default and c++17 with the stl header files (standalone 
include files--not usage) and didn't find any problems.

c:/Program files (x86)/Microsoft Visual 
Studio/2019/Professional/VC/Tools/MSVC/14.28.29333/


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105951/new/

https://reviews.llvm.org/D105951

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


[PATCH] D95159: [ASTReader] Allow controlling separately whether validation should be disabled for a PCH vs a module file

2021-07-23 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

Whoops, shouldn't mess with the mkdir line

diff --git a/clang/test/Index/preamble-reparse-changed-module.m 
b/clang/test/Index/preamble-reparse-changed-module.m
index 1c63e802ce0c..349ed0db27d0 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


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95159/new/

https://reviews.llvm.org/D95159

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


[PATCH] D95159: [ASTReader] Allow controlling separately whether validation should be disabled for a PCH vs a module file

2021-07-23 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

@bnbarham 
I think you mean a patch like this, is it right?  I'd like to fix the test in a 
pre-commit and then re-push my patch

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


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95159/new/

https://reviews.llvm.org/D95159

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


[PATCH] D93769: [clang] Add support for option -ffp-eval-method and extend #pragma float_control similarly

2021-07-22 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

@MaskRay I experience that the failing test 
clang/test/Index/preamble-reparse-changed-module.m is non-deterministic and 
currently I cannot reproduce the fail.  I added details in D95159 
.  Are you able to reproduce if you clean your 
build area? Do you have a suggestion for how I can solve this problem?  Thanks 
a lot


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93769/new/

https://reviews.llvm.org/D93769

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


[PATCH] D95159: [ASTReader] Allow controlling separately whether validation should be disabled for a PCH vs a module file

2021-07-22 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a subscriber: MaskRay.
mibintc added a comment.

More info about the test failure I'm seeing for 
clang/test/Index/preamble-reparse-changed-module.m

It appears it might be a non-deterministic failure, perhaps some test 
dependencies are missing?

Yesterday before I pushed my clang patch, I saw it fail when I used "ninja 
check-clang".  I quickly executed each step used by this test (llvm-lit -v ; 
then save all the RUN commands to a file ; then "source" the file -- nothing 
was printed to stdout and also the return code was 0).  I thought the fail 
report wasn't real at this point and I pushed the patch.  This was a Debug 
build.

Then I saw a bot failure, @MaskRay pinged my clang patch and said my patch had 
caused this test to fail.  He told me there was an assertion fail.

Then I created a new build area, configured with Debug and "enable llvm 
assertions", and "ninja check-clang".  This time 0 tests reported as fail.

Then I went back into the build-debug build where "ninja check-clang" had 
reported the fail and used gdb to debug.  In the course of debugging gdb told 
me that the build was out-of-date w.r.t. the source file, so I exitted gdb, 
"ninja clean" "ninja check-clang".  But now no tests are failing.  I don't know 
why gdb told me the build was out of date, I believe I did not change any of 
the files but I'm not 100% certain.

I removed the patch and created another build area, and rebuilt with Debug and 
asserts, everything is clean there too.

I captured the stdout from executing c-index-test, there is a difference 
between patched and unpatched. The __FLT_EVAL_METHOD__ line is not present in 
the patched, this is expected.

Can you suggest how to find the problem?  Thanks a lot.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95159/new/

https://reviews.llvm.org/D95159

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


[PATCH] D74436: Change clang option -ffp-model=precise to select ffp-contract=on

2021-07-22 Thread Melanie Blower via Phabricator via cfe-commits
mibintc reopened this revision.
mibintc added a comment.
This revision is now accepted and ready to land.

I had to revert again, it's still failing on Intel buildbots. Cannot reproduce 
on Intel-internal Broadwell server.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74436/new/

https://reviews.llvm.org/D74436

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


[PATCH] D74436: Change clang option -ffp-model=precise to select ffp-contract=on

2021-07-22 Thread Melanie Blower via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb9b696bba670: [clang][fpenv][patch] Change clang option 
-ffp-model=precise to select ffp… (authored by mibintc).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74436/new/

https://reviews.llvm.org/D74436

Files:
  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

Index: clang/test/Driver/fp-model.c
===
--- clang/test/Driver/fp-model.c
+++ clang/test/Driver/fp-model.c
@@ -1,88 +1,90 @@
 // Test that incompatible combinations of -ffp-model= options
 // and other floating point options get a warning diagnostic.
-//
-// REQUIRES: clang-driver
 
-// RUN: %clang -### -ffp-model=fast -ffp-contract=off -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=fast -ffp-contract=off -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARN %s
 // WARN: warning: overriding '-ffp-model=fast' option with '-ffp-contract=off' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=fast -ffp-contract=on -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=fast -ffp-contract=on -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARN1 %s
 // WARN1: warning: overriding '-ffp-model=fast' option with '-ffp-contract=on' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -fassociative-math -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict -fassociative-math -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARN2 %s
 // WARN2: warning: overriding '-ffp-model=strict' option with '-fassociative-math' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -ffast-math -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict -ffast-math -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARN3 %s
 // WARN3: warning: overriding '-ffp-model=strict' option with '-ffast-math' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -ffinite-math-only -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict -ffinite-math-only -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARN4 %s
 // WARN4: warning: overriding '-ffp-model=strict' option with '-ffinite-math-only' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -ffp-contract=fast -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict -ffp-contract=fast -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARN5 %s
 // WARN5: warning: overriding '-ffp-model=strict' option with '-ffp-contract=fast' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -ffp-contract=on -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict -ffp-contract=fast -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN6 %s
+// WARN6: warning: overriding '-ffp-model=strict' option with '-ffp-contract=fast' [-Woverriding-t-option]
+
+// RUN: %clang -target x86_64 -### -ffp-model=strict -ffp-contract=on -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARN7 %s
 // WARN7: warning: overriding '-ffp-model=strict' option with '-ffp-contract=on' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -fno-honor-infinities -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict -fno-honor-infinities -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARN8 %s
 // WARN8: warning: overriding '-ffp-model=strict' option with '-fno-honor-infinities' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -fno-honor-nans -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict -fno-honor-nans -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARN9 %s
 // WARN9: warning: overriding '-ffp-model=strict' option with '-fno-honor-nans' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -fno-rounding-math -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict -fno-rounding-math -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARNa %s
 // WARNa: warning: overriding '-ffp-model=strict' option with '-fno-rounding-math' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -fno-signed-zeros -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict -fno-signed-zeros -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARNb %s
 // WARNb: warning: overriding '-ffp-model=strict' option with '-fno-signed-zeros' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -fno-trapping-math -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict -fno-trapping-math -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARNc %s
 // WARNc: warning: overriding '-ffp-model=strict' option with '-fno-trapping-math' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -freciprocal-math -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict

[PATCH] D95159: [ASTReader] Allow controlling separately whether validation should be disabled for a PCH vs a module file

2021-07-21 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a subscriber: aaron.ballman.
mibintc added a comment.

@aaron.ballman suggested I may have made a mistake adding the new option, I'll 
look there.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95159/new/

https://reviews.llvm.org/D95159

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


[PATCH] D95159: [ASTReader] Allow controlling separately whether validation should be disabled for a PCH vs a module file

2021-07-21 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

The newly added test case clang/test/Index/preamble-reparse-changed-module.m is 
failing on the patch that I'm trying to commit, https://reviews.llvm.org/D93769

Actually the result of the test is a bit flaky, when I build the Debug version 
on Linux, running ninja check-clang does show the test fail, but when I do an 
identical build and in addition enabling llvm assertions, llvm-lit does not 
show this lit test failing.

I think the problem has something to do with the macro __FLT_EVAL_METHOD__.  
The patch now treats this macro specially, more like __LINE__ a macro that can 
vary depending on where it is seen in the source code.

In my patch, __FLT_EVAL_MACRO__ is not expanded in -E mode, it just appears as 
its name in the preprocessed output.  The reason is, the actual value of the 
macro depends on the floating point settings at a particular source code 
location (depends on #pragma float_control settings).  The pragma are 
determined in Sema, and -E runs before Sema so the actual value isn't available.

This macro is the only reason i can think why this test is failing.

Can you help me understand what to do about this test case/about my patch/ so 
that i can get my patch committed? I don't understand what this test is doing. 
In the debugger it hits a failed assertion, looks like index out-of-range. 
here's a little massaged traceback
__assert_fail
 llvm::SmallVectorTemplateCommon unsigned long, void ::indexing operator
clang::ASTReader::ReadString
clang::ASTReader::ParseLanguageOptions
clang::ASTReader::ReadOptionsBlock
clang::ASTReader::ReadControlBlock
clang::ASTReader::ReadASTCore
clang::ASTReader::ReadAST
clang::CompilerInstance::findOrCompileModuleAndReadAST
clang::CompilerInstance::loadModule
clang::Preprocessor::LexAfterModuleImport

Thanks a lot


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95159/new/

https://reviews.llvm.org/D95159

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


[PATCH] D93769: [clang] Add support for option -ffp-eval-method and extend #pragma float_control similarly

2021-07-20 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

In D93769#2891552 , @MaskRay wrote:

> In D93769#2891549 , @mibintc wrote:
>
>> In D93769#2891545 , @MaskRay wrote:
>>
>>> This breaks `clang/test/Index/preamble-reparse-changed-module.m`
>
> Seems like a libclang crash (an `assert` failure) if you enable 
> LLVM_ENABLE_ASSERTIONS=on.
>
> You can reproduce with check-clang-index

Thanks for this, I'm building with assertions on now.  This patch doesn't 
expand __FLT_EVAL_METHOD__ in -E mode, I'm guessing that's why it fails. It 
can't expand the macro during -E because the context showing the value of the 
macro setting is only available in Sema. I haven't yet studied the test but do 
you know have an idea how I might be able to solve the problem?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93769/new/

https://reviews.llvm.org/D93769

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


[PATCH] D93769: [clang] Add support for option -ffp-eval-method and extend #pragma float_control similarly

2021-07-20 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added inline comments.



Comment at: clang/test/Preprocessor/predefined-flteval-macro.c:332
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=riscv64 -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=riscv64-unknown-linux 
-fsyntax-only %s
+#ifndef FEM

MaskRay wrote:
> So many clang invocations slow down testsuite execution.
> 
> 
> Can some RUN lines be removed if their coverage value is low ?
OK. I was trying to demonstrate that my changes hadn't modified the macro 
settings across all


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93769/new/

https://reviews.llvm.org/D93769

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


[PATCH] D93769: [clang] Add support for option -ffp-eval-method and extend #pragma float_control similarly

2021-07-20 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

In D93769#2891545 , @MaskRay wrote:

> This breaks `clang/test/Index/preamble-reparse-changed-module.m`
>
> http://45.33.8.238/linux/51638/step_7.txt

I saw this fail on console when i do "ninja check-clang" but when I run each 
step in this test separately there is no failure
the return code is 0
I don't understand what the failure is, how can I discover the problem?  Thank 
you.  I can revert the patch


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93769/new/

https://reviews.llvm.org/D93769

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


[PATCH] D93769: [clang] Add support for option -ffp-eval-method and extend #pragma float_control similarly

2021-07-20 Thread Melanie Blower via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGce8024e8ff76: [CLANG][PATCH][FPEnv] Add support for option 
-ffp-eval-method and extend… (authored by mibintc).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93769/new/

https://reviews.llvm.org/D93769

Files:
  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
  clang/test/Preprocessor/predefined-flteval-macro.c

Index: clang/test/Preprocessor/predefined-flteval-macro.c
===
--- /dev/null
+++ clang/test/Preprocessor/predefined-flteval-macro.c
@@ -0,0 +1,346 @@
+// RUN: %clang_cc1 -std=c11  -E -triple=aarch64 -xc  %s | FileCheck %s
+// RUN: %clang_cc1 -std=c11  -triple=aarch64 -xc  -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -triple=arm64 -xc  -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -triple=aarch64_be -xc  -fsyntax-only %s
+// RUN: %clang_cc1  -triple=arm64 -xc++  -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=aarch64-apple-ios7.0 -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=aarch64-windows-msvc -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -triple=aarch64 -mcmodel=small -xc  -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -triple=aarch64 -mcmodel=tiny -xc  -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -triple=aarch64 -mcmodel=large -xc  -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=thumbv7-windows-msvc -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=arm-none-none -fsyntax-only %s
+// RUN: %clang_cc1  -x c++ -ffreestanding -triple=arm-none-none -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple arm-none-none -target-abi apcs-gnu -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=armeb-none-none -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=arm-none-linux-gnueabi -target-feature +soft-float -target-feature +soft-float-abi -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=arm-none-linux-gnueabi -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=armv6-unknown-cloudabi-eabihf -fsyntax-only %s
+// RUN: %clang -c -ffreestanding -target arm-netbsd-eabi -fsyntax-only %s
+// RUN: %clang -c -ffreestanding -target arm-netbsd-eabihf -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=arm-none-eabi -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=arm-none-eabihf -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=aarch64-none-eabi -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=aarch64-none-eabihf -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=aarch64-none-elf -fsyntax-only %s
+// RUN: %clang -target x86_64-apple-darwin -arch armv7s -x c -fsyntax-only %s
+// RUN: %clang -target x86_64-apple-darwin -arch armv6m -x c -fsyntax-only %s
+// RUN: %clang -target x86_64-apple-darwin -arch armv7m -x c -fsyntax-only %s
+// RUN: %clang -target x86_64-apple-darwin -arch armv7em -x c -fsyntax-only %s
+// RUN: %clang -target x86_64-apple-darwin -arch armv7 -x c -fsyntax-only %s
+// RUN: %clang -c -target arm -mhwdiv=arm -x c -fsyntax-only %s
+// RUN: %clang -c -target arm -mthumb -mhwdiv=thumb -x c -fsyntax-only %s
+// RUN: %clang -c -target arm -x c -fsyntax-only %s
+// RUN: %clang -c -target arm -mthumb -x c -fsyntax-only %s
+// RUN: %clang -c -target arm -mhwdiv=thumb -x c -fsyntax-only %s
+// RUN: %clang -c -target arm -mthumb -mhwdiv=arm -x c -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=armv8-none-none -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=armebv8-none-none -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  

[PATCH] D102343: [clang][patch][FPEnv} Initialization of C++ globals not strictfp aware

2021-07-20 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 360225.
mibintc added a comment.

Removed use of auto, and used different capitalization for local var name


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102343/new/

https://reviews.llvm.org/D102343

Files:
  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

Index: clang/unittests/Sema/ExternalSemaSourceTest.cpp
===
--- clang/unittests/Sema/ExternalSemaSourceTest.cpp
+++ clang/unittests/Sema/ExternalSemaSourceTest.cpp
@@ -163,7 +163,8 @@
   CurrentSema->getPreprocessor().getIdentifierInfo(CorrectTo);
   auto *NewFunction = FunctionDecl::Create(
   Context, DestContext, SourceLocation(), SourceLocation(), ToIdent,
-  Context.getFunctionType(Context.VoidTy, {}, {}), nullptr, SC_Static);
+  Context.getFunctionType(Context.VoidTy, {}, {}), nullptr, SC_Static,
+  /*UsesFPIntrin*/ false);
   DestContext->addDecl(NewFunction);
   TypoCorrection Correction(ToIdent);
   Correction.addCorrectionDecl(NewFunction);
Index: clang/test/CodeGen/fp-floatcontrol-stack.cpp
===
--- clang/test/CodeGen/fp-floatcontrol-stack.cpp
+++ clang/test/CodeGen/fp-floatcontrol-stack.cpp
@@ -6,6 +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
 float fun_default FUN(1)
 //CHECK-LABEL: define {{.*}} @_Z11fun_defaultf{{.*}}
 #if DEFAULT
@@ -28,6 +32,10 @@
 // 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
 float exc_on FUN(2)
 //CHECK-LABEL: define {{.*}} @_Z6exc_onf{{.*}}
 #if DEFAULT
@@ -46,7 +54,11 @@
 #endif
 
 #pragma float_control(pop)
-float exc_pop FUN(5)
+// 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
+float exc_pop FUN(5)
 //CHECK-LABEL: define {{.*}} @_Z7exc_popf{{.*}}
 #if DEFAULT
 //CHECK-DDEFAULT: call float @llvm.fmuladd{{.*}}
@@ -63,7 +75,7 @@
 #endif
 
 #pragma float_control(except, off)
-float exc_off FUN(5)
+float exc_off FUN(5)
 //CHECK-LABEL: define {{.*}} @_Z7exc_offf{{.*}}
 #if DEFAULT
 //CHECK-DDEFAULT: call float @llvm.fmuladd{{.*}}
@@ -80,7 +92,7 @@
 #endif
 
 #pragma float_control(precise, on, push)
-float precise_on FUN(3)
+float precise_on FUN(3)
 //CHECK-LABEL: define {{.*}} @_Z10precise_onf{{.*}}
 #if DEFAULT
 //CHECK-DDEFAULT: float {{.*}}llvm.fmuladd{{.*}}
@@ -97,7 +109,7 @@
 #endif
 
 #pragma float_control(pop)
-float precise_pop FUN(3)
+float precise_pop FUN(3)
 //CHECK-LABEL: define {{.*}} @_Z11precise_popf{{.*}}
 #if DEFAULT
 //CHECK-DDEFAULT: float {{.*}}llvm.fmuladd{{.*}}
@@ -113,7 +125,7 @@
 //CHECK-FAST: fadd fast float
 #endif
 #pragma float_control(precise, off)
-float precise_off FUN(4)
+float precise_off FUN(4)
 //CHECK-LABEL: define {{.*}} @_Z11precise_offf{{.*}}
 #if DEFAULT
 // Note: precise_off enables fp_contract=fast and the instructions
@@ -137,7 +149,7 @@
 #endif
 
 #pragma float_control(precise, on)
-float precise_on2 FUN(3)
+float precise_on2 FUN(3)
 //CHECK-LABEL: define {{.*}} @_Z11precise_on2f{{.*}}
 #if DEFAULT
 //CHECK-DDEFAULT: llvm.fmuladd{{.*}}
@@ -154,7 +166,7 @@
 #endif
 
 #pragma float_control(push)
-fl

[PATCH] D102343: [clang][patch][FPEnv} Initialization of C++ globals not strictfp aware

2021-07-20 Thread Melanie Blower via Phabricator via cfe-commits
mibintc marked an inline comment as done.
mibintc added a comment.

Question for Aaron




Comment at: clang/include/clang/AST/Decl.h:1993
const DeclarationNameInfo &NameInfo, QualType T,
-   TypeSourceInfo *TInfo, StorageClass S, bool isInlineSpecified,
-   ConstexprSpecKind ConstexprKind,
+   TypeSourceInfo *TInfo, StorageClass S, bool UsesFPIntrin,
+   bool isInlineSpecified, ConstexprSpecKind ConstexprKind,

aaron.ballman wrote:
> I have no idea if others agree, but I have a slight preference for putting 
> `UsesFPIntrin` towards the end of the parameter list (here and in the Create 
> methods) -- this flag seems less important than the constexpr kind or whether 
> inline is specified (and, it helpfully avoids putting two `bool` parameters 
> next to one another).
> 
> If you agree, perhaps it could be moved to before `TrailingRequiresClause`?
I spent a few hours recoding to rearrange the parameter list, but there are 
downstream types from FunctionDecl which would presumably also need to be 
rearranged, and those types add more parameters and some of those parameters 
have default values, and moving the new boolean before TrailingRequiresClause 
doesn't work, I decided to throw away the mess I made and ask if you could live 
with it this way. 



Comment at: clang/lib/CodeGen/CodeGenFunction.cpp:939
+  llvm::RoundingMode RM = getLangOpts().getFPRoundingMode();
+  auto fpExceptionBehavior =
+  ToConstrainedExceptMD(getLangOpts().getFPExceptionMode());

aaron.ballman wrote:
> Please spell out the type rather than use `auto`, also, should probably be 
> `FP` rather than `fp` per the usual naming conventions.
oops i didn't get this one


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102343/new/

https://reviews.llvm.org/D102343

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


[PATCH] D102343: [clang][patch][FPEnv} Initialization of C++ globals not strictfp aware

2021-07-20 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 360222.
mibintc added a comment.

Partially respond to @aaron.ballman 's review by refactoring a change into a 
separate commit, but I'll push back on another request, I'll add that reply 
inline.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102343/new/

https://reviews.llvm.org/D102343

Files:
  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

Index: clang/unittests/Sema/ExternalSemaSourceTest.cpp
===
--- clang/unittests/Sema/ExternalSemaSourceTest.cpp
+++ clang/unittests/Sema/ExternalSemaSourceTest.cpp
@@ -163,7 +163,8 @@
   CurrentSema->getPreprocessor().getIdentifierInfo(CorrectTo);
   auto *NewFunction = FunctionDecl::Create(
   Context, DestContext, SourceLocation(), SourceLocation(), ToIdent,
-  Context.getFunctionType(Context.VoidTy, {}, {}), nullptr, SC_Static);
+  Context.getFunctionType(Context.VoidTy, {}, {}), nullptr, SC_Static,
+  /*UsesFPIntrin*/ false);
   DestContext->addDecl(NewFunction);
   TypoCorrection Correction(ToIdent);
   Correction.addCorrectionDecl(NewFunction);
Index: clang/test/CodeGen/fp-floatcontrol-stack.cpp
===
--- clang/test/CodeGen/fp-floatcontrol-stack.cpp
+++ clang/test/CodeGen/fp-floatcontrol-stack.cpp
@@ -6,6 +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
 float fun_default FUN(1)
 //CHECK-LABEL: define {{.*}} @_Z11fun_defaultf{{.*}}
 #if DEFAULT
@@ -28,6 +32,10 @@
 // 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
 float exc_on FUN(2)
 //CHECK-LABEL: define {{.*}} @_Z6exc_onf{{.*}}
 #if DEFAULT
@@ -46,7 +54,11 @@
 #endif
 
 #pragma float_control(pop)
-float exc_pop FUN(5)
+// 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
+float exc_pop FUN(5)
 //CHECK-LABEL: define {{.*}} @_Z7exc_popf{{.*}}
 #if DEFAULT
 //CHECK-DDEFAULT: call float @llvm.fmuladd{{.*}}
@@ -63,7 +75,7 @@
 #endif
 
 #pragma float_control(except, off)
-float exc_off FUN(5)
+float exc_off FUN(5)
 //CHECK-LABEL: define {{.*}} @_Z7exc_offf{{.*}}
 #if DEFAULT
 //CHECK-DDEFAULT: call float @llvm.fmuladd{{.*}}
@@ -80,7 +92,7 @@
 #endif
 
 #pragma float_control(precise, on, push)
-float precise_on FUN(3)
+float precise_on FUN(3)
 //CHECK-LABEL: define {{.*}} @_Z10precise_onf{{.*}}
 #if DEFAULT
 //CHECK-DDEFAULT: float {{.*}}llvm.fmuladd{{.*}}
@@ -97,7 +109,7 @@
 #endif
 
 #pragma float_control(pop)
-float precise_pop FUN(3)
+float precise_pop FUN(3)
 //CHECK-LABEL: define {{.*}} @_Z11precise_popf{{.*}}
 #if DEFAULT
 //CHECK-DDEFAULT: float {{.*}}llvm.fmuladd{{.*}}
@@ -113,7 +125,7 @@
 //CHECK-FAST: fadd fast float
 #endif
 #pragma float_control(precise, off)
-float precise_off FUN(4)
+float precise_off FUN(4)
 //CHECK-LABEL: define {{.*}} @_Z11precise_offf{{.*}}
 #if DEFAULT
 // Note: precise_off enables fp_contract=fast and the instructions
@@ -137,7 +149,7 @@
 #endif
 
 #pragma float_control(precise, on)
-float precise_on2 FUN(3)
+float precise_on2 FUN(3)
 //CHECK-LABEL: define {{.*}} @_Z11precise_on2f{{.*}}
 #if DEFAULT
 //CHECK-DDEFAULT: llvm.fmuladd{{.*}}
@@ -1

[PATCH] D105997: Implement _ExtInt conversion rules

2021-07-19 Thread Melanie Blower via Phabricator via cfe-commits
mibintc accepted this revision.
mibintc added a comment.
This revision is now accepted and ready to land.

LGTM


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105997/new/

https://reviews.llvm.org/D105997

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


[PATCH] D93769: [clang] Add support for option -ffp-eval-method and extend #pragma float_control similarly

2021-07-19 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 359847.
mibintc marked 3 inline comments as done.
mibintc added a reviewer: zahiraam.
mibintc added a comment.

I've rebased and applied clang-format. I'd like to push this, looking for your 
+1, thank you!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93769/new/

https://reviews.llvm.org/D93769

Files:
  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
  clang/test/Preprocessor/predefined-flteval-macro.c

Index: clang/test/Preprocessor/predefined-flteval-macro.c
===
--- /dev/null
+++ clang/test/Preprocessor/predefined-flteval-macro.c
@@ -0,0 +1,346 @@
+// RUN: %clang_cc1 -std=c11  -E -triple=aarch64 -xc  %s | FileCheck %s
+// RUN: %clang_cc1 -std=c11  -triple=aarch64 -xc  -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -triple=arm64 -xc  -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -triple=aarch64_be -xc  -fsyntax-only %s
+// RUN: %clang_cc1  -triple=arm64 -xc++  -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=aarch64-apple-ios7.0 -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=aarch64-windows-msvc -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -triple=aarch64 -mcmodel=small -xc  -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -triple=aarch64 -mcmodel=tiny -xc  -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -triple=aarch64 -mcmodel=large -xc  -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=thumbv7-windows-msvc -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=arm-none-none -fsyntax-only %s
+// RUN: %clang_cc1  -x c++ -ffreestanding -triple=arm-none-none -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple arm-none-none -target-abi apcs-gnu -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=armeb-none-none -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=arm-none-linux-gnueabi -target-feature +soft-float -target-feature +soft-float-abi -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=arm-none-linux-gnueabi -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=armv6-unknown-cloudabi-eabihf -fsyntax-only %s
+// RUN: %clang -c -ffreestanding -target arm-netbsd-eabi -fsyntax-only %s
+// RUN: %clang -c -ffreestanding -target arm-netbsd-eabihf -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=arm-none-eabi -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=arm-none-eabihf -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=aarch64-none-eabi -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=aarch64-none-eabihf -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=aarch64-none-elf -fsyntax-only %s
+// RUN: %clang -target x86_64-apple-darwin -arch armv7s -x c -fsyntax-only %s
+// RUN: %clang -target x86_64-apple-darwin -arch armv6m -x c -fsyntax-only %s
+// RUN: %clang -target x86_64-apple-darwin -arch armv7m -x c -fsyntax-only %s
+// RUN: %clang -target x86_64-apple-darwin -arch armv7em -x c -fsyntax-only %s
+// RUN: %clang -target x86_64-apple-darwin -arch armv7 -x c -fsyntax-only %s
+// RUN: %clang -c -target arm -mhwdiv=arm -x c -fsyntax-only %s
+// RUN: %clang -c -target arm -mthumb -mhwdiv=thumb -x c -fsyntax-only %s
+// RUN: %clang -c -target arm -x c -fsyntax-only %s
+// RUN: %clang -c -target arm -mthumb -x c -fsyntax-only %s
+// RUN: %clang -c -target arm -mhwdiv=thumb -x c -fsyntax-only %s
+// RUN: %clang -c -target arm -mthumb -mhwdiv=arm -x c -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=armv8-none-none -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=armebv8-none-none -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding 

[PATCH] D102343: [clang][patch][FPEnv} Initialization of C++ globals not strictfp aware

2021-07-19 Thread Melanie Blower via Phabricator via cfe-commits
mibintc marked an inline comment as done.
mibintc added inline comments.



Comment at: clang/lib/Sema/SemaLambda.cpp:395
   MethodNameLoc),
-  MethodType, MethodTypeInfo, SC_None,
+  MethodType, MethodTypeInfo, SC_None, /*UsesFPIntrin*/ false,
   /*isInline=*/true, ConstexprKind, EndLoc, TrailingRequiresClause);

aaron.ballman wrote:
> Should lambdas pick up the same fp constraints as the function defining the 
> lambda?
I made it use the FP settings from Sema, 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102343/new/

https://reviews.llvm.org/D102343

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


[PATCH] D102343: [clang][patch][FPEnv} Initialization of C++ globals not strictfp aware

2021-07-19 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 359772.
mibintc added a reviewer: zahiraam.
mibintc added a comment.

Respond to @aaron.ballman 's review, rebased & used clang-format


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102343/new/

https://reviews.llvm.org/D102343

Files:
  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

Index: clang/unittests/Sema/ExternalSemaSourceTest.cpp
===
--- clang/unittests/Sema/ExternalSemaSourceTest.cpp
+++ clang/unittests/Sema/ExternalSemaSourceTest.cpp
@@ -163,7 +163,8 @@
   CurrentSema->getPreprocessor().getIdentifierInfo(CorrectTo);
   auto *NewFunction = FunctionDecl::Create(
   Context, DestContext, SourceLocation(), SourceLocation(), ToIdent,
-  Context.getFunctionType(Context.VoidTy, {}, {}), nullptr, SC_Static);
+  Context.getFunctionType(Context.VoidTy, {}, {}), nullptr, SC_Static,
+  /*UsesFPIntrin*/ false);
   DestContext->addDecl(NewFunction);
   TypoCorrection Correction(ToIdent);
   Correction.addCorrectionDecl(NewFunction);
Index: clang/test/CodeGen/fp-floatcontrol-stack.cpp
===
--- clang/test/CodeGen/fp-floatcontrol-stack.cpp
+++ clang/test/CodeGen/fp-floatcontrol-stack.cpp
@@ -6,6 +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
 float fun_default FUN(1)
 //CHECK-LABEL: define {{.*}} @_Z11fun_defaultf{{.*}}
 #if DEFAULT
@@ -28,6 +32,10 @@
 // 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
 float exc_on FUN(2)
 //CHECK-LABEL: define {{.*}} @_Z6exc_onf{{.*}}
 #if DEFAULT
@@ -46,7 +54,11 @@
 #endif
 
 #pragma float_control(pop)
-float exc_pop FUN(5)
+// 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
+float exc_pop FUN(5)
 //CHECK-LABEL: define {{.*}} @_Z7exc_popf{{.*}}
 #if DEFAULT
 //CHECK-DDEFAULT: call float @llvm.fmuladd{{.*}}
@@ -63,7 +75,7 @@
 #endif
 
 #pragma float_control(except, off)
-float exc_off FUN(5)
+float exc_off FUN(5)
 //CHECK-LABEL: define {{.*}} @_Z7exc_offf{{.*}}
 #if DEFAULT
 //CHECK-DDEFAULT: call float @llvm.fmuladd{{.*}}
@@ -80,7 +92,7 @@
 #endif
 
 #pragma float_control(precise, on, push)
-float precise_on FUN(3)
+float precise_on FUN(3)
 //CHECK-LABEL: define {{.*}} @_Z10precise_onf{{.*}}
 #if DEFAULT
 //CHECK-DDEFAULT: float {{.*}}llvm.fmuladd{{.*}}
@@ -97,7 +109,7 @@
 #endif
 
 #pragma float_control(pop)
-float precise_pop FUN(3)
+float precise_pop FUN(3)
 //CHECK-LABEL: define {{.*}} @_Z11precise_popf{{.*}}
 #if DEFAULT
 //CHECK-DDEFAULT: float {{.*}}llvm.fmuladd{{.*}}
@@ -113,7 +125,7 @@
 //CHECK-FAST: fadd fast float
 #endif
 #pragma float_control(precise, off)
-float precise_off FUN(4)
+float precise_off FUN(4)
 //CHECK-LABEL: define {{.*}} @_Z11precise_offf{{.*}}
 #if DEFAULT
 // Note: precise_off enables fp_contract=fast and the instructions
@@ -137,7 +149,7 @@
 #endif
 
 #pragma float_control(precise, on)
-float precise_on2 FUN(3)
+float precise_on2 FUN(3)
 //CHECK-LABEL: define {{.*}} @_Z11precise_on2f{{.*}}
 #if DEFAULT
 //CHECK-DDEFAULT: llvm.fmuladd{{.*}}
@@ -154,7 +166,7 @@
 #endif
 
 #pragma float_control(push)
-   

[PATCH] D105951: [clang] P2266 implicit moves STL workaround

2021-07-15 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

Intel compiles VS2019 #include files regularly with clang, and the file 
 compiled with -std:c++latest encounters this error report, which 
@aaron.ballman suggests is related to this effort.

  In file included from tst_incl_filesystem.cpp:2:
  c:/Program files (x86)/Microsoft Visual 
Studio/2019/Professional/VC/Tools/MSVC/14.28.29910/include\filesystem(3099,20): 
error: call to deleted constructor of 'unique_ptr'
  return _Cleaned_link;
 ^
  c:/Program files (x86)/Microsoft Visual 
Studio/2019/Professional/VC/Tools/MSVC/14.28.29910/include\memory(3566,5): 
note: 'unique_ptr' has been explicitly marked deleted here
  unique_ptr(const unique_ptr&) = delete;
  ^
  In file included from tst_incl_filesystem.cpp:2:
  c:/Program files (x86)/Microsoft Visual 
Studio/2019/Professional/VC/Tools/MSVC/14.28.29910/include\filesystem(3125,16): 
error: call to deleted constructor of 'unique_ptr'
  return _Cleaned_link;
 ^
  c:/Program files (x86)/Microsoft Visual 
Studio/2019/Professional/VC/Tools/MSVC/14.28.29910/include\memory(3566,5): 
note: 'unique_ptr' has been explicitly marked deleted here
  unique_ptr(const unique_ptr&) = delete;

I used creduce with the same command line, looking for that error diagnostic 
with std:c++latest versus no diagnostic with std:c++20 ; this smaller test 
case, with a few edits, is the result

  # 1 "test.cpp" 1
  # 2 "test.cpp" 3
  namespace std {
  template  struct b { static constexpr c = a; };
  template  using d = b;
  using e = d;
  template  using f = int;
  template  using g = int;
  template  constexpr am = e ::c;
  template  constexpr au = false;
  class h {
  public:
template  h(i);
template  using j = f>;
template , int, int>>> h(h &) = delete;
  };
  h k() {
h l(new wchar_t);
return l;
  }
  }
  # 22 "test.cpp" 2


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105951/new/

https://reviews.llvm.org/D105951

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


[PATCH] D100118: [clang] Add support for new builtin __arithmetic_fence to control floating point optimization, and new clang option fprotect-parens

2021-06-30 Thread Melanie Blower via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe773216f4636: [clang][patch] Add builtin __arithmetic_fence 
and option fprotect-parens (authored by mibintc).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100118/new/

https://reviews.llvm.org/D100118

Files:
  clang/docs/UsersManual.rst
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Basic/TargetInfo.h
  clang/include/clang/Driver/Options.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ExprConstant.cpp
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Basic/Targets/X86.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaCoroutine.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/AST/arithmetic-fence-builtin.c
  clang/test/CodeGen/arithmetic-fence-builtin.c
  clang/test/Driver/clang_f_opts.c
  clang/test/Sema/arithmetic-fence-builtin.c

Index: clang/test/Sema/arithmetic-fence-builtin.c
===
--- /dev/null
+++ clang/test/Sema/arithmetic-fence-builtin.c
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -o - -verify -x c++ %s
+// RUN: %clang_cc1 -triple ppc64le -DPPC -emit-llvm -o - -verify -x c++ %s
+// RUN: not %clang_cc1 -triple ppc64le -DPPC -emit-llvm -o - -x c++ %s \
+// RUN:-fprotect-parens 2>&1 | FileCheck -check-prefix=PPC %s
+#ifndef PPC
+int v;
+template  T addT(T a, T b) {
+  T *q = __arithmetic_fence(&a);
+  // expected-error@-1 {{invalid operand of type 'float *' where floating, complex or a vector of such types is required}}
+  // expected-error@-2 {{invalid operand of type 'int *' where floating, complex or a vector of such types is required}}
+  return __arithmetic_fence(a + b);
+  // expected-error@-1 {{invalid operand of type 'int' where floating, complex or a vector of such types is required}}
+}
+int addit(int a, int b) {
+  float x, y;
+  typedef struct {
+int a, b;
+  } stype;
+  stype s;
+  s = __arithmetic_fence(s);// expected-error {{invalid operand of type 'stype' where floating, complex or a vector of such types is required}}
+  x = __arithmetic_fence(); // expected-error {{too few arguments to function call, expected 1, have 0}}
+  x = __arithmetic_fence(x, y); // expected-error {{too many arguments to function call, expected 1, have 2}}
+  // Complex is supported.
+  _Complex double cd, cd1;
+  cd = __arithmetic_fence(cd1);
+  // Vector is supported.
+  typedef float __v4hi __attribute__((__vector_size__(8)));
+  __v4hi vec1, vec2;
+  vec1 = __arithmetic_fence(vec2);
+
+  v = __arithmetic_fence(a + b); // expected-error {{invalid operand of type 'int' where floating, complex or a vector of such types is required}}
+  float f = addT(a, b);   // expected-note {{in instantiation of function template specialization 'addT' requested here}}
+  int i = addT(1, 2);   // expected-note {{in instantiation of function template specialization 'addT' requested here}}
+  constexpr float d = 1.0 + 2.0;
+  constexpr float c = __arithmetic_fence(1.0 + 2.0);
+  constexpr float e = __arithmetic_fence(d);
+  return 0;
+}
+bool func(float f1, float f2, float f3) {
+  return (f1 == f2 && f1 == f3) || f2 == f3; // Should not warn here
+}
+static_assert( __arithmetic_fence(1.0 + 2.0), "message" );
+#else
+float addit(float a, float b) {
+  return __arithmetic_fence(a+b); // expected-error {{builtin is not supported on this target}}
+}
+#endif
+//PPC: error: option '-fprotect-parens' cannot be specified on this target
Index: clang/test/Driver/clang_f_opts.c
===
--- clang/test/Driver/clang_f_opts.c
+++ clang/test/Driver/clang_f_opts.c
@@ -1,13 +1,14 @@
 // REQUIRES: clang-driver
 
 // RUN: %clang -### -S -fasm -fblocks -fbuiltin -fno-math-errno -fcommon -fpascal-strings -fno-blocks -fno-builtin -fmath-errno -fno-common -fno-pascal-strings -fblocks -fbuiltin -fmath-errno -fcommon -fpascal-strings -fsplit-stack %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS1 %s
-// RUN: %clang -### -S -fasm -fblocks -fbuiltin -fno-math-errno -fcommon -fpascal-strings -fno-asm -fno-blocks -fno-builtin -fmath-errno -fno-common -fno-pascal-strings -fno-show-source-location -fshort-enums %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS2 %s
+// RUN: %clang -### -S -fasm -fblocks -fbuiltin -fno-math-errno -fcommon -fpascal-strings -fno-asm -fno-blocks -fno-builtin -fmath-errno -fno-common -fno-pascal-strings -fno-show-source-location -fshort-enums -fprotect-parens %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS2 %s
 
 // CHECK-OPTIONS1: -fsplit-stack
 // CHECK-OPTIONS1: -fgnu-keywords
 // CHECK-OPTIONS1: -fblocks
 // CHECK-OPTIONS1: -fpascal-strings
 
+// CHECK-OPTIONS2: -fprotect-parens
 // CHECK-OPTIONS2: -fmath-errno
 // C

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

2021-06-29 Thread Melanie Blower via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGaaba37187fda: [clang][PATCH][nfc] Refactor 
TargetInfo::adjust to pass DiagnosticsEngine to… (authored by mibintc).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104729/new/

https://reviews.llvm.org/D104729

Files:
  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

Index: lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
@@ -704,7 +704,7 @@
   if (!instance->hasTarget())
 return nullptr;
 
-  instance->getTarget().adjust(instance->getLangOpts());
+  instance->getTarget().adjust(*diagnostics_engine, instance->getLangOpts());
 
   if (!action->BeginSourceFile(*instance,
instance->getFrontendOpts().Inputs[0]))
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -658,7 +658,8 @@
   //
   // FIXME: We shouldn't need to do this, the target should be immutable once
   // created. This complexity should be lifted elsewhere.
-  m_compiler->getTarget().adjust(m_compiler->getLangOpts());
+  m_compiler->getTarget().adjust(m_compiler->getDiagnostics(),
+		 m_compiler->getLangOpts());
 
   // 6. Set up the diagnostic buffer for reporting errors
 
Index: clang/tools/clang-import-test/clang-import-test.cpp
===
--- clang/tools/clang-import-test/clang-import-test.cpp
+++ clang/tools/clang-import-test/clang-import-test.cpp
@@ -208,7 +208,7 @@
   TargetInfo *TI = TargetInfo::CreateTargetInfo(
   Ins->getDiagnostics(), Ins->getInvocation().TargetOpts);
   Ins->setTarget(TI);
-  Ins->getTarget().adjust(Ins->getLangOpts());
+  Ins->getTarget().adjust(Ins->getDiagnostics(), Ins->getLangOpts());
   Ins->createFileManager();
   Ins->createSourceManager(Ins->getFileManager());
   Ins->createPreprocessor(TU_Complete);
Index: clang/lib/Interpreter/Interpreter.cpp
===
--- clang/lib/Interpreter/Interpreter.cpp
+++ clang/lib/Interpreter/Interpreter.cpp
@@ -110,7 +110,7 @@
"Initialization failed. "
"Target is missing");
 
-  Clang->getTarget().adjust(Clang->getLangOpts());
+  Clang->getTarget().adjust(Clang->getDiagnostics(), Clang->getLangOpts());
 
   return std::move(Clang);
 }
Index: clang/lib/Frontend/CompilerInstance.cpp
===
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -142,7 +142,7 @@
   // Inform the target of the language options.
   // FIXME: We shouldn't need to do this, the target should be immutable once
   // created. This complexity should be lifted elsewhere.
-  getTarget().adjust(getLangOpts());
+  getTarget().adjust(getDiagnostics(), getLangOpts());
 
   // Adjust target options based on codegen options.
   getTarget().adjustTargetOptions(getCodeGenOpts(), getTargetOpts());
@@ -457,7 +457,7 @@
   getSourceManager(), *HeaderInfo, *this,
   /*IdentifierInfoLookup=*/nullptr,
   /*OwnsHeaderSearch=*/true, TUKind);
-  getTarget().adjust(getLangOpts());
+  getTarget().adjust(getDiagnostics(), getLangOpts());
   PP->Initialize(getTarget(), getAuxTarget());
 
   if (PPOpts.DetailedRecord)
Index: clang/lib/Frontend/ASTUnit.cpp
===
--- clang/lib/Frontend/ASTUnit.cpp
+++ clang/lib/Frontend/ASTUnit.cpp
@@ -588,7 +588,7 @@
 //
 // FIXME: We shouldn't need to do this, the target should be immutable once
 // created. This complexity should be lifted elsewhere.
-Target->adjust(LangOpt);
+Target->adjust(PP.getDiagnostics(), LangOpt);
 
 // Initialize the preprocessor.
 PP.Initialize(*Target);
Index

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

2021-06-28 Thread Melanie Blower via Phabricator via cfe-commits
mibintc reopened this revision.
mibintc added a comment.
This revision is now accepted and ready to land.
Herald added a subscriber: JDevlieghere.

More buildbot failures


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104729/new/

https://reviews.llvm.org/D104729

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


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

2021-06-28 Thread Melanie Blower via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2dbe1c675fe9: [clang][PATCH][nfc] Refactor 
TargetInfo::adjust to pass DiagnosticsEngine to… (authored by mibintc).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Changed prior to commit:
  https://reviews.llvm.org/D104729?vs=354932&id=354981#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104729/new/

https://reviews.llvm.org/D104729

Files:
  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

Index: lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
@@ -704,7 +704,7 @@
   if (!instance->hasTarget())
 return nullptr;
 
-  instance->getTarget().adjust(instance->getLangOpts());
+  instance->getTarget().adjust(*diagnostics_engine, instance->getLangOpts());
 
   if (!action->BeginSourceFile(*instance,
instance->getFrontendOpts().Inputs[0]))
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -658,7 +658,8 @@
   //
   // FIXME: We shouldn't need to do this, the target should be immutable once
   // created. This complexity should be lifted elsewhere.
-  m_compiler->getTarget().adjust(m_compiler->getLangOpts());
+  m_compiler->getTarget().adjust(m_compiler->getDiagnostics(),
+		 m_compiler->getLangOpts());
 
   // 6. Set up the diagnostic buffer for reporting errors
 
Index: clang/tools/clang-import-test/clang-import-test.cpp
===
--- clang/tools/clang-import-test/clang-import-test.cpp
+++ clang/tools/clang-import-test/clang-import-test.cpp
@@ -208,7 +208,7 @@
   TargetInfo *TI = TargetInfo::CreateTargetInfo(
   Ins->getDiagnostics(), Ins->getInvocation().TargetOpts);
   Ins->setTarget(TI);
-  Ins->getTarget().adjust(Ins->getLangOpts());
+  Ins->getTarget().adjust(Ins->getDiagnostics(), Ins->getLangOpts());
   Ins->createFileManager();
   Ins->createSourceManager(Ins->getFileManager());
   Ins->createPreprocessor(TU_Complete);
Index: clang/lib/Interpreter/Interpreter.cpp
===
--- clang/lib/Interpreter/Interpreter.cpp
+++ clang/lib/Interpreter/Interpreter.cpp
@@ -110,7 +110,7 @@
"Initialization failed. "
"Target is missing");
 
-  Clang->getTarget().adjust(Clang->getLangOpts());
+  Clang->getTarget().adjust(Clang->getDiagnostics(), Clang->getLangOpts());
 
   return std::move(Clang);
 }
Index: clang/lib/Frontend/CompilerInstance.cpp
===
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -142,7 +142,7 @@
   // Inform the target of the language options.
   // FIXME: We shouldn't need to do this, the target should be immutable once
   // created. This complexity should be lifted elsewhere.
-  getTarget().adjust(getLangOpts());
+  getTarget().adjust(getDiagnostics(), getLangOpts());
 
   // Adjust target options based on codegen options.
   getTarget().adjustTargetOptions(getCodeGenOpts(), getTargetOpts());
@@ -457,7 +457,7 @@
   getSourceManager(), *HeaderInfo, *this,
   /*IdentifierInfoLookup=*/nullptr,
   /*OwnsHeaderSearch=*/true, TUKind);
-  getTarget().adjust(getLangOpts());
+  getTarget().adjust(getDiagnostics(), getLangOpts());
   PP->Initialize(getTarget(), getAuxTarget());
 
   if (PPOpts.DetailedRecord)
Index: clang/lib/Frontend/ASTUnit.cpp
===
--- clang/lib/Frontend/ASTUnit.cpp
+++ clang/lib/Frontend/ASTUnit.cpp
@@ -588,7 +588,7 @@
 //
 // FIXME: We shouldn't need to do this, the target should be immutable once
 // created. This complexity should be lifted elsewhere

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

2021-06-28 Thread Melanie Blower via Phabricator via cfe-commits
mibintc reopened this revision.
mibintc added a comment.
This revision is now accepted and ready to land.

buildbot fails in lldb, will submit updates


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104729/new/

https://reviews.llvm.org/D104729

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


[PATCH] D100118: [clang] Add support for new builtin __arithmetic_fence to control floating point optimization, and new clang option fprotect-parens

2021-06-28 Thread Melanie Blower via Phabricator via cfe-commits
mibintc reopened this revision.
mibintc added a comment.
This revision is now accepted and ready to land.

buildbot fails on lldb need to update this patch


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100118/new/

https://reviews.llvm.org/D100118

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


[PATCH] D100118: [clang] Add support for new builtin __arithmetic_fence to control floating point optimization, and new clang option fprotect-parens

2021-06-28 Thread Melanie Blower via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4f1238e44d80: [clang][patch][fpenv] Add builtin 
__arithmetic_fence and option fprotect-parens (authored by mibintc).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100118/new/

https://reviews.llvm.org/D100118

Files:
  clang/docs/UsersManual.rst
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Basic/TargetInfo.h
  clang/include/clang/Driver/Options.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ExprConstant.cpp
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Basic/Targets/X86.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaCoroutine.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/AST/arithmetic-fence-builtin.c
  clang/test/CodeGen/arithmetic-fence-builtin.c
  clang/test/Driver/clang_f_opts.c
  clang/test/Sema/arithmetic-fence-builtin.c

Index: clang/test/Sema/arithmetic-fence-builtin.c
===
--- /dev/null
+++ clang/test/Sema/arithmetic-fence-builtin.c
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -o - -verify -x c++ %s
+// RUN: %clang_cc1 -triple ppc64le -DPPC -emit-llvm -o - -verify -x c++ %s
+// RUN: not %clang_cc1 -triple ppc64le -DPPC -emit-llvm -o - -x c++ %s \
+// RUN:-fprotect-parens 2>&1 | FileCheck -check-prefix=PPC %s
+#ifndef PPC
+int v;
+template  T addT(T a, T b) {
+  T *q = __arithmetic_fence(&a);
+  // expected-error@-1 {{invalid operand of type 'float *' where floating, complex or a vector of such types is required}}
+  // expected-error@-2 {{invalid operand of type 'int *' where floating, complex or a vector of such types is required}}
+  return __arithmetic_fence(a + b);
+  // expected-error@-1 {{invalid operand of type 'int' where floating, complex or a vector of such types is required}}
+}
+int addit(int a, int b) {
+  float x, y;
+  typedef struct {
+int a, b;
+  } stype;
+  stype s;
+  s = __arithmetic_fence(s);// expected-error {{invalid operand of type 'stype' where floating, complex or a vector of such types is required}}
+  x = __arithmetic_fence(); // expected-error {{too few arguments to function call, expected 1, have 0}}
+  x = __arithmetic_fence(x, y); // expected-error {{too many arguments to function call, expected 1, have 2}}
+  // Complex is supported.
+  _Complex double cd, cd1;
+  cd = __arithmetic_fence(cd1);
+  // Vector is supported.
+  typedef float __v4hi __attribute__((__vector_size__(8)));
+  __v4hi vec1, vec2;
+  vec1 = __arithmetic_fence(vec2);
+
+  v = __arithmetic_fence(a + b); // expected-error {{invalid operand of type 'int' where floating, complex or a vector of such types is required}}
+  float f = addT(a, b);   // expected-note {{in instantiation of function template specialization 'addT' requested here}}
+  int i = addT(1, 2);   // expected-note {{in instantiation of function template specialization 'addT' requested here}}
+  constexpr float d = 1.0 + 2.0;
+  constexpr float c = __arithmetic_fence(1.0 + 2.0);
+  constexpr float e = __arithmetic_fence(d);
+  return 0;
+}
+bool func(float f1, float f2, float f3) {
+  return (f1 == f2 && f1 == f3) || f2 == f3; // Should not warn here
+}
+static_assert( __arithmetic_fence(1.0 + 2.0), "message" );
+#else
+float addit(float a, float b) {
+  return __arithmetic_fence(a+b); // expected-error {{builtin is not supported on this target}}
+}
+#endif
+//PPC: error: option '-fprotect-parens' cannot be specified on this target
Index: clang/test/Driver/clang_f_opts.c
===
--- clang/test/Driver/clang_f_opts.c
+++ clang/test/Driver/clang_f_opts.c
@@ -1,13 +1,14 @@
 // REQUIRES: clang-driver
 
 // RUN: %clang -### -S -fasm -fblocks -fbuiltin -fno-math-errno -fcommon -fpascal-strings -fno-blocks -fno-builtin -fmath-errno -fno-common -fno-pascal-strings -fblocks -fbuiltin -fmath-errno -fcommon -fpascal-strings -fsplit-stack %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS1 %s
-// RUN: %clang -### -S -fasm -fblocks -fbuiltin -fno-math-errno -fcommon -fpascal-strings -fno-asm -fno-blocks -fno-builtin -fmath-errno -fno-common -fno-pascal-strings -fno-show-source-location -fshort-enums %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS2 %s
+// RUN: %clang -### -S -fasm -fblocks -fbuiltin -fno-math-errno -fcommon -fpascal-strings -fno-asm -fno-blocks -fno-builtin -fmath-errno -fno-common -fno-pascal-strings -fno-show-source-location -fshort-enums -fprotect-parens %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS2 %s
 
 // CHECK-OPTIONS1: -fsplit-stack
 // CHECK-OPTIONS1: -fgnu-keywords
 // CHECK-OPTIONS1: -fblocks
 // CHECK-OPTIONS1: -fpascal-strings
 
+// CHECK-OP

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

2021-06-28 Thread Melanie Blower via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2c02b0c3f454: [clang][PATCH][nfc] Refactor 
TargetInfo::adjust to pass DiagnosticsEngine to… (authored by mibintc).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104729/new/

https://reviews.llvm.org/D104729

Files:
  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

Index: clang/tools/clang-import-test/clang-import-test.cpp
===
--- clang/tools/clang-import-test/clang-import-test.cpp
+++ clang/tools/clang-import-test/clang-import-test.cpp
@@ -208,7 +208,7 @@
   TargetInfo *TI = TargetInfo::CreateTargetInfo(
   Ins->getDiagnostics(), Ins->getInvocation().TargetOpts);
   Ins->setTarget(TI);
-  Ins->getTarget().adjust(Ins->getLangOpts());
+  Ins->getTarget().adjust(Ins->getDiagnostics(), Ins->getLangOpts());
   Ins->createFileManager();
   Ins->createSourceManager(Ins->getFileManager());
   Ins->createPreprocessor(TU_Complete);
Index: clang/lib/Interpreter/Interpreter.cpp
===
--- clang/lib/Interpreter/Interpreter.cpp
+++ clang/lib/Interpreter/Interpreter.cpp
@@ -110,7 +110,7 @@
"Initialization failed. "
"Target is missing");
 
-  Clang->getTarget().adjust(Clang->getLangOpts());
+  Clang->getTarget().adjust(Clang->getDiagnostics(), Clang->getLangOpts());
 
   return std::move(Clang);
 }
Index: clang/lib/Frontend/CompilerInstance.cpp
===
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -142,7 +142,7 @@
   // Inform the target of the language options.
   // FIXME: We shouldn't need to do this, the target should be immutable once
   // created. This complexity should be lifted elsewhere.
-  getTarget().adjust(getLangOpts());
+  getTarget().adjust(getDiagnostics(), getLangOpts());
 
   // Adjust target options based on codegen options.
   getTarget().adjustTargetOptions(getCodeGenOpts(), getTargetOpts());
@@ -457,7 +457,7 @@
   getSourceManager(), *HeaderInfo, *this,
   /*IdentifierInfoLookup=*/nullptr,
   /*OwnsHeaderSearch=*/true, TUKind);
-  getTarget().adjust(getLangOpts());
+  getTarget().adjust(getDiagnostics(), getLangOpts());
   PP->Initialize(getTarget(), getAuxTarget());
 
   if (PPOpts.DetailedRecord)
Index: clang/lib/Frontend/ASTUnit.cpp
===
--- clang/lib/Frontend/ASTUnit.cpp
+++ clang/lib/Frontend/ASTUnit.cpp
@@ -588,7 +588,7 @@
 //
 // FIXME: We shouldn't need to do this, the target should be immutable once
 // created. This complexity should be lifted elsewhere.
-Target->adjust(LangOpt);
+Target->adjust(PP.getDiagnostics(), LangOpt);
 
 // Initialize the preprocessor.
 PP.Initialize(*Target);
Index: clang/lib/Basic/Targets/WebAssembly.h
===
--- clang/lib/Basic/Targets/WebAssembly.h
+++ clang/lib/Basic/Targets/WebAssembly.h
@@ -138,7 +138,7 @@
 
   bool hasProtectedVisibility() const override { return false; }
 
-  void adjust(LangOptions &Opts) override;
+  void adjust(DiagnosticsEngine &Diags, LangOptions &Opts) override;
 };
 
 class LLVM_LIBRARY_VISIBILITY WebAssembly32TargetInfo
Index: clang/lib/Basic/Targets/WebAssembly.cpp
===
--- clang/lib/Basic/Targets/WebAssembly.cpp
+++ clang/lib/Basic/Targets/WebAssembly.cpp
@@ -234,7 +234,8 @@
  Builtin::FirstTSBuiltin);
 }
 
-void WebAssemblyTargetInfo::adjust(LangOptions &Opts) {
+void WebAssemblyTargetInfo::adjust(DiagnosticsEngine &Diags,
+   LangOptions &Opts) {
   // If the Atomics feature isn't available, turn off POSIXThreads and
   // ThreadModel, so that we don't predefine _REENTRANT or __STDCPP_THREADS__.
   if (!HasAtomics) {
Index: clang/lib/Basic/Targets/SPIR.h
===
--- clang/lib/Basic/Targets/SPIR.h
+++ clang/lib/Basic/Targets/SPIR.h
@@ -135,8 +135,8 @@
 AddrSpaceMap = DefaultIsGeneric ? &SPIRDefIsGenMap : &SPIRDefIsPrivMap;
   }
 
-  void adjust(LangOptions &Opts) override {
-TargetInfo::adjust

[PATCH] D99675: [llvm][clang] Create new intrinsic llvm.arithmetic.fence to control FP optimization at expression level

2021-06-28 Thread Melanie Blower via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG931e95687d6d: [llvm][clang][fpenv] Create new intrinsic 
llvm.arith.fence to control FP… (authored by mibintc).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D99675/new/

https://reviews.llvm.org/D99675

Files:
  llvm/docs/LangRef.rst
  llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
  llvm/include/llvm/CodeGen/BasicTTIImpl.h
  llvm/include/llvm/CodeGen/ISDOpcodes.h
  llvm/include/llvm/CodeGen/SelectionDAGISel.h
  llvm/include/llvm/IR/IRBuilder.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/include/llvm/Support/TargetOpcodes.def
  llvm/include/llvm/Target/Target.td
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
  llvm/test/CodeGen/X86/arithmetic_fence.ll
  llvm/test/CodeGen/X86/arithmetic_fence2.ll

Index: llvm/test/CodeGen/X86/arithmetic_fence2.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/arithmetic_fence2.ll
@@ -0,0 +1,170 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+sse2 | FileCheck %s --check-prefix=X86
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+sse2 | FileCheck %s --check-prefix=X64
+
+define double @f1(double %a) {
+; X86-LABEL: f1:
+; X86:   # %bb.0:
+; X86-NEXT:pushl %ebp
+; X86-NEXT:.cfi_def_cfa_offset 8
+; X86-NEXT:.cfi_offset %ebp, -8
+; X86-NEXT:movl %esp, %ebp
+; X86-NEXT:.cfi_def_cfa_register %ebp
+; X86-NEXT:andl $-8, %esp
+; X86-NEXT:subl $8, %esp
+; X86-NEXT:movsd {{.*#+}} xmm0 = mem[0],zero
+; X86-NEXT:mulsd {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0
+; X86-NEXT:movsd %xmm0, (%esp)
+; X86-NEXT:fldl (%esp)
+; X86-NEXT:movl %ebp, %esp
+; X86-NEXT:popl %ebp
+; X86-NEXT:.cfi_def_cfa %esp, 4
+; X86-NEXT:retl
+;
+; X64-LABEL: f1:
+; X64:   # %bb.0:
+; X64-NEXT:mulsd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
+; X64-NEXT:retq
+  %1 = fadd fast double %a, %a
+  %2 = fadd fast double %a, %a
+  %3 = fadd fast double %1, %2
+  ret double %3
+}
+
+define double @f2(double %a) {
+; X86-LABEL: f2:
+; X86:   # %bb.0:
+; X86-NEXT:pushl %ebp
+; X86-NEXT:.cfi_def_cfa_offset 8
+; X86-NEXT:.cfi_offset %ebp, -8
+; X86-NEXT:movl %esp, %ebp
+; X86-NEXT:.cfi_def_cfa_register %ebp
+; X86-NEXT:andl $-8, %esp
+; X86-NEXT:subl $8, %esp
+; X86-NEXT:movsd {{.*#+}} xmm0 = mem[0],zero
+; X86-NEXT:addsd %xmm0, %xmm0
+; X86-NEXT:movapd %xmm0, %xmm1
+; X86-NEXT:#ARITH_FENCE
+; X86-NEXT:addsd %xmm0, %xmm1
+; X86-NEXT:movsd %xmm1, (%esp)
+; X86-NEXT:fldl (%esp)
+; X86-NEXT:movl %ebp, %esp
+; X86-NEXT:popl %ebp
+; X86-NEXT:.cfi_def_cfa %esp, 4
+; X86-NEXT:retl
+;
+; X64-LABEL: f2:
+; X64:   # %bb.0:
+; X64-NEXT:addsd %xmm0, %xmm0
+; X64-NEXT:movapd %xmm0, %xmm1
+; X64-NEXT:#ARITH_FENCE
+; X64-NEXT:addsd %xmm0, %xmm1
+; X64-NEXT:movapd %xmm1, %xmm0
+; X64-NEXT:retq
+  %1 = fadd fast double %a, %a
+  %t = call double @llvm.arithmetic.fence.f64(double %1)
+  %2 = fadd fast double %a, %a
+  %3 = fadd fast double %t, %2
+  ret double %3
+}
+
+define <2 x float> @f3(<2 x float> %a) {
+; X86-LABEL: f3:
+; X86:   # %bb.0:
+; X86-NEXT:mulps {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0
+; X86-NEXT:retl
+;
+; X64-LABEL: f3:
+; X64:   # %bb.0:
+; X64-NEXT:mulps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
+; X64-NEXT:retq
+  %1 = fadd fast <2 x float> %a, %a
+  %2 = fadd fast <2 x float> %a, %a
+  %3 = fadd fast <2 x float> %1, %2
+  ret <2 x float> %3
+}
+
+define <2 x float> @f4(<2 x float> %a) {
+; X86-LABEL: f4:
+; X86:   # %bb.0:
+; X86-NEXT:addps %xmm0, %xmm0
+; X86-NEXT:movaps %xmm0, %xmm1
+; X86-NEXT:#ARITH_FENCE
+; X86-NEXT:addps %xmm0, %xmm1
+; X86-NEXT:movaps %xmm1, %xmm0
+; X86-NEXT:retl
+;
+; X64-LABEL: f4:
+; X64:   # %bb.0:
+; X64-NEXT:addps %xmm0, %xmm0
+; X64-NEXT:movaps %xmm0, %xmm1
+; X64-NEXT:#ARITH_FENCE
+; X64-NEXT:addps %xmm0, %xmm1
+; X64-NEXT:movaps %xmm1, %xmm0
+; X64-NEXT:retq
+  %1 = fadd fast <2 x float> %a, %a
+  %t = call <2 x float> @llvm.arithmetic.fence.v2f32(<2 x float> %1)
+  %2 = fadd fast <2 x float> %a, %a
+  %3 = fadd fast <2 x float> %t, %2
+  ret <2 x float> %3
+}
+
+define <8 x float> @f5(<8 x float> %a) {
+; X86-LABEL: f5:
+; X86:   # %bb.0:
+; X86-NEXT:movaps {{.*#+}} xmm2 = [4.0E+0,4.0E+0,4.0E+0,4.0E+0]
+; X86-NEXT:mulps %xmm2, %xmm0
+; X86-NEXT:mulps %xmm2, %xmm1
+; X86-NEXT:retl
+;
+; X64-LABEL: f5:
+; X64:   # %bb.0:
+; X64-NEXT:movaps {{.*#+}} xmm2 = [4.0E+0,4.0E+0,4.0E+0,4.0E+0]
+; X64-NEXT:mulps %xmm2, %xmm0
+;

[PATCH] D100118: [clang] Add support for new builtin __arithmetic_fence to control floating point optimization, and new clang option fprotect-parens

2021-06-24 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 354301.
mibintc added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100118/new/

https://reviews.llvm.org/D100118

Files:
  clang/docs/UsersManual.rst
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Basic/TargetInfo.h
  clang/include/clang/Driver/Options.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ExprConstant.cpp
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Basic/Targets/X86.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaCoroutine.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/AST/arithmetic-fence-builtin.c
  clang/test/CodeGen/arithmetic-fence-builtin.c
  clang/test/Driver/clang_f_opts.c
  clang/test/Sema/arithmetic-fence-builtin.c

Index: clang/test/Sema/arithmetic-fence-builtin.c
===
--- /dev/null
+++ clang/test/Sema/arithmetic-fence-builtin.c
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -o - -verify -x c++ %s
+// RUN: %clang_cc1 -triple ppc64le -DPPC -emit-llvm -o - -verify -x c++ %s
+// RUN: not %clang_cc1 -triple ppc64le -DPPC -emit-llvm -o - -x c++ %s \
+// RUN:-fprotect-parens 2>&1 | FileCheck -check-prefix=PPC %s
+#ifndef PPC
+int v;
+template  T addT(T a, T b) {
+  T *q = __arithmetic_fence(&a);
+  // expected-error@-1 {{invalid operand of type 'float *' where floating, complex or a vector of such types is required}}
+  // expected-error@-2 {{invalid operand of type 'int *' where floating, complex or a vector of such types is required}}
+  return __arithmetic_fence(a + b);
+  // expected-error@-1 {{invalid operand of type 'int' where floating, complex or a vector of such types is required}}
+}
+int addit(int a, int b) {
+  float x, y;
+  typedef struct {
+int a, b;
+  } stype;
+  stype s;
+  s = __arithmetic_fence(s);// expected-error {{invalid operand of type 'stype' where floating, complex or a vector of such types is required}}
+  x = __arithmetic_fence(); // expected-error {{too few arguments to function call, expected 1, have 0}}
+  x = __arithmetic_fence(x, y); // expected-error {{too many arguments to function call, expected 1, have 2}}
+  // Complex is supported.
+  _Complex double cd, cd1;
+  cd = __arithmetic_fence(cd1);
+  // Vector is supported.
+  typedef float __v4hi __attribute__((__vector_size__(8)));
+  __v4hi vec1, vec2;
+  vec1 = __arithmetic_fence(vec2);
+
+  v = __arithmetic_fence(a + b); // expected-error {{invalid operand of type 'int' where floating, complex or a vector of such types is required}}
+  float f = addT(a, b);   // expected-note {{in instantiation of function template specialization 'addT' requested here}}
+  int i = addT(1, 2);   // expected-note {{in instantiation of function template specialization 'addT' requested here}}
+  constexpr float d = 1.0 + 2.0;
+  constexpr float c = __arithmetic_fence(1.0 + 2.0);
+  constexpr float e = __arithmetic_fence(d);
+  return 0;
+}
+bool func(float f1, float f2, float f3) {
+  return (f1 == f2 && f1 == f3) || f2 == f3; // Should not warn here
+}
+static_assert( __arithmetic_fence(1.0 + 2.0), "message" );
+#else
+float addit(float a, float b) {
+  return __arithmetic_fence(a+b); // expected-error {{builtin is not supported on this target}}
+}
+#endif
+//PPC: error: option '-fprotect-parens' cannot be specified on this target
Index: clang/test/Driver/clang_f_opts.c
===
--- clang/test/Driver/clang_f_opts.c
+++ clang/test/Driver/clang_f_opts.c
@@ -1,13 +1,14 @@
 // REQUIRES: clang-driver
 
 // RUN: %clang -### -S -fasm -fblocks -fbuiltin -fno-math-errno -fcommon -fpascal-strings -fno-blocks -fno-builtin -fmath-errno -fno-common -fno-pascal-strings -fblocks -fbuiltin -fmath-errno -fcommon -fpascal-strings -fsplit-stack %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS1 %s
-// RUN: %clang -### -S -fasm -fblocks -fbuiltin -fno-math-errno -fcommon -fpascal-strings -fno-asm -fno-blocks -fno-builtin -fmath-errno -fno-common -fno-pascal-strings -fno-show-source-location -fshort-enums %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS2 %s
+// RUN: %clang -### -S -fasm -fblocks -fbuiltin -fno-math-errno -fcommon -fpascal-strings -fno-asm -fno-blocks -fno-builtin -fmath-errno -fno-common -fno-pascal-strings -fno-show-source-location -fshort-enums -fprotect-parens %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS2 %s
 
 // CHECK-OPTIONS1: -fsplit-stack
 // CHECK-OPTIONS1: -fgnu-keywords
 // CHECK-OPTIONS1: -fblocks
 // CHECK-OPTIONS1: -fpascal-strings
 
+// CHECK-OPTIONS2: -fprotect-parens
 // CHECK-OPTIONS2: -fmath-errno
 // CHECK-OPTIONS2: -fno-gnu-keywords
 // CHECK-OPTIONS2: -fno-builtin
Index: clang/test/CodeGen/arithmetic-fence-builtin.c
=

[PATCH] D99675: [llvm][clang] Create new intrinsic llvm.arithmetic.fence to control FP optimization at expression level

2021-06-24 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 354300.
mibintc added a comment.

Rebasing.  Hope this clears lit fails.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D99675/new/

https://reviews.llvm.org/D99675

Files:
  llvm/docs/LangRef.rst
  llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
  llvm/include/llvm/CodeGen/BasicTTIImpl.h
  llvm/include/llvm/CodeGen/ISDOpcodes.h
  llvm/include/llvm/CodeGen/SelectionDAGISel.h
  llvm/include/llvm/IR/IRBuilder.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/include/llvm/Support/TargetOpcodes.def
  llvm/include/llvm/Target/Target.td
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
  llvm/test/CodeGen/X86/arithmetic_fence.ll
  llvm/test/CodeGen/X86/arithmetic_fence2.ll

Index: llvm/test/CodeGen/X86/arithmetic_fence2.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/arithmetic_fence2.ll
@@ -0,0 +1,170 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+sse2 | FileCheck %s --check-prefix=X86
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+sse2 | FileCheck %s --check-prefix=X64
+
+define double @f1(double %a) {
+; X86-LABEL: f1:
+; X86:   # %bb.0:
+; X86-NEXT:pushl %ebp
+; X86-NEXT:.cfi_def_cfa_offset 8
+; X86-NEXT:.cfi_offset %ebp, -8
+; X86-NEXT:movl %esp, %ebp
+; X86-NEXT:.cfi_def_cfa_register %ebp
+; X86-NEXT:andl $-8, %esp
+; X86-NEXT:subl $8, %esp
+; X86-NEXT:movsd {{.*#+}} xmm0 = mem[0],zero
+; X86-NEXT:mulsd {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0
+; X86-NEXT:movsd %xmm0, (%esp)
+; X86-NEXT:fldl (%esp)
+; X86-NEXT:movl %ebp, %esp
+; X86-NEXT:popl %ebp
+; X86-NEXT:.cfi_def_cfa %esp, 4
+; X86-NEXT:retl
+;
+; X64-LABEL: f1:
+; X64:   # %bb.0:
+; X64-NEXT:mulsd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
+; X64-NEXT:retq
+  %1 = fadd fast double %a, %a
+  %2 = fadd fast double %a, %a
+  %3 = fadd fast double %1, %2
+  ret double %3
+}
+
+define double @f2(double %a) {
+; X86-LABEL: f2:
+; X86:   # %bb.0:
+; X86-NEXT:pushl %ebp
+; X86-NEXT:.cfi_def_cfa_offset 8
+; X86-NEXT:.cfi_offset %ebp, -8
+; X86-NEXT:movl %esp, %ebp
+; X86-NEXT:.cfi_def_cfa_register %ebp
+; X86-NEXT:andl $-8, %esp
+; X86-NEXT:subl $8, %esp
+; X86-NEXT:movsd {{.*#+}} xmm0 = mem[0],zero
+; X86-NEXT:addsd %xmm0, %xmm0
+; X86-NEXT:movapd %xmm0, %xmm1
+; X86-NEXT:#ARITH_FENCE
+; X86-NEXT:addsd %xmm0, %xmm1
+; X86-NEXT:movsd %xmm1, (%esp)
+; X86-NEXT:fldl (%esp)
+; X86-NEXT:movl %ebp, %esp
+; X86-NEXT:popl %ebp
+; X86-NEXT:.cfi_def_cfa %esp, 4
+; X86-NEXT:retl
+;
+; X64-LABEL: f2:
+; X64:   # %bb.0:
+; X64-NEXT:addsd %xmm0, %xmm0
+; X64-NEXT:movapd %xmm0, %xmm1
+; X64-NEXT:#ARITH_FENCE
+; X64-NEXT:addsd %xmm0, %xmm1
+; X64-NEXT:movapd %xmm1, %xmm0
+; X64-NEXT:retq
+  %1 = fadd fast double %a, %a
+  %t = call double @llvm.arithmetic.fence.f64(double %1)
+  %2 = fadd fast double %a, %a
+  %3 = fadd fast double %t, %2
+  ret double %3
+}
+
+define <2 x float> @f3(<2 x float> %a) {
+; X86-LABEL: f3:
+; X86:   # %bb.0:
+; X86-NEXT:mulps {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0
+; X86-NEXT:retl
+;
+; X64-LABEL: f3:
+; X64:   # %bb.0:
+; X64-NEXT:mulps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
+; X64-NEXT:retq
+  %1 = fadd fast <2 x float> %a, %a
+  %2 = fadd fast <2 x float> %a, %a
+  %3 = fadd fast <2 x float> %1, %2
+  ret <2 x float> %3
+}
+
+define <2 x float> @f4(<2 x float> %a) {
+; X86-LABEL: f4:
+; X86:   # %bb.0:
+; X86-NEXT:addps %xmm0, %xmm0
+; X86-NEXT:movaps %xmm0, %xmm1
+; X86-NEXT:#ARITH_FENCE
+; X86-NEXT:addps %xmm0, %xmm1
+; X86-NEXT:movaps %xmm1, %xmm0
+; X86-NEXT:retl
+;
+; X64-LABEL: f4:
+; X64:   # %bb.0:
+; X64-NEXT:addps %xmm0, %xmm0
+; X64-NEXT:movaps %xmm0, %xmm1
+; X64-NEXT:#ARITH_FENCE
+; X64-NEXT:addps %xmm0, %xmm1
+; X64-NEXT:movaps %xmm1, %xmm0
+; X64-NEXT:retq
+  %1 = fadd fast <2 x float> %a, %a
+  %t = call <2 x float> @llvm.arithmetic.fence.v2f32(<2 x float> %1)
+  %2 = fadd fast <2 x float> %a, %a
+  %3 = fadd fast <2 x float> %t, %2
+  ret <2 x float> %3
+}
+
+define <8 x float> @f5(<8 x float> %a) {
+; X86-LABEL: f5:
+; X86:   # %bb.0:
+; X86-NEXT:movaps {{.*#+}} xmm2 = [4.0E+0,4.0E+0,4.0E+0,4.0E+0]
+; X86-NEXT:mulps %xmm2, %xmm0
+; X86-NEXT:mulps %xmm2, %xmm1
+; X86-NEXT:retl
+;
+; X64-LABEL: f5:
+; X64:   # %bb.0:
+; X64-NEXT:movaps {{.*#+}} xmm2 = [4.0E+0,4.0E+0,4.0E+0,4.0E+0]
+; X64-NEXT:mulps %xmm2, %xmm0
+; X64-NEXT:mulps %xmm2, %xmm1
+; X64-NEXT:retq
+  %1 = fadd fast <8 x float> %a, %a
+  %2 = fadd fast <8 x float> %a, %a
+  %3 = fadd fast <8 

[PATCH] D100118: [clang] Add support for new builtin __arithmetic_fence to control floating point optimization, and new clang option fprotect-parens

2021-06-23 Thread Melanie Blower via Phabricator via cfe-commits
mibintc marked 11 inline comments as done.
mibintc added a comment.

some inline replies.  I think this is all set now.




Comment at: clang/lib/Sema/SemaExpr.cpp:4026
+  !E->isLValue() &&
+  (ExprTy->isFloatingType() || (ExprTy->isComplexType( {
+return BuildBuiltinCallExpr(R, Builtin::BI__arithmetic_fence, E);

mibintc wrote:
> aaron.ballman wrote:
> > Do you have to worry about vector types here as well?
> Oh yes, i didn't get this one. 
Yes thanks, i also added a little test case for this


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100118/new/

https://reviews.llvm.org/D100118

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


[PATCH] D100118: [clang] Add support for new builtin __arithmetic_fence to control floating point optimization, and new clang option fprotect-parens

2021-06-23 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 354061.
mibintc marked 2 inline comments as done.
mibintc added a comment.

Respond to @aaron.ballman 's review


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100118/new/

https://reviews.llvm.org/D100118

Files:
  clang/docs/UsersManual.rst
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Basic/TargetInfo.h
  clang/include/clang/Driver/Options.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ExprConstant.cpp
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Basic/Targets/X86.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaCoroutine.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/AST/arithmetic-fence-builtin.c
  clang/test/CodeGen/arithmetic-fence-builtin.c
  clang/test/Driver/clang_f_opts.c
  clang/test/Sema/arithmetic-fence-builtin.c

Index: clang/test/Sema/arithmetic-fence-builtin.c
===
--- /dev/null
+++ clang/test/Sema/arithmetic-fence-builtin.c
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -o - -verify -x c++ %s
+// RUN: %clang_cc1 -triple ppc64le -DPPC -emit-llvm -o - -verify -x c++ %s
+// RUN: not %clang_cc1 -triple ppc64le -DPPC -emit-llvm -o - -x c++ %s \
+// RUN:-fprotect-parens 2>&1 | FileCheck -check-prefix=PPC %s
+#ifndef PPC
+int v;
+template  T addT(T a, T b) {
+  T *q = __arithmetic_fence(&a);
+  // expected-error@-1 {{invalid operand of type 'float *' where floating, complex or a vector of such types is required}}
+  // expected-error@-2 {{invalid operand of type 'int *' where floating, complex or a vector of such types is required}}
+  return __arithmetic_fence(a + b);
+  // expected-error@-1 {{invalid operand of type 'int' where floating, complex or a vector of such types is required}}
+}
+int addit(int a, int b) {
+  float x, y;
+  typedef struct {
+int a, b;
+  } stype;
+  stype s;
+  s = __arithmetic_fence(s);// expected-error {{invalid operand of type 'stype' where floating, complex or a vector of such types is required}}
+  x = __arithmetic_fence(); // expected-error {{too few arguments to function call, expected 1, have 0}}
+  x = __arithmetic_fence(x, y); // expected-error {{too many arguments to function call, expected 1, have 2}}
+  // Complex is supported.
+  _Complex double cd, cd1;
+  cd = __arithmetic_fence(cd1);
+  // Vector is supported.
+  typedef float __v4hi __attribute__((__vector_size__(8)));
+  __v4hi vec1, vec2;
+  vec1 = __arithmetic_fence(vec2);
+
+  v = __arithmetic_fence(a + b); // expected-error {{invalid operand of type 'int' where floating, complex or a vector of such types is required}}
+  float f = addT(a, b);   // expected-note {{in instantiation of function template specialization 'addT' requested here}}
+  int i = addT(1, 2);   // expected-note {{in instantiation of function template specialization 'addT' requested here}}
+  constexpr float d = 1.0 + 2.0;
+  constexpr float c = __arithmetic_fence(1.0 + 2.0);
+  constexpr float e = __arithmetic_fence(d);
+  return 0;
+}
+bool func(float f1, float f2, float f3) {
+  return (f1 == f2 && f1 == f3) || f2 == f3; // Should not warn here
+}
+static_assert( __arithmetic_fence(1.0 + 2.0), "message" );
+#else
+float addit(float a, float b) {
+  return __arithmetic_fence(a+b); // expected-error {{builtin is not supported on this target}}
+}
+#endif
+//PPC: error: option '-fprotect-parens' cannot be specified on this target
Index: clang/test/Driver/clang_f_opts.c
===
--- clang/test/Driver/clang_f_opts.c
+++ clang/test/Driver/clang_f_opts.c
@@ -1,13 +1,14 @@
 // REQUIRES: clang-driver
 
 // RUN: %clang -### -S -fasm -fblocks -fbuiltin -fno-math-errno -fcommon -fpascal-strings -fno-blocks -fno-builtin -fmath-errno -fno-common -fno-pascal-strings -fblocks -fbuiltin -fmath-errno -fcommon -fpascal-strings -fsplit-stack %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS1 %s
-// RUN: %clang -### -S -fasm -fblocks -fbuiltin -fno-math-errno -fcommon -fpascal-strings -fno-asm -fno-blocks -fno-builtin -fmath-errno -fno-common -fno-pascal-strings -fno-show-source-location -fshort-enums %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS2 %s
+// RUN: %clang -### -S -fasm -fblocks -fbuiltin -fno-math-errno -fcommon -fpascal-strings -fno-asm -fno-blocks -fno-builtin -fmath-errno -fno-common -fno-pascal-strings -fno-show-source-location -fshort-enums -fprotect-parens %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS2 %s
 
 // CHECK-OPTIONS1: -fsplit-stack
 // CHECK-OPTIONS1: -fgnu-keywords
 // CHECK-OPTIONS1: -fblocks
 // CHECK-OPTIONS1: -fpascal-strings
 
+// CHECK-OPTIONS2: -fprotect-parens
 // CHECK-OPTIONS2: -fmath-errno
 // CHECK-OPTIONS2: -fno-gnu-keywords
 // CHECK-OPTIONS2: 

[PATCH] D100118: [clang] Add support for new builtin __arithmetic_fence to control floating point optimization, and new clang option fprotect-parens

2021-06-23 Thread Melanie Blower via Phabricator via cfe-commits
mibintc marked 9 inline comments as done.
mibintc added a comment.

A couple inline replies to go along with the updated patch




Comment at: clang/include/clang/Driver/Options.td:1757
+  LangOpts<"ProtectParens">, DefaultFalse,
+  PosFlag Should this option also be exposed to clang-cl (should it be a `CoreOption`)?
I don't know the answer to this, do you have a recommendation? 



Comment at: clang/lib/Sema/SemaChecking.cpp:6427-6430
+if (const VectorType *VT = dyn_cast(ArgTy.getCanonicalType()))
+  return VT->getElementType().getTypePtr()->isFloatingType();
+if (const ComplexType *CT = 
dyn_cast(ArgTy.getCanonicalType()))
+  return CT->getElementType().getTypePtr()->isFloatingType();

aaron.ballman wrote:
> 
I found there was a boolean function, so i got rid of the lambda. 



Comment at: clang/lib/Sema/SemaCoroutine.cpp:294
 
-static Expr *buildBuiltinCall(Sema &S, SourceLocation Loc, Builtin::ID Id,
-  MultiExprArg CallArgs) {

I moved this function to public because another file is also using the same 
logic



Comment at: clang/lib/Sema/SemaExpr.cpp:4026
+  !E->isLValue() &&
+  (ExprTy->isFloatingType() || (ExprTy->isComplexType( {
+return BuildBuiltinCallExpr(R, Builtin::BI__arithmetic_fence, E);

aaron.ballman wrote:
> Do you have to worry about vector types here as well?
Oh yes, i didn't get this one. 



Comment at: clang/lib/Sema/SemaExpr.cpp:4027
+  (ExprTy->isFloatingType() || (ExprTy->isComplexType( {
+return BuildBuiltinCallExpr(R, Builtin::BI__arithmetic_fence, E);
+  }

aaron.ballman wrote:
> One worry I have about this is that the AST will be a bit mysterious for 
> people writing AST matchers. The source code will have parens in it, but the 
> AST will have a `ParenExpr` node or not only depending on the language 
> options. This may also cause problems for other parts of the code that are 
> checking for properly-parenthesized expressions (like && and || within the 
> same expression), so we should probably have a test case like:
> ```
> bool func(float f1, float f2, float f3) {
>   return (f1 == f2 && f1 == f3) || f2 == f3; // Should not warn here
> }
> ```
I added an AST test case 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100118/new/

https://reviews.llvm.org/D100118

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


[PATCH] D100118: [clang] Add support for new builtin __arithmetic_fence to control floating point optimization, and new clang option fprotect-parens

2021-06-23 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 354009.
mibintc added a comment.

The patch I uploaded for review yesterday wasn't correct, not sure what 
happened.  This one looks better.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100118/new/

https://reviews.llvm.org/D100118

Files:
  clang/docs/UsersManual.rst
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Basic/TargetInfo.h
  clang/include/clang/Driver/Options.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ExprConstant.cpp
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Basic/Targets/X86.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaCoroutine.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/AST/arithmetic-fence-builtin.c
  clang/test/CodeGen/arithmetic-fence-builtin.c
  clang/test/Driver/clang_f_opts.c
  clang/test/Sema/arithmetic-fence-builtin.c

Index: clang/test/Sema/arithmetic-fence-builtin.c
===
--- /dev/null
+++ clang/test/Sema/arithmetic-fence-builtin.c
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -o - -verify -x c++ %s
+// RUN: %clang_cc1 -triple ppc64le -DPPC -emit-llvm -o - -verify -x c++ %s
+// RUN: not %clang_cc1 -triple ppc64le -DPPC -emit-llvm -o - -x c++ %s \
+// RUN:-fprotect-parens 2>&1 | FileCheck -check-prefix=PPC %s
+#ifndef PPC
+int v;
+template  T addT(T a, T b) {
+  T *q = __arithmetic_fence(&a);
+  // expected-error@-1 {{invalid operand of type 'float *' where floating, complex or a vector of such types is required}}
+  // expected-error@-2 {{invalid operand of type 'int *' where floating, complex or a vector of such types is required}}
+  return __arithmetic_fence(a + b);
+  // expected-error@-1 {{invalid operand of type 'int' where floating, complex or a vector of such types is required}}
+}
+int addit(int a, int b) {
+  float x, y;
+  typedef struct {
+int a, b;
+  } stype;
+  stype s;
+  s = __arithmetic_fence(s);// expected-error {{invalid operand of type 'stype' where floating, complex or a vector of such types is required}}
+  x = __arithmetic_fence(); // expected-error {{too few arguments to function call, expected 1, have 0}}
+  x = __arithmetic_fence(x, y); // expected-error {{too many arguments to function call, expected 1, have 2}}
+  // Complex is supported.
+  _Complex double cd, cd1;
+  cd = __arithmetic_fence(cd1);
+  // Vector is supported.
+  typedef float __v4hi __attribute__((__vector_size__(8)));
+  __v4hi vec1, vec2;
+  vec1 = __arithmetic_fence(vec2);
+
+  v = __arithmetic_fence(a + b); // expected-error {{invalid operand of type 'int' where floating, complex or a vector of such types is required}}
+  float f = addT(a, b);   // expected-note {{in instantiation of function template specialization 'addT' requested here}}
+  int i = addT(1, 2);   // expected-note {{in instantiation of function template specialization 'addT' requested here}}
+  constexpr float d = 1.0 + 2.0;
+  constexpr float c = __arithmetic_fence(1.0 + 2.0);
+  constexpr float e = __arithmetic_fence(d);
+  return 0;
+}
+bool func(float f1, float f2, float f3) {
+  return (f1 == f2 && f1 == f3) || f2 == f3; // Should not warn here
+}
+static_assert( __arithmetic_fence(1.0 + 2.0), "message" );
+#else
+float addit(float a, float b) {
+  return __arithmetic_fence(a+b); // expected-error {{builtin is not supported on this target}}
+}
+#endif
+//PPC: error: option '-fprotect-parens' cannot be specified on this target
Index: clang/test/Driver/clang_f_opts.c
===
--- clang/test/Driver/clang_f_opts.c
+++ clang/test/Driver/clang_f_opts.c
@@ -1,13 +1,14 @@
 // REQUIRES: clang-driver
 
 // RUN: %clang -### -S -fasm -fblocks -fbuiltin -fno-math-errno -fcommon -fpascal-strings -fno-blocks -fno-builtin -fmath-errno -fno-common -fno-pascal-strings -fblocks -fbuiltin -fmath-errno -fcommon -fpascal-strings -fsplit-stack %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS1 %s
-// RUN: %clang -### -S -fasm -fblocks -fbuiltin -fno-math-errno -fcommon -fpascal-strings -fno-asm -fno-blocks -fno-builtin -fmath-errno -fno-common -fno-pascal-strings -fno-show-source-location -fshort-enums %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS2 %s
+// RUN: %clang -### -S -fasm -fblocks -fbuiltin -fno-math-errno -fcommon -fpascal-strings -fno-asm -fno-blocks -fno-builtin -fmath-errno -fno-common -fno-pascal-strings -fno-show-source-location -fshort-enums -fprotect-parens %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS2 %s
 
 // CHECK-OPTIONS1: -fsplit-stack
 // CHECK-OPTIONS1: -fgnu-keywords
 // CHECK-OPTIONS1: -fblocks
 // CHECK-OPTIONS1: -fpascal-strings
 
+// CHECK-OPTIONS2: -fprotect-parens
 // CHECK-OPTIONS2: -fmath-errno
 // CHECK-OPTIONS2: -fno-gnu-

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

2021-06-22 Thread Melanie Blower via Phabricator via cfe-commits
mibintc created this revision.
mibintc added a reviewer: aaron.ballman.
mibintc added a project: clang.
Herald added subscribers: kerbowa, kbarton, jgravelle-google, sbc100, nhaehnle, 
jvesely, nemanjai, dschuff.
mibintc requested review of this revision.
Herald added a subscriber: aheejin.

In the clang patch https://reviews.llvm.org/D100118 @aaron.ballman suggested 
that I pull out these changes into a precursor patch


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D104729

Files:
  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

Index: clang/tools/clang-import-test/clang-import-test.cpp
===
--- clang/tools/clang-import-test/clang-import-test.cpp
+++ clang/tools/clang-import-test/clang-import-test.cpp
@@ -208,7 +208,7 @@
   TargetInfo *TI = TargetInfo::CreateTargetInfo(
   Ins->getDiagnostics(), Ins->getInvocation().TargetOpts);
   Ins->setTarget(TI);
-  Ins->getTarget().adjust(Ins->getLangOpts());
+  Ins->getTarget().adjust(Ins->getDiagnostics(), Ins->getLangOpts());
   Ins->createFileManager();
   Ins->createSourceManager(Ins->getFileManager());
   Ins->createPreprocessor(TU_Complete);
Index: clang/lib/Interpreter/Interpreter.cpp
===
--- clang/lib/Interpreter/Interpreter.cpp
+++ clang/lib/Interpreter/Interpreter.cpp
@@ -110,7 +110,7 @@
"Initialization failed. "
"Target is missing");
 
-  Clang->getTarget().adjust(Clang->getLangOpts());
+  Clang->getTarget().adjust(Clang->getDiagnostics(), Clang->getLangOpts());
 
   return std::move(Clang);
 }
Index: clang/lib/Frontend/CompilerInstance.cpp
===
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -142,7 +142,7 @@
   // Inform the target of the language options.
   // FIXME: We shouldn't need to do this, the target should be immutable once
   // created. This complexity should be lifted elsewhere.
-  getTarget().adjust(getLangOpts());
+  getTarget().adjust(getDiagnostics(), getLangOpts());
 
   // Adjust target options based on codegen options.
   getTarget().adjustTargetOptions(getCodeGenOpts(), getTargetOpts());
@@ -457,7 +457,7 @@
   getSourceManager(), *HeaderInfo, *this,
   /*IdentifierInfoLookup=*/nullptr,
   /*OwnsHeaderSearch=*/true, TUKind);
-  getTarget().adjust(getLangOpts());
+  getTarget().adjust(getDiagnostics(), getLangOpts());
   PP->Initialize(getTarget(), getAuxTarget());
 
   if (PPOpts.DetailedRecord)
Index: clang/lib/Frontend/ASTUnit.cpp
===
--- clang/lib/Frontend/ASTUnit.cpp
+++ clang/lib/Frontend/ASTUnit.cpp
@@ -588,7 +588,7 @@
 //
 // FIXME: We shouldn't need to do this, the target should be immutable once
 // created. This complexity should be lifted elsewhere.
-Target->adjust(LangOpt);
+Target->adjust(PP.getDiagnostics(), LangOpt);
 
 // Initialize the preprocessor.
 PP.Initialize(*Target);
Index: clang/lib/Basic/Targets/WebAssembly.h
===
--- clang/lib/Basic/Targets/WebAssembly.h
+++ clang/lib/Basic/Targets/WebAssembly.h
@@ -138,7 +138,7 @@
 
   bool hasProtectedVisibility() const override { return false; }
 
-  void adjust(LangOptions &Opts) override;
+  void adjust(DiagnosticsEngine &Diags, LangOptions &Opts) override;
 };
 
 class LLVM_LIBRARY_VISIBILITY WebAssembly32TargetInfo
Index: clang/lib/Basic/Targets/WebAssembly.cpp
===
--- clang/lib/Basic/Targets/WebAssembly.cpp
+++ clang/lib/Basic/Targets/WebAssembly.cpp
@@ -234,7 +234,8 @@
  Builtin::FirstTSBuiltin);
 }
 
-void WebAssemblyTargetInfo::adjust(LangOptions &Opts) {
+void WebAssemblyTargetInfo::adjust(DiagnosticsEngine &Diags,
+   LangOptions &Opts) {
   // If the Atomics feature isn't available, turn off POSIXThreads and
   // ThreadModel, so that we don't predefine _REENTRANT or __STDCPP_THREADS__.
   if (!HasAtomics) {
Index: clang/lib/Basic/Targets/SPIR.h
===
--- clang/lib/Basic/Targets/SPIR.h
+++ clang/lib/Basic/Targets/SPIR.h
@@ -135,8 +135,8 @@
   

[PATCH] D100118: [clang] Add support for new builtin __arithmetic_fence to control floating point optimization, and new clang option fprotect-parens

2021-06-22 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 353719.
mibintc added a comment.
Herald added subscribers: jdoerfert, hiraditya.

This patch addresses almost all the review comments, not yet sure about 
@aaron.ballman 's question about CoreOptions


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100118/new/

https://reviews.llvm.org/D100118

Files:
  llvm/docs/LangRef.rst
  llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
  llvm/include/llvm/CodeGen/BasicTTIImpl.h
  llvm/include/llvm/CodeGen/ISDOpcodes.h
  llvm/include/llvm/CodeGen/SelectionDAGISel.h
  llvm/include/llvm/IR/IRBuilder.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/include/llvm/Support/TargetOpcodes.def
  llvm/include/llvm/Target/Target.td
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
  llvm/test/CodeGen/X86/arithmetic_fence.ll
  llvm/test/CodeGen/X86/arithmetic_fence2.ll

Index: llvm/test/CodeGen/X86/arithmetic_fence2.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/arithmetic_fence2.ll
@@ -0,0 +1,170 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+sse2 | FileCheck %s --check-prefix=X86
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+sse2 | FileCheck %s --check-prefix=X64
+
+define double @f1(double %a) {
+; X86-LABEL: f1:
+; X86:   # %bb.0:
+; X86-NEXT:pushl %ebp
+; X86-NEXT:.cfi_def_cfa_offset 8
+; X86-NEXT:.cfi_offset %ebp, -8
+; X86-NEXT:movl %esp, %ebp
+; X86-NEXT:.cfi_def_cfa_register %ebp
+; X86-NEXT:andl $-8, %esp
+; X86-NEXT:subl $8, %esp
+; X86-NEXT:movsd {{.*#+}} xmm0 = mem[0],zero
+; X86-NEXT:mulsd {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0
+; X86-NEXT:movsd %xmm0, (%esp)
+; X86-NEXT:fldl (%esp)
+; X86-NEXT:movl %ebp, %esp
+; X86-NEXT:popl %ebp
+; X86-NEXT:.cfi_def_cfa %esp, 4
+; X86-NEXT:retl
+;
+; X64-LABEL: f1:
+; X64:   # %bb.0:
+; X64-NEXT:mulsd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
+; X64-NEXT:retq
+  %1 = fadd fast double %a, %a
+  %2 = fadd fast double %a, %a
+  %3 = fadd fast double %1, %2
+  ret double %3
+}
+
+define double @f2(double %a) {
+; X86-LABEL: f2:
+; X86:   # %bb.0:
+; X86-NEXT:pushl %ebp
+; X86-NEXT:.cfi_def_cfa_offset 8
+; X86-NEXT:.cfi_offset %ebp, -8
+; X86-NEXT:movl %esp, %ebp
+; X86-NEXT:.cfi_def_cfa_register %ebp
+; X86-NEXT:andl $-8, %esp
+; X86-NEXT:subl $8, %esp
+; X86-NEXT:movsd {{.*#+}} xmm0 = mem[0],zero
+; X86-NEXT:addsd %xmm0, %xmm0
+; X86-NEXT:movapd %xmm0, %xmm1
+; X86-NEXT:#ARITH_FENCE
+; X86-NEXT:addsd %xmm0, %xmm1
+; X86-NEXT:movsd %xmm1, (%esp)
+; X86-NEXT:fldl (%esp)
+; X86-NEXT:movl %ebp, %esp
+; X86-NEXT:popl %ebp
+; X86-NEXT:.cfi_def_cfa %esp, 4
+; X86-NEXT:retl
+;
+; X64-LABEL: f2:
+; X64:   # %bb.0:
+; X64-NEXT:addsd %xmm0, %xmm0
+; X64-NEXT:movapd %xmm0, %xmm1
+; X64-NEXT:#ARITH_FENCE
+; X64-NEXT:addsd %xmm0, %xmm1
+; X64-NEXT:movapd %xmm1, %xmm0
+; X64-NEXT:retq
+  %1 = fadd fast double %a, %a
+  %t = call double @llvm.arithmetic.fence.f64(double %1)
+  %2 = fadd fast double %a, %a
+  %3 = fadd fast double %t, %2
+  ret double %3
+}
+
+define <2 x float> @f3(<2 x float> %a) {
+; X86-LABEL: f3:
+; X86:   # %bb.0:
+; X86-NEXT:mulps {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0
+; X86-NEXT:retl
+;
+; X64-LABEL: f3:
+; X64:   # %bb.0:
+; X64-NEXT:mulps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
+; X64-NEXT:retq
+  %1 = fadd fast <2 x float> %a, %a
+  %2 = fadd fast <2 x float> %a, %a
+  %3 = fadd fast <2 x float> %1, %2
+  ret <2 x float> %3
+}
+
+define <2 x float> @f4(<2 x float> %a) {
+; X86-LABEL: f4:
+; X86:   # %bb.0:
+; X86-NEXT:addps %xmm0, %xmm0
+; X86-NEXT:movaps %xmm0, %xmm1
+; X86-NEXT:#ARITH_FENCE
+; X86-NEXT:addps %xmm0, %xmm1
+; X86-NEXT:movaps %xmm1, %xmm0
+; X86-NEXT:retl
+;
+; X64-LABEL: f4:
+; X64:   # %bb.0:
+; X64-NEXT:addps %xmm0, %xmm0
+; X64-NEXT:movaps %xmm0, %xmm1
+; X64-NEXT:#ARITH_FENCE
+; X64-NEXT:addps %xmm0, %xmm1
+; X64-NEXT:movaps %xmm1, %xmm0
+; X64-NEXT:retq
+  %1 = fadd fast <2 x float> %a, %a
+  %t = call <2 x float> @llvm.arithmetic.fence.v2f32(<2 x float> %1)
+  %2 = fadd fast <2 x float> %a, %a
+  %3 = fadd fast <2 x float> %t, %2
+  ret <2 x float> %3
+}
+
+define <8 x float> @f5(<8 x float> %a) {
+; X86-LABEL: f5:
+; X86:   # %bb.0:
+; X86-NEXT:movaps {{.*#+}} xmm2 = [4.0E+0,4.0E+0,4.0E+0,4.0E+0]
+; X86-NEXT:mulps %xmm2, %xmm0
+; X86-NEXT:mulps %xmm2, %xmm1
+; X86-NEXT:retl
+;
+; X64-LABEL: f5:
+; X64:   # %bb.0:
+; X64-NEXT:movaps {{.*#+}} xmm2 = [4.0E+0,4.0E+0,4.0E+0,4.0E+0]
+; X64-NEXT:mulps %xmm2, %xmm0
+; X64-NEXT:mulps 

[PATCH] D74436: Change clang option -ffp-model=precise to select ffp-contract=on

2021-06-19 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

I’ve been trying to commit this patch. However, when I commit, the tests fail 
some 21 floating point tests in LNT.  Also there is both performance 
improvement as well as regression which shouldn’t happen because the sum total 
of my clang patch + my LNT patch should effectively be a no-op.

It appears that the correction I made to LNT is not effective, but I’ve tested 
the patch on my Linux box and it does work.  My patch unconditionally overrides 
the command line to restore the original LNT behavior. I verified the commit 
revision to LNT and the bot is running my patched version of LNT.  It looks 
like the bot is using a different rule to build the test cases.

It’s hard to see exactly what the bot is doing, there isn’t enough information. 
 It would be nice if the bot Makefile was built with ‘verbose’ so I could see 
all the compile commands that the bot is using.

One of the bot failures is here: http://lnt.llvm.org/db_default/v4/nts/147167

I can see the bot owner is Yin Yang, I will reach out.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74436/new/

https://reviews.llvm.org/D74436

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


[PATCH] D100118: [clang] Add support for new builtin __arithmetic_fence to control floating point optimization, and new clang option fprotect-parens

2021-06-18 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

Reply to @joerg proposing new wording for the option description




Comment at: clang/docs/UsersManual.rst:1484
+   Where unsafe floating point optimizations are enabled, this option
+   determines whether the optimizer honors parentheses when floating-point
+   expressions are evaluated.  If unsafe floating point optimizations are

joerg wrote:
> aaron.ballman wrote:
> > mibintc wrote:
> > > aaron.ballman wrote:
> > > > We may need to expound on what "honor parentheses" means. The summary 
> > > > for the patch mentions `(a + b) + c`, but does this also mean `(x + y) 
> > > > * z`  could be interpreted as `x + (y * z)`? What about for 
> > > > non-arithmetic expressions involving parentheses, like `(float1 == 
> > > > float2 && float1 == float3) || blah()`?
> > > Thanks for your review. Just a quick first response, What do you mean "(x 
> > > + y) * z could be reinterpreted as x + (y * z)" -- not following you 
> > > here? 
> > "whether the optimizer honors the parentheses" reads to me like `(x + y) * 
> > z` could either honor or not honor the parentheses, so that could either 
> > evaluate as `(x + y) * z` or `x + (y * z)` depending on whether the parens 
> > are honored or not.
> I would prefer to start with a description of the intended behavior from 
> first principles. The logic here should not be tied to fast-mode as it also 
> overlaps a lot with the formulation of fused multiply-add expressions and 
> certainly should have specified behavior on the interaction. I'm also not 
> sure about what you mean with value-safe FP modes, IIRC the C/C++ standard 
> explicitly leave it open in which order floating point expressions of the 
> same operand priority are evaluated.
> 
> I'm also a bit puzzled why __arithmethic_fence should not be considered a 
> constant expression?
> I would prefer to start with a description of the intended behavior from 
> first principles. The logic here should not be tied to fast-mode as it also 
> overlaps a lot with the formulation of fused multiply-add expressions and 
> certainly should have specified behavior on the interaction. I'm also not 
> sure about what you mean with value-safe FP modes, IIRC the C/C++ standard 
> explicitly leave it open in which order floating point expressions of the 
> same operand priority are evaluated.

@joerg  Thank you.  What do you think about this modified description of the 
option:
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.

> 
> I'm also a bit puzzled why __arithmethic_fence should not be considered a 
> constant expression?
I can see your point about that. I was leery of steering into constant folding 
waters but I will make that change.




Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100118/new/

https://reviews.llvm.org/D100118

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


[PATCH] D74436: Change clang option -ffp-model=precise to select ffp-contract=on

2021-06-10 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

The bot is showing a fail due to this patch, see 
https://lab.llvm.org/buildbot#builders/110/builds/4007

It looks like my updates to LNT earlier this week haven't been migrated to the 
bot, is that right?

See https://reviews.llvm.org/rTccc86f938839d02de3a6564b2d80fb47a60aa069

In the json log I can see ffp-contract=off but it should be overridden to 
ffp-contract=off on the command line due to the LNT change.

Is there something else I need to do to update those sources?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74436/new/

https://reviews.llvm.org/D74436

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


[PATCH] D74436: Change clang option -ffp-model=precise to select ffp-contract=on

2021-06-10 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added inline comments.



Comment at: clang/docs/UsersManual.rst:1501
 
-   * ``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.

xbolva00 wrote:
> Maybe you should add short info to Release Notes as well?
> Maybe you should add short info to Release Notes as well?

Good idea thanks. Can I do that in a separate patch?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74436/new/

https://reviews.llvm.org/D74436

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


[PATCH] D74436: Change clang option -ffp-model=precise to select ffp-contract=on

2021-06-10 Thread Melanie Blower via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8daac3714083: [clang][FPEnv] Clang floatng point model 
ffp-model=precise enables ffp… (authored by mibintc).

Changed prior to commit:
  https://reviews.llvm.org/D74436?vs=345526&id=351156#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74436/new/

https://reviews.llvm.org/D74436

Files:
  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

Index: clang/test/Driver/fp-model.c
===
--- clang/test/Driver/fp-model.c
+++ clang/test/Driver/fp-model.c
@@ -1,88 +1,90 @@
 // Test that incompatible combinations of -ffp-model= options
 // and other floating point options get a warning diagnostic.
-//
-// REQUIRES: clang-driver
 
-// RUN: %clang -### -ffp-model=fast -ffp-contract=off -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=fast -ffp-contract=off -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARN %s
 // WARN: warning: overriding '-ffp-model=fast' option with '-ffp-contract=off' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=fast -ffp-contract=on -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=fast -ffp-contract=on -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARN1 %s
 // WARN1: warning: overriding '-ffp-model=fast' option with '-ffp-contract=on' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -fassociative-math -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict -fassociative-math -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARN2 %s
 // WARN2: warning: overriding '-ffp-model=strict' option with '-fassociative-math' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -ffast-math -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict -ffast-math -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARN3 %s
 // WARN3: warning: overriding '-ffp-model=strict' option with '-ffast-math' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -ffinite-math-only -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict -ffinite-math-only -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARN4 %s
 // WARN4: warning: overriding '-ffp-model=strict' option with '-ffinite-math-only' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -ffp-contract=fast -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict -ffp-contract=fast -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARN5 %s
 // WARN5: warning: overriding '-ffp-model=strict' option with '-ffp-contract=fast' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -ffp-contract=on -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict -ffp-contract=fast -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN6 %s
+// WARN6: warning: overriding '-ffp-model=strict' option with '-ffp-contract=fast' [-Woverriding-t-option]
+
+// RUN: %clang -target x86_64 -### -ffp-model=strict -ffp-contract=on -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARN7 %s
 // WARN7: warning: overriding '-ffp-model=strict' option with '-ffp-contract=on' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -fno-honor-infinities -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict -fno-honor-infinities -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARN8 %s
 // WARN8: warning: overriding '-ffp-model=strict' option with '-fno-honor-infinities' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -fno-honor-nans -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict -fno-honor-nans -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARN9 %s
 // WARN9: warning: overriding '-ffp-model=strict' option with '-fno-honor-nans' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -fno-rounding-math -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict -fno-rounding-math -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARNa %s
 // WARNa: warning: overriding '-ffp-model=strict' option with '-fno-rounding-math' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -fno-signed-zeros -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict -fno-signed-zeros -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARNb %s
 // WARNb: warning: overriding '-ffp-model=strict' option with '-fno-signed-zeros' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -fno-trapping-math -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict -fno-trapping-math -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARNc %s
 // WARNc: warning: overriding '-ffp-model=strict' option with '-fno-trapping-math' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -fre

[PATCH] D99675: [llvm][clang] Create new intrinsic llvm.arithmetic.fence to control FP optimization at expression level

2021-06-09 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 350912.
mibintc retitled this revision from "[llvm][clang] Create new intrinsic 
llvm.arith.fence to control FP optimization at expression level" to 
"[llvm][clang] Create new intrinsic llvm.arithmetic.fence to control FP 
optimization at expression level".
mibintc added a comment.

Correct small formatting issue in LangRef.rst thanks @pengfei


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D99675/new/

https://reviews.llvm.org/D99675

Files:
  llvm/docs/LangRef.rst
  llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
  llvm/include/llvm/CodeGen/BasicTTIImpl.h
  llvm/include/llvm/CodeGen/ISDOpcodes.h
  llvm/include/llvm/CodeGen/SelectionDAGISel.h
  llvm/include/llvm/IR/IRBuilder.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/include/llvm/Support/TargetOpcodes.def
  llvm/include/llvm/Target/Target.td
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
  llvm/test/CodeGen/X86/arithmetic_fence.ll
  llvm/test/CodeGen/X86/arithmetic_fence2.ll

Index: llvm/test/CodeGen/X86/arithmetic_fence2.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/arithmetic_fence2.ll
@@ -0,0 +1,170 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+sse2 | FileCheck %s --check-prefix=X86
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+sse2 | FileCheck %s --check-prefix=X64
+
+define double @f1(double %a) {
+; X86-LABEL: f1:
+; X86:   # %bb.0:
+; X86-NEXT:pushl %ebp
+; X86-NEXT:.cfi_def_cfa_offset 8
+; X86-NEXT:.cfi_offset %ebp, -8
+; X86-NEXT:movl %esp, %ebp
+; X86-NEXT:.cfi_def_cfa_register %ebp
+; X86-NEXT:andl $-8, %esp
+; X86-NEXT:subl $8, %esp
+; X86-NEXT:movsd {{.*#+}} xmm0 = mem[0],zero
+; X86-NEXT:mulsd {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0
+; X86-NEXT:movsd %xmm0, (%esp)
+; X86-NEXT:fldl (%esp)
+; X86-NEXT:movl %ebp, %esp
+; X86-NEXT:popl %ebp
+; X86-NEXT:.cfi_def_cfa %esp, 4
+; X86-NEXT:retl
+;
+; X64-LABEL: f1:
+; X64:   # %bb.0:
+; X64-NEXT:mulsd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
+; X64-NEXT:retq
+  %1 = fadd fast double %a, %a
+  %2 = fadd fast double %a, %a
+  %3 = fadd fast double %1, %2
+  ret double %3
+}
+
+define double @f2(double %a) {
+; X86-LABEL: f2:
+; X86:   # %bb.0:
+; X86-NEXT:pushl %ebp
+; X86-NEXT:.cfi_def_cfa_offset 8
+; X86-NEXT:.cfi_offset %ebp, -8
+; X86-NEXT:movl %esp, %ebp
+; X86-NEXT:.cfi_def_cfa_register %ebp
+; X86-NEXT:andl $-8, %esp
+; X86-NEXT:subl $8, %esp
+; X86-NEXT:movsd {{.*#+}} xmm0 = mem[0],zero
+; X86-NEXT:addsd %xmm0, %xmm0
+; X86-NEXT:movapd %xmm0, %xmm1
+; X86-NEXT:#ARITH_FENCE
+; X86-NEXT:addsd %xmm0, %xmm1
+; X86-NEXT:movsd %xmm1, (%esp)
+; X86-NEXT:fldl (%esp)
+; X86-NEXT:movl %ebp, %esp
+; X86-NEXT:popl %ebp
+; X86-NEXT:.cfi_def_cfa %esp, 4
+; X86-NEXT:retl
+;
+; X64-LABEL: f2:
+; X64:   # %bb.0:
+; X64-NEXT:addsd %xmm0, %xmm0
+; X64-NEXT:movapd %xmm0, %xmm1
+; X64-NEXT:#ARITH_FENCE
+; X64-NEXT:addsd %xmm0, %xmm1
+; X64-NEXT:movapd %xmm1, %xmm0
+; X64-NEXT:retq
+  %1 = fadd fast double %a, %a
+  %t = call double @llvm.arithmetic.fence.f64(double %1)
+  %2 = fadd fast double %a, %a
+  %3 = fadd fast double %t, %2
+  ret double %3
+}
+
+define <2 x float> @f3(<2 x float> %a) {
+; X86-LABEL: f3:
+; X86:   # %bb.0:
+; X86-NEXT:mulps {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0
+; X86-NEXT:retl
+;
+; X64-LABEL: f3:
+; X64:   # %bb.0:
+; X64-NEXT:mulps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
+; X64-NEXT:retq
+  %1 = fadd fast <2 x float> %a, %a
+  %2 = fadd fast <2 x float> %a, %a
+  %3 = fadd fast <2 x float> %1, %2
+  ret <2 x float> %3
+}
+
+define <2 x float> @f4(<2 x float> %a) {
+; X86-LABEL: f4:
+; X86:   # %bb.0:
+; X86-NEXT:addps %xmm0, %xmm0
+; X86-NEXT:movaps %xmm0, %xmm1
+; X86-NEXT:#ARITH_FENCE
+; X86-NEXT:addps %xmm0, %xmm1
+; X86-NEXT:movaps %xmm1, %xmm0
+; X86-NEXT:retl
+;
+; X64-LABEL: f4:
+; X64:   # %bb.0:
+; X64-NEXT:addps %xmm0, %xmm0
+; X64-NEXT:movaps %xmm0, %xmm1
+; X64-NEXT:#ARITH_FENCE
+; X64-NEXT:addps %xmm0, %xmm1
+; X64-NEXT:movaps %xmm1, %xmm0
+; X64-NEXT:retq
+  %1 = fadd fast <2 x float> %a, %a
+  %t = call <2 x float> @llvm.arithmetic.fence.v2f32(<2 x float> %1)
+  %2 = fadd fast <2 x float> %a, %a
+  %3 = fadd fast <2 x float> %t, %2
+  ret <2 x float> %3
+}
+
+define <8 x float> @f5(<8 x float> %a) {
+; X86-LABEL: f5:
+; X86:   # %bb.0:
+; X86-NEXT:movaps {{.*#+}} xmm2 = [4.0E+0,4.0E+0,4.0E+0,4.0E+0]
+; X86-NEXT:mulps %xmm2, %xmm0
+; X86-NEXT:mulps %xmm2, %xmm1
+; X86-NEXT:retl
+;
+; X64-LABEL: f5:
+; X6

[PATCH] D99675: [llvm][clang] Create new intrinsic llvm.arith.fence to control FP optimization at expression level

2021-06-08 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 350700.
mibintc added a comment.

I corrected error in LangRef documentation that @pengfei pointed out.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D99675/new/

https://reviews.llvm.org/D99675

Files:
  llvm/docs/LangRef.rst
  llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
  llvm/include/llvm/CodeGen/BasicTTIImpl.h
  llvm/include/llvm/CodeGen/ISDOpcodes.h
  llvm/include/llvm/CodeGen/SelectionDAGISel.h
  llvm/include/llvm/IR/IRBuilder.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/include/llvm/Support/TargetOpcodes.def
  llvm/include/llvm/Target/Target.td
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
  llvm/test/CodeGen/X86/arithmetic_fence.ll
  llvm/test/CodeGen/X86/arithmetic_fence2.ll

Index: llvm/test/CodeGen/X86/arithmetic_fence2.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/arithmetic_fence2.ll
@@ -0,0 +1,170 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+sse2 | FileCheck %s --check-prefix=X86
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+sse2 | FileCheck %s --check-prefix=X64
+
+define double @f1(double %a) {
+; X86-LABEL: f1:
+; X86:   # %bb.0:
+; X86-NEXT:pushl %ebp
+; X86-NEXT:.cfi_def_cfa_offset 8
+; X86-NEXT:.cfi_offset %ebp, -8
+; X86-NEXT:movl %esp, %ebp
+; X86-NEXT:.cfi_def_cfa_register %ebp
+; X86-NEXT:andl $-8, %esp
+; X86-NEXT:subl $8, %esp
+; X86-NEXT:movsd {{.*#+}} xmm0 = mem[0],zero
+; X86-NEXT:mulsd {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0
+; X86-NEXT:movsd %xmm0, (%esp)
+; X86-NEXT:fldl (%esp)
+; X86-NEXT:movl %ebp, %esp
+; X86-NEXT:popl %ebp
+; X86-NEXT:.cfi_def_cfa %esp, 4
+; X86-NEXT:retl
+;
+; X64-LABEL: f1:
+; X64:   # %bb.0:
+; X64-NEXT:mulsd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
+; X64-NEXT:retq
+  %1 = fadd fast double %a, %a
+  %2 = fadd fast double %a, %a
+  %3 = fadd fast double %1, %2
+  ret double %3
+}
+
+define double @f2(double %a) {
+; X86-LABEL: f2:
+; X86:   # %bb.0:
+; X86-NEXT:pushl %ebp
+; X86-NEXT:.cfi_def_cfa_offset 8
+; X86-NEXT:.cfi_offset %ebp, -8
+; X86-NEXT:movl %esp, %ebp
+; X86-NEXT:.cfi_def_cfa_register %ebp
+; X86-NEXT:andl $-8, %esp
+; X86-NEXT:subl $8, %esp
+; X86-NEXT:movsd {{.*#+}} xmm0 = mem[0],zero
+; X86-NEXT:addsd %xmm0, %xmm0
+; X86-NEXT:movapd %xmm0, %xmm1
+; X86-NEXT:#ARITH_FENCE
+; X86-NEXT:addsd %xmm0, %xmm1
+; X86-NEXT:movsd %xmm1, (%esp)
+; X86-NEXT:fldl (%esp)
+; X86-NEXT:movl %ebp, %esp
+; X86-NEXT:popl %ebp
+; X86-NEXT:.cfi_def_cfa %esp, 4
+; X86-NEXT:retl
+;
+; X64-LABEL: f2:
+; X64:   # %bb.0:
+; X64-NEXT:addsd %xmm0, %xmm0
+; X64-NEXT:movapd %xmm0, %xmm1
+; X64-NEXT:#ARITH_FENCE
+; X64-NEXT:addsd %xmm0, %xmm1
+; X64-NEXT:movapd %xmm1, %xmm0
+; X64-NEXT:retq
+  %1 = fadd fast double %a, %a
+  %t = call double @llvm.arithmetic.fence.f64(double %1)
+  %2 = fadd fast double %a, %a
+  %3 = fadd fast double %t, %2
+  ret double %3
+}
+
+define <2 x float> @f3(<2 x float> %a) {
+; X86-LABEL: f3:
+; X86:   # %bb.0:
+; X86-NEXT:mulps {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0
+; X86-NEXT:retl
+;
+; X64-LABEL: f3:
+; X64:   # %bb.0:
+; X64-NEXT:mulps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
+; X64-NEXT:retq
+  %1 = fadd fast <2 x float> %a, %a
+  %2 = fadd fast <2 x float> %a, %a
+  %3 = fadd fast <2 x float> %1, %2
+  ret <2 x float> %3
+}
+
+define <2 x float> @f4(<2 x float> %a) {
+; X86-LABEL: f4:
+; X86:   # %bb.0:
+; X86-NEXT:addps %xmm0, %xmm0
+; X86-NEXT:movaps %xmm0, %xmm1
+; X86-NEXT:#ARITH_FENCE
+; X86-NEXT:addps %xmm0, %xmm1
+; X86-NEXT:movaps %xmm1, %xmm0
+; X86-NEXT:retl
+;
+; X64-LABEL: f4:
+; X64:   # %bb.0:
+; X64-NEXT:addps %xmm0, %xmm0
+; X64-NEXT:movaps %xmm0, %xmm1
+; X64-NEXT:#ARITH_FENCE
+; X64-NEXT:addps %xmm0, %xmm1
+; X64-NEXT:movaps %xmm1, %xmm0
+; X64-NEXT:retq
+  %1 = fadd fast <2 x float> %a, %a
+  %t = call <2 x float> @llvm.arithmetic.fence.v2f32(<2 x float> %1)
+  %2 = fadd fast <2 x float> %a, %a
+  %3 = fadd fast <2 x float> %t, %2
+  ret <2 x float> %3
+}
+
+define <8 x float> @f5(<8 x float> %a) {
+; X86-LABEL: f5:
+; X86:   # %bb.0:
+; X86-NEXT:movaps {{.*#+}} xmm2 = [4.0E+0,4.0E+0,4.0E+0,4.0E+0]
+; X86-NEXT:mulps %xmm2, %xmm0
+; X86-NEXT:mulps %xmm2, %xmm1
+; X86-NEXT:retl
+;
+; X64-LABEL: f5:
+; X64:   # %bb.0:
+; X64-NEXT:movaps {{.*#+}} xmm2 = [4.0E+0,4.0E+0,4.0E+0,4.0E+0]
+; X64-NEXT:mulps %xmm2, %xmm0
+; X64-NEXT:mulps %xmm2, %xmm1
+; X64-NEXT:retq
+  %1 = fadd fast <8 x float> %a, %a
+  %2 = fadd fast <8 x floa

[PATCH] D99675: [llvm][clang] Create new intrinsic llvm.arith.fence to control FP optimization at expression level

2021-06-07 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 350307.
mibintc added a comment.

This patch addresses all of @craig.topper comments and adds documentation for 
the new intrinsic to the language reference as requested by @LuoYuanke nke


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D99675/new/

https://reviews.llvm.org/D99675

Files:
  llvm/docs/LangRef.rst
  llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
  llvm/include/llvm/CodeGen/BasicTTIImpl.h
  llvm/include/llvm/CodeGen/ISDOpcodes.h
  llvm/include/llvm/CodeGen/SelectionDAGISel.h
  llvm/include/llvm/IR/IRBuilder.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/include/llvm/Support/TargetOpcodes.def
  llvm/include/llvm/Target/Target.td
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
  llvm/test/CodeGen/X86/arithmetic_fence.ll
  llvm/test/CodeGen/X86/arithmetic_fence2.ll

Index: llvm/test/CodeGen/X86/arithmetic_fence2.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/arithmetic_fence2.ll
@@ -0,0 +1,170 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+sse2 | FileCheck %s --check-prefix=X86
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+sse2 | FileCheck %s --check-prefix=X64
+
+define double @f1(double %a) {
+; X86-LABEL: f1:
+; X86:   # %bb.0:
+; X86-NEXT:pushl %ebp
+; X86-NEXT:.cfi_def_cfa_offset 8
+; X86-NEXT:.cfi_offset %ebp, -8
+; X86-NEXT:movl %esp, %ebp
+; X86-NEXT:.cfi_def_cfa_register %ebp
+; X86-NEXT:andl $-8, %esp
+; X86-NEXT:subl $8, %esp
+; X86-NEXT:movsd {{.*#+}} xmm0 = mem[0],zero
+; X86-NEXT:mulsd {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0
+; X86-NEXT:movsd %xmm0, (%esp)
+; X86-NEXT:fldl (%esp)
+; X86-NEXT:movl %ebp, %esp
+; X86-NEXT:popl %ebp
+; X86-NEXT:.cfi_def_cfa %esp, 4
+; X86-NEXT:retl
+;
+; X64-LABEL: f1:
+; X64:   # %bb.0:
+; X64-NEXT:mulsd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
+; X64-NEXT:retq
+  %1 = fadd fast double %a, %a
+  %2 = fadd fast double %a, %a
+  %3 = fadd fast double %1, %2
+  ret double %3
+}
+
+define double @f2(double %a) {
+; X86-LABEL: f2:
+; X86:   # %bb.0:
+; X86-NEXT:pushl %ebp
+; X86-NEXT:.cfi_def_cfa_offset 8
+; X86-NEXT:.cfi_offset %ebp, -8
+; X86-NEXT:movl %esp, %ebp
+; X86-NEXT:.cfi_def_cfa_register %ebp
+; X86-NEXT:andl $-8, %esp
+; X86-NEXT:subl $8, %esp
+; X86-NEXT:movsd {{.*#+}} xmm0 = mem[0],zero
+; X86-NEXT:addsd %xmm0, %xmm0
+; X86-NEXT:movapd %xmm0, %xmm1
+; X86-NEXT:#ARITH_FENCE
+; X86-NEXT:addsd %xmm0, %xmm1
+; X86-NEXT:movsd %xmm1, (%esp)
+; X86-NEXT:fldl (%esp)
+; X86-NEXT:movl %ebp, %esp
+; X86-NEXT:popl %ebp
+; X86-NEXT:.cfi_def_cfa %esp, 4
+; X86-NEXT:retl
+;
+; X64-LABEL: f2:
+; X64:   # %bb.0:
+; X64-NEXT:addsd %xmm0, %xmm0
+; X64-NEXT:movapd %xmm0, %xmm1
+; X64-NEXT:#ARITH_FENCE
+; X64-NEXT:addsd %xmm0, %xmm1
+; X64-NEXT:movapd %xmm1, %xmm0
+; X64-NEXT:retq
+  %1 = fadd fast double %a, %a
+  %t = call double @llvm.arithmetic.fence.f64(double %1)
+  %2 = fadd fast double %a, %a
+  %3 = fadd fast double %t, %2
+  ret double %3
+}
+
+define <2 x float> @f3(<2 x float> %a) {
+; X86-LABEL: f3:
+; X86:   # %bb.0:
+; X86-NEXT:mulps {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0
+; X86-NEXT:retl
+;
+; X64-LABEL: f3:
+; X64:   # %bb.0:
+; X64-NEXT:mulps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
+; X64-NEXT:retq
+  %1 = fadd fast <2 x float> %a, %a
+  %2 = fadd fast <2 x float> %a, %a
+  %3 = fadd fast <2 x float> %1, %2
+  ret <2 x float> %3
+}
+
+define <2 x float> @f4(<2 x float> %a) {
+; X86-LABEL: f4:
+; X86:   # %bb.0:
+; X86-NEXT:addps %xmm0, %xmm0
+; X86-NEXT:movaps %xmm0, %xmm1
+; X86-NEXT:#ARITH_FENCE
+; X86-NEXT:addps %xmm0, %xmm1
+; X86-NEXT:movaps %xmm1, %xmm0
+; X86-NEXT:retl
+;
+; X64-LABEL: f4:
+; X64:   # %bb.0:
+; X64-NEXT:addps %xmm0, %xmm0
+; X64-NEXT:movaps %xmm0, %xmm1
+; X64-NEXT:#ARITH_FENCE
+; X64-NEXT:addps %xmm0, %xmm1
+; X64-NEXT:movaps %xmm1, %xmm0
+; X64-NEXT:retq
+  %1 = fadd fast <2 x float> %a, %a
+  %t = call <2 x float> @llvm.arithmetic.fence.v2f32(<2 x float> %1)
+  %2 = fadd fast <2 x float> %a, %a
+  %3 = fadd fast <2 x float> %t, %2
+  ret <2 x float> %3
+}
+
+define <8 x float> @f5(<8 x float> %a) {
+; X86-LABEL: f5:
+; X86:   # %bb.0:
+; X86-NEXT:movaps {{.*#+}} xmm2 = [4.0E+0,4.0E+0,4.0E+0,4.0E+0]
+; X86-NEXT:mulps %xmm2, %xmm0
+; X86-NEXT:mulps %xmm2, %xmm1
+; X86-NEXT:retl
+;
+; X64-LABEL: f5:
+; X64:   # %bb.0:
+; X64-NEXT:movaps {{.*#+}} xmm2 = [4.0E+0,4.0E+0,4.0E+0,4.0E+0]
+; X64-NEXT:mulps %xmm2, %xmm0
+; X64-NEXT:mulps %xmm2, %xmm1
+

[PATCH] D100118: [clang] Add support for new builtin __arithmetic_fence to control floating point optimization, and new clang option fprotect-parens

2021-06-04 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

question for @aaron.ballman




Comment at: clang/docs/UsersManual.rst:1484
+   Where unsafe floating point optimizations are enabled, this option
+   determines whether the optimizer honors parentheses when floating-point
+   expressions are evaluated.  If unsafe floating point optimizations are

aaron.ballman wrote:
> We may need to expound on what "honor parentheses" means. The summary for the 
> patch mentions `(a + b) + c`, but does this also mean `(x + y) * z`  could be 
> interpreted as `x + (y * z)`? What about for non-arithmetic expressions 
> involving parentheses, like `(float1 == float2 && float1 == float3) || 
> blah()`?
Thanks for your review. Just a quick first response, What do you mean "(x + y) 
* z could be reinterpreted as x + (y * z)" -- not following you here? 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100118/new/

https://reviews.llvm.org/D100118

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


[PATCH] D100118: [clang] Add support for new builtin __arithmetic_fence to control floating point optimization, and new clang option fprotect-parens

2021-06-03 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 349644.
mibintc added a comment.

I made a change to ActOnParenExpr to check that the parenthesized expression is 
not an lvalue before inserting the call to builtin __arithmetic_fence


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100118/new/

https://reviews.llvm.org/D100118

Files:
  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/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/Basic/Targets/X86.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/ASTUnit.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Interpreter/Interpreter.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaCoroutine.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGen/arithmetic-fence-builtin.c
  clang/test/Driver/clang_f_opts.c
  clang/test/Sema/arithmetic-fence-builtin.c
  clang/tools/clang-import-test/clang-import-test.cpp

Index: clang/tools/clang-import-test/clang-import-test.cpp
===
--- clang/tools/clang-import-test/clang-import-test.cpp
+++ clang/tools/clang-import-test/clang-import-test.cpp
@@ -208,7 +208,7 @@
   TargetInfo *TI = TargetInfo::CreateTargetInfo(
   Ins->getDiagnostics(), Ins->getInvocation().TargetOpts);
   Ins->setTarget(TI);
-  Ins->getTarget().adjust(Ins->getLangOpts());
+  Ins->getTarget().adjust(Ins->getDiagnostics(), Ins->getLangOpts());
   Ins->createFileManager();
   Ins->createSourceManager(Ins->getFileManager());
   Ins->createPreprocessor(TU_Complete);
Index: clang/test/Sema/arithmetic-fence-builtin.c
===
--- /dev/null
+++ clang/test/Sema/arithmetic-fence-builtin.c
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -o - -verify -x c++ %s
+// RUN: %clang_cc1 -triple ppc64le -DPPC -emit-llvm -o - -verify -x c++ %s
+// RUN: not %clang_cc1 -triple ppc64le -DPPC -emit-llvm -o - -x c++ %s \
+// RUN:-fprotect-parens 2>&1 | FileCheck -check-prefix=PPC %s
+#ifndef PPC
+int v;
+template  T addT(T a, T b) {
+  T *q = __arithmetic_fence(&a);
+  // expected-error@-1 {{operand of type 'float *' where floating, complex or a vector of such types is required ('float *' invalid)}}
+  // expected-error@-2 {{operand of type 'int *' where floating, complex or a vector of such types is required ('int *' invalid)}}
+  return __arithmetic_fence(a + b);
+  // expected-error@-1 {{operand of type 'int' where floating, complex or a vector of such types is required ('int' invalid)}}
+}
+int addit(int a, int b) {
+  float x, y;
+  typedef struct {
+int a, b;
+  } stype;
+  stype s;
+  s = __arithmetic_fence(s);// expected-error {{operand of type 'stype' where floating, complex or a vector of such types is required ('stype' invalid)}}
+  x = __arithmetic_fence(x, y); // expected-error {{too many arguments to function call, expected 1, have 2}}
+  // Complex is supported.
+  _Complex double cd, cd1;
+  cd = __arithmetic_fence(cd1);
+  // Vector is supported.
+  typedef float __v4hi __attribute__((__vector_size__(8)));
+  __v4hi vec1, vec2;
+  vec1 = __arithmetic_fence(vec2);
+
+  v = __arithmetic_fence(a + b); // expected-error {{operand of type 'int' where floating, complex or a vector of such types is required ('int' invalid)}}
+  float f = addT(a, b);   // expected-note {{in instantiation of function template specialization 'addT' requested here}}
+  int i = addT(1, 2);   // expected-note {{in instantiation of function template specialization 'addT' requested here}}
+  constexpr float d = 1.0 + 2.0;
+  constexpr float c = __arithmetic_fence(1.0 + 2.0);
+  // expected-error@-1 {{constexpr variable 'c' must be initialized by a constant expression}}
+  return 0;
+}
+// expected-error@+1 {{static_assert expression is not an integral constant expression}}
+static_assert( __arithmetic_fence(1.0 + 2.0), "message" );
+#else
+float addit(float a, float b) {
+  return __arithmetic_fence(a+b); // expected-error {{builtin is not supported on this target}}
+}
+#endif
+//PPC: error: option '-fprotect-parens' cannot be specified on this target
Index: clang/test/Driver/clang_f_opts.c
===
--- clang/test/Driver/clang_f_opts.c
+++ clang/test/Driver/clang_f_opts.c
@@ -1,13 +1,14 @@
 // REQUIRES: clang-driver
 
 // RUN: %clang -### -S -fasm -fblocks -fbu

[PATCH] D74436: Change clang option -ffp-model=precise to select ffp-contract=on

2021-05-27 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a subscriber: lebedev.ri.
mibintc added a comment.

In D74436#2785730 , @lebedev.ri wrote:

> No real comments from me.
> I assume, the errors are because `-ffp-contract=on` actually results in 
> *less* error?

Yes, FMA improves accuracy, thank you!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74436/new/

https://reviews.llvm.org/D74436

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


[PATCH] D74436: Change clang option -ffp-model=precise to select ffp-contract=on

2021-05-27 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

Hoping @lebedev.ri will take a look since he requested changes, thanks!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74436/new/

https://reviews.llvm.org/D74436

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


[PATCH] D100118: [clang] Add support for new builtin __arithmetic_fence to control floating point optimization, and new clang option fprotect-parens

2021-05-26 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 348052.
mibintc retitled this revision from "[clang] RFC Support new builtin 
__arithmetic_fence to control floating point optimization, and new clang option 
fprotect-parens" to "[clang] Add support for new builtin __arithmetic_fence to 
control floating point optimization, and new clang option fprotect-parens".
mibintc edited the summary of this revision.
mibintc added a comment.

Rebased the patch.  The parent patch is updated and corrected as well, and 
tests can run end-to-end.

Ready for your code review, thanks!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100118/new/

https://reviews.llvm.org/D100118

Files:
  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/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/Basic/Targets/X86.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/ASTUnit.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Interpreter/Interpreter.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaCoroutine.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGen/arithmetic-fence-builtin.c
  clang/test/Driver/clang_f_opts.c
  clang/test/Sema/arithmetic-fence-builtin.c
  clang/tools/clang-import-test/clang-import-test.cpp

Index: clang/tools/clang-import-test/clang-import-test.cpp
===
--- clang/tools/clang-import-test/clang-import-test.cpp
+++ clang/tools/clang-import-test/clang-import-test.cpp
@@ -208,7 +208,7 @@
   TargetInfo *TI = TargetInfo::CreateTargetInfo(
   Ins->getDiagnostics(), Ins->getInvocation().TargetOpts);
   Ins->setTarget(TI);
-  Ins->getTarget().adjust(Ins->getLangOpts());
+  Ins->getTarget().adjust(Ins->getDiagnostics(), Ins->getLangOpts());
   Ins->createFileManager();
   Ins->createSourceManager(Ins->getFileManager());
   Ins->createPreprocessor(TU_Complete);
Index: clang/test/Sema/arithmetic-fence-builtin.c
===
--- /dev/null
+++ clang/test/Sema/arithmetic-fence-builtin.c
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -o - -verify -x c++ %s
+// RUN: %clang_cc1 -triple ppc64le -DPPC -emit-llvm -o - -verify -x c++ %s
+// RUN: not %clang_cc1 -triple ppc64le -DPPC -emit-llvm -o - -x c++ %s \
+// RUN:-fprotect-parens 2>&1 | FileCheck -check-prefix=PPC %s
+#ifndef PPC
+int v;
+template  T addT(T a, T b) {
+  T *q = __arithmetic_fence(&a);
+  // expected-error@-1 {{operand of type 'float *' where floating, complex or a vector of such types is required ('float *' invalid)}}
+  // expected-error@-2 {{operand of type 'int *' where floating, complex or a vector of such types is required ('int *' invalid)}}
+  return __arithmetic_fence(a + b);
+  // expected-error@-1 {{operand of type 'int' where floating, complex or a vector of such types is required ('int' invalid)}}
+}
+int addit(int a, int b) {
+  float x, y;
+  typedef struct {
+int a, b;
+  } stype;
+  stype s;
+  s = __arithmetic_fence(s);// expected-error {{operand of type 'stype' where floating, complex or a vector of such types is required ('stype' invalid)}}
+  x = __arithmetic_fence(x, y); // expected-error {{too many arguments to function call, expected 1, have 2}}
+  // Complex is supported.
+  _Complex double cd, cd1;
+  cd = __arithmetic_fence(cd1);
+  // Vector is supported.
+  typedef float __v4hi __attribute__((__vector_size__(8)));
+  __v4hi vec1, vec2;
+  vec1 = __arithmetic_fence(vec2);
+
+  v = __arithmetic_fence(a + b); // expected-error {{operand of type 'int' where floating, complex or a vector of such types is required ('int' invalid)}}
+  float f = addT(a, b);   // expected-note {{in instantiation of function template specialization 'addT' requested here}}
+  int i = addT(1, 2);   // expected-note {{in instantiation of function template specialization 'addT' requested here}}
+  constexpr float d = 1.0 + 2.0;
+  constexpr float c = __arithmetic_fence(1.0 + 2.0);
+  // expected-error@-1 {{constexpr variable 'c' must be initialized by a constant expression}}
+  return 0;
+}
+// expected-error@+1 {{static_assert expression is not an integral constant expression}}
+static_assert( __arithmetic_fence(1.0 + 2.0), "message" );
+#else
+float addit(float a, float b) {
+  return __arithmetic_fence(a+b); // expected-error {{builtin is not supported on this target}}
+}
+#endif
+//PPC: 

[PATCH] D99675: [llvm][clang] Create new intrinsic llvm.arith.fence to control FP optimization at expression level

2021-05-26 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 348046.
mibintc retitled this revision from "RFC [llvm][clang] Create new intrinsic 
llvm.arith.fence to control FP optimization at expression level" to 
"[llvm][clang] Create new intrinsic llvm.arith.fence to control FP optimization 
at expression level".
mibintc edited the summary of this revision.
mibintc added a comment.

Rebased to ToT. It fixes the previous illegal type lowering problems. It also 
updates the tests to show the functionality in a better way as well as fixes a 
newly found problem.

Ready for your code review and +1

We think this patch provides basic functionality for the intrinsic, and 
enhancements can be added in future patches.

Thanks!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D99675/new/

https://reviews.llvm.org/D99675

Files:
  llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
  llvm/include/llvm/CodeGen/BasicTTIImpl.h
  llvm/include/llvm/CodeGen/ISDOpcodes.h
  llvm/include/llvm/CodeGen/SelectionDAGISel.h
  llvm/include/llvm/IR/IRBuilder.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/include/llvm/Support/TargetOpcodes.def
  llvm/include/llvm/Target/Target.td
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
  llvm/test/CodeGen/X86/arithmetic_fence.ll

Index: llvm/test/CodeGen/X86/arithmetic_fence.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/arithmetic_fence.ll
@@ -0,0 +1,161 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+fma | FileCheck %s --check-prefix=X86
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+fma | FileCheck %s --check-prefix=X64
+
+define float @f1(float %a, float %b, float %c) {
+; X86-LABEL: f1:
+; X86:   # %bb.0:
+; X86-NEXT:pushl %eax
+; X86-NEXT:.cfi_def_cfa_offset 8
+; X86-NEXT:vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero
+; X86-NEXT:vmovss {{.*#+}} xmm1 = mem[0],zero,zero,zero
+; X86-NEXT:vfmadd213ss {{.*#+}} xmm1 = (xmm0 * xmm1) + mem
+; X86-NEXT:vmovss %xmm1, (%esp)
+; X86-NEXT:flds (%esp)
+; X86-NEXT:popl %eax
+; X86-NEXT:.cfi_def_cfa_offset 4
+; X86-NEXT:retl
+;
+; X64-LABEL: f1:
+; X64:   # %bb.0:
+; X64-NEXT:vfmadd213ss {{.*#+}} xmm0 = (xmm1 * xmm0) + xmm2
+; X64-NEXT:retq
+  %mul = fmul fast float %b, %a
+  %add = fadd fast float %mul, %c
+  ret float %add
+}
+
+define float @f2(float %a, float %b, float %c) {
+; X86-LABEL: f2:
+; X86:   # %bb.0:
+; X86-NEXT:pushl %eax
+; X86-NEXT:.cfi_def_cfa_offset 8
+; X86-NEXT:vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero
+; X86-NEXT:vmulss {{[0-9]+}}(%esp), %xmm0, %xmm0
+; X86-NEXT:#ARITH_FENCE
+; X86-NEXT:vaddss {{[0-9]+}}(%esp), %xmm0, %xmm0
+; X86-NEXT:vmovss %xmm0, (%esp)
+; X86-NEXT:flds (%esp)
+; X86-NEXT:popl %eax
+; X86-NEXT:.cfi_def_cfa_offset 4
+; X86-NEXT:retl
+;
+; X64-LABEL: f2:
+; X64:   # %bb.0:
+; X64-NEXT:vmulss %xmm0, %xmm1, %xmm0
+; X64-NEXT:#ARITH_FENCE
+; X64-NEXT:vaddss %xmm2, %xmm0, %xmm0
+; X64-NEXT:retq
+  %mul = fmul fast float %b, %a
+  %tmp = call float @llvm.arithmetic.fence.f32(float %mul)
+  %add = fadd fast float %tmp, %c
+  ret float %add
+}
+
+define double @f3(double %a) {
+; X86-LABEL: f3:
+; X86:   # %bb.0:
+; X86-NEXT:pushl %ebp
+; X86-NEXT:.cfi_def_cfa_offset 8
+; X86-NEXT:.cfi_offset %ebp, -8
+; X86-NEXT:movl %esp, %ebp
+; X86-NEXT:.cfi_def_cfa_register %ebp
+; X86-NEXT:andl $-8, %esp
+; X86-NEXT:subl $8, %esp
+; X86-NEXT:vmovsd {{.*#+}} xmm0 = mem[0],zero
+; X86-NEXT:vmulsd {{\.LCPI[0-9]+_[0-9]+}}, %xmm0, %xmm0
+; X86-NEXT:vmovsd %xmm0, (%esp)
+; X86-NEXT:fldl (%esp)
+; X86-NEXT:movl %ebp, %esp
+; X86-NEXT:popl %ebp
+; X86-NEXT:.cfi_def_cfa %esp, 4
+; X86-NEXT:retl
+;
+; X64-LABEL: f3:
+; X64:   # %bb.0:
+; X64-NEXT:vmulsd {{.*}}(%rip), %xmm0, %xmm0
+; X64-NEXT:retq
+  %1 = fadd fast double %a, %a
+  %2 = fadd fast double %a, %a
+  %3 = fadd fast double %1, %2
+  ret double %3
+}
+
+define double @f4(double %a) {
+; X86-LABEL: f4:
+; X86:   # %bb.0:
+; X86-NEXT:pushl %ebp
+; X86-NEXT:.cfi_def_cfa_offset 8
+; X86-NEXT:.cfi_offset %ebp, -8
+; X86-NEXT:movl %esp, %ebp
+; X86-NEXT:.cfi_def_cfa_register %ebp
+; X86-NEXT:andl $-8, %esp
+; X86-NEXT:subl $8, %esp
+; X86-NEXT:vmovsd {{.*#+}} xmm0 = mem[0],zero
+; X86-NEXT:vaddsd %xmm0, %xmm0, %xmm0
+; X86-NEXT:vmovapd %xmm0, %xmm1
+; X86-NEXT:#ARITH_FENCE
+; X86-NEXT:vaddsd %xmm0, %xmm1, %xmm0
+; X86-NEXT:vmovsd %xmm0, (%esp)
+; X86-NEXT:fldl (%esp)
+; X86-NEXT:movl %ebp, %esp
+; X86-NEXT:popl %ebp
+; X86-NEXT:.cfi_def_cfa %esp, 4
+; X86-NEXT:retl
+;

[PATCH] D74436: Change clang option -ffp-model=precise to select ffp-contract=on

2021-05-20 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

I created https://reviews.llvm.org/D102861 to make changes to the failing LNT 
tests. Hoping to push this commit after the test changes in D102862 
 are approved.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74436/new/

https://reviews.llvm.org/D74436

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


[PATCH] D74436: Change clang option -ffp-model=precise to select ffp-contract=on

2021-05-20 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

In D74436#2190566 , @lebedev.ri wrote:

> In D74436#2190492 , @lebedev.ri 
> wrote:
>
>> <...>
>
> And by codegen changes i mostly mean newly-set/now-unset fp fast-math 
> instruction flags.

I added some codegen tests to show you what ffp-contract is doing: the tests 
added are: ffp-contract={on,off,fast} * {ffast-math * fno-fast-math}


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74436/new/

https://reviews.llvm.org/D74436

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


[PATCH] D101640: [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 Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd30dfa86760c: [clang][patch] Add support for option 
-fextend-arguments={32,64}: widen integer… (authored by mibintc).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101640/new/

https://reviews.llvm.org/D101640

Files:
  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
  clang/test/CodeGen/extend-arg-64.c
  clang/test/Driver/fextend-args.c

Index: clang/test/Driver/fextend-args.c
===
--- /dev/null
+++ clang/test/Driver/fextend-args.c
@@ -0,0 +1,17 @@
+// Options for intel arch
+// RUN: %clang -### -target x86_64-apple-darwin -fextend-arguments=32 %s 2>&1 \
+// RUN: | FileCheck --implicit-check-not "-fextend-arguments=32"  %s
+// RUN: %clang -### -target x86_64-apple-darwin -fextend-arguments=64 %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK-64 %s
+
+// Unsupported target
+// RUN: not %clang -target aarch64-unknown-windows-msvc -fextend-arguments=32 %s 2>&1 \
+// RUN: | FileCheck -check-prefix=UNSUPPORTED-TARGET %s
+
+// Invalid option value
+// RUN: not %clang -target x86_64-apple-darwin -fextend-arguments=0 %s 2>&1 \
+// RUN: | FileCheck -check-prefix=INVALID-VALUE %s
+
+// CHECK-64: "-cc1" {{.*}}"-fextend-arguments=64"
+// UNSUPPORTED-TARGET: error: unsupported option
+// INVALID-VALUE: error: invalid argument '0' to -fextend-arguments
Index: clang/test/CodeGen/extend-arg-64.c
===
--- /dev/null
+++ clang/test/CodeGen/extend-arg-64.c
@@ -0,0 +1,103 @@
+// RUN: %clang_cc1 -DD128 -triple x86_64-apple-darwin -fextend-arguments=64  \
+// RUN:%s -emit-llvm -o - | FileCheck %s -check-prefix=CHECKEXT
+
+// When the option isn't selected, no effect
+// RUN: %clang_cc1 -DD128 -triple x86_64-apple-darwin  \
+// RUN: %s -emit-llvm -o - | FileCheck %s \
+// RUN:--implicit-check-not "ext {{.*}}to i64"
+
+// The option isn't supported on x86, no effect
+// RUN: %clang_cc1 -triple i386-pc-linux-gnu -fextend-arguments=64 \
+// RUN: %s -emit-llvm -o - | FileCheck %s \
+// RUN:--implicit-check-not "ext {{.*}}to i64"
+
+// The option isn't supported on ppc, no effect
+// RUN: %clang_cc1 -triple ppc64le -fextend-arguments=64 \
+// RUN: %s -emit-llvm -o - | FileCheck %s \
+// RUN:--implicit-check-not "ext {{.*}}to i64"
+
+int vararg(int, ...);
+void knr();
+
+unsigned int u32;
+int s32;
+unsigned short u16;
+short s16;
+unsigned char u8;
+signed char s8;
+long long ll;
+_ExtInt(23) ei23;
+float ff;
+double dd;
+#ifdef D128
+__int128 i128;
+#endif
+
+int test() {
+  // CHECK: define{{.*}} i32 @test{{.*}}
+
+  // CHECKEXT:  [[TAG_u32:%.*]] = load i32, i32* @u32{{.*}}
+  // CHECKEXT: [[CONV_u32:%.*]] = zext i32 [[TAG_u32]] to i64
+
+  // CHECKEXT:  [[TAG_s32:%.*]] = load i32, i32* @s32
+  // CHECKEXT: [[CONV_s32:%.*]] = sext i32 [[TAG_s32]] to i64
+
+  // CHECKEXT:  [[TAG_u16:%.*]] = load i16, i16* @u16
+  // CHECKEXT: [[CONV_u16:%.*]] = zext i16 [[TAG_u16]] to i64
+
+  // CHECKEXT:  [[TAG_s16:%.*]] = load i16, i16* @s16
+  // CHECKEXT: [[CONV_s16:%.*]] = sext i16 [[TAG_s16]] to i64
+
+  // CHECKEXT:  [[TAG_u8:%.*]] = load i8, i8* @u8
+  // CHECKEXT: [[CONV_u8:%.*]] = zext i8 [[TAG_u8]] to i64
+
+  // CHECKEXT:  [[TAG_s8:%.*]] = load i8, i8* @s8
+  // CHECKEXT: [[CONV_s8:%.*]] = sext i8 [[TAG_s8]] to i64
+  // CHECKEXT: call{{.*}} @vararg(i32 %0, i64 [[CONV_u32]], i64 [[CONV_s32]], i64 [[CONV_u16]], i64 [[CONV_s16]], i64 [[CONV_u8]], i64 [[CONV_s8]]
+
+  int sum = 0;
+  sum = vararg(sum, u32, s32, u16, s16, u8, s8);
+  knr(ll);
+  // CHECKEXT: load i64, i64* @ll
+  // CHECKEXT-NEXT: call void (i64, ...) bitcast {{.*}} @knr
+
+  knr(ei23);
+  // CHECKEXT: load i23, i23* @ei23
+  // CHECKEXT-NEXT: call void (i23, ...) bitcast{{.*}} @knr
+
+  knr(ff);
+  // CHECKEXT: load float
+  // CHECKEXT-NEXT: fpext float {{.*}} to double
+  // CHECKEXT-NEXT: call{{.*}} void (double, ...) bitcast{{.*}} @knr
+
+  knr(dd);
+  // CHECKEXT: load double
+  // CHECKEXT-NEXT: call{{.*}} void (double, ...) bitcast{{.*}} @knr
+
+#ifdef D128
+  knr(i128);
+  // CHECKEXT: load i128
+  // CHECKEXT: call{{.*}} void (i64, i64, ...) bitcast{{.*}} @knr
+#endif
+
+  knr(u32, s32, u16, s16, u8, s8);
+  // CHECKEXT:  [[TAg_u32:%.*]] = load i32, i32* @u32{{.*}}
+  // CHECKEXT: [[CONv_u32:%.*]] = zext i32 [[TAg_u32]] to i64
+
+  // CHECKEXT:  [[TAg_s32:%.*]] = load i32, i32* @s32
+  // CHECKEXT: [[CONv_s32:%.*]] = sext i32 [[TAg_s32]] to i64
+
+  // CHECKEXT:  [[TAg_u16:%.*]] = load i16, i16* @u16
+  // CHECKEXT: [[CONv_u16:%.*]] = zext i16 [[TA

[PATCH] D101192: Add support for #elifdef and #elifndef

2021-05-17 Thread Melanie Blower via Phabricator via cfe-commits
mibintc accepted this revision.
mibintc added a comment.
This revision is now accepted and ready to land.

let 'er rip


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101192/new/

https://reviews.llvm.org/D101192

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


[PATCH] D74436: Change clang option -ffp-model=precise to select ffp-contract=on

2021-05-14 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

There are 3 clang settings for ffp-contract (on, off, fast) but the FMF bits 
have only "allow contract".  Clang sets the "allow contract" bit in the 
IRBuilder only when ffp-contract=fast


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74436/new/

https://reviews.llvm.org/D74436

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


[PATCH] D74436: Change clang option -ffp-model=precise to select ffp-contract=on

2021-05-14 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 345526.
mibintc added a comment.

I rebased and enhanced the test case  clang/test/CodeGen/ffp-contract-option.c 
to show the effect of various ffp-contract={on,fast,off} * ffast-math=on,off in 
response to the request from @lebedev.ri  ; sorry for leaving this hanging for 
so long, I wasn't sure what to do about the optimization discrepancies but I 
have a plan now. We think it could be caused by a particular nuance on 
Broadwell.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74436/new/

https://reviews.llvm.org/D74436

Files:
  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

Index: clang/test/Driver/fp-model.c
===
--- clang/test/Driver/fp-model.c
+++ clang/test/Driver/fp-model.c
@@ -1,88 +1,90 @@
 // Test that incompatible combinations of -ffp-model= options
 // and other floating point options get a warning diagnostic.
-//
-// REQUIRES: clang-driver
 
-// RUN: %clang -### -ffp-model=fast -ffp-contract=off -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=fast -ffp-contract=off -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARN %s
 // WARN: warning: overriding '-ffp-model=fast' option with '-ffp-contract=off' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=fast -ffp-contract=on -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=fast -ffp-contract=on -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARN1 %s
 // WARN1: warning: overriding '-ffp-model=fast' option with '-ffp-contract=on' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -fassociative-math -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict -fassociative-math -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARN2 %s
 // WARN2: warning: overriding '-ffp-model=strict' option with '-fassociative-math' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -ffast-math -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict -ffast-math -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARN3 %s
 // WARN3: warning: overriding '-ffp-model=strict' option with '-ffast-math' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -ffinite-math-only -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict -ffinite-math-only -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARN4 %s
 // WARN4: warning: overriding '-ffp-model=strict' option with '-ffinite-math-only' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -ffp-contract=fast -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict -ffp-contract=fast -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARN5 %s
 // WARN5: warning: overriding '-ffp-model=strict' option with '-ffp-contract=fast' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -ffp-contract=on -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict -ffp-contract=fast -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN6 %s
+// WARN6: warning: overriding '-ffp-model=strict' option with '-ffp-contract=fast' [-Woverriding-t-option]
+
+// RUN: %clang -target x86_64 -### -ffp-model=strict -ffp-contract=on -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARN7 %s
 // WARN7: warning: overriding '-ffp-model=strict' option with '-ffp-contract=on' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -fno-honor-infinities -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict -fno-honor-infinities -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARN8 %s
 // WARN8: warning: overriding '-ffp-model=strict' option with '-fno-honor-infinities' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -fno-honor-nans -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict -fno-honor-nans -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARN9 %s
 // WARN9: warning: overriding '-ffp-model=strict' option with '-fno-honor-nans' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -fno-rounding-math -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict -fno-rounding-math -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARNa %s
 // WARNa: warning: overriding '-ffp-model=strict' option with '-fno-rounding-math' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -fno-signed-zeros -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict -fno-signed-zeros -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARNb %s
 // WARNb: warning: overriding '-ffp-model=strict' option with '-fno-signed-zeros' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -fno-trapping-math -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict -fno-trapping-math -c %s 2>&1 \
 // RUN:   |

[PATCH] D94376: [MemCpyOpt] Enable MemorySSA by default

2021-05-14 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

In my premerge testing, I see this fail which looks like the check string is 
incorrect:

  command stderr:
  
C:\ws\w16e2-2\llvm-project\premerge-checks\llvm\test\Other\new-pm-lto-defaults.ll:84:21:
 error: CHECK-O23SZ-NEXT: expected string not found in input
  
  ; CHECK-O23SZ-NEXT: Running pass: InvalidateAnalysisPass on 
foo
  
  ^
  
  :49:40: note: scanning from here
  
  Running analysis: GlobalsAA on [module]
  
 ^
  
  :50:1: note: possible intended match here
  
  Running pass: InvalidateAnalysisPass on foo
  
  https://reviews.llvm.org/harbormaster/unit/view/743692/ for D101640


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94376/new/

https://reviews.llvm.org/D94376

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


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

2021-05-13 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 345273.
mibintc added a comment.

Corrected the failing lit test and applied the clang-format patch


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101640/new/

https://reviews.llvm.org/D101640

Files:
  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
  clang/test/CodeGen/extend-arg-64.c
  clang/test/Driver/fextend-args.c

Index: clang/test/Driver/fextend-args.c
===
--- /dev/null
+++ clang/test/Driver/fextend-args.c
@@ -0,0 +1,17 @@
+// Options for intel arch
+// RUN: %clang -### -target x86_64-apple-darwin -fextend-arguments=32 %s 2>&1 \
+// RUN: | FileCheck --implicit-check-not "-fextend-arguments=32"  %s
+// RUN: %clang -### -target x86_64-apple-darwin -fextend-arguments=64 %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK-64 %s
+
+// Unsupported target
+// RUN: not %clang -target aarch64-unknown-windows-msvc -fextend-arguments=32 %s 2>&1 \
+// RUN: | FileCheck -check-prefix=UNSUPPORTED-TARGET %s
+
+// Invalid option value
+// RUN: not %clang -target x86_64-apple-darwin -fextend-arguments=0 %s 2>&1 \
+// RUN: | FileCheck -check-prefix=INVALID-VALUE %s
+
+// CHECK-64: "-cc1" {{.*}}"-fextend-arguments=64"
+// UNSUPPORTED-TARGET: error: unsupported option
+// INVALID-VALUE: error: invalid argument '0' to -fextend-arguments
Index: clang/test/CodeGen/extend-arg-64.c
===
--- /dev/null
+++ clang/test/CodeGen/extend-arg-64.c
@@ -0,0 +1,103 @@
+// RUN: %clang_cc1 -DD128 -triple x86_64-apple-darwin -fextend-arguments=64  \
+// RUN:%s -emit-llvm -o - | FileCheck %s -check-prefix=CHECKEXT
+
+// When the option isn't selected, no effect
+// RUN: %clang_cc1 -DD128 -triple x86_64-apple-darwin  \
+// RUN: %s -emit-llvm -o - | FileCheck %s \
+// RUN:--implicit-check-not "ext {{.*}}to i64"
+
+// The option isn't supported on x86, no effect
+// RUN: %clang_cc1 -triple i386-pc-linux-gnu -fextend-arguments=64 \
+// RUN: %s -emit-llvm -o - | FileCheck %s \
+// RUN:--implicit-check-not "ext {{.*}}to i64"
+
+// The option isn't supported on ppc, no effect
+// RUN: %clang_cc1 -triple ppc64le -fextend-arguments=64 \
+// RUN: %s -emit-llvm -o - | FileCheck %s \
+// RUN:--implicit-check-not "ext {{.*}}to i64"
+
+int vararg(int, ...);
+void knr();
+
+unsigned int u32;
+int s32;
+unsigned short u16;
+short s16;
+unsigned char u8;
+signed char s8;
+long long ll;
+_ExtInt(23) ei23;
+float ff;
+double dd;
+#ifdef D128
+__int128 i128;
+#endif
+
+int test() {
+  // CHECK: define{{.*}} i32 @test{{.*}}
+
+  // CHECKEXT:  [[TAG_u32:%.*]] = load i32, i32* @u32{{.*}}
+  // CHECKEXT: [[CONV_u32:%.*]] = zext i32 [[TAG_u32]] to i64
+
+  // CHECKEXT:  [[TAG_s32:%.*]] = load i32, i32* @s32
+  // CHECKEXT: [[CONV_s32:%.*]] = sext i32 [[TAG_s32]] to i64
+
+  // CHECKEXT:  [[TAG_u16:%.*]] = load i16, i16* @u16
+  // CHECKEXT: [[CONV_u16:%.*]] = zext i16 [[TAG_u16]] to i64
+
+  // CHECKEXT:  [[TAG_s16:%.*]] = load i16, i16* @s16
+  // CHECKEXT: [[CONV_s16:%.*]] = sext i16 [[TAG_s16]] to i64
+
+  // CHECKEXT:  [[TAG_u8:%.*]] = load i8, i8* @u8
+  // CHECKEXT: [[CONV_u8:%.*]] = zext i8 [[TAG_u8]] to i64
+
+  // CHECKEXT:  [[TAG_s8:%.*]] = load i8, i8* @s8
+  // CHECKEXT: [[CONV_s8:%.*]] = sext i8 [[TAG_s8]] to i64
+  // CHECKEXT: call{{.*}} @vararg(i32 %0, i64 [[CONV_u32]], i64 [[CONV_s32]], i64 [[CONV_u16]], i64 [[CONV_s16]], i64 [[CONV_u8]], i64 [[CONV_s8]]
+
+  int sum = 0;
+  sum = vararg(sum, u32, s32, u16, s16, u8, s8);
+  knr(ll);
+  // CHECKEXT: load i64, i64* @ll
+  // CHECKEXT-NEXT: call void (i64, ...) bitcast {{.*}} @knr
+
+  knr(ei23);
+  // CHECKEXT: load i23, i23* @ei23
+  // CHECKEXT-NEXT: call void (i23, ...) bitcast{{.*}} @knr
+
+  knr(ff);
+  // CHECKEXT: load float
+  // CHECKEXT-NEXT: fpext float {{.*}} to double
+  // CHECKEXT-NEXT: call{{.*}} void (double, ...) bitcast{{.*}} @knr
+
+  knr(dd);
+  // CHECKEXT: load double
+  // CHECKEXT-NEXT: call{{.*}} void (double, ...) bitcast{{.*}} @knr
+
+#ifdef D128
+  knr(i128);
+  // CHECKEXT: load i128
+  // CHECKEXT: call{{.*}} void (i64, i64, ...) bitcast{{.*}} @knr
+#endif
+
+  knr(u32, s32, u16, s16, u8, s8);
+  // CHECKEXT:  [[TAg_u32:%.*]] = load i32, i32* @u32{{.*}}
+  // CHECKEXT: [[CONv_u32:%.*]] = zext i32 [[TAg_u32]] to i64
+
+  // CHECKEXT:  [[TAg_s32:%.*]] = load i32, i32* @s32
+  // CHECKEXT: [[CONv_s32:%.*]] = sext i32 [[TAg_s32]] to i64
+
+  // CHECKEXT:  [[TAg_u16:%.*]] = load i16, i16* @u16
+  // CHECKEXT: [[CONv_u16:%.*]] = zext i16 [[TAg_u16]] to i64
+
+  // CHECKEXT:  [[TAg_s16:%.*]] = load i16, i16* @s16
+  // CHECKEXT: [[CONv_s16:%.*]] = sext i16 [[TAg_s16]] t

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

2021-05-13 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

In D101640#2757316 , @aaron.ballman 
wrote:

> In D101640#2757178 , @mibintc wrote:
>
>> In D101640#2757039 , 
>> @aaron.ballman wrote:
>>
>>> Thanks! The last remaining question to me is whether this should be a 
>>> target-specific option or whether it makes sense to allow it as an option 
>>> for any target.
>>
>> I thought the patch may be more acceptable to the community if we restricted 
>> it.
>
> I think we usually prefer more general solutions to target-specific ones, 
> typically. Given that the functionality is generally useful for easing 
> porting projects from 32- to 64-bits and that the code is simpler without the 
> target-specific bits, my preference is to go with the general solution unless 
> someone else has objections.

Actually I thought about it some more and I don't know, generally, in what 
condition to enable the option. For example, on x86 we don't want any 
transformation made, and on intel64 we do want the implicit cast inserted.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101640/new/

https://reviews.llvm.org/D101640

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


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

2021-05-13 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

In D101640#2757039 , @aaron.ballman 
wrote:

> Thanks! The last remaining question to me is whether this should be a 
> target-specific option or whether it makes sense to allow it as an option for 
> any target.

I thought the patch may be more acceptable to the community if we restricted it.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101640/new/

https://reviews.llvm.org/D101640

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


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

2021-05-13 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 345154.
mibintc added a comment.

I responded to most all @aaron.ballman 's review comments, may need a little 
more wordsmithing


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101640/new/

https://reviews.llvm.org/D101640

Files:
  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
  clang/test/CodeGen/extend-arg-64.c
  clang/test/Driver/fextend-args.c

Index: clang/test/Driver/fextend-args.c
===
--- /dev/null
+++ clang/test/Driver/fextend-args.c
@@ -0,0 +1,17 @@
+// Options for intel arch
+// RUN: %clang -### -target x86_64-apple-darwin -fextend-arguments=32 %s 2>&1 \
+// RUN: | FileCheck --implicit-check-not "-fextend-arguments=32"  %s
+// RUN: %clang -### -target x86_64-apple-darwin -fextend-arguments=64 %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK-64 %s
+
+// Unsupported target
+// RUN: not %clang -target aarch64-unknown-windows-msvc -fextend-arguments=32 %s 2>&1 \
+// RUN: | FileCheck -check-prefix=UNSUPPORTED-TARGET %s
+
+// Invalid option value
+// RUN: not %clang -target x86_64-apple-darwin -fextend-arguments=0 %s 2>&1 \
+// RUN: | FileCheck -check-prefix=INVALID-VALUE %s
+
+// CHECK-64: "-cc1" {{.*}}"-fextend-arguments=64"
+// UNSUPPORTED-TARGET: error: unsupported option
+// INVALID-VALUE: error: invalid argument '0' to -fextend-arguments
Index: clang/test/CodeGen/extend-arg-64.c
===
--- /dev/null
+++ clang/test/CodeGen/extend-arg-64.c
@@ -0,0 +1,99 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -fextend-arguments=64  \
+// RUN:%s -emit-llvm -o - | FileCheck %s -check-prefix=CHECKEXT
+
+// When the option isn't selected, no effect
+// RUN: %clang_cc1 -triple x86_64-apple-darwin  \
+// RUN: %s -emit-llvm -o - | FileCheck %s \
+// RUN:--implicit-check-not "ext {{.*}}to i64"
+
+// The option isn't supported on x86, no effect
+// RUN: %clang_cc1 -triple i386-pc-linux-gnu -fextend-arguments=64 \
+// RUN: %s -emit-llvm -o - | FileCheck %s \
+// RUN:--implicit-check-not "ext {{.*}}to i64"
+
+// The option isn't supported on ppc, no effect
+// RUN: %clang_cc1 -triple ppc64le -fextend-arguments=64 \
+// RUN: %s -emit-llvm -o - | FileCheck %s \
+// RUN:--implicit-check-not "ext {{.*}}to i64"
+
+int vararg(int, ...);
+void knr();
+
+unsigned int u32;
+int s32;
+unsigned short u16;
+short s16;
+unsigned char u8;
+signed char s8;
+long long ll;
+_ExtInt(23) ei23;
+float ff;
+double dd;
+__int128 i128;
+
+int test() {
+  // CHECK: define{{.*}} i32 @test{{.*}}
+
+  // CHECKEXT:  [[TAG_u32:%.*]] = load i32, i32* @u32{{.*}}
+  // CHECKEXT: [[CONV_u32:%.*]] = zext i32 [[TAG_u32]] to i64
+
+  // CHECKEXT:  [[TAG_s32:%.*]] = load i32, i32* @s32
+  // CHECKEXT: [[CONV_s32:%.*]] = sext i32 [[TAG_s32]] to i64
+
+  // CHECKEXT:  [[TAG_u16:%.*]] = load i16, i16* @u16
+  // CHECKEXT: [[CONV_u16:%.*]] = zext i16 [[TAG_u16]] to i64
+
+  // CHECKEXT:  [[TAG_s16:%.*]] = load i16, i16* @s16
+  // CHECKEXT: [[CONV_s16:%.*]] = sext i16 [[TAG_s16]] to i64
+
+  // CHECKEXT:  [[TAG_u8:%.*]] = load i8, i8* @u8
+  // CHECKEXT: [[CONV_u8:%.*]] = zext i8 [[TAG_u8]] to i64
+
+  // CHECKEXT:  [[TAG_s8:%.*]] = load i8, i8* @s8
+  // CHECKEXT: [[CONV_s8:%.*]] = sext i8 [[TAG_s8]] to i64
+  // CHECKEXT: call{{.*}} @vararg(i32 %0, i64 [[CONV_u32]], i64 [[CONV_s32]], i64 [[CONV_u16]], i64 [[CONV_s16]], i64 [[CONV_u8]], i64 [[CONV_s8]]
+
+  int sum = 0;
+  sum = vararg(sum, u32, s32, u16, s16, u8, s8);
+  knr(ll);
+  // CHECKEXT: load i64, i64* @ll
+  // CHECKEXT-NEXT: call void (i64, ...) bitcast {{.*}} @knr
+
+  knr(ei23);
+  // CHECKEXT: load i23, i23* @ei23
+  // CHECKEXT-NEXT: call void (i23, ...) bitcast{{.*}} @knr
+
+  knr(ff);
+  // CHECKEXT: load float
+  // CHECKEXT-NEXT: fpext float {{.*}} to double
+  // CHECKEXT-NEXT: call{{.*}} void (double, ...) bitcast{{.*}} @knr
+
+  knr(dd);
+  // CHECKEXT: load double
+  // CHECKEXT-NEXT: call{{.*}} void (double, ...) bitcast{{.*}} @knr
+
+  knr(i128);
+  // CHECKEXT: load i128
+  // CHECKEXT: call{{.*}} void (i64, i64, ...) bitcast{{.*}} @knr
+
+  knr(u32, s32, u16, s16, u8, s8);
+  // CHECKEXT:  [[TAg_u32:%.*]] = load i32, i32* @u32{{.*}}
+  // CHECKEXT: [[CONv_u32:%.*]] = zext i32 [[TAg_u32]] to i64
+
+  // CHECKEXT:  [[TAg_s32:%.*]] = load i32, i32* @s32
+  // CHECKEXT: [[CONv_s32:%.*]] = sext i32 [[TAg_s32]] to i64
+
+  // CHECKEXT:  [[TAg_u16:%.*]] = load i16, i16* @u16
+  // CHECKEXT: [[CONv_u16:%.*]] = zext i16 [[TAg_u16]] to i64
+
+  // CHECKEXT:  [[TAg_s16:%.*]] = load i16, i16* @s16
+  // CHECKEXT: [[CONv_s16:%.*]] = sext i16 [[TAg_s16]] to i64
+
+  // CHECKEXT:  [[

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

2021-05-12 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added inline comments.



Comment at: clang/test/CodeGen/extend-arg-64.c:19
+
+int vararg(int, ...);
+

aaron.ballman wrote:
> Can you also add a test for K&R C functions? e.g., `int knr();` `sum = 
> knr(sum, u32, s32, u16, s16, u8, s8);`
> 
> Also, can you show what happens when passing a `long long` and an `_ExtInt`
Yes I can add those tests.  BTW the _ExtInt types are not "promotable" 
therefore the UsualUnaryConversions have no effect. 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101640/new/

https://reviews.llvm.org/D101640

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


[PATCH] D102343: [clang][patch][FPEnv} Initialization of C++ globals not strictfp aware

2021-05-12 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added inline comments.



Comment at: clang/lib/CodeGen/CodeGenFunction.cpp:700
   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())

there's a whole bunch of places in this func that creates FD, I changed them 
into a single place. hope that's OK, or i could pull it out as a pre-patch if 
you prefer


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102343/new/

https://reviews.llvm.org/D102343

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


[PATCH] D102343: [clang][patch][FPEnv} Initialization of C++ globals not strictfp aware

2021-05-12 Thread Melanie Blower via Phabricator via cfe-commits
mibintc created this revision.
mibintc added reviewers: kpn, rjmccall, aaron.ballman, pcc.
Herald added a subscriber: martong.
Herald added a reviewer: shafik.
mibintc requested review of this revision.
Herald added a project: clang.

In the proposed patch https://reviews.llvm.org/D81178 @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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102343

Files:
  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/CGBlocks.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGNonTrivialStruct.cpp
  clang/lib/CodeGen/CGObjC.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  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

Index: clang/unittests/Sema/ExternalSemaSourceTest.cpp
===
--- clang/unittests/Sema/ExternalSemaSourceTest.cpp
+++ clang/unittests/Sema/ExternalSemaSourceTest.cpp
@@ -163,7 +163,8 @@
   CurrentSema->getPreprocessor().getIdentifierInfo(CorrectTo);
   auto *NewFunction = FunctionDecl::Create(
   Context, DestContext, SourceLocation(), SourceLocation(), ToIdent,
-  Context.getFunctionType(Context.VoidTy, {}, {}), nullptr, SC_Static);
+  Context.getFunctionType(Context.VoidTy, {}, {}), nullptr, SC_Static,
+  /*UsesFPIntrin*/ false);
   DestContext->addDecl(NewFunction);
   TypoCorrection Correction(ToIdent);
   Correction.addCorrectionDecl(NewFunction);
Index: clang/test/CodeGen/fp-floatcontrol-stack.cpp
===
--- clang/test/CodeGen/fp-floatcontrol-stack.cpp
+++ clang/test/CodeGen/fp-floatcontrol-stack.cpp
@@ -6,6 +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: noinline nounwind optnone mustprogress
+// CHECK-NOHONOR Function Attrs: noinline nounwind optnone mustprogress
 float fun_default FUN(1)
 //CHECK-LABEL: define {{.*}} @_Z11fun_defaultf{{.*}}
 #if DEFAULT
@@ -28,6 +32,10 @@
 // Rule: precise must be enabled
 #pragma float_control(except, on)
 #endif
+// CHECK-FAST: Function Attrs: noinline nounwind optnone mustprogress
+// 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
 float exc_on FUN(2)
 //CHECK-LABEL: define {{.*}} @_Z6exc_onf{{.*}}
 #if DEFAULT
@@ -46,7 +54,11 @@
 #endif
 
 #pragma float_control(pop)
-float exc_pop FUN(5)
+// CHECK-DDEFAULT Function Attrs: noinline nounwind optnone mustprogress
+// CHECK-DEBSTRICT Function Attrs: noinline nounwind optnone strictfp mustprogress
+// CHECK-FAST: Function Attrs: noinline nounwind optnone mustprogress
+// CHECK-NOHONOR Function Attrs: noinline nounwind optnone mustprogress
+float exc_pop FUN(5)
 //CHECK-LABEL: define {{.*}} @_Z7exc_popf{{.*}}
 #if DEFAULT
 //CHECK-DDEFAULT: call float @llvm.fmuladd{{.*}}
@@ -63,7 +75,7 @@
 #endif
 
 #pragma float_control(except, off)
-float exc_off FUN(5)
+float exc_off FUN(5)
 //CHECK-LABEL: define {{.*}} @_Z7exc_offf{{.*}}
 #if DEFAULT
 //CHECK-DDEFAULT: call float @llvm.fmuladd{{.*}}
@@ -80,7 +92,7 @@
 #endif
 
 #pragma float_control(precise, on, push)
-float precise_on FUN(3)
+float precise_on FUN(3)
 //CHECK-LABEL: define {{.*}} @_Z10precise_onf{{.*}}
 #if DEFAULT
 //CHECK-DDEFAULT: float {{.*}}llvm.fmuladd{{.*}}
@@ -97,7 +109,7 @@
 #endif
 
 #pragma float_control(pop)
-float precise_pop FUN(3)
+float precise_pop F

[PATCH] D93769: [clang] Add support for option -ffp-eval-method and extend #pragma float_control similarly

2021-05-07 Thread Melanie Blower via Phabricator via cfe-commits
mibintc marked 9 inline comments as done.
mibintc added inline comments.



Comment at: clang/include/clang/Lex/Preprocessor.h:181
   IdentifierInfo *Ident__is_target_environment;// __is_target_environment
+  IdentifierInfo *Ident__FLT_EVAL_METHOD__;// __FLT_EVAL_METHOD__
 

aaron.ballman wrote:
> Otherwise, when `LexExpandSpecialBuiltins` is `false`, I think this winds up 
> being an uninitialized pointer value.
thanks for catching this!



Comment at: clang/lib/Lex/PPMacroExpansion.cpp:1714
   });
-  } else if (II == Ident__has_cpp_attribute ||
- II == Ident__has_c_attribute) {
+  } else if (II == Ident__has_cpp_attribute || II == Ident__has_c_attribute) {
 bool IsCXX = II == Ident__has_cpp_attribute;

aaron.ballman wrote:
> It looks like some unrelated formatting changes snuck in.
clang-format really wants to fix this file



Comment at: clang/lib/Sema/Sema.cpp:216
+// Use setting from TargetInfo.
+PP.setCurrentFltEvalMethod(static_cast(
+ctxt.getTargetInfo().getFloatEvalMethod()));

aaron.ballman wrote:
> I don't think this cast is needed, is it? (It might make sense for the 
> `getFloatEvalMethod()` return type to be `int` rather than `unisnged` though, 
> given that we support negative values for implementation-defined semantics?)
You are so right. i changed the type and modified the identifier like you 
suggested to make things more easily understandable



Comment at: clang/test/CodeGen/fp-floatcontrol-pragma.cpp:240
+
+float mySub(float x, float y) {
+  // CHECK: define {{.*}}float {{.*}}mySub{{.*}}

aaron.ballman wrote:
> Can we also get some tests that show how this behaves with the less common 
> floating-point types like float16, bfloat16, float128, half?
I added tests __fp16 and __float128. I don't know if the other type names are 
supported in Intel, _Float16 isn't supported. I didn't see a typename half nor 
bfloat16 being used in any of the CodeGen tests, is this sufficient? if the 
predicate IsFloatingType is true and if the expression comes into 
UsualUnaryConversions then this new code should take effect 



Comment at: clang/test/Preprocessor/predefined-flteval-macro.c:1
+// RUN: %clang_cc1 -std=c11  -E -triple=aarch64 -xc  %s | FileCheck %s
+// RUN: %clang_cc1 -std=c11  -triple=aarch64 -xc  -fsyntax-only %s

Since __FLT_EVAL_METHOD__ is no longer a typical predefined macro, I removed 
all the tests from clang/test/Preprocessor/init.c (see above) and created this 
to test all the combinations


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93769/new/

https://reviews.llvm.org/D93769

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


[PATCH] D93769: [clang] Add support for option -ffp-eval-method and extend #pragma float_control similarly

2021-05-07 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 343666.
mibintc added a comment.

Respond to @aaron.ballman 's review


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93769/new/

https://reviews.llvm.org/D93769

Files:
  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
  clang/test/Preprocessor/predefined-flteval-macro.c

Index: clang/test/Preprocessor/predefined-flteval-macro.c
===
--- /dev/null
+++ clang/test/Preprocessor/predefined-flteval-macro.c
@@ -0,0 +1,346 @@
+// RUN: %clang_cc1 -std=c11  -E -triple=aarch64 -xc  %s | FileCheck %s
+// RUN: %clang_cc1 -std=c11  -triple=aarch64 -xc  -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -triple=arm64 -xc  -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -triple=aarch64_be -xc  -fsyntax-only %s
+// RUN: %clang_cc1  -triple=arm64 -xc++  -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=aarch64-apple-ios7.0 -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=aarch64-windows-msvc -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -triple=aarch64 -mcmodel=small -xc  -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -triple=aarch64 -mcmodel=tiny -xc  -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -triple=aarch64 -mcmodel=large -xc  -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=thumbv7-windows-msvc -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=arm-none-none -fsyntax-only %s
+// RUN: %clang_cc1  -x c++ -ffreestanding -triple=arm-none-none -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple arm-none-none -target-abi apcs-gnu -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=armeb-none-none -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=arm-none-linux-gnueabi -target-feature +soft-float -target-feature +soft-float-abi -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=arm-none-linux-gnueabi -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=armv6-unknown-cloudabi-eabihf -fsyntax-only %s
+// RUN: %clang -c -ffreestanding -target arm-netbsd-eabi -fsyntax-only %s
+// RUN: %clang -c -ffreestanding -target arm-netbsd-eabihf -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=arm-none-eabi -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=arm-none-eabihf -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=aarch64-none-eabi -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=aarch64-none-eabihf -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=aarch64-none-elf -fsyntax-only %s
+// RUN: %clang -target x86_64-apple-darwin -arch armv7s -x c -fsyntax-only %s
+// RUN: %clang -target x86_64-apple-darwin -arch armv6m -x c -fsyntax-only %s
+// RUN: %clang -target x86_64-apple-darwin -arch armv7m -x c -fsyntax-only %s
+// RUN: %clang -target x86_64-apple-darwin -arch armv7em -x c -fsyntax-only %s
+// RUN: %clang -target x86_64-apple-darwin -arch armv7 -x c -fsyntax-only %s
+// RUN: %clang -c -target arm -mhwdiv=arm -x c -fsyntax-only %s
+// RUN: %clang -c -target arm -mthumb -mhwdiv=thumb -x c -fsyntax-only %s
+// RUN: %clang -c -target arm -x c -fsyntax-only %s
+// RUN: %clang -c -target arm -mthumb -x c -fsyntax-only %s
+// RUN: %clang -c -target arm -mhwdiv=thumb -x c -fsyntax-only %s
+// RUN: %clang -c -target arm -mthumb -mhwdiv=arm -x c -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=armv8-none-none -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=armebv8-none-none -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=thumbv8 -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=thumbebv8 -fsyntax-only %s
+// RUN: %clang_cc1 -std

[PATCH] D93769: [clang] Add support for option -ffp-eval-method and extend #pragma float_control similarly

2021-05-04 Thread Melanie Blower via Phabricator via cfe-commits
mibintc marked 5 inline comments as done.
mibintc added inline comments.



Comment at: clang/include/clang/Basic/LangOptions.h:234
+FEM_Extended,
+/// Use the default float eval method specified by Target
+FEM_TargetDefault

mibintc wrote:
> aaron.ballman wrote:
> > FYI: it may be somewhat confusing that we have an enumerator with `default` 
> > in the name but that enumerator isn't the default.
> That's true. I had a heck of a time getting the initialization of the lang 
> option setting correct: the setting should come from the TargetInfo if 
> command line options don't override. That seems simple enough but there's 
> somethng really odd about initialization. Adding the "default target" 
> enumeral allowed me to get it initialized the way I wanted.
I redid the comments to eliminate the confusion



Comment at: clang/lib/Sema/SemaAttr.cpp:429
+  case PFC_Source:
+//Builder.defineMacro("__FLT_EVAL_METHOD__", Twine("0"));
+NewFPFeatures.setFPEvalMethodOverride(LangOptions::FEM_Source);

mibintc wrote:
> @rjmccall I would like to push a new value for __FLT_EVAL_METHOD__ at the 
> start of the scope of this pragma, then pop that value of the macro to 
> restore the previous setting when the scope is exited, should I do that in 
> ParsePragma? Can I do that by injecting "pragma push_macro(...)" into the 
> token stream, do you have other suggestion or is there something similar in 
> clang that I can study how to do this? 
Nevermind, I found a way to set the macro.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93769/new/

https://reviews.llvm.org/D93769

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


[PATCH] D93769: [clang] Add support for option -ffp-eval-method and extend #pragma float_control similarly

2021-05-04 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 342792.
mibintc added a comment.

I rebased the patch and responded to review comments from @aaron.ballman and 
@jansvoboda11


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93769/new/

https://reviews.llvm.org/D93769

Files:
  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/Driver/Options.td
  clang/include/clang/Lex/Preprocessor.h
  clang/include/clang/Lex/PreprocessorOptions.h
  clang/include/clang/Sema/Sema.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
  clang/test/Preprocessor/predefined-flteval-macro.c

Index: clang/test/Preprocessor/predefined-flteval-macro.c
===
--- /dev/null
+++ clang/test/Preprocessor/predefined-flteval-macro.c
@@ -0,0 +1,346 @@
+// RUN: %clang_cc1 -std=c11  -E -triple=aarch64 -xc  %s | FileCheck %s
+// RUN: %clang_cc1 -std=c11  -triple=aarch64 -xc  -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -triple=arm64 -xc  -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -triple=aarch64_be -xc  -fsyntax-only %s
+// RUN: %clang_cc1  -triple=arm64 -xc++  -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=aarch64-apple-ios7.0 -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=aarch64-windows-msvc -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -triple=aarch64 -mcmodel=small -xc  -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -triple=aarch64 -mcmodel=tiny -xc  -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -triple=aarch64 -mcmodel=large -xc  -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=thumbv7-windows-msvc -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=arm-none-none -fsyntax-only %s
+// RUN: %clang_cc1  -x c++ -ffreestanding -triple=arm-none-none -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple arm-none-none -target-abi apcs-gnu -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=armeb-none-none -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=arm-none-linux-gnueabi -target-feature +soft-float -target-feature +soft-float-abi -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=arm-none-linux-gnueabi -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=armv6-unknown-cloudabi-eabihf -fsyntax-only %s
+// RUN: %clang -c -ffreestanding -target arm-netbsd-eabi -fsyntax-only %s
+// RUN: %clang -c -ffreestanding -target arm-netbsd-eabihf -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=arm-none-eabi -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=arm-none-eabihf -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=aarch64-none-eabi -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=aarch64-none-eabihf -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=aarch64-none-elf -fsyntax-only %s
+// RUN: %clang -target x86_64-apple-darwin -arch armv7s -x c -fsyntax-only %s
+// RUN: %clang -target x86_64-apple-darwin -arch armv6m -x c -fsyntax-only %s
+// RUN: %clang -target x86_64-apple-darwin -arch armv7m -x c -fsyntax-only %s
+// RUN: %clang -target x86_64-apple-darwin -arch armv7em -x c -fsyntax-only %s
+// RUN: %clang -target x86_64-apple-darwin -arch armv7 -x c -fsyntax-only %s
+// RUN: %clang -c -target arm -mhwdiv=arm -x c -fsyntax-only %s
+// RUN: %clang -c -target arm -mthumb -mhwdiv=thumb -x c -fsyntax-only %s
+// RUN: %clang -c -target arm -x c -fsyntax-only %s
+// RUN: %clang -c -target arm -mthumb -x c -fsyntax-only %s
+// RUN: %clang -c -target arm -mhwdiv=thumb -x c -fsyntax-only %s
+// RUN: %clang -c -target arm -mthumb -mhwdiv=arm -x c -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=armv8-none-none -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=armebv8-none-none -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=thumbv8 -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=thumbebv8 -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=thumbv5 -fsyntax-only %s
+

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

2021-05-04 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 342750.
mibintc added a comment.

Responded to suggestions from @jansvoboda11


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101640/new/

https://reviews.llvm.org/D101640

Files:
  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
  clang/test/CodeGen/extend-arg-64.c
  clang/test/Driver/fextend-args.c

Index: clang/test/Driver/fextend-args.c
===
--- /dev/null
+++ clang/test/Driver/fextend-args.c
@@ -0,0 +1,17 @@
+// Options for intel arch
+// RUN: %clang -### -target x86_64-apple-darwin -fextend-arguments=32 %s 2>&1 \
+// RUN: | FileCheck --implicit-check-not "-fextend-arguments=32"  %s
+// RUN: %clang -### -target x86_64-apple-darwin -fextend-arguments=64 %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK-64 %s
+
+// Unsupported target
+// RUN: not %clang -target aarch64-unknown-windows-msvc -fextend-arguments=32 %s 2>&1 \
+// RUN: | FileCheck -check-prefix=UNSUPPORTED-TARGET %s
+
+// Invalid option value
+// RUN: not %clang -target x86_64-apple-darwin -fextend-arguments=0 %s 2>&1 \
+// RUN: | FileCheck -check-prefix=INVALID-VALUE %s
+
+// CHECK-64: "-cc1" {{.*}}"-fextend-arguments=64"
+// UNSUPPORTED-TARGET: error: unsupported option
+// INVALID-VALUE: error: invalid argument '0' to -fextend-arguments
Index: clang/test/CodeGen/extend-arg-64.c
===
--- /dev/null
+++ clang/test/CodeGen/extend-arg-64.c
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -fextend-arguments=64  \
+// RUN:%s -emit-llvm -o - | FileCheck %s -check-prefix=CHECKEXT
+
+// When the option isn't selected, no effect
+// RUN: %clang_cc1 -triple x86_64-apple-darwin  \
+// RUN: %s -emit-llvm -o - | FileCheck %s \
+// RUN:--implicit-check-not "ext {{.*}}to i64"
+
+// The option isn't supported on x86, no effect
+// RUN: %clang_cc1 -triple i386-pc-linux-gnu -fextend-arguments=64 \
+// RUN: %s -emit-llvm -o - | FileCheck %s \
+// RUN:--implicit-check-not "ext {{.*}}to i64"
+
+// The option isn't supported on ppc, no effect
+// RUN: %clang_cc1 -triple ppc64le -fextend-arguments=64 \
+// RUN: %s -emit-llvm -o - | FileCheck %s \
+// RUN:--implicit-check-not "ext {{.*}}to i64"
+
+int vararg(int, ...);
+
+unsigned int u32;
+int s32;
+unsigned short u16;
+short s16;
+unsigned char u8;
+signed char s8;
+
+int test() {
+  // CHECK: define{{.*}} i32 @test{{.*}}
+
+  // CHECKEXT:  [[TAG_u32:%.*]] = load i32, i32* @u32{{.*}}
+  // CHECKEXT: [[CONV_u32:%.*]] = zext i32 [[TAG_u32]] to i64
+
+  // CHECKEXT:  [[TAG_s32:%.*]] = load i32, i32* @s32
+  // CHECKEXT: [[CONV_s32:%.*]] = sext i32 [[TAG_s32]] to i64
+
+  // CHECKEXT:  [[TAG_u16:%.*]] = load i16, i16* @u16
+  // CHECKEXT: [[CONV_u16:%.*]] = zext i16 [[TAG_u16]] to i64
+
+  // CHECKEXT:  [[TAG_s16:%.*]] = load i16, i16* @s16
+  // CHECKEXT: [[CONV_s16:%.*]] = sext i16 [[TAG_s16]] to i64
+
+  // CHECKEXT:  [[TAG_u8:%.*]] = load i8, i8* @u8
+  // CHECKEXT: [[CONV_u8:%.*]] = zext i8 [[TAG_u8]] to i64
+
+  // CHECKEXT:  [[TAG_s8:%.*]] = load i8, i8* @s8
+  // CHECKEXT: [[CONV_s8:%.*]] = sext i8 [[TAG_s8]] to i64
+  // CHECKEXT: call{{.*}} @vararg(i32 %0, i64 [[CONV_u32]], i64 [[CONV_s32]], i64 [[CONV_u16]], i64 [[CONV_s16]], i64 [[CONV_u8]], i64 [[CONV_s8]]
+
+  int sum = 0;
+  sum = vararg(sum, u32, s32, u16, s16, u8, s8);
+  return sum;
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -821,6 +821,17 @@
   E = ImpCastExprToType(E, Context.DoubleTy, CK_FloatingCast).get();
 }
   }
+  if (BTy &&
+  getLangOpts().getExtendIntArgs() ==
+  LangOptions::ExtendArgsKind::ExtendTo64 &&
+  Context.getTargetInfo().supportsExtendIntArgs() && Ty->isIntegerType()) {
+E = (Ty->isUnsignedIntegerType())
+? ImpCastExprToType(E, Context.UnsignedLongLongTy, CK_IntegralCast)
+  .get()
+: ImpCastExprToType(E, Context.LongLongTy, CK_IntegralCast).get();
+assert(8 == Context.getTypeSizeInChars(Context.LongLongTy).getQuantity() &&
+   "Unexpected typesize for LongLongTy");
+  }
 
   // C++ performs lvalue-to-rvalue conversion as a default argument
   // promotion, even on class types, but note:
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4908,6 +4908,20 @@
 
   RenderFloatingPointOptions(TC, D, OFastEnabled, Args, CmdArgs, JA);
 
+  if (Arg *A = Args.getL

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

2021-05-03 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 342478.
mibintc retitled this revision from "[clang][patch] Add support for option 
-fextend-arguments-64: widen integer arguments to int64 in unprototyped 
function calls" to "[clang][patch] Add support for option 
-fextend-arguments={32,64}: widen integer arguments to int64 in unprototyped 
function calls".
mibintc added a comment.

Respond to review comments from @jansvoboda11


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101640/new/

https://reviews.llvm.org/D101640

Files:
  clang/include/clang/Basic/LangOptions.def
  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
  clang/test/CodeGen/extend-arg-64.c
  clang/test/Driver/fextend-args.c

Index: clang/test/Driver/fextend-args.c
===
--- /dev/null
+++ clang/test/Driver/fextend-args.c
@@ -0,0 +1,17 @@
+// Options for intel arch
+// RUN: %clang -### -target x86_64-apple-darwin -fextend-arguments=32 %s 2>&1 \
+// RUN: | FileCheck --implicit-check-not "-fextend-arguments=32"  %s
+// RUN: %clang -### -target x86_64-apple-darwin -fextend-arguments=64 %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK-64 %s
+
+// Unsupported target
+// RUN: not %clang -target aarch64-unknown-windows-msvc -fextend-arguments=32 %s 2>&1 \
+// RUN: | FileCheck -check-prefix=UNSUPPORTED-TARGET %s
+
+// Invalid option value
+// RUN: not %clang -target x86_64-apple-darwin -fextend-arguments=0 %s 2>&1 \
+// RUN: | FileCheck -check-prefix=INVALID-VALUE %s
+
+// CHECK-64: "-cc1" {{.*}}"-fextend-arguments=64"
+// UNSUPPORTED-TARGET: error: unsupported option
+// INVALID-VALUE: error: invalid argument '0' to -fextend-arguments
Index: clang/test/CodeGen/extend-arg-64.c
===
--- /dev/null
+++ clang/test/CodeGen/extend-arg-64.c
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -fextend-arguments=64  \
+// RUN:%s -emit-llvm -o - | FileCheck %s -check-prefix=CHECKEXT
+
+// When the option isn't selected, no effect
+// RUN: %clang_cc1 -triple x86_64-apple-darwin  \
+// RUN: %s -emit-llvm -o - | FileCheck %s \
+// RUN:--implicit-check-not "ext {{.*}}to i64"
+
+// The option isn't supported on x86, no effect
+// RUN: %clang_cc1 -triple i386-pc-linux-gnu -fextend-arguments=64 \
+// RUN: %s -emit-llvm -o - | FileCheck %s \
+// RUN:--implicit-check-not "ext {{.*}}to i64"
+
+// The option isn't supported on ppc, no effect
+// RUN: %clang_cc1 -triple ppc64le -fextend-arguments=64 \
+// RUN: %s -emit-llvm -o - | FileCheck %s \
+// RUN:--implicit-check-not "ext {{.*}}to i64"
+
+int vararg(int, ...);
+
+unsigned int u32;
+int s32;
+unsigned short u16;
+short s16;
+unsigned char u8;
+signed char s8;
+
+int test() {
+  // CHECK: define{{.*}} i32 @test{{.*}}
+
+  // CHECKEXT:  [[TAG_u32:%.*]] = load i32, i32* @u32{{.*}}
+  // CHECKEXT: [[CONV_u32:%.*]] = zext i32 [[TAG_u32]] to i64
+
+  // CHECKEXT:  [[TAG_s32:%.*]] = load i32, i32* @s32
+  // CHECKEXT: [[CONV_s32:%.*]] = sext i32 [[TAG_s32]] to i64
+
+  // CHECKEXT:  [[TAG_u16:%.*]] = load i16, i16* @u16
+  // CHECKEXT: [[CONV_u16:%.*]] = zext i16 [[TAG_u16]] to i64
+
+  // CHECKEXT:  [[TAG_s16:%.*]] = load i16, i16* @s16
+  // CHECKEXT: [[CONV_s16:%.*]] = sext i16 [[TAG_s16]] to i64
+
+  // CHECKEXT:  [[TAG_u8:%.*]] = load i8, i8* @u8
+  // CHECKEXT: [[CONV_u8:%.*]] = zext i8 [[TAG_u8]] to i64
+
+  // CHECKEXT:  [[TAG_s8:%.*]] = load i8, i8* @s8
+  // CHECKEXT: [[CONV_s8:%.*]] = sext i8 [[TAG_s8]] to i64
+  // CHECKEXT: call{{.*}} @vararg(i32 %0, i64 [[CONV_u32]], i64 [[CONV_s32]], i64 [[CONV_u16]], i64 [[CONV_s16]], i64 [[CONV_u8]], i64 [[CONV_s8]]
+
+  int sum = 0;
+  sum = vararg(sum, u32, s32, u16, s16, u8, s8);
+  return sum;
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -821,6 +821,15 @@
   E = ImpCastExprToType(E, Context.DoubleTy, CK_FloatingCast).get();
 }
   }
+  if (BTy && getLangOpts().ExtendIntArgs == 64 &&
+  Context.getTargetInfo().supportsExtendIntArgs() && Ty->isIntegerType()) {
+E = (Ty->isUnsignedIntegerType())
+? ImpCastExprToType(E, Context.UnsignedLongLongTy, CK_IntegralCast)
+  .get()
+: ImpCastExprToType(E, Context.LongLongTy, CK_IntegralCast).get();
+assert(8 == Context.getTypeSizeInChars(Context.LongLongTy).getQuantity() &&
+   "Unexpected typesize for LongLongTy");
+  }
 
   // C++ performs lvalue-to-rvalue conversion as a default argument
   // promotion, even on class types, but note:
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- 

[PATCH] D101640: [clang][patch] Add support for option -fextend-arguments-64: widen integer arguments to int64 in unprototyped function calls

2021-04-30 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

@erichkeane Can you suggest reviewers for this patch?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101640/new/

https://reviews.llvm.org/D101640

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


[PATCH] D101640: [clang][patch] Add support for option -fextend-arguments-64: widen integer arguments to int64 in unprototyped function calls

2021-04-30 Thread Melanie Blower via Phabricator via cfe-commits
mibintc created this revision.
mibintc added reviewers: kbsmith1, erichkeane.
mibintc added a project: clang-c.
Herald added subscribers: dexonsmith, dang, Anastasia.
mibintc requested review of this revision.
Herald added a project: clang.

The Intel C++ and Fortran compilers support the option 
-fextend-arguments={32,64}. One of our customers has requested that this 
support be added clang.  This option controls how scalar integral arguments are 
extended in calls to unprototyped and varargs functions. When we investigated 
the support for the ICL option, we discovered that "-fextend-arguments=32" had 
no effect in the generated code, so this patch proposes to support only 64 bit 
extension.  This patch is only meaningful for targets that pass int arguments 
in 64 bits.

For supported targets, signed int values are sign extended to 64 bits in the 
parameter list, and unsigned int values are zero extended to 64 bits.

@kbsmith1 tells me that this option is primarily useful for porting 32-bit 
programs to the 64-bit environment, and although that architecture shift 
happened years ago, the customer is still interested in this support.

It turns out that there is currently similar logic in clang support for the 
OpenCL option "cl_khr_fp64" which causes certain float arguments, in 
unprototyped context, to be expanded to float or double.

Will this change be acceptable?


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101640

Files:
  clang/include/clang/Basic/LangOptions.def
  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
  clang/test/CodeGen/extend-arg-64.c

Index: clang/test/CodeGen/extend-arg-64.c
===
--- /dev/null
+++ clang/test/CodeGen/extend-arg-64.c
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -fextend-arguments-64  \
+// RUN:%s -emit-llvm -o - | FileCheck %s -check-prefix=CHECKEXT
+
+// When the option isn't selected, no effect
+// RUN: %clang_cc1 -triple x86_64-apple-darwin  \
+// RUN: %s -emit-llvm -o - | FileCheck %s \
+// RUN:--implicit-check-not "ext {{.*}}to i64"
+
+// The option isn't supported on x86, no effect
+// RUN: %clang_cc1 -triple i386-pc-linux-gnu -fextend-arguments-64 \
+// RUN: %s -emit-llvm -o - | FileCheck %s \
+// RUN:--implicit-check-not "ext {{.*}}to i64"
+
+// The option isn't supported on ppc, no effect
+// RUN: %clang_cc1 -triple ppc64le -fextend-arguments-64 \
+// RUN: %s -emit-llvm -o - | FileCheck %s \
+// RUN:--implicit-check-not "ext {{.*}}to i64"
+
+int vararg(int, ...);
+
+unsigned int u32;
+int s32;
+unsigned short u16;
+short s16;
+unsigned char u8;
+signed char s8;
+
+int test() {
+  // CHECK: define{{.*}} i32 @test{{.*}}
+
+  // CHECKEXT:  [[TAG_u32:%.*]] = load i32, i32* @u32{{.*}}
+  // CHECKEXT: [[CONV_u32:%.*]] = zext i32 [[TAG_u32]] to i64
+
+  // CHECKEXT:  [[TAG_s32:%.*]] = load i32, i32* @s32
+  // CHECKEXT: [[CONV_s32:%.*]] = sext i32 [[TAG_s32]] to i64
+
+  // CHECKEXT:  [[TAG_u16:%.*]] = load i16, i16* @u16
+  // CHECKEXT: [[CONV_u16:%.*]] = zext i16 [[TAG_u16]] to i64
+
+  // CHECKEXT:  [[TAG_s16:%.*]] = load i16, i16* @s16
+  // CHECKEXT: [[CONV_s16:%.*]] = sext i16 [[TAG_s16]] to i64
+
+  // CHECKEXT:  [[TAG_u8:%.*]] = load i8, i8* @u8
+  // CHECKEXT: [[CONV_u8:%.*]] = zext i8 [[TAG_u8]] to i64
+
+  // CHECKEXT:  [[TAG_s8:%.*]] = load i8, i8* @s8
+  // CHECKEXT: [[CONV_s8:%.*]] = sext i8 [[TAG_s8]] to i64
+  // CHECKEXT: call{{.*}} @vararg(i32 %0, i64 [[CONV_u32]], i64 [[CONV_s32]], i64 [[CONV_u16]], i64 [[CONV_s16]], i64 [[CONV_u8]], i64 [[CONV_s8]]
+
+  int sum = 0;
+  sum = vararg(sum, u32, s32, u16, s16, u8, s8);
+  return sum;
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -821,6 +821,15 @@
   E = ImpCastExprToType(E, Context.DoubleTy, CK_FloatingCast).get();
 }
   }
+  if (BTy && getLangOpts().ExtendArgs64 &&
+  Context.getTargetInfo().supportsExtendArgs64() && Ty->isIntegerType()) {
+E = (Ty->isUnsignedIntegerType())
+? ImpCastExprToType(E, Context.UnsignedLongLongTy, CK_IntegralCast)
+  .get()
+: ImpCastExprToType(E, Context.LongLongTy, CK_IntegralCast).get();
+assert(8 == Context.getTypeSizeInChars(Context.LongLongTy).getQuantity() &&
+   "Unexpected typesize for LongLongTy");
+  }
 
   // C++ performs lvalue-to-rvalue conversion as a default argument
   // promotion, even on class types, but note:
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4908,6 +4908,9 @@
 
   RenderFloatingPo

[PATCH] D96203: [clang][patch] Modify sanitizer options names: renaming blacklist to blocklist

2021-04-27 Thread Melanie Blower via Phabricator via cfe-commits
mibintc abandoned this revision.
mibintc added a comment.

There was no resolution about what option name would be acceptable


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96203/new/

https://reviews.llvm.org/D96203

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


[PATCH] D100118: [clang] RFC Support new builtin __arithmetic_fence to control floating point optimization, and new clang option fprotect-parens

2021-04-26 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

some inline comments for reviewers




Comment at: clang/include/clang/Basic/TargetInfo.h:1162
   /// the language based on the target options where applicable.
-  virtual void adjust(LangOptions &Opts);
+  virtual void adjust(DiagnosticsEngine &Diags, LangOptions &Opts);
 

There's no good place to diagnose when LangOptions and TargetOptions conflict, 
I see "conflict" diagnostics being emitted in clang/CodeGen when creating the 
func or module, which seems wrong to me. On the other hand, the "adjust" 
function makes a good place to do the reconciliation I think. This is the 
change that could be pulled out in a refactoring and committed prior to this 
patch. What do you think? 



Comment at: clang/include/clang/Driver/Options.td:4300
 defm pack_derived : BooleanFFlag<"pack-derived">, Group;
-defm protect_parens : BooleanFFlag<"protect-parens">, Group;
+//defm protect_parens : BooleanFFlag<"protect-parens">, Group;
 defm range_check : BooleanFFlag<"range-check">, Group;

@jansvoboda11 This is a gfortran option, but I don't think there's a way to 
allow the same option spelling for gfortran and clang. Other clang options, 
like -short-enum, also have been pulled out of gfortran group, and the gfortran 
option test is an expected-fail test.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100118/new/

https://reviews.llvm.org/D100118

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


[PATCH] D100118: [clang] RFC Support new builtin __arithmetic_fence to control floating point optimization, and new clang option fprotect-parens

2021-04-26 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 340598.
mibintc added a reviewer: aaron.ballman.
mibintc added a comment.
Herald added subscribers: jansvoboda11, dexonsmith, lxfind, dang, kerbowa, 
kbarton, aheejin, jgravelle-google, sbc100, nhaehnle, jvesely, nemanjai, 
dschuff.

I think this patch is complete except it needs to wait until the parent patch 
is finished.  Also some re-factoring may be desireable, I'll add some inline 
comments about that.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100118/new/

https://reviews.llvm.org/D100118

Files:
  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/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/Basic/Targets/X86.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/ASTUnit.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaCoroutine.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGen/arithmetic-fence-builtin.c
  clang/test/Driver/clang_f_opts.c
  clang/test/Sema/arithmetic-fence-builtin.c
  clang/tools/clang-import-test/clang-import-test.cpp

Index: clang/tools/clang-import-test/clang-import-test.cpp
===
--- clang/tools/clang-import-test/clang-import-test.cpp
+++ clang/tools/clang-import-test/clang-import-test.cpp
@@ -208,7 +208,7 @@
   TargetInfo *TI = TargetInfo::CreateTargetInfo(
   Ins->getDiagnostics(), Ins->getInvocation().TargetOpts);
   Ins->setTarget(TI);
-  Ins->getTarget().adjust(Ins->getLangOpts());
+  Ins->getTarget().adjust(Ins->getDiagnostics(), Ins->getLangOpts());
   Ins->createFileManager();
   Ins->createSourceManager(Ins->getFileManager());
   Ins->createPreprocessor(TU_Complete);
Index: clang/test/Sema/arithmetic-fence-builtin.c
===
--- /dev/null
+++ clang/test/Sema/arithmetic-fence-builtin.c
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -o - -verify -x c++ %s
+// RUN: %clang_cc1 -triple ppc64le -DPPC -emit-llvm -o - -verify -x c++ %s
+// RUN: not %clang_cc1 -triple ppc64le -DPPC -emit-llvm -o - -x c++ %s \
+// RUN:-fprotect-parens 2>&1 | FileCheck -check-prefix=PPC %s
+#ifndef PPC
+int v;
+template  T addT(T a, T b) {
+  T *q = __arithmetic_fence(&a);
+  // expected-error@-1 {{operand of type 'float *' where floating, complex or a vector of such types is required ('float *' invalid)}}
+  // expected-error@-2 {{operand of type 'int *' where floating, complex or a vector of such types is required ('int *' invalid)}}
+  return __arithmetic_fence(a + b);
+  // expected-error@-1 {{operand of type 'int' where floating, complex or a vector of such types is required ('int' invalid)}}
+}
+int addit(int a, int b) {
+  float x, y;
+  typedef struct {
+int a, b;
+  } stype;
+  stype s;
+  s = __arithmetic_fence(s);// expected-error {{operand of type 'stype' where floating, complex or a vector of such types is required ('stype' invalid)}}
+  x = __arithmetic_fence(x, y); // expected-error {{too many arguments to function call, expected 1, have 2}}
+  // Complex is supported.
+  _Complex double cd, cd1;
+  cd = __arithmetic_fence(cd1);
+  // Vector is supported.
+  typedef float __v4hi __attribute__((__vector_size__(8)));
+  __v4hi vec1, vec2;
+  vec1 = __arithmetic_fence(vec2);
+
+  v = __arithmetic_fence(a + b); // expected-error {{operand of type 'int' where floating, complex or a vector of such types is required ('int' invalid)}}
+  float f = addT(a, b);   // expected-note {{in instantiation of function template specialization 'addT' requested here}}
+  int i = addT(1, 2);   // expected-note {{in instantiation of function template specialization 'addT' requested here}}
+  constexpr float d = 1.0 + 2.0;
+  constexpr float c = __arithmetic_fence(1.0 + 2.0);
+  // expected-error@-1 {{constexpr variable 'c' must be initialized by a constant expression}}
+  return 0;
+}
+// expected-error@+1 {{static_assert expression is not an integral constant expression}}
+static_assert( __arithmetic_fence(1.0 + 2.0), "message" );
+#else
+float addit(float a, float b) {
+  return __arithmetic_fence(a+b); // expected-error {{builtin is not supported on this target}}
+}
+#endif
+//PPC: error: option '-fprotect-parens' cannot be specified on this target
Index: clang/test/Driver/clang_f_opts.c
=

[PATCH] D101192: Add support for #elifdef and #elifndef

2021-04-26 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

Wow thanks for doing this! I worked on it a couple days a while ago but I 
abandoned the effort and went back to my day job.  It seems like preprocessing 
ought to be something like a "state machine" but I couldn't figure out the 
mechanism. Would it make sense to add some kind of high level description of 
the components, now that you've gone to the [presumably massive] effort of 
understanding it? Just a couple small comments above.




Comment at: clang/lib/Lex/PPDirectives.cpp:1059
+case tok::pp_elifdef:
+  return HandleElifdefDirective(Result, SavedHash, false,
+true /*not valid for miopt*/);

please put a comment on 'false'



Comment at: clang/lib/Lex/PPDirectives.cpp:1063
+  return HandleElifdefDirective(Result, SavedHash, true,
+ReadAnyTokensBeforeDirective);
 case tok::pp_else:

please put a comment on true 


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101192/new/

https://reviews.llvm.org/D101192

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


[PATCH] D100118: [clang] RFC Support new builtin __arithmetic_fence to control floating point optimization, and new clang option fprotect-parens

2021-04-21 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:2844
+  return RValue::get(
+  Builder.CreateArithmeticFence(ArgValue, ConvertType(ArgType)));
+return RValue::get(ArgValue);

mibintc wrote:
> mibintc wrote:
> > kpn wrote:
> > > Does this say that the fence will be silently dropped if any of the fast 
> > > math flags are disabled? Silently dropping something used for correctness 
> > > makes me nervous. Is there a case where all of these flags are required 
> > > for correct behavior of the fence?
> > Yes that is the idea, the clang builtin is only meaningful for float 
> > operations when -ffast-math is enabled.  If fast math isn't enabled then 
> > the operations should already be performed strictly.  I didn't have 
> > "isFast", should rewrite with isFast to make it easier to understand 
> Oops I'm wrong. @kbsmith1 tells me only the reassoc bit is interesting. i'll 
> need to fix this in the documentation etc. Thanks for your careful reading. 
BTW in the options parsing, any of the unsafe fp math options freciprocal-math, 
fsigned-zeros and fapprox-func have the effect of enabing 
LangOptions.AllowFPReassoc.  This is in the file Options.td


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100118/new/

https://reviews.llvm.org/D100118

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


[PATCH] D100118: [clang] RFC Support new builtin __arithmetic_fence to control floating point optimization, and new clang option fprotect-parens

2021-04-20 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:2844
+  return RValue::get(
+  Builder.CreateArithmeticFence(ArgValue, ConvertType(ArgType)));
+return RValue::get(ArgValue);

mibintc wrote:
> kpn wrote:
> > Does this say that the fence will be silently dropped if any of the fast 
> > math flags are disabled? Silently dropping something used for correctness 
> > makes me nervous. Is there a case where all of these flags are required for 
> > correct behavior of the fence?
> Yes that is the idea, the clang builtin is only meaningful for float 
> operations when -ffast-math is enabled.  If fast math isn't enabled then the 
> operations should already be performed strictly.  I didn't have "isFast", 
> should rewrite with isFast to make it easier to understand 
Oops I'm wrong. @kbsmith1 tells me only the reassoc bit is interesting. i'll 
need to fix this in the documentation etc. Thanks for your careful reading. 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100118/new/

https://reviews.llvm.org/D100118

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


[PATCH] D100118: [clang] RFC Support new builtin __arithmetic_fence to control floating point optimization, and new clang option fprotect-parens

2021-04-20 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:2844
+  return RValue::get(
+  Builder.CreateArithmeticFence(ArgValue, ConvertType(ArgType)));
+return RValue::get(ArgValue);

kpn wrote:
> Does this say that the fence will be silently dropped if any of the fast math 
> flags are disabled? Silently dropping something used for correctness makes me 
> nervous. Is there a case where all of these flags are required for correct 
> behavior of the fence?
Yes that is the idea, the clang builtin is only meaningful for float operations 
when -ffast-math is enabled.  If fast math isn't enabled then the operations 
should already be performed strictly.  I didn't have "isFast", should rewrite 
with isFast to make it easier to understand 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100118/new/

https://reviews.llvm.org/D100118

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


[PATCH] D100834: Bug 49739 - [Matrix] Support #pragma clang fp

2021-04-20 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

The diff appears to be 2 separate commits, so on first glance this is only 
patching the test files. Usually if I am working on a patch and have responded 
to comments, I compress the patch+updates into a single commit (git rebase -i) 
before creating a diff to upload to Phabricator.

Are there Matrix builtins that you wish to have decorated with the FMF? e.g. 
look at CGBuiltin.cpp


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100834/new/

https://reviews.llvm.org/D100834

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


[PATCH] D99675: RFC [llvm][clang] Create new intrinsic llvm.arith.fence to control FP optimization at expression level

2021-04-16 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

In D99675#2695424 , @kpn wrote:

> What changes are needed for a backend, and what happens if they aren't done?

In the clang patch, I'm planning to add into TargetInfo a function like "does 
the target support __arithmetic_fence"?
In the llvm patch, the fallback implementation could be to merely ignore the 
call, and pass through the operand value. Is that adequate?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D99675/new/

https://reviews.llvm.org/D99675

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


[PATCH] D99675: RFC [llvm][clang] Create new intrinsic llvm.arith.fence to control FP optimization at expression level

2021-04-16 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 338099.
mibintc added a comment.

I accidentally dropped the test case in previous commit.  Just adding it back 
in -- under the llvm/test directory (previously it was in the wrong location).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D99675/new/

https://reviews.llvm.org/D99675

Files:
  llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
  llvm/include/llvm/CodeGen/BasicTTIImpl.h
  llvm/include/llvm/CodeGen/ISDOpcodes.h
  llvm/include/llvm/CodeGen/SelectionDAGISel.h
  llvm/include/llvm/IR/IRBuilder.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/include/llvm/Support/TargetOpcodes.def
  llvm/include/llvm/Target/Target.td
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
  llvm/test/CodeGen/X86/arithmetic_fence.ll

Index: llvm/test/CodeGen/X86/arithmetic_fence.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/arithmetic_fence.ll
@@ -0,0 +1,122 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+fma | FileCheck %s --check-prefix=X86
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+fma | FileCheck %s --check-prefix=X64
+
+define float @f1(float %a, float %b, float %c) {
+; X86-LABEL: f1:
+; X86:   # %bb.0:
+; X86-NEXT:pushl %eax
+; X86-NEXT:.cfi_def_cfa_offset 8
+; X86-NEXT:vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero
+; X86-NEXT:vmovss {{.*#+}} xmm1 = mem[0],zero,zero,zero
+; X86-NEXT:vfmadd213ss {{.*#+}} xmm1 = (xmm0 * xmm1) + mem
+; X86-NEXT:vmovss %xmm1, (%esp)
+; X86-NEXT:flds (%esp)
+; X86-NEXT:popl %eax
+; X86-NEXT:.cfi_def_cfa_offset 4
+; X86-NEXT:retl
+;
+; X64-LABEL: f1:
+; X64:   # %bb.0:
+; X64-NEXT:vfmadd213ss {{.*#+}} xmm0 = (xmm1 * xmm0) + xmm2
+; X64-NEXT:retq
+  %mul = fmul fast float %b, %a
+  %add = fadd fast float %mul, %c
+  ret float %add
+}
+
+define float @f2(float %a, float %b, float %c) {
+; X86-LABEL: f2:
+; X86:   # %bb.0:
+; X86-NEXT:pushl %eax
+; X86-NEXT:.cfi_def_cfa_offset 8
+; X86-NEXT:vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero
+; X86-NEXT:vmulss {{[0-9]+}}(%esp), %xmm0, %xmm0
+; X86-NEXT:#ARITH_FENCE
+; X86-NEXT:vaddss {{[0-9]+}}(%esp), %xmm0, %xmm0
+; X86-NEXT:vmovss %xmm0, (%esp)
+; X86-NEXT:flds (%esp)
+; X86-NEXT:popl %eax
+; X86-NEXT:.cfi_def_cfa_offset 4
+; X86-NEXT:retl
+;
+; X64-LABEL: f2:
+; X64:   # %bb.0:
+; X64-NEXT:vmulss %xmm0, %xmm1, %xmm0
+; X64-NEXT:#ARITH_FENCE
+; X64-NEXT:vaddss %xmm2, %xmm0, %xmm0
+; X64-NEXT:retq
+  %mul = fmul fast float %b, %a
+  %tmp = call float @llvm.arithmetic.fence.f32(float %mul)
+  %add = fadd fast float %tmp, %c
+  ret float %add
+}
+
+define double @f3(double %a, double %b, double %c) {
+; X86-LABEL: f3:
+; X86:   # %bb.0:
+; X86-NEXT:pushl %ebp
+; X86-NEXT:.cfi_def_cfa_offset 8
+; X86-NEXT:.cfi_offset %ebp, -8
+; X86-NEXT:movl %esp, %ebp
+; X86-NEXT:.cfi_def_cfa_register %ebp
+; X86-NEXT:andl $-8, %esp
+; X86-NEXT:subl $8, %esp
+; X86-NEXT:vmovsd {{.*#+}} xmm0 = mem[0],zero
+; X86-NEXT:vaddsd 16(%ebp), %xmm0, %xmm0
+; X86-NEXT:vmovsd %xmm0, (%esp)
+; X86-NEXT:fldl (%esp)
+; X86-NEXT:movl %ebp, %esp
+; X86-NEXT:popl %ebp
+; X86-NEXT:.cfi_def_cfa %esp, 4
+; X86-NEXT:retl
+;
+; X64-LABEL: f3:
+; X64:   # %bb.0:
+; X64-NEXT:vaddsd %xmm2, %xmm1, %xmm0
+; X64-NEXT:retq
+  %1 = fadd fast double %a, %b
+  %2 = fsub fast double %c, %a
+  %3 = fadd fast double %1, %2
+  ret double %3
+}
+
+define double @f4(double %a, double %b, double %c) {
+; X86-LABEL: f4:
+; X86:   # %bb.0:
+; X86-NEXT:pushl %ebp
+; X86-NEXT:.cfi_def_cfa_offset 8
+; X86-NEXT:.cfi_offset %ebp, -8
+; X86-NEXT:movl %esp, %ebp
+; X86-NEXT:.cfi_def_cfa_register %ebp
+; X86-NEXT:andl $-8, %esp
+; X86-NEXT:subl $8, %esp
+; X86-NEXT:vmovsd {{.*#+}} xmm0 = mem[0],zero
+; X86-NEXT:vmovsd {{.*#+}} xmm1 = mem[0],zero
+; X86-NEXT:vaddsd 16(%ebp), %xmm1, %xmm2
+; X86-NEXT:#ARITH_FENCE
+; X86-NEXT:vsubsd %xmm1, %xmm0, %xmm0
+; X86-NEXT:vaddsd %xmm0, %xmm2, %xmm0
+; X86-NEXT:vmovsd %xmm0, (%esp)
+; X86-NEXT:fldl (%esp)
+; X86-NEXT:movl %ebp, %esp
+; X86-NEXT:popl %ebp
+; X86-NEXT:.cfi_def_cfa %esp, 4
+; X86-NEXT:retl
+;
+; X64-LABEL: f4:
+; X64:   # %bb.0:
+; X64-NEXT:vaddsd %xmm1, %xmm0, %xmm1
+; X64-NEXT:#ARITH_FENCE
+; X64-NEXT:vsubsd %xmm0, %xmm2, %xmm0
+; X64-NEXT:vaddsd %xmm0, %xmm1, %xmm0
+; X64-NEXT:retq
+  %1 = fadd fast double %a, %b
+  %t = call double @llvm.arithmetic.fence.f64(double %1)
+  %2 = fsub fast double %c, %a
+  %3 = fadd fast double %t, %2
+  ret double %3
+}
+
+declare float @llvm.arithmetic.fence.f32(float)
+declare

[PATCH] D100118: [clang] RFC Support new builtin __arithmetic_fence to control floating point optimization, and new clang option fprotect-parens

2021-04-15 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 337881.
mibintc retitled this revision from "[clang] RFC Support new builtin 
__arithmetic_fence to control floating point optiization" to "[clang] RFC 
Support new builtin __arithmetic_fence to control floating point optimization, 
and new clang option fprotect-parens".
mibintc added a comment.

This is a minor change with only formatting changes, this patch is not yet 
ready for review, only discussion. 
Together with the llvm parent patch, this simple program can now run end-to-end

  clang -c -ffast-math test.c
  
  float addF(float x, float y) {
return __arithmetic_fence(x + y);
  }


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100118/new/

https://reviews.llvm.org/D100118

Files:
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ExprConstant.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/arithmetic-fence-builtin.c
  clang/test/Sema/arithmetic-fence-builtin.c

Index: clang/test/Sema/arithmetic-fence-builtin.c
===
--- /dev/null
+++ clang/test/Sema/arithmetic-fence-builtin.c
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -o - -verify -x c++ %s
+int v;
+template  T addT(T a, T b) {
+  T *q = __arithmetic_fence(&a);
+  // expected-error@-1 {{operand of type 'float *' where floating, complex or a vector of such types is required ('float *' invalid)}}
+  // expected-error@-2 {{operand of type 'int *' where floating, complex or a vector of such types is required ('int *' invalid)}}
+  return __arithmetic_fence(a + b);
+  // expected-error@-1 {{operand of type 'int' where floating, complex or a vector of such types is required ('int' invalid)}}
+}
+int addit(int a, int b) {
+  float x, y;
+  typedef struct {
+int a, b;
+  } stype;
+  stype s;
+  s = __arithmetic_fence(s);// expected-error {{operand of type 'stype' where floating, complex or a vector of such types is required ('stype' invalid)}}
+  x = __arithmetic_fence(x, y); // expected-error {{too many arguments to function call, expected 1, have 2}}
+  // Complex is supported.
+  _Complex double cd, cd1;
+  cd = __arithmetic_fence(cd1);
+  // Vector is supported.
+  typedef float __v4hi __attribute__((__vector_size__(8)));
+  __v4hi vec1, vec2;
+  vec1 = __arithmetic_fence(vec2);
+
+  v = __arithmetic_fence(a + b); // expected-error {{operand of type 'int' where floating, complex or a vector of such types is required ('int' invalid)}}
+  float f = addT(a, b);   // expected-note {{in instantiation of function template specialization 'addT' requested here}}
+  int i = addT(1, 2);   // expected-note {{in instantiation of function template specialization 'addT' requested here}}
+  constexpr float d = 1.0 + 2.0;
+  constexpr float c = __arithmetic_fence(1.0 + 2.0);
+  // expected-error@-1 {{constexpr variable 'c' must be initialized by a constant expression}}
+  return 0;
+}
Index: clang/test/CodeGen/arithmetic-fence-builtin.c
===
--- /dev/null
+++ clang/test/CodeGen/arithmetic-fence-builtin.c
@@ -0,0 +1,35 @@
+// Test with fast math
+// RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm \
+// RUN: -menable-no-infs -menable-no-nans -menable-unsafe-fp-math \
+// RUN: -fno-signed-zeros -mreassociate -freciprocal-math \
+// RUN: -ffp-contract=fast -fno-rounding-math -ffast-math -ffinite-math-only \
+// RUN: -o - %s | FileCheck %s
+//
+// Test with fast math, showing incomplete implementaton for Complex
+// this test fails.
+// RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm \
+// RUN: -menable-no-infs -menable-no-nans -menable-unsafe-fp-math \
+// RUN: -fno-signed-zeros -mreassociate -freciprocal-math \
+// RUN: -ffp-contract=fast -fno-rounding-math -ffast-math -ffinite-math-only \
+// RUN: -o - -DSHOWBUG %s | FileCheck %s
+//
+// TBD: Add test without fast flags showing llvm intrinsic not created
+int v;
+int addit(float a, float b) {
+//CHECK: define {{.*}} @addit(float %a, float %b) #0 {
+#ifdef SHOWBUG
+  // Assertion fail in clang when try to Emit complex expression
+  // Complex should be supported.
+  _Complex double cd, cd1;
+  cd = __arithmetic_fence(cd1);
+#endif
+  // Vector should be supported.
+  typedef float __v2f32 __attribute__((__vector_size__(8)));
+  __v2f32 vec1, vec2;
+  vec1 = __arithmetic_fence(vec2);
+  // CHECK: call fast <2 x float> @llvm.arithmetic.fence.v2f32
+
+  v = __arithmetic_fence(a + b);
+  // CHECK: call fast float @llvm.arithmetic.fence.f32(float %add)
+  return 0;
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -1555,6 +1555,10 @@
 Diag(TheCall->getBeginLoc(), diag::warn_alloca)
 << 

[PATCH] D99675: RFC [llvm][clang] Create new intrinsic llvm.arith.fence to control FP optimization at expression level

2021-04-15 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 337879.
mibintc edited the summary of this revision.
mibintc added a comment.

This is a minor update from @pengfei which allows simple tests cases to run 
end-to-end with clang.
Also I changed the "summary" to reflect the review discussion around the FMA 
optimization, to choose "FMA is not allowed across a fence".


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D99675/new/

https://reviews.llvm.org/D99675

Files:
  llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
  llvm/include/llvm/CodeGen/BasicTTIImpl.h
  llvm/include/llvm/CodeGen/ISDOpcodes.h
  llvm/include/llvm/CodeGen/SelectionDAGISel.h
  llvm/include/llvm/IR/IRBuilder.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/include/llvm/Support/TargetOpcodes.def
  llvm/include/llvm/Target/Target.td
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp

Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
===
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
@@ -2321,6 +2321,11 @@
N->getOperand(0));
 }
 
+void SelectionDAGISel::Select_ARITH_FENCE(SDNode *N) {
+  CurDAG->SelectNodeTo(N, TargetOpcode::ARITH_FENCE, N->getValueType(0),
+   N->getOperand(0));
+}
+
 /// GetVBR - decode a vbr encoding whose top bit is set.
 LLVM_ATTRIBUTE_ALWAYS_INLINE static uint64_t
 GetVBR(uint64_t Val, const unsigned char *MatcherTable, unsigned &Idx) {
@@ -2872,6 +2877,9 @@
   case ISD::FREEZE:
 Select_FREEZE(NodeToMatch);
 return;
+  case ISD::ARITH_FENCE:
+Select_ARITH_FENCE(NodeToMatch);
+return;
   }
 
   assert(!NodeToMatch->isMachineOpcode() && "Node already selected!");
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
===
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -7210,6 +7210,13 @@
 }
 break;
   }
+  case Intrinsic::arithmetic_fence: {
+auto DL = getCurSDLoc();
+SDValue Val = getValue(FPI.getArgOperand(0));
+EVT ResultVT = TLI.getValueType(DAG.getDataLayout(), FPI.getType());
+setValue(&FPI, DAG.getNode(ISD::ARITH_FENCE, DL, ResultVT, Val));
+return;
+  }
   }
 
   // A few strict DAG nodes carry additional operands that are not
Index: llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
===
--- llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -1275,6 +1275,9 @@
   case TargetOpcode::PSEUDO_PROBE:
 emitPseudoProbe(MI);
 break;
+  case TargetOpcode::ARITH_FENCE:
+OutStreamer->emitRawComment("ARITH_FENCE");
+break;
   default:
 emitInstruction(&MI);
 if (CanDoExtraAnalysis) {
Index: llvm/include/llvm/Target/Target.td
===
--- llvm/include/llvm/Target/Target.td
+++ llvm/include/llvm/Target/Target.td
@@ -1172,6 +1172,12 @@
   let AsmString = "PSEUDO_PROBE";
   let hasSideEffects = 1;
 }
+def ARITH_FENCE : StandardPseudoInstruction {
+  let OutOperandList = (outs unknown:$dst);
+  let InOperandList = (ins unknown:$src);
+  let AsmString = "";
+  let hasSideEffects = false;
+}
 
 def STACKMAP : StandardPseudoInstruction {
   let OutOperandList = (outs);
Index: llvm/include/llvm/Support/TargetOpcodes.def
===
--- llvm/include/llvm/Support/TargetOpcodes.def
+++ llvm/include/llvm/Support/TargetOpcodes.def
@@ -117,6 +117,9 @@
 /// Pseudo probe
 HANDLE_TARGET_OPCODE(PSEUDO_PROBE)
 
+/// Arithmetic fence.
+HANDLE_TARGET_OPCODE(ARITH_FENCE)
+
 /// A Stackmap instruction captures the location of live variables at its
 /// position in the instruction stream. It is followed by a shadow of bytes
 /// that must lie within the function and not contain another stackmap.
Index: llvm/include/llvm/IR/Intrinsics.td
===
--- llvm/include/llvm/IR/Intrinsics.td
+++ llvm/include/llvm/IR/Intrinsics.td
@@ -1311,6 +1311,9 @@
 def int_pseudoprobe : Intrinsic<[], [llvm_i64_ty, llvm_i64_ty, llvm_i32_ty, llvm_i64_ty],
 [IntrInaccessibleMemOnly, IntrWillReturn]>;
 
+// Arithmetic fence intrinsic.
+def int_arithmetic_fence : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>], [IntrNoMem]>;
+
 // Intrinsics to support half precision floating point format
 let IntrProperties = [IntrNoMem, IntrWillReturn] in {
 def int_convert_to_fp16   : DefaultAttrsIntrinsic<[llvm_i16_ty], [llvm_anyfloat_ty]>;
Index: llvm/include/llvm/IR/IRBuilder.h
===

[PATCH] D100511: [clang] Modify diagnostic level from err to warn: anyx86_interrupt_regsave

2021-04-15 Thread Melanie Blower via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG938b863bb53f: [clang][patch] Modify diagnostic level from 
err to warn… (authored by mibintc).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100511/new/

https://reviews.llvm.org/D100511

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


Index: clang/test/Sema/attr-x86-interrupt.c
===
--- clang/test/Sema/attr-x86-interrupt.c
+++ clang/test/Sema/attr-x86-interrupt.c
@@ -51,7 +51,7 @@
 __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) {
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -6607,7 +6607,7 @@
 }
 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;
 }
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -293,9 +293,10 @@
   "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;


Index: clang/test/Sema/attr-x86-interrupt.c
===
--- clang/test/Sema/attr-x86-interrupt.c
+++ clang/test/Sema/attr-x86-interrupt.c
@@ -51,7 +51,7 @@
 __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) {
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -6607,7 +6607,7 @@
 }
 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;
 }
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -293,9 +293,10 @@
   "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;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D100511: [clang] Modify diagnostic level from err to warn: anyx86_interrupt_regsave

2021-04-15 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 337789.
mibintc marked an inline comment as done.
mibintc added a comment.

I added the InGroup rule for the new warning diagnostic like Aaron requested


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100511/new/

https://reviews.llvm.org/D100511

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


Index: clang/test/Sema/attr-x86-interrupt.c
===
--- clang/test/Sema/attr-x86-interrupt.c
+++ clang/test/Sema/attr-x86-interrupt.c
@@ -51,7 +51,7 @@
 __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) {
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -6607,7 +6607,7 @@
 }
 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;
 }
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -293,9 +293,10 @@
   "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;


Index: clang/test/Sema/attr-x86-interrupt.c
===
--- clang/test/Sema/attr-x86-interrupt.c
+++ clang/test/Sema/attr-x86-interrupt.c
@@ -51,7 +51,7 @@
 __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) {
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -6607,7 +6607,7 @@
 }
 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;
 }
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -293,9 +293,10 @@
   "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;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D100511: [clang] Modify diagnostic level from err to warn: anyx86_interrupt_regsave

2021-04-15 Thread Melanie Blower via Phabricator via cfe-commits
mibintc marked an inline comment as done.
mibintc added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:299
+  " with attribute 'no_caller_saved_registers'">,
+   InGroup;
 def warn_arm_interrupt_calling_convention : Warning<

rsmith wrote:
> Please don't add warnings directly to `-Wextra`; this should have its own 
> flag so that people who want to do this can turn the warning off without 
> turning off all of `-Wextra`.
Thanks, I had thought about removing InGroup before uploading to review 
but hurrying at the end of my work day and forgot. I was expecting the lit test 
to fail and I'd have to add Wextra onto the RUN line but I didn't need to do 
that, the diagnostic was produced without enabling.  Anyway I got rid of it 
like you asked.

BTW the only other diagnostic in this file marked Wextra is the arm diagnostic. 
That was added in https://reviews.llvm.org/D28820 
"warn_arm_interrupt_calling_convention"


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100511/new/

https://reviews.llvm.org/D100511

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


[PATCH] D100511: [clang] Modify diagnostic level from err to warn: anyx86_interrupt_regsave

2021-04-15 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 337731.
mibintc added a comment.

I removed the diagnostic from InGroup, that's the only change from 
previous revision


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100511/new/

https://reviews.llvm.org/D100511

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


Index: clang/test/Sema/attr-x86-interrupt.c
===
--- clang/test/Sema/attr-x86-interrupt.c
+++ clang/test/Sema/attr-x86-interrupt.c
@@ -51,7 +51,7 @@
 __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) {
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -6607,7 +6607,7 @@
 }
 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;
 }
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -293,8 +293,8 @@
   "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"
+def warn_anyx86_interrupt_regsave : Warning<
+  "interrupt service routine should 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">,


Index: clang/test/Sema/attr-x86-interrupt.c
===
--- clang/test/Sema/attr-x86-interrupt.c
+++ clang/test/Sema/attr-x86-interrupt.c
@@ -51,7 +51,7 @@
 __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) {
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -6607,7 +6607,7 @@
 }
 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;
 }
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -293,8 +293,8 @@
   "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"
+def warn_anyx86_interrupt_regsave : Warning<
+  "interrupt service routine should 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">,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D100511: [clang] Modify diagnostic level from err to warn: anyx86_interrupt_regsave

2021-04-14 Thread Melanie Blower via Phabricator via cfe-commits
mibintc created this revision.
mibintc added a reviewer: aaron.ballman.
Herald added a subscriber: pengfei.
mibintc requested review of this revision.
Herald added a project: clang.

I got a bug report that https://reviews.llvm.org/D97764 which introduced this 
diagnostic, was causing problems in interrupt service routines, complaining 
about functions like abort, exit, or the x86intrin routines (that are really 
just inlined asm). I think modifying the diagnostic level from error to warn is 
the safest way to deal with the problem.  Checking "always inline" attribute on 
the called function isn't itself enough without knowing that the called 
function is leaf.  (Separately, perhaps x86intrin functions should be decorated 
with attribute 'no_caller_saved_registers' in their declarations.)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100511

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


Index: clang/test/Sema/attr-x86-interrupt.c
===
--- clang/test/Sema/attr-x86-interrupt.c
+++ clang/test/Sema/attr-x86-interrupt.c
@@ -51,7 +51,7 @@
 __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) {
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -6607,7 +6607,7 @@
 }
 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;
 }
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -293,9 +293,10 @@
   "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;


Index: clang/test/Sema/attr-x86-interrupt.c
===
--- clang/test/Sema/attr-x86-interrupt.c
+++ clang/test/Sema/attr-x86-interrupt.c
@@ -51,7 +51,7 @@
 __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) {
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -6607,7 +6607,7 @@
 }
 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;
 }
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -293,9 +293,10 @@
   "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_interrup

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

2021-04-13 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

In D97764#2685742 , @craig.topper 
wrote:

> In D97764#2685655 , @mibintc wrote:
>
>> I received a bug report that this patch creates error diagnostics for calls 
>> to a builtin, like calling 'abort', 'exit' or one of the target builtins 
>> like __builtin_ia32_packssw then that call should be allowed without remark 
>> but this patch causes the compilation to fail.  We could require that all 
>> builtin's be declared with "no caller saved reg" but that's a big 
>> modification. I'm planning to make a change which igores builtin calls, but 
>> continue to error on any implicitly declared or user declared functions 
>> without the "no caller saved reg" attribute.
>
> Builtins like __builtin_ia32_packssw aren't usually called directly. The user 
> should be calling the always_inline wrapper functions in x86intrin.h. Would 
> that also fail?

Thanks for the suggestion Craig!  I could change the check to look for 
"always_inline" [that means they're always inlined and the call would never be 
created even with optimization disabled right? ] However, I don't see 
_builtin_ia32_packssw declared in .  In immintrin it is declared 
implicitly when the usage is seen for example 
_mm_packs_pi16(__m64 __m1, __m64 __m2)
{

  return (__m64)__builtin_ia32_packsswb((__v4hi)__m1, (__v4hi)__m2);

}

Is it a bug that __builtin_ia32_packsswb is omitted from the x86intrin 
declarations? Is there some tricky reason it's not declared?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97764/new/

https://reviews.llvm.org/D97764

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


  1   2   3   4   5   >