[clang] ac2c5af - [OPENMP] Fix mixture of omp and clang pragmas

2020-05-21 Thread KAWASHIMA Takahiro via cfe-commits

Author: ISHIGURO, Hiroshi
Date: 2020-05-22T12:53:37+09:00
New Revision: ac2c5af67f036ec810556372b16548ae9b663f36

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

LOG: [OPENMP] Fix mixture of omp and clang pragmas

Fixes PR45753

When a program that contains a loop to which both `omp parallel for`
pragma and `clang loop` pragma are associated is compiled with the
-fopenmp option, `clang loop` pragma did not take effect. The example
below should not be vectorized by the `clang loop` pragma but it was
actually vectorized. The cause is that `llvm.loop.vectorize.width`
was not output to the IR when -fopenmp is specified.

The fix attaches attributes if they exist for the loop.

[example.c]

```
int a[100], b[100];
void foo() {
  #pragma omp parallel for
  #pragma clang loop vectorize(disable)
  for (int i = 0; i < 100; i++)
a[i] += b[i] * i;
}
```

[compile]

```
$ clang -O2 -fopenmp example.c -c -Rpass=vect
example.c:3:11: remark: vectorized loop (vectorization width: 4, interleaved 
count: 2) [-Rpass=loop-vectorize]
  #pragma omp parallel for
  ^
```

[IR with -fopenmp]

```
$ clang -O2 exmaple.c -S -emit-llvm -mllvm -disable-llvm-optzns -o - -fopenmp | 
grep 'vectorize\.width'
```

[IR with -fno-openmp]

```
$ clang -O2 example.c -S -emit-llvm -mllvm -disable-llvm-optzns -o - 
-fno-openmp | grep 'vectorize\.width'
!7 = !{!"llvm.loop.vectorize.width", i32 1}
```

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

Added: 
clang/test/OpenMP/omp_with_loop_pragma.c

Modified: 
clang/lib/CodeGen/CGStmtOpenMP.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp 
b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index b6d45f026bbf..d12aa65af0ba 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -1730,8 +1730,19 @@ void CodeGenFunction::EmitOMPInnerLoop(
   auto CondBlock = createBasicBlock("omp.inner.for.cond");
   EmitBlock(CondBlock);
   const SourceRange R = S.getSourceRange();
-  LoopStack.push(CondBlock, SourceLocToDebugLoc(R.getBegin()),
- SourceLocToDebugLoc(R.getEnd()));
+
+  // If attributes are attached, push to the basic block with them.
+  const auto &OMPED = cast(S);
+  const CapturedStmt *ICS = OMPED.getInnermostCapturedStmt();
+  const Stmt *SS = ICS->getCapturedStmt();
+  const AttributedStmt *AS = dyn_cast_or_null(SS);
+  if (AS)
+LoopStack.push(CondBlock, CGM.getContext(), CGM.getCodeGenOpts(),
+   AS->getAttrs(), SourceLocToDebugLoc(R.getBegin()),
+   SourceLocToDebugLoc(R.getEnd()));
+  else
+LoopStack.push(CondBlock, SourceLocToDebugLoc(R.getBegin()),
+   SourceLocToDebugLoc(R.getEnd()));
 
   // If there are any cleanups between here and the loop-exit scope,
   // create a block to stage a loop exit along.

diff  --git a/clang/test/OpenMP/omp_with_loop_pragma.c 
b/clang/test/OpenMP/omp_with_loop_pragma.c
new file mode 100644
index ..c1536afa9901
--- /dev/null
+++ b/clang/test/OpenMP/omp_with_loop_pragma.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -verify -fopenmp -x c -emit-llvm %s -triple 
x86_64-unknown-linux -o - -femit-all-decls -disable-llvm-passes | FileCheck %s
+// RUN: %clang_cc1 -verify -x c -emit-llvm %s -triple x86_64-unknown-linux -o 
- -femit-all-decls -disable-llvm-passes | FileCheck %s
+// expected-no-diagnostics
+
+// CHECK: !{{[0-9]+}} = !{!"llvm.loop.vectorize.width", i32 1}
+void sub(double *restrict a, double *restrict b, int n) {
+  int i;
+
+#pragma omp parallel for
+#pragma clang loop vectorize(disable)
+  for (i = 0; i < n; i++) {
+a[i] = a[i] + b[i];
+  }
+}



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


[clang] 799b6b9 - [clang][docs] Use `option` directive in User's Manual

2022-11-21 Thread KAWASHIMA Takahiro via cfe-commits

Author: KAWASHIMA Takahiro
Date: 2022-11-22T10:40:54+09:00
New Revision: 799b6b9f3193bd8a4499da063dc7f74cfccadefd

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

LOG: [clang][docs] Use `option` directive in User's Manual

Sphinx has the `option` directive. Most option descriptions
in `clang/docs/UsersManual.rst` used it but some didn't.
This commit changes the remaining option descriptions to use
the `option` directive. This makes a consistent view in HTML.

The `option` directive automatically creates a cross-reference target.
So labeling by `.. _opt_XXX:` is almost unnecessary. However, options
with and without `no-` (e.g. `-fno-show-column`/`-fshow-column`)
cannot be distinguish for the cross-reference. So some required
`.. _opt_XXX:` directives are kept unremoved.

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

Added: 


Modified: 
clang/docs/OpenCLSupport.rst
clang/docs/UsersManual.rst

Removed: 




diff  --git a/clang/docs/OpenCLSupport.rst b/clang/docs/OpenCLSupport.rst
index 9372e63c0e62..8b68aa927116 100644
--- a/clang/docs/OpenCLSupport.rst
+++ b/clang/docs/OpenCLSupport.rst
@@ -34,7 +34,7 @@ Missing features or with limited support
   list
   
`__.
 
-- Command-line flag :ref:`-cl-ext ` (used to override 
extensions/
+- Command-line flag :option:`-cl-ext` (used to override extensions/
   features supported by a target) is missing support of some functionality 
i.e. that is
   implemented fully through libraries (see :ref:`library-based features and
   extensions `).
@@ -235,7 +235,7 @@ Note that by default targets like `SPIR-V`, `SPIR` or `X86` 
expose all the OpenC
 extensions. For all other targets the configuration has to be made explicitly.
 
 Note that the target extension support performed by clang can be overridden
-with :ref:`-cl-ext ` command-line flags.
+with :option:`-cl-ext` command-line flags.
 
 .. _opencl_ext_libs:
 
@@ -345,7 +345,7 @@ OpenCL C 3.0 Usage
 OpenCL C 3.0 language standard makes most OpenCL C 2.0 features optional. 
Optional
 functionality in OpenCL C 3.0 is indicated with the presence of feature-test 
macros
 (list of feature-test macros is `here 
`__).
-Command-line flag :ref:`-cl-ext ` can be used to override 
features supported by a target.
+Command-line flag :option:`-cl-ext` can be used to override features supported 
by a target.
 
 For cases when there is an associated extension for a specific feature (fp64 
and 3d image writes)
 user should specify both (extension and feature) in command-line flag:

diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 69dcd495d689..dd4356d48f10 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -165,7 +165,8 @@ output format of the diagnostics that it generates.
 
 .. _opt_fshow-column:
 
-**-f[no-]show-column**
+.. option:: -f[no-]show-column
+
Print column number in diagnostic.
 
This option, which defaults to on, controls whether or not Clang
@@ -187,7 +188,8 @@ output format of the diagnostics that it generates.
 
 .. _opt_fshow-source-location:
 
-**-f[no-]show-source-location**
+.. option:: -f[no-]show-source-location
+
Print source file/line/column information in diagnostic.
 
This option, which defaults to on, controls whether or not Clang
@@ -206,7 +208,8 @@ output format of the diagnostics that it generates.
 
 .. _opt_fcaret-diagnostics:
 
-**-f[no-]caret-diagnostics**
+.. option:: -f[no-]caret-diagnostics
+
Print source line and ranges from source code in diagnostic.
This option, which defaults to on, controls whether or not Clang
prints the source line, source ranges, and caret when emitting a
@@ -220,7 +223,8 @@ output format of the diagnostics that it generates.
 ^
 //
 
-**-f[no-]color-diagnostics**
+.. option:: -f[no-]color-diagnostics
+
This option, which defaults to on when a color-capable terminal is
detected, controls whether or not Clang prints diagnostics in color.
 
@@ -247,7 +251,8 @@ output format of the diagnostics that it generates.
 ^
 //
 
-**-fansi-escape-codes**
+.. option:: -fansi-escape-codes
+
Controls whether ANSI escape codes are used instead of the Windows Console
API to output colored diagnostics. This option is only used on Windows and
defaults to off.
@@ -277,7 +282,8 @@ output format of the diagnostics that it generates.
 
 .. _opt_fdiagnostics-show-option:
 
-**-f[no-]diagnostics-show-option**
+.. option:: -f[no-]diagnostics-show-option
+
Enable ``[-Woption]`` information in diagnostic line.
 
This option,

[clang] 2a0919b - [clang][docs] Remove an unnecessary space

2022-11-21 Thread KAWASHIMA Takahiro via cfe-commits

Author: KAWASHIMA Takahiro
Date: 2022-11-22T10:40:55+09:00
New Revision: 2a0919b965b88080ef67fdffe57d3fa8d865d885

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

LOG: [clang][docs] Remove an unnecessary space

Added: 


Modified: 
clang/docs/UsersManual.rst

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index dd4356d48f10..d93f0f2ce606 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -365,7 +365,7 @@ output format of the diagnostics that it generates.
* ``clang -fsave-optimization-record -c in.c -o out.o`` will generate
  ``out.opt.yaml``
 
-   * ``clang -fsave-optimization-record -c in.c `` will generate
+   * ``clang -fsave-optimization-record -c in.c`` will generate
  ``in.opt.yaml``
 
When targeting (Thin)LTO, the base is derived from the output filename, and



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


[clang] 9359185 - [clang][docs] Correct indent of option explanation

2022-11-21 Thread KAWASHIMA Takahiro via cfe-commits

Author: KAWASHIMA Takahiro
Date: 2022-11-22T10:40:56+09:00
New Revision: 93591851d8416b64ee756a87508add76da2395aa

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

LOG: [clang][docs] Correct indent of option explanation

Indentation is significant for Sphinx. Lines with indentation after
a `.. option::` line are treated as explanations of the option.

Added: 


Modified: 
clang/docs/UsersManual.rst

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index d93f0f2ce606..2861c6a4c3c2 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -681,8 +681,8 @@ control the crash diagnostics.
 
   Disable auto-generation of preprocessed source files during a clang crash.
 
-The -fno-crash-diagnostics flag can be helpful for speeding the process
-of generating a delta reduced test case.
+  The -fno-crash-diagnostics flag can be helpful for speeding the process
+  of generating a delta reduced test case.
 
 .. option:: -fcrash-diagnostics-dir=
 
@@ -849,14 +849,14 @@ Clang options that don't fit neatly into other categories.
   for NMake or Jom. Ignored unless another option causes Clang to emit a
   dependency file.
 
-When Clang emits a dependency file (e.g., you supplied the -M option)
-most filenames can be written to the file without any special formatting.
-Different Make tools will treat 
diff erent sets of characters as "special"
-and use 
diff erent conventions for telling the Make tool that the character
-is actually part of the filename. Normally Clang uses backslash to "escape"
-a special character, which is the convention used by GNU Make. The -MV
-option tells Clang to put double-quotes around the entire filename, which
-is the convention used by NMake and Jom.
+  When Clang emits a dependency file (e.g., you supplied the -M option)
+  most filenames can be written to the file without any special formatting.
+  Different Make tools will treat 
diff erent sets of characters as "special"
+  and use 
diff erent conventions for telling the Make tool that the character
+  is actually part of the filename. Normally Clang uses backslash to "escape"
+  a special character, which is the convention used by GNU Make. The -MV
+  option tells Clang to put double-quotes around the entire filename, which
+  is the convention used by NMake and Jom.
 
 .. option:: -femit-dwarf-unwind=
 
@@ -870,10 +870,10 @@ is the convention used by NMake and Jom.
   * ``default`` - Use the platform-specific default (``always`` for all
 non-arm64-platforms).
 
-``no-compact-unwind`` is a performance optimization -- Clang will emit smaller
-object files that are more quickly processed by the linker. This may cause
-binary compatibility issues on older x86_64 targets, however, so use it with
-caution.
+  ``no-compact-unwind`` is a performance optimization -- Clang will emit 
smaller
+  object files that are more quickly processed by the linker. This may cause
+  binary compatibility issues on older x86_64 targets, however, so use it with
+  caution.
 
 .. _configuration-files:
 
@@ -1431,7 +1431,7 @@ floating point semantic models: precise (the default), 
strict, and fast.
below to disable any of the individual optimizations in ``-ffast-math``
will cause ``__FAST_MATH__`` to no longer be set.
 
-  This option implies:
+   This option implies:
 
* ``-fno-honor-infinities``
 
@@ -1546,8 +1546,8 @@ floating point semantic models: precise (the default), 
strict, and fast.
 
Control floating point exception behavior. ``-fno-trapping-math`` allows 
optimizations that assume that floating point operations cannot generate traps 
such as divide-by-zero, overflow and underflow.
 
-- The option ``-ftrapping-math`` behaves identically to 
``-ffp-exception-behavior=strict``.
-- The option ``-fno-trapping-math`` behaves identically to 
``-ffp-exception-behavior=ignore``.   This is the default.
+   - The option ``-ftrapping-math`` behaves identically to 
``-ffp-exception-behavior=strict``.
+   - The option ``-fno-trapping-math`` behaves identically to 
``-ffp-exception-behavior=ignore``.   This is the default.
 
 .. option:: -ffp-contract=
 
@@ -1630,14 +1630,14 @@ floating point semantic models: precise (the default), 
strict, and fast.
 
 .. option:: -f[no-]rounding-math
 
-Force floating-point operations to honor the dynamically-set rounding mode by 
default.
+   Force floating-point operations to honor the dynamically-set rounding mode 
by default.
 
-The result of a floating-point operation often cannot be exactly represented 
in the result type and therefore must be rounded.  IEEE 754 describes 
diff erent rounding modes that control how to perform this rounding, not all of 
which are supported by all implementations.  C provides interfaces 
(``f

[clang] 3a95d7d - [clang] Fix -fp-model={strict|precise} to disable -fapprox-func

2022-11-21 Thread KAWASHIMA Takahiro via cfe-commits

Author: KAWASHIMA Takahiro
Date: 2022-11-22T13:04:26+09:00
New Revision: 3a95d7d0983af26811e72d238d94f11c25f1851a

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

LOG: [clang] Fix -fp-model={strict|precise} to disable -fapprox-func

`-fapprox-func` should be disabled by `-fp-model={strict|precise}`,
as well as other fast-math flags. See the last changes in
`clang/test/Driver/fp-model.c`.

Probably this route (`case options::OPT_ffp_model_EQ`) was forgot
to update in D106191 and D114564. There is no appropriate reason not
to disable the flag.

This commit also updates other regression tests, which are not directly
related to this bug, for consistency with other fast-math flags.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/CodeGen/fp-options-to-fast-math-flags.c
clang/test/Driver/fast-math.c
clang/test/Driver/fp-model.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 3833fb4b0bafd..fcf99c88d4c2c 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2808,6 +2808,7 @@ static void RenderFloatingPointOptions(const ToolChain 
&TC, const Driver &D,
   // If -ffp-model= is seen, reset to fno-fast-math
   HonorINFs = true;
   HonorNaNs = true;
+  ApproxFunc = false;
   // Turning *off* -ffast-math restores the toolchain default.
   MathErrno = TC.IsMathErrnoDefault();
   AssociativeMath = false;

diff  --git a/clang/test/CodeGen/fp-options-to-fast-math-flags.c 
b/clang/test/CodeGen/fp-options-to-fast-math-flags.c
index bd44eb3874048..d7fcc586fed4b 100644
--- a/clang/test/CodeGen/fp-options-to-fast-math-flags.c
+++ b/clang/test/CodeGen/fp-options-to-fast-math-flags.c
@@ -5,6 +5,7 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -fno-signed-zeros -emit-llvm 
-o - %s | FileCheck -check-prefix CHECK-NO-SIGNED-ZEROS %s
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -mreassociate -emit-llvm -o 
- %s | FileCheck -check-prefix CHECK-REASSOC %s
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -freciprocal-math -emit-llvm 
-o - %s | FileCheck -check-prefix CHECK-RECIP %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fapprox-func -emit-llvm -o 
- %s | FileCheck -check-prefix CHECK-AFN %s
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -funsafe-math-optimizations 
-emit-llvm -o - %s | FileCheck -check-prefix CHECK-UNSAFE %s
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -ffast-math -emit-llvm -o - 
%s | FileCheck -check-prefix CHECK-FAST %s
 
@@ -35,6 +36,9 @@ float test(float a) {
 // CHECK-RECIP: [[CALL_RES:%.+]] = call arcp float @fn(float noundef {{%.+}})
 // CHECK-RECIP: {{%.+}} = fadd arcp float {{%.+}}, [[CALL_RES]]
 
+// CHECK-AFN: [[CALL_RES:%.+]] = call afn float @fn(float noundef {{%.+}})
+// CHECK-AFN: {{%.+}} = fadd afn float {{%.+}}, [[CALL_RES]]
+
 // CHECK-UNSAFE: [[CALL_RES:%.+]] = call reassoc nsz arcp afn float @fn(float 
noundef {{%.+}})
 // CHECK-UNSAFE: {{%.+}} = fadd reassoc nsz arcp afn float {{%.+}}, 
[[CALL_RES]]
 

diff  --git a/clang/test/Driver/fast-math.c b/clang/test/Driver/fast-math.c
index 869c85650465e..fd21ef7913ded 100644
--- a/clang/test/Driver/fast-math.c
+++ b/clang/test/Driver/fast-math.c
@@ -91,6 +91,16 @@
 // CHECK-APPROX-FUNC: "-cc1"
 // CHECK-APPROX-FUNC: "-fapprox-func"
 //
+// RUN: %clang -### -fno-fast-math -fapprox-func -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-FAST-MATH-APPROX-FUNC %s
+// CHECK-NO-FAST-MATH-APPROX-FUNC: "-cc1"
+// CHECK-NO-FAST-MATH-APPROX-FUNC: "-fapprox-func"
+//
+// RUN: %clang -### -fapprox-func -fno-fast-math -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-APPROX-FUNC-NO-FAST-MATH %s
+// CHECK-APPROX-FUNC-NO-FAST-MATH: "-cc1"
+// CHECK-APPROX-FUNC-NO-FAST-MATH-NOT: "-fapprox-func"
+//
 // RUN: %clang -### -fmath-errno -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-MATH-ERRNO %s
 // CHECK-MATH-ERRNO: "-cc1"

diff  --git a/clang/test/Driver/fp-model.c b/clang/test/Driver/fp-model.c
index 4253cf7a50f20..28410afa595ae 100644
--- a/clang/test/Driver/fp-model.c
+++ b/clang/test/Driver/fp-model.c
@@ -77,6 +77,10 @@
 // RUN:   --check-prefix=WARN12 %s
 // WARN12-NOT: warning: overriding '-ffp-model=strict' option with 
'-ffp-model=strict' [-Woverriding-t-option]
 
+// RUN: %clang -### -ffp-model=strict -fapprox-func -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN13 %s
+// WARN13: warning: overriding '-ffp-model=strict' option with '-fapprox-func' 
[-Woverriding-t-option]
+
 // RUN: %clang -### -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-NOROUND %s
 // CHECK-NOROUND: "-cc1"
@@ -97,6 +101,7 @@
 // CHECK-FPM-FAST: "-cc1"
 // CHEC

[clang] 498abe2 - [clang][docs] Correct floating point option explanations

2022-12-02 Thread KAWASHIMA Takahiro via cfe-commits

Author: KAWASHIMA Takahiro
Date: 2022-12-02T17:50:13+09:00
New Revision: 498abe27dcf89ba7eb865ea6c46b217a7b68f082

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

LOG: [clang][docs] Correct floating point option explanations

Explanations for options of floating point are updated to match
the `RenderFloatingPointOptions` function in
`clang/lib/Driver/ToolChains/Clang.cpp`.

Missing explanations are also added.

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

Added: 


Modified: 
clang/docs/UsersManual.rst

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 2861c6a4c3c2c..d4e5b3565ee06 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -1437,6 +1437,8 @@ floating point semantic models: precise (the default), 
strict, and fast.
 
* ``-fno-honor-nans``
 
+   * ``-fapprox-func``
+
* ``-fno-math-errno``
 
* ``-ffinite-math-only``
@@ -1449,6 +1451,8 @@ floating point semantic models: precise (the default), 
strict, and fast.
 
* ``-fno-trapping-math``
 
+   * ``-fno-rounding-math``
+
* ``-ffp-contract=fast``
 
Note: ``-ffast-math`` causes ``crtfastmath.o`` to be linked with code. See
@@ -1457,7 +1461,7 @@ floating point semantic models: precise (the default), 
strict, and fast.
 .. option:: -fno-fast-math
 
Disable fast-math mode.  This options disables unsafe floating-point
-   optimizations by preventing the compiler from making any tranformations that
+   optimizations by preventing the compiler from making any transformations 
that
could affect the results.
 
This option implies:
@@ -1466,7 +1470,7 @@ floating point semantic models: precise (the default), 
strict, and fast.
 
* ``-fhonor-nans``
 
-   * ``-fmath-errno``
+   * ``-fno-approx-func``
 
* ``-fno-finite-math-only``
 
@@ -1476,14 +1480,15 @@ floating point semantic models: precise (the default), 
strict, and fast.
 
* ``-fsigned-zeros``
 
-   * ``-fno-trapping-math``
-
* ``-ffp-contract=on``
 
-   * ``-fdenormal-fp-math=ieee``
+   Also, this option resets following options to their target-dependent 
defaults.
+
+   * ``-f[no-]math-errno``
+   * ``-fdenormal-fp-math=``
 
There is ambiguity about how ``-ffp-contract``, ``-ffast-math``,
-   and ``-fno-fast-math`` behave in combination. To keep the value of
+   and ``-fno-fast-math`` behave when combined. To keep the value of
``-ffp-contract`` consistent, we define this set of rules:
 
* ``-ffast-math`` sets ``ffp-contract`` to ``fast``.
@@ -1516,7 +1521,8 @@ floating point semantic models: precise (the default), 
strict, and fast.
* ``preserve-sign`` - the sign of a flushed-to-zero number is preserved in 
the sign of 0
* ``positive-zero`` - denormals are flushed to positive zero
 
-   Defaults to ``ieee``.
+   The default value depends on the target. For most targets, defaults to
+   ``ieee``.
 
 .. option:: -f[no-]strict-float-cast-overflow
 
@@ -1525,6 +1531,7 @@ floating point semantic models: precise (the default), 
strict, and fast.
By default, Clang will not guarantee any particular result in that case.
With the 'no-strict' option, Clang will saturate towards the smallest and
largest representable integer values instead. NaNs will be converted to 
zero.
+   Defaults to ``-fstrict-float-cast-overflow``.
 
 .. option:: -f[no-]math-errno
 
@@ -1572,11 +1579,19 @@ floating point semantic models: precise (the default), 
strict, and fast.
 
 .. option:: -f[no-]honor-infinities
 
+   Allow floating-point optimizations that assume arguments and results are
+   not +-Inf.
+   Defaults to ``-fhonor-infinities``.
+
If both ``-fno-honor-infinities`` and ``-fno-honor-nans`` are used,
has the same effect as specifying ``-ffinite-math-only``.
 
 .. option:: -f[no-]honor-nans
 
+   Allow floating-point optimizations that assume arguments and results are
+   not NaNs.
+   Defaults to ``-fhonor-nans``.
+
If both ``-fno-honor-infinities`` and ``-fno-honor-nans`` are used,
has the same effect as specifying ``-ffinite-math-only``.
 
@@ -1592,7 +1607,7 @@ floating point semantic models: precise (the default), 
strict, and fast.
 .. option:: -f[no-]signed-zeros
 
Allow optimizations that ignore the sign of floating point zeros.
-   Defaults to ``-fno-signed-zeros``.
+   Defaults to ``-fsigned-zeros``.
 
 .. option:: -f[no-]associative-math
 
@@ -1608,24 +1623,48 @@ floating point semantic models: precise (the default), 
strict, and fast.
 
 .. option:: -f[no-]unsafe-math-optimizations
 
-   Allow unsafe floating-point optimizations. Also implies:
+   Allow unsafe floating-point optimizations.
+   ``-funsafe-math-optimizations`` also implies:
 
+   * ``-fapprox-func``
* ``-fassociative-math``
* ``-freciprocal

[clang] c8cd1a9 - [AArch64] Add support for Fujitsu A64FX

2020-03-09 Thread KAWASHIMA Takahiro via cfe-commits

Author: KAWASHIMA Takahiro
Date: 2020-03-09T19:15:09+09:00
New Revision: c8cd1a994d28e5e822bd0d3c9a6b0aae2abb510f

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

LOG: [AArch64] Add support for Fujitsu A64FX

A64FX is an Armv8.2-A CPU used in FUJITSU Supercomputer
PRIMEHPC FX1000, PRIMEHPC FX700, and supercomputer Fugaku.

https://www.fujitsu.com/global/products/computing/servers/supercomputer/specifications/

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

Added: 


Modified: 
clang/test/Driver/aarch64-cpus.c
clang/test/Preprocessor/aarch64-target-features.c
llvm/include/llvm/Support/AArch64TargetParser.def
llvm/lib/Support/Host.cpp
llvm/lib/Target/AArch64/AArch64.td
llvm/lib/Target/AArch64/AArch64Subtarget.cpp
llvm/lib/Target/AArch64/AArch64Subtarget.h
llvm/test/CodeGen/AArch64/cpus.ll
llvm/test/CodeGen/AArch64/preferred-function-alignment.ll
llvm/unittests/Support/Host.cpp
llvm/unittests/Support/TargetParserTest.cpp

Removed: 




diff  --git a/clang/test/Driver/aarch64-cpus.c 
b/clang/test/Driver/aarch64-cpus.c
index f1b53d98e150..36444f02e955 100644
--- a/clang/test/Driver/aarch64-cpus.c
+++ b/clang/test/Driver/aarch64-cpus.c
@@ -269,6 +269,20 @@
 // ARM64-THUNDERX2T99-TUNE: "-cc1"{{.*}} "-triple" "arm64{{.*}}" "-target-cpu" 
"generic"
 // ARM64-THUNDERX2T99-TUNE-NOT: +v8.1a
 
+// RUN: %clang -target aarch64 -mcpu=a64fx -### -c %s 2>&1 | FileCheck 
-check-prefix=A64FX %s
+// RUN: %clang -target aarch64 -mlittle-endian -mcpu=a64fx -### -c %s 2>&1 | 
FileCheck -check-prefix=A64FX %s
+// RUN: %clang -target aarch64 -mtune=a64fx -### -c %s 2>&1 | FileCheck 
-check-prefix=A64FX-TUNE %s
+// RUN: %clang -target aarch64 -mlittle-endian -mtune=a64fx -### -c %s 2>&1 | 
FileCheck -check-prefix=A64FX-TUNE %s
+// A64FX: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "a64fx"
+// A64FX-TUNE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "generic"
+
+// RUN: %clang -target arm64 -mcpu=a64fx -### -c %s 2>&1 | FileCheck 
-check-prefix=ARM64-A64FX %s
+// RUN: %clang -target arm64 -mlittle-endian -mcpu=a64fx -### -c %s 2>&1 | 
FileCheck -check-prefix=ARM64-A64FX %s
+// RUN: %clang -target arm64 -mtune=a64fx -### -c %s 2>&1 | FileCheck 
-check-prefix=ARM64-A64FX-TUNE %s
+// RUN: %clang -target arm64 -mlittle-endian -mtune=a64fx -### -c %s 2>&1 | 
FileCheck -check-prefix=ARM64-A64FX-TUNE %s
+// ARM64-A64FX: "-cc1"{{.*}} "-triple" "arm64{{.*}}" "-target-cpu" "a64fx"
+// ARM64-A64FX-TUNE: "-cc1"{{.*}} "-triple" "arm64{{.*}}" "-target-cpu" 
"generic"
+
 // RUN: %clang -target aarch64_be -### -c %s 2>&1 | FileCheck 
-check-prefix=GENERIC-BE %s
 // RUN: %clang -target aarch64 -mbig-endian -### -c %s 2>&1 | FileCheck 
-check-prefix=GENERIC-BE %s
 // RUN: %clang -target aarch64_be -mbig-endian -### -c %s 2>&1 | FileCheck 
-check-prefix=GENERIC-BE %s

diff  --git a/clang/test/Preprocessor/aarch64-target-features.c 
b/clang/test/Preprocessor/aarch64-target-features.c
index 9fb8dcecb9c0..c62c82a0c96a 100644
--- a/clang/test/Preprocessor/aarch64-target-features.c
+++ b/clang/test/Preprocessor/aarch64-target-features.c
@@ -160,6 +160,7 @@
 // RUN: %clang -target aarch64 -mcpu=exynos-m5 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-MCPU-M4 %s
 // RUN: %clang -target aarch64 -mcpu=kryo -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-MCPU-KRYO %s
 // RUN: %clang -target aarch64 -mcpu=thunderx2t99 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-MCPU-THUNDERX2T99 %s
+// RUN: %clang -target aarch64 -mcpu=a64fx -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-MCPU-A64FX %s
 // CHECK-MCPU-APPLE-A7: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" 
"-target-feature" "+fp-armv8" "-target-feature" "+neon" "-target-feature" 
"+crypto" "-target-feature" "+zcm" "-target-feature" "+zcz" "-target-feature" 
"+sha2" "-target-feature" "+aes"
 // CHECK-MCPU-APPLE-A10: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" 
"-target-feature" "+fp-armv8" "-target-feature" "+neon" "-target-feature" 
"+crc" "-target-feature" "+crypto" "-target-feature" "+rdm" "-target-feature" 
"+zcm" "-target-feature" "+zcz" "-target-feature" "+sha2" "-target-feature" 
"+aes"
 // CHECK-MCPU-APPLE-A11: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" 
"-target-feature" "+v8.2a" "-target-feature" "+fp-armv8" "-target-feature" 
"+neon" "-target-feature" "+crc" "-target-feature" "+crypto" "-target-feature" 
"+ras" "-target-feature" "+lse" "-target-feature" "+rdm" "-target-feature" 
"+zcm" "-target-feature" "+zcz" "-target-feature" "+sha2" "-target-feature" 
"+aes"
@@ -175,6 +176,7 @@
 // CHECK-MCPU-M4: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+neon" "-target-feature" "+crc" "-target-feature" "+crypto" "-target-feature" 
"+dotprod" "-target-feature" "+fullfp16"
 // CHECK-MCPU-KRYO: "-cc1"{{.*}} "-tripl

[clang] 6240627 - [docs] Fix bullet list formatting

2023-02-14 Thread KAWASHIMA Takahiro via cfe-commits

Author: KAWASHIMA Takahiro
Date: 2023-02-14T19:14:03+09:00
New Revision: 6240627cfda444550975ccaea20a3b6d68c9ad15

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

LOG: [docs] Fix bullet list formatting

reST requires an empty line before a bullet list.

Added: 


Modified: 
clang/docs/LanguageExtensions.rst

Removed: 




diff  --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index 20c8bb5de044..99f8cd59abec 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -797,6 +797,7 @@ emulation.
 ``_Float16`` will be supported on more targets as they define ABIs for it.
 
 ``__bf16`` is purely a storage format; it is currently only supported on the 
following targets:
+
 * 32-bit ARM
 * 64-bit ARM (AArch64)
 * X86 (see below)



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


[clang] e8d4484 - [docs] Update the ACLE URL

2023-02-14 Thread KAWASHIMA Takahiro via cfe-commits

Author: KAWASHIMA Takahiro
Date: 2023-02-14T19:14:04+09:00
New Revision: e8d44841c5d5f1e7ca2013ab2ae23bb4cec45d1e

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

LOG: [docs] Update the ACLE URL

Added: 


Modified: 
clang/docs/LanguageExtensions.rst

Removed: 




diff  --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index 99f8cd59abec..faebc024df11 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -808,7 +808,7 @@ includes all 64-bit and all recent 32-bit processors.
 ``__fp16`` is a storage and interchange format only.  This means that values of
 ``__fp16`` are immediately promoted to (at least) ``float`` when used in 
arithmetic
 operations, so that e.g. the result of adding two ``__fp16`` values has type 
``float``.
-The behavior of ``__fp16`` is specified by the ARM C Language Extensions 
(`ACLE 
`_).
+The behavior of ``__fp16`` is specified by the Arm C Language Extensions 
(`ACLE `_).
 Clang uses the ``binary16`` format from IEEE 754-2008 for ``__fp16``, not the 
ARM
 alternative format.
 
@@ -3791,8 +3791,8 @@ ARM/AArch64 Language Extensions
 Memory Barrier Intrinsics
 ^
 Clang implements the ``__dmb``, ``__dsb`` and ``__isb`` intrinsics as defined
-in the `ARM C Language Extensions Release 2.0
-`_.
+in the `Arm C Language Extensions
+`_.
 Note that these intrinsics are implemented as motion barriers that block
 reordering of memory accesses and side effect instructions. Other instructions
 like simple arithmetic may be reordered around the intrinsic. If you expect to



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


[clang] [clang][AArch64] Add validation for Global Register Variable. (PR #94271)

2024-06-07 Thread KAWASHIMA Takahiro via cfe-commits

https://github.com/kawashima-fj approved this pull request.

Thanks for the fix. I left a minor suggestion.

Some notes:

- This commit make Clang emit `error: size of register '???' does not match 
variable size` error instead of `fatal error: error in backend: Invalid 
register name "???"`, regardless of the `-ffixed-???` option.
- #76426 says "When `-ffixed-x15` is specified, it can be compiled.". When 
`-ffixed-x15` is specified, older revisions (including 18.1.x releases) 
compiles the program in #76426 without an error but the generated code is 
incorrect (the `foo` function is compiled into `mrs w0, NZCV; ret`!). Recent 
revisions emits `fatal error: error in backend: Invalid register name "x15".`. 
So make it a Clang error is appropriate.
- GCC allows this variable-register size mismatch. Clang does not allow.
- We don't need to use `starts_with_insensitive`. Register names are 
case-sensitive (same as GCC).

https://github.com/llvm/llvm-project/pull/94271
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][AArch64] Add validation for Global Register Variable. (PR #94271)

2024-06-07 Thread KAWASHIMA Takahiro via cfe-commits


@@ -0,0 +1,13 @@
+// Check that -ffixed register handled for globals.
+// Regression test for #76426
+// RUN: %clang --target=aarch64-none-gnu -ffixed-x15 -### %s 2>&1 | FileCheck 
%s
+// CHECK-NOT: fatal error: error in backend: Invalid register name "x15".

kawashima-fj wrote:

You modified Clang code but this error message is the one of the LLVM backend.
Is it better to check the Clang-side message `error: size of register 'x15' 
does not match variable size`?

https://github.com/llvm/llvm-project/pull/94271
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][AArch64] Add validation for Global Register Variable. (PR #94271)

2024-06-07 Thread KAWASHIMA Takahiro via cfe-commits

https://github.com/kawashima-fj edited 
https://github.com/llvm/llvm-project/pull/94271
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [AArch64] Add validation for Global Register Variable. (PR #94271)

2024-06-04 Thread KAWASHIMA Takahiro via cfe-commits

kawashima-fj wrote:

@DanielKristofKiss Thanks for the fix. At first glance, LGTM. I'll take a 
closer look in a few days.
I'm not so familiar with the code. If someone else can review, I'll leave it to 
them.

https://github.com/llvm/llvm-project/pull/94271
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [llvm] [flang][driver] rename flang-new to flang (PR #110023)

2024-09-25 Thread KAWASHIMA Takahiro via cfe-commits

kawashima-fj wrote:

Thanks for the PR.
Is there a symbolic link `flang-new` -> `flang`? We would like to have a 
transitional period.

https://github.com/llvm/llvm-project/pull/110023
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][AArch64] Avoid a crash when a non-reserved register is used (PR #117419)

2024-11-26 Thread KAWASHIMA Takahiro via cfe-commits


@@ -232,13 +232,23 @@ bool AArch64TargetInfo::validateTarget(DiagnosticsEngine 
&Diags) const {
 
 bool AArch64TargetInfo::validateGlobalRegisterVariable(
 StringRef RegName, unsigned RegSize, bool &HasSizeMismatch) const {
-  if ((RegName == "sp") || RegName.starts_with("x")) {
-HasSizeMismatch = RegSize != 64;
-return true;
-  } else if (RegName.starts_with("w")) {
+  if (RegName.starts_with("w")) {
 HasSizeMismatch = RegSize != 32;
 return true;
   }
+  if (RegName == "sp") {
+HasSizeMismatch = RegSize != 64;
+return true;
+  }
+  if (RegName.starts_with("x")) {
+HasSizeMismatch = RegSize != 64;
+// Check if the register is reserved. See also
+// AArch64TargetLowering::getRegisterByName().
+return RegName == "x0" ||
+   (RegName == "x18" &&
+llvm::AArch64::isX18ReservedByDefault(getTriple())) ||
+   getTargetOpts().FeatureMap.lookup(("reserve-" + RegName).str());

kawashima-fj wrote:

To avoid the `fatal error: error in backend: Invalid register name "x??"` error 
in #109778, this check is sufficient.

I think the original purpose of rejecting a global register variable associated 
with a non-reserved register is to avoid unintended register use. `w??` 
registers are lower half bits of the corresponding `x??` registers. So when 
`x??` register is not reserved, should we reject a global register variable 
associated with the corresponding `w??`?

For this purpose, maybe [the 
backend](https://github.com/llvm/llvm-project/blob/bc28260/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp#L11611)
 should also check `w??` registers. Actually, [old backend code checked `w??` 
regsters](https://github.com/llvm/llvm-project/commit/fcbec02ea6fb2a76352b64790cd9ae300f6a9943#diff-6291e4657dea1f4fecdcb9dc96bfb014f79d4c617f080b2f033943e52732cf69).

https://github.com/llvm/llvm-project/pull/117419
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][AArch64] Avoid a crash when a non-reserved register is used (PR #117419)

2024-12-05 Thread KAWASHIMA Takahiro via cfe-commits

https://github.com/kawashima-fj approved this pull request.

LGTM. Thanks!

https://github.com/llvm/llvm-project/pull/117419
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [flang] add -floop-interchange and enable it with opt levels (PR #140182)

2025-05-26 Thread KAWASHIMA Takahiro via cfe-commits

kawashima-fj wrote:

I've confirmed the result of Fujitsu Compiler Test Suite. The only correctness 
issue affected by this commit is 
https://github.com/fujitsu/compiler-test-suite/blob/main/Fortran/0347/0347_0240.f,
 which will be resolved by #140709.

https://github.com/llvm/llvm-project/pull/140182
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits