platform/upstream/llvm.git
2 years agoRevert "[Support] Add llvm::compression::{getReasonIfUnsupported,compress,decompress}"
Nikita Popov [Thu, 8 Sep 2022 07:32:54 +0000 (09:32 +0200)]
Revert "[Support] Add llvm::compression::{getReasonIfUnsupported,compress,decompress}"

This reverts commit 19dc3cff0f771bb8933136ef68e782553e920d04.
This reverts commit 5b19a1f8e88da9ec92b995bfee90043795c2c252.
This reverts commit 9397648ac8ad192f7e6e6a8e6894c27bf7e024e9.
This reverts commit 10842b44759f987777b08e7714ef77da2526473a.

Breaks the GCC build, as reported here:
https://reviews.llvm.org/D130506#3776415

2 years ago[Support] Work around GCC's enum support
Fangrui Song [Thu, 8 Sep 2022 07:13:25 +0000 (00:13 -0700)]
[Support] Work around GCC's enum support

2 years ago[MC] Support writing ELFCOMPRESS_ZSTD compressed debug info sections
Fangrui Song [Thu, 8 Sep 2022 07:03:39 +0000 (00:03 -0700)]
[MC] Support writing ELFCOMPRESS_ZSTD compressed debug info sections

and add --compress-debug-sections=zstd to llvm-mc for testing.

Reviewed By: dblaikie

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

2 years ago[llvm-objcopy] Support --{,de}compress-debug-sections for zstd
Fangrui Song [Thu, 8 Sep 2022 06:53:40 +0000 (23:53 -0700)]
[llvm-objcopy] Support --{,de}compress-debug-sections for zstd

Also, add ELFCOMPRESS_ZSTD (2) from the approved generic-abi proposal:
https://groups.google.com/g/generic-abi/c/satyPkuMisk
("Add new ch_type value: ELFCOMPRESS_ZSTD")

Link: https://discourse.llvm.org/t/rfc-zstandard-as-a-second-compression-method-to-llvm/63399
("[RFC] Zstandard as a second compression method to LLVM")

Reviewed By: jhenderson, dblaikie

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

2 years ago[Support] Add llvm::compression::{getReasonIfUnsupported,compress,decompress}
Fangrui Song [Thu, 8 Sep 2022 06:53:14 +0000 (23:53 -0700)]
[Support] Add llvm::compression::{getReasonIfUnsupported,compress,decompress}

as high-level API on top of `llvm::compression::{zlib,zstd}::*`:

* getReasonIfUnsupported: return nullptr if the specified format is
  supported, or (if unsupported) a string like `LLVM was not built with LLVM_ENABLE_ZLIB ...`
* compress: dispatch to zlib::uncompress or zstd::uncompress
* decompress: dispatch to zlib::uncompress or zstd::uncompress

Move `llvm::DebugCompressionType` from MC to Support to avoid Support->MC cyclic
dependency. There are 40+ uses in llvm-project.

Add another enum class `llvm::compression::Format` to represent supported
compression formats, which may be a superset of ELF compression formats.

See D130458 (llvm-objcopy --{,de}compress-debug-sections for zstd) for a use
case.

Link: https://discourse.llvm.org/t/rfc-zstandard-as-a-second-compression-method-to-llvm/63399
("[RFC] Zstandard as a second compression method to LLVM")

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

2 years ago[mlir][Math] Add constant folder for RoundOp.
jacquesguan [Wed, 7 Sep 2022 06:28:46 +0000 (14:28 +0800)]
[mlir][Math] Add constant folder for RoundOp.

This patch uses round/roundf of libm to fold RoundOp of constant.

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

2 years ago[LoongArch] Add codegen support for atomicrmw xchg operation on LA32
gonglingqin [Thu, 8 Sep 2022 05:56:59 +0000 (13:56 +0800)]
[LoongArch] Add codegen support for atomicrmw xchg operation on LA32

Depends on D131228

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

2 years ago[LoongArch] Add codegen support for atomicrmw xchg operation on LA64
gonglingqin [Tue, 19 Jul 2022 08:39:05 +0000 (16:39 +0800)]
[LoongArch] Add codegen support for atomicrmw xchg operation on LA64

In order to avoid the patch being too large, the atomicrmw xchg operation
on LA32 will be added later

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

2 years ago[MLIR] NFC: add back exports_files(["run_lit.sh"]).
Christian Sigg [Thu, 8 Sep 2022 05:46:10 +0000 (07:46 +0200)]
[MLIR] NFC: add back exports_files(["run_lit.sh"]).

2 years ago[clang][Interp][NFC] Use constexpr if when possible in Integral.h
Timm Bäder [Tue, 6 Sep 2022 07:34:23 +0000 (09:34 +0200)]
[clang][Interp][NFC] Use constexpr if when possible in Integral.h

2 years ago[clang][Interp][NFC] Context::classify() can be const
Timm Bäder [Mon, 29 Aug 2022 18:29:19 +0000 (20:29 +0200)]
[clang][Interp][NFC] Context::classify() can be const

2 years ago[clang][Interp] Implement array initializers and subscript expressions
Timm Bäder [Wed, 31 Aug 2022 14:09:40 +0000 (16:09 +0200)]
[clang][Interp] Implement array initializers and subscript expressions

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

2 years ago[clang][Interp] Handle missing local initializers better
Timm Bäder [Mon, 29 Aug 2022 08:20:24 +0000 (10:20 +0200)]
[clang][Interp] Handle missing local initializers better

This is illegal in a constexpr context. We can already figure that out,
but we'd still run into an assertion later on when trying to visit the
missing initializer or run the invalid function.

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

2 years ago[clang][Interp] Handle SubstNonTypeTemplateParmExprs
Timm Bäder [Sat, 27 Aug 2022 15:37:26 +0000 (17:37 +0200)]
[clang][Interp] Handle SubstNonTypeTemplateParmExprs

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

2 years ago[clang][Interp] Implement ImplicitValueInitExprs
Timm Bäder [Sat, 27 Aug 2022 06:21:59 +0000 (08:21 +0200)]
[clang][Interp] Implement ImplicitValueInitExprs

Take the existing Zero opcode and emit it.

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

2 years ago[clang][Interp] Implement IntegralToBoolean casts
Timm Bäder [Fri, 26 Aug 2022 13:39:17 +0000 (15:39 +0200)]
[clang][Interp] Implement IntegralToBoolean casts

Redo how we do IntegralCasts and implement IntegralToBoolean casts using
the already existing cast op.

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

2 years ago[clang][Interp] Implement function calls
Timm Bäder [Fri, 19 Aug 2022 11:45:11 +0000 (13:45 +0200)]
[clang][Interp] Implement function calls

Add Call() and CallVoid() ops and use them to call functions. Only
FunctionDecls are supported for now.

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

2 years ago[clang] Perform implicit lvalue-to-rvalue cast with new interpreter
Timm Bäder [Thu, 18 Aug 2022 14:06:08 +0000 (16:06 +0200)]
[clang] Perform implicit lvalue-to-rvalue cast with new interpreter

The EvaluateAsRValue() documentation mentions that an implicit
lvalue-to-rvalue cast is being performed if the result is an lvalue.
However, that was not being done if the new constant interpreter was in
use.

Just always do it.

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

2 years ago[NewPM] Switch -filter-passes from ClassName to pass-name
Fangrui Song [Thu, 8 Sep 2022 05:02:26 +0000 (22:02 -0700)]
[NewPM] Switch -filter-passes from ClassName to pass-name

NewPM -filter-passes (D86360) uses ClassName instead of pass-name as used in
`-passes`, `-print-after`, etc. D87216 has added a mechanism to map
ClassName to pass-name. Adopt it for -filter-passes.

Reviewed By: aeubanks

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

2 years ago[NFC][MachineFunctionPass] Only lookup pass name if we request printing
Arthur Eubanks [Thu, 8 Sep 2022 04:38:00 +0000 (21:38 -0700)]
[NFC][MachineFunctionPass] Only lookup pass name if we request printing

Should report the small compile time regression reported in D133055.

2 years ago[X86] Pre-commit test for PR57576. NFC
Craig Topper [Thu, 8 Sep 2022 03:54:49 +0000 (20:54 -0700)]
[X86] Pre-commit test for PR57576. NFC

2 years ago[BOLT][TEST] Remove functions with dynamic exception specification
Amir Ayupov [Thu, 8 Sep 2022 02:17:39 +0000 (19:17 -0700)]
[BOLT][TEST] Remove functions with dynamic exception specification

Clang has switched to gnu++17 by default with https://reviews.llvm.org/D131465.
C++17 removes dynamic exception specification. Remove its use as it wasn't
properly tested.

Reviewed By: maksfb

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

2 years ago[InstCombine] extractvalue (any_mul_with_overflow X, 2^n), 0 -> X << n
Chenbing Zheng [Thu, 8 Sep 2022 03:12:55 +0000 (11:12 +0800)]
[InstCombine] extractvalue (any_mul_with_overflow X, 2^n), 0 -> X << n

Alive2: https://alive2.llvm.org/ce/z/JLmabt (umul)
        https://alive2.llvm.org/ce/z/J_ruXR  (smul)
        https://alive2.llvm.org/ce/z/o9SVSz (vector)

Reviewed By: spatel, RKSimon

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

2 years ago[NFC][DSE] Add a masked dead store test that should rely on additional guards for...
Michael Berg [Thu, 8 Sep 2022 02:20:13 +0000 (19:20 -0700)]
[NFC][DSE] Add a masked dead store test that should rely on additional guards for removal.

2 years ago[libunwind] Fix a few libunwind includes
Ryan Prichard [Wed, 7 Sep 2022 21:27:57 +0000 (17:27 -0400)]
[libunwind] Fix a few libunwind includes

In UnwindCursor.hpp, include config.h before checking _LIBUNWIND_SUPPORT_SEH_UNWIND.

Include libunwind_ext.h for UNW_STEP_SUCCESS.

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

2 years ago[flang] Write semantics test for atomic_fetch_add
Katherine Rasmussen [Wed, 31 Aug 2022 19:12:00 +0000 (12:12 -0700)]
[flang] Write semantics test for atomic_fetch_add

Write a semantics test for the atomic intrinsic subroutine,
atomic_fetch_add.

Reviewed By: rouson

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

2 years agoApply clang-tidy fixes for readability-identifier-naming in CRunnerUtils.cpp (NFC)
Mehdi Amini [Mon, 29 Aug 2022 11:24:57 +0000 (11:24 +0000)]
Apply clang-tidy fixes for readability-identifier-naming in CRunnerUtils.cpp (NFC)

2 years agoApply clang-tidy fixes for performance-unnecessary-value-param in VectorDistribute...
Mehdi Amini [Mon, 29 Aug 2022 11:22:27 +0000 (11:22 +0000)]
Apply clang-tidy fixes for performance-unnecessary-value-param in VectorDistribute.cpp (NFC)

2 years ago[mlir:PassTiming] Always use parentInfo for determining pipeline parent scope
River Riddle [Tue, 30 Aug 2022 22:25:55 +0000 (15:25 -0700)]
[mlir:PassTiming] Always use parentInfo for determining pipeline parent scope

This fixes a bug where, depending on thread usage, a pipeline may be
misattributed to a timer that wasn't it's parent.

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

2 years ago[BOLT] Distinguish sections in heatmap
Fabian Parzefall [Wed, 7 Sep 2022 23:28:01 +0000 (16:28 -0700)]
[BOLT] Distinguish sections in heatmap

Output different letters for different sections in the heatmap to
visually separate sections.

Reviewed By: maksfb

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

2 years ago[AMDGPU] Drop _oneuse checks from med3 patterns
Justin Bogner [Wed, 24 Aug 2022 22:35:02 +0000 (15:35 -0700)]
[AMDGPU] Drop _oneuse checks from med3 patterns

We use _oneuse checks to make sure combines won't accidentally
increase code size, but this prevents the optimization in cases where
we happen to want to clamp multiple values to the same range

It's safe to drop these checks for two reasons:

1. The pattern of max/min operations for med3 is complicated enough
   it's unlikely to come up by accident, so this will still only fire
   when appropriate to do so
2. Even if every intermediate is used and we don't save a single
   operation, we still won't end up with more operations since the
   med3 replaces the final max/min.

In pathological cases we could potentially end up with a larger
encoding size or possibly slightly increased vgpr pressure, but the
risk of that is low, especially considering the upside.

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

2 years ago[AMDGPU] Fix liveness verifier error in hazard recognizer
Stanislav Mekhanoshin [Wed, 7 Sep 2022 22:24:11 +0000 (15:24 -0700)]
[AMDGPU] Fix liveness verifier error in hazard recognizer

After D133067 we are inserting swaps to use a new physical
register. I have noticed verifier errors about undefined
physical register uses if we are tracking liveness post RA.

We have no access to LIS at this point, so mark new register
uses as undef to calm down the verifier. Liveness should not
matter at this point anyway.

Note the description of the RegState::Undef: "Value of the
register doesn't matter." I.e. it does not say it is strictly
undefined. In fact that is what we really need: this value
does not matter.

I also had to modify the test a bit since with tracking enabled
it does not pass verification even before the recognizer.

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

2 years ago[libc][math] Implement asinf function correctly rounded for all rounding modes.
Tue Ly [Wed, 7 Sep 2022 06:20:45 +0000 (02:20 -0400)]
[libc][math] Implement asinf function correctly rounded for all rounding modes.

Implement asinf function correctly rounded for all rounding modes.

For `|x| <= 0.5`, we approximate `asin(x)` by
```
  asin(x) = x * P(x^2)
```
where `P(X^2) = Q(X)` is a degree-20 minimax even polynomial approximating
`asin(x)/x` on `[0, 0.5]` generated by Sollya with:
```
  > Q = fpminimax(asin(x)/x, [|0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20|],
                 [|1, D...|], [0, 0.5]);
```

When `|x| > 0.5`, we perform range reduction as follow:
Assume further that `0.5 < x <= 1`, and let:
```
  y = asin(x)
```
We will use the double angle formula:
```
  cos(2X) = 1 - 2 sin^2(X)
```
and the complement angle identity:
```
  x = sin(y) = cos(pi/2 - y)
              = 1 - 2 sin^2 (pi/4 - y/2)
```
So:
```
  sin(pi/4 - y/2) = sqrt( (1 - x)/2 )
```
And hence:
```
  pi/4 - y/2 = asin( sqrt( (1 - x)/2 ) )
```
Equivalently:
```
  asin(x) = y = pi/2 - 2 * asin( sqrt( (1 - x)/2 ) )
```
Let `u = (1 - x)/2`, then
```
  asin(x) = pi/2 - 2 * asin(u)
```
Moreover, since `0.5 < x <= 1`,
```
  0 <= u < 1/4, and 0 <= sqrt(u) < 0.5.
```
And hence we can reuse the same polynomial approximation of `asin(x)` when
`|x| <= 0.5`:
```
  asin(x) = pi/2 - 2 * u * P(u^2).
```

Performance benchmark using `perf` tool from the CORE-MATH project on Ryzen 1700:
```
$ CORE_MATH_PERF_MODE="rdtsc" ./perf.sh asinf
CORE-MATH reciprocal throughput   : 23.418
System LIBC reciprocal throughput : 27.310
LIBC reciprocal throughput        : 22.741

$ CORE_MATH_PERF_MODE="rdtsc" ./perf.sh asinf --latency
GNU libc version: 2.35
GNU libc release: stable
CORE-MATH latency   : 58.884
System LIBC latency : 62.055
LIBC latency        : 62.037
```

Reviewed By: orex, zimmermann6

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

2 years ago[mlir][sparse] change variable dimension to fixed attribute pointers/indices
Aart Bik [Wed, 7 Sep 2022 22:08:29 +0000 (15:08 -0700)]
[mlir][sparse] change variable dimension to fixed attribute pointers/indices

The "sparsification" pass does not need the ability to use runtime values for
the dimension, so the only source for variability would have been user code.
Restricting the dimension to constants simplifies code generation.

Reviewed By: Peiming, wrengr

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

2 years ago[libc] Return correct values for hypot when overflowed.
Tue Ly [Tue, 6 Sep 2022 18:18:18 +0000 (14:18 -0400)]
[libc] Return correct values for hypot when overflowed.

Hypot incorrectly returns +Inf when overflowed with FE_DOWNWARD and
FE_TOWARDZERO rounding modes.

Reviewed By: sivachandra, zimmermann6

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

2 years ago[InstCombine] Baseline tests for folding x + (x | -x) to x & (x - 1)
Marc Auberer [Wed, 7 Sep 2022 23:12:23 +0000 (19:12 -0400)]
[InstCombine] Baseline tests for folding x + (x | -x) to x & (x - 1)

Baseline tests for D133362

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

2 years agoRevert D133266 "[MinGW] Reject explicit non-default visibility applied to dllexport...
Fangrui Song [Wed, 7 Sep 2022 23:06:19 +0000 (16:06 -0700)]
Revert D133266 "[MinGW] Reject explicit non-default visibility applied to dllexport/dllimport declaration"

This reverts commit 91d8324366f405e871aa8174ab61fc66912964dd.

The combo dllexport protected makes sense and is used by PlayStation.
Will change the patch to allow dllexport protected.

2 years ago[gn build] Port 97c2220565ab
LLVM GN Syncbot [Wed, 7 Sep 2022 23:00:40 +0000 (23:00 +0000)]
[gn build] Port 97c2220565ab

2 years ago[gn build] Port 3e7350f3173b
LLVM GN Syncbot [Wed, 7 Sep 2022 23:00:39 +0000 (23:00 +0000)]
[gn build] Port 3e7350f3173b

2 years ago[InstCombine] Fix a crash in -kcfi debug block
Sami Tolvanen [Wed, 7 Sep 2022 19:22:17 +0000 (19:22 +0000)]
[InstCombine] Fix a crash in -kcfi debug block

Don't attempt to print out DebugLoc as we may not have one.

2 years ago[gn build] port aa484c90cf59
Nico Weber [Wed, 7 Sep 2022 22:55:07 +0000 (18:55 -0400)]
[gn build] port aa484c90cf59

2 years ago[gn build] port e321c8dd2cea
Nico Weber [Wed, 7 Sep 2022 22:52:06 +0000 (18:52 -0400)]
[gn build] port e321c8dd2cea

2 years ago[Libomptarget] Implement OpenMP 5.2 semantics for device pointers
Joseph Huber [Wed, 7 Sep 2022 18:37:26 +0000 (13:37 -0500)]
[Libomptarget] Implement OpenMP 5.2 semantics for device pointers

In OpenMP 5.2, §5.8.6, page 160 line 32-33, when a device pointer
allocated by omp_target_alloc has implicitly been included on a target
construct as a zero-length array, the pointer initialisation should not
find a matching mapped list item, and so should retain its value as a
firstprivate variable. Previously, we would return a null pointer if the
list item was not found. This patch updates the map handling to the
OpenMP 5.2 semantics.

Reviewed By: jdoerfert, ye-luo

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

2 years ago[Hexagon] Move vectorization checks from subtarget to TTI
Krzysztof Parzyszek [Wed, 7 Sep 2022 21:46:22 +0000 (14:46 -0700)]
[Hexagon] Move vectorization checks from subtarget to TTI

2 years ago[ODRHash diagnostics] Move `ODRDiagsEmitter` to libAST in separate files. NFC.
Volodymyr Sapsai [Tue, 28 Jun 2022 03:06:07 +0000 (20:06 -0700)]
[ODRHash diagnostics] Move `ODRDiagsEmitter` to libAST in separate files. NFC.

Intend to use `ODRDiagsEmitter` during parsing to diagnose a parsed
definition differing from a definition with the same name from a hidden
[sub]module.

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

2 years ago[AMDGPU] W/a hazard if 64 bit shift amount is a highest allocated VGPR
Stanislav Mekhanoshin [Wed, 31 Aug 2022 21:14:05 +0000 (14:14 -0700)]
[AMDGPU] W/a hazard if 64 bit shift amount is a highest allocated VGPR

In this case gfx90a uses v0 instead of the correct register. Swap
the value temporarily with a lower register and then swap it back.

Unfortunately hazard recognizer works after wait count insertion,
so we cannot simply reuse an arbitrary register, hence w/a also
includes a full waitcount. This can be avoided if we run it from
expandPostRAPseudo, but that is a complete misplacement.

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

2 years agoC++/ObjC++: switch to gnu++17 as the default standard
Fangrui Song [Wed, 7 Sep 2022 21:17:52 +0000 (14:17 -0700)]
C++/ObjC++: switch to gnu++17 as the default standard

Clang's default C++ standard is now `gnu++17` instead of `gnu++14`:
https://discourse.llvm.org/t/c-objc-switch-to-gnu-17-as-the-default-dialect/64360

* CUDA/HIP are unchanged: C++14 from D103221.
* Sony PS4/PS5 are unchanged: https://discourse.llvm.org/t/c-objc-switch-to-gnu-17-as-the-default-dialect/64360/6
* lit feature `default-std-cxx` is added to keep CLANG_DEFAULT_STD_CXX=xxx tests working.
  Whether the cmake variable should be retained is disccused in D133375.

Depends on D131464

Close https://github.com/llvm/llvm-project/issues/56946

Reviewed By: #clang-language-wg, aaron.ballman

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

2 years ago[ASan] Show memory rather than tag addresses in tag dump
Florian Mayer [Wed, 7 Sep 2022 00:44:20 +0000 (17:44 -0700)]
[ASan] Show memory rather than tag addresses in tag dump

Reviewed By: eugenis

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

2 years ago[MLIR] NFC: add back `exports_files(["LICENSE.txt"])`.
Christian Sigg [Wed, 7 Sep 2022 19:57:02 +0000 (21:57 +0200)]
[MLIR] NFC: add back `exports_files(["LICENSE.txt"])`.

2 years ago[MLIR] NFC: expand comment in bazel BUILD file
Christian Sigg [Wed, 7 Sep 2022 19:57:02 +0000 (21:57 +0200)]
[MLIR] NFC: expand comment in bazel BUILD file

... and remove unnecessry `exports_files()`.

2 years ago[Bazel] Make clang/unittests:lex_tests depend on //llvm:TestingSupport
Fangrui Song [Wed, 7 Sep 2022 19:51:31 +0000 (12:51 -0700)]
[Bazel] Make clang/unittests:lex_tests depend on //llvm:TestingSupport

2 years agoApply clang-tidy fixes for llvm-else-after-return in SparseTensorRewriting.cpp (NFC)
Mehdi Amini [Mon, 29 Aug 2022 11:12:46 +0000 (11:12 +0000)]
Apply clang-tidy fixes for llvm-else-after-return in SparseTensorRewriting.cpp (NFC)

2 years agoApply clang-tidy fixes for performance-unnecessary-value-param in Utils.cpp (NFC)
Mehdi Amini [Mon, 29 Aug 2022 11:09:54 +0000 (11:09 +0000)]
Apply clang-tidy fixes for performance-unnecessary-value-param in Utils.cpp (NFC)

2 years ago[Clang] Introduce -fexperimental-sanitize-metadata=
Marco Elver [Tue, 6 Sep 2022 13:49:39 +0000 (15:49 +0200)]
[Clang] Introduce -fexperimental-sanitize-metadata=

Introduces the frontend flag -fexperimental-sanitize-metadata=, which
enables SanitizerBinaryMetadata instrumentation.

The first intended user of the binary metadata emitted will be a variant
of GWP-TSan [1]. The plan is to open source a stable and production
quality version of GWP-TSan. The development of which, however, requires
upstream compiler support.

[1] https://llvm.org/devmtg/2020-09/slides/Morehouse-GWP-Tsan.pdf

Until the tool has been open sourced, we mark this kind of
instrumentation as "experimental", and reserve the option to change
binary format, remove features, and similar.

Reviewed By: vitalybuka, MaskRay

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

2 years ago[SanitizerBinaryMetadata] Introduce SanitizerBinaryMetadata instrumentation pass
Marco Elver [Tue, 6 Sep 2022 13:49:33 +0000 (15:49 +0200)]
[SanitizerBinaryMetadata] Introduce SanitizerBinaryMetadata instrumentation pass

Introduces the SanitizerBinaryMetadata instrumentation pass which uses
the new MD_pcsections metadata kinds to instrument certain types of
instructions and functions required for breakpoint-based sanitizers.

The first intended user of the binary metadata emitted will be a variant
of GWP-TSan [1]. GWP-TSan will require information about atomic
accesses; to unambiguously determine if an access is atomic or not, we
also require "covered" information which code has been compiled with
SanitizerBinaryMetadata instrumentation enabled.

[1] https://llvm.org/devmtg/2020-09/slides/Morehouse-GWP-Tsan.pdf

Reviewed By: dvyukov

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

2 years ago[Libomptarget] Remove leftover ELF header from x86 plugin
Joseph Huber [Wed, 7 Sep 2022 18:40:54 +0000 (13:40 -0500)]
[Libomptarget] Remove leftover ELF header from x86 plugin

Summary:
We removed the linking support for `gelf.h` in a previous patch. This
header was incorrectly leftover causing build problems on some systems.

2 years ago[RISCV] Remove space before colon in error message.
Craig Topper [Wed, 7 Sep 2022 18:30:03 +0000 (11:30 -0700)]
[RISCV] Remove space before colon in error message.

2 years ago[lld-macho] Hardlink -object_path_lto files to cache when possible
Leonard Grey [Fri, 2 Sep 2022 17:50:01 +0000 (13:50 -0400)]
[lld-macho] Hardlink -object_path_lto files to cache when possible

This is a follow-up to https://reviews.llvm.org/D131624 (specifically to https://reviews.llvm.org/D131624#3716584)

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

2 years ago[libc++] Fixes CI.
Mark de Wever [Wed, 7 Sep 2022 17:56:52 +0000 (19:56 +0200)]
[libc++] Fixes CI.

It seems merging the changes in transitive macros and recent commits
conflicted.

2 years ago[mlir][sparse] Refactoring: remove dependence on tuple type when lowering sparse...
Peiming Liu [Wed, 7 Sep 2022 00:49:44 +0000 (00:49 +0000)]
[mlir][sparse] Refactoring: remove dependence on tuple type when lowering sparse tensors.

Reviewed By: aartbik

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

2 years ago[Libomptarget] Replace libelf with LLVM's Elf libraries
Joseph Huber [Fri, 5 Aug 2022 18:32:42 +0000 (14:32 -0400)]
[Libomptarget] Replace libelf with LLVM's Elf libraries

This patch replaces the dependency on `libelf` with LLVM's ELF support.
With this patch the user no-longer needs to have `libelf` on their
system to build and configure OpenMP offloading. The replacement is
mostly mechanical, with the exception of the hash table support which
was added in D131309.

Depends on D131309

Reviewed By: JonChesterfield, saiislam

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

2 years ago[Libomptarget] Add utility functions for loading an ELF symbol by name
Joseph Huber [Sat, 3 Sep 2022 16:38:26 +0000 (11:38 -0500)]
[Libomptarget] Add utility functions for loading an ELF symbol by name

The `SHT_HASH` sections in an ELF are used to look up a symbol in the
symbol table using a symbol's name. This is done by obtaining the
`SHT_HASH` section and using its `sh_link` attribute to access the
associated symbol table, from which we can access the string table
containing the associated name. We can then search for the symbol using
the hash of the name and the buckets and chains in the hash table
itself

This patch adds utility functions that allow us to look up a symbol in
an ELF file by name. It will first attempt to look through the hash
tables, and then search the section tables manually if failed. This
allows us to pull out constants necessary for setting up offloading
without first loading the object.

Reviewed By: JonChesterfield

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

2 years ago[AArch64] Add tests for using tbl for fp conversions.
Florian Hahn [Wed, 7 Sep 2022 17:35:29 +0000 (18:35 +0100)]
[AArch64] Add tests for using tbl for fp conversions.

2 years ago[RISCV] Remove unnecessary word from error message.
Craig Topper [Wed, 7 Sep 2022 17:29:58 +0000 (10:29 -0700)]
[RISCV] Remove unnecessary word from error message.

2 years ago[Lex/DependencyDirectivesScanner] Keep track of the presence of tokens between the...
Argyrios Kyrtzidis [Mon, 5 Sep 2022 21:28:32 +0000 (14:28 -0700)]
[Lex/DependencyDirectivesScanner] Keep track of the presence of tokens between the last scanned directive and EOF

Directive `dependency_directives_scan::tokens_present_before_eof` is introduced to indicate there were tokens present before
the last scanned dependency directive and EOF.
This is useful to ensure we correctly identify the macro guards when lexing using the dependency directives.

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

2 years ago[amdgpu] Always, instead of mostly, remove unused LDS symbols
Jon Chesterfield [Wed, 7 Sep 2022 17:28:14 +0000 (18:28 +0100)]
[amdgpu] Always, instead of mostly, remove unused LDS symbols

Currently LDS variables are removed by the lower module pass
if they have a use which is caught by the replace with struct control flow.
This makes tests brittle to changes to that control flow which induces
noise when trying to improve lowering. Some tests already check that
variables are removed, while others checked that they are not removed.

LDS variables are not (currently) externally accessible, and if that
changes the machinery which makes them externally accessible will look
like a use. This change therefore breaks no applications.

Reviewed By: rampitec

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

2 years ago[mlir][sparse] minor zero test refactoring in rewriting
Aart Bik [Tue, 6 Sep 2022 23:09:17 +0000 (16:09 -0700)]
[mlir][sparse] minor zero test refactoring in rewriting

Reviewed By: bixia

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

2 years ago[mlir][sparse] fix python indentation in test
Aart Bik [Tue, 6 Sep 2022 23:57:19 +0000 (16:57 -0700)]
[mlir][sparse] fix python indentation in test

Reviewed By: bixia

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

2 years ago[gn build] Port e5d2d3eafbb3
LLVM GN Syncbot [Wed, 7 Sep 2022 16:59:10 +0000 (16:59 +0000)]
[gn build] Port e5d2d3eafbb3

2 years ago[libc++][locale] Removes an transitive include.
Mark de Wever [Wed, 7 Sep 2022 16:52:41 +0000 (18:52 +0200)]
[libc++][locale] Removes an transitive include.

Removes <cstdarg> transitive include from <locale> in C++23.

Reviewed By: #libc, ldionne

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

2 years ago[AArch64] Add additional tests for tbl expansion.
Florian Hahn [Wed, 7 Sep 2022 16:47:59 +0000 (17:47 +0100)]
[AArch64] Add additional tests for tbl expansion.

Add test coverage to make sure tbl expansion isn't used when optimizing
for size or when the zext is only executed conditionally in a loop.

2 years agoAvoid __builtin_assume_aligned crash when the 1st arg is array type
yronglin [Wed, 7 Sep 2022 16:46:20 +0000 (12:46 -0400)]
Avoid __builtin_assume_aligned crash when the 1st arg is array type

Avoid __builtin_assume_aligned crash when the 1st arg is array type (or
string literal).

Fixes Issue #57169

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

2 years ago[libc++][chrono] Implements formatter day.
Mark de Wever [Sun, 20 Mar 2022 12:40:02 +0000 (13:40 +0100)]
[libc++][chrono] Implements formatter day.

This implements the enabled specializaton
template<class charT> struct formatter<chrono::day, charT>;

and
template<class charT, class traits>
    basic_ostream<charT, traits>&
      operator<<(basic_ostream<charT, traits>& os, const day& d);

Implements:
- LWG 3241 chrono-spec grammar ambiguity in §[time.format]

Partially implements:
- P1361 Integration of chrono with text formatting

Reviewed By: #libc, ldionne

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

2 years ago[libc++][format] Updates feature-test macros.
Mark de Wever [Sun, 4 Sep 2022 11:56:36 +0000 (13:56 +0200)]
[libc++][format] Updates feature-test macros.

During the discussion on the SG-10 mailinglist regarding the format
feature-test macros voted in during the last plenary it turns out libc++
can't mark the format feature-test macro as implemented.

According to
  https://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations#__cpp_lib_format
the not yet implemented paper
  P1361R2 Integration of chrono with text formatting
affects the feature test macro.

Note that P1361R2 doesn't mention the feature-test macro nor is there an
LWG-issue to address the issue. The reporter of the issue didn't recall
where this requirement exactly has been decided.

Reviewed By: ldionne, #libc

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

2 years ago[RISCV][MC] Add minimal support for Ztso extension
Philip Reames [Wed, 7 Sep 2022 15:45:50 +0000 (08:45 -0700)]
[RISCV][MC] Add minimal support for Ztso extension

This is a minimalist implementation which simply adds the extension (in the experimental namespace since its not ratified), and wires up the setting of the required ELF header flag. Future changes will include codegen changes to exploit the stronger memory model.

This is intended to implement v0.1 of the proposed specification which can be found in Chapter 25 of https://github.com/riscv/riscv-isa-manual/releases/download/draft-20220723-10eea63/riscv-spec.pdf.

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

2 years ago[SCCP] convert signed div/rem to unsigned for non-negative operands, 2nd try
Sanjay Patel [Wed, 7 Sep 2022 15:44:27 +0000 (11:44 -0400)]
[SCCP] convert signed div/rem to unsigned for non-negative operands, 2nd try

The original commit ( fe1f3cfc2669 ) was reverted because it could
crash / assert when trying to fold a value that was replaced
by a constant. In that case, there might not be an entry for the
constant in the solver yet.

This version adds a check for that possibility along with tests to
exercise that pattern (they used to crash).

Original commit message:
This extends the transform added with D81756 to handle div/rem opcodes.
For example:
https://alive2.llvm.org/ce/z/cX6za6

This replicates part of what CVP already does, but the motivating example
from issue #57472 demonstrates a phase ordering problem - we convert
branches to select before CVP runs and miss the transform.

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

2 years ago[mlir] Use std::size instead of llvm::array_lengthof
Joe Loser [Wed, 7 Sep 2022 00:01:39 +0000 (18:01 -0600)]
[mlir] Use std::size instead of llvm::array_lengthof

LLVM contains a helpful function for getting the size of a C-style
array: `llvm::array_lengthof`. This is useful prior to C++17, but not as
helpful for C++17 or later: `std::size` already has support for C-style
arrays.

Change call sites to use `std::size` instead.

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

2 years ago[clangd] Add Macro Expansion to Hover
Qingyuan Zheng [Wed, 7 Sep 2022 15:44:32 +0000 (17:44 +0200)]
[clangd] Add Macro Expansion to Hover

This patch adds macro expansion preview to hover info. Basically, the refactor infrastructure for expanding macro is used for this purpose. The following steps are added to getHoverContents for macros:
1. calling AST.getTokens().expansionStartingAt(...) to get expanded tokens
2. calling reformat(...) to format expanded tokens

Some opinions are wanted:
1. Should we present macro expansion before definition in the hover card?
2. Should we truncate/ignore macro expansion if it's too long? For performance and presentation reason, it might not be a good idea to expand pages worth of tokens in hover card. If so, what's the preferred threshold?

Also, some limitation applies:
1. Expansion isn't available in macro definition/arguments as the refactor code action isn't either.

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

2 years agoRemoving myself from the CODE_OWNERS.TXT file as I am no longer working
Eric Schweitz [Wed, 7 Sep 2022 15:40:55 +0000 (08:40 -0700)]
Removing myself from the CODE_OWNERS.TXT file as I am no longer working
on the flang project. Ownership reverts to Steve Scalpone for now.

2 years ago[clangd] Fix hover crashing on integral or enumeral casts
Georg Kotheimer [Mon, 5 Sep 2022 09:14:27 +0000 (11:14 +0200)]
[clangd] Fix hover crashing on integral or enumeral casts

When pretty printing the value of an expression, we cannot infer from
the type of the expression the type of the constant that the expression
evaluates to, as the expression might contain a type cast.

2 years ago[clangd] Improve Selection testcase, pin to C++17
Sam McCall [Wed, 7 Sep 2022 14:00:21 +0000 (16:00 +0200)]
[clangd] Improve Selection testcase, pin to C++17

17 vs 14 have different ASTs, this causes D131465 to have to touch this test.
While here, make sure we're being clear about *which* nodes we're matching.

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

2 years ago[Sema] Move Diags.isIgnored() checks off hot paths, it's not free. NFC
Sam McCall [Wed, 13 Jul 2022 19:11:44 +0000 (21:11 +0200)]
[Sema] Move Diags.isIgnored() checks off hot paths, it's not free. NFC

This speeds up clangd's buildAST() (i.e. parsing with a preamble) by 5% on
clangd/AST.cpp, by avoiding filling up the diagnostic state map with entries for
all the files where templates are being instantiated from.

(I would assume it has a similar effect on PCH and modules compiles).

This approach is obviously pretty fragile, and we should find ways to make
isIgnored() cheaper instead. But these changes in particular don't seem to make
the code worse in any case.

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

2 years agoOne-shot-bufferize: allow non-tensor arguments in scg.while/for.
Johannes Reifferscheid [Wed, 7 Sep 2022 12:35:50 +0000 (14:35 +0200)]
One-shot-bufferize: allow non-tensor arguments in scg.while/for.

Currently, one-shot-bufferize crashes as soon as there's
a mixture of tensor and non-tensor arguments. This seems
to happen for no good reason.

Reviewed By: springerm

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

2 years ago[mlir][complex] Canonicalization for complex.sub adding same numbers
Kai Sasaki [Wed, 7 Sep 2022 12:55:28 +0000 (14:55 +0200)]
[mlir][complex] Canonicalization for complex.sub adding same numbers

Canonicalization for complex.sub adding same numbers. This canonicalization supports the case like complex.sub(complex.add(a, b), b) -> a.

Reviewed By: pifon2a

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

2 years ago[mlir][Math] Fix RoundEven constant folder.
jacquesguan [Wed, 7 Sep 2022 12:45:57 +0000 (12:45 +0000)]
[mlir][Math] Fix RoundEven constant folder.

Use roundToIntegral instead roundeven of libm to avoid window build failed.

Reviewed By: mehdi_amini

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

2 years ago[InstCombine] fold add+negate through select into sub
Sanjay Patel [Wed, 7 Sep 2022 11:53:38 +0000 (07:53 -0400)]
[InstCombine] fold add+negate through select into sub

This transform came up as a potential DAGCombine in D133282,
so I wanted to see how it escaped in IR too.

We do general folds in InstCombiner::SimplifySelectsFeedingBinaryOp()
by checking if either arm of a select simplifies when the trailing
binop is threaded into the select.

So as long as one side simplifies, it's a good fold to combine a
negate and add into 1 subtract.

This is an example with a zero arm in the select:
https://alive2.llvm.org/ce/z/Hgu_Tj

And this models the tests with a cancelling 'not' op:
https://alive2.llvm.org/ce/z/BuzVV_

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

2 years ago[InstCombine] add tests for SimplifySelectsFeedingBinaryOp(); NFC
Sanjay Patel [Tue, 6 Sep 2022 17:24:27 +0000 (13:24 -0400)]
[InstCombine] add tests for SimplifySelectsFeedingBinaryOp(); NFC

2 years agoSink/hoist memory instructions between loop fusion candidates
Aaron Kogon [Wed, 7 Sep 2022 11:42:00 +0000 (07:42 -0400)]
Sink/hoist memory instructions between loop fusion candidates

Currently, instructions in the preheader of the second of two fusion
candidates are sunk and hoisted whenever possible, to try to allow the
loops to fuse. Memory instructions are skipped, and are never sunk or
hoisted. This change adds memory instructions for sinking/hoisting
consideration.

This change uses DependenceAnalysis to check if a mem inst in the
preheader of FC1 depends on an instruction in FC0's header, across
which it will be hoisted, or FC1's header, across which it will be
sunk. We reject cases where the dependency is a data hazard.

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

2 years ago[mlir] Change CombiningKind in Vector dialect to EnumAttr.
Oleg Shyshkov [Wed, 7 Sep 2022 11:33:02 +0000 (13:33 +0200)]
[mlir] Change CombiningKind in Vector dialect to EnumAttr.

CombiningKind was implemented before EnumAttr, so it reimplements the same behaviour with the custom code. Except for a few places, EnumAttr is a drop-in replacement.

Reviewed By: nicolasvasilache, pifon2a

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

2 years ago[MCA] Correctly check pipeline availability for partially overlapping resource groups.
Andrea Di Biagio [Wed, 7 Sep 2022 10:27:22 +0000 (11:27 +0100)]
[MCA] Correctly check pipeline availability for partially overlapping resource groups.

This patch mostly reverts commit 70b37f4c03c which fixed PR50725.

In case of explicit consumption of multiple partially overlapping group
resources, the ResourceManager was not correctly checking pipeline
esources availability.

The fix for PR50725 only partially addressed a few instances of that issue.
This is a more general (although, technically slower) fix for that same issue.

It also fixes Issue #57548

Thanks to Haohai Wen for the small reproducible.

2 years ago[clangd] Support renaming virtual methods
Tom Praschan [Wed, 7 Sep 2022 10:03:55 +0000 (12:03 +0200)]
[clangd] Support renaming virtual methods

Fixes https://github.com/clangd/clangd/issues/706

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

2 years ago[CostModel][X86] Merge getTypeBasedIntrinsicInstrCost into getIntrinsicInstrCost
Simon Pilgrim [Wed, 7 Sep 2022 10:27:40 +0000 (11:27 +0100)]
[CostModel][X86] Merge getTypeBasedIntrinsicInstrCost into getIntrinsicInstrCost

For the few non type based intrinsic cases we can just check for !isTypeBasedOnly() to access the args directly.

I don't think we have a need to keep getTypeBasedIntrinsicInstrCost in BasicTTIImpl.h any more and can do a similar merge there as well - but it's a messier refactor and will take a while.

2 years ago[AMDGPU][MC][GFX11][NFC] Update disassembler tests for VOP3 instructions
Dmitry Preobrazhensky [Wed, 7 Sep 2022 10:55:27 +0000 (13:55 +0300)]
[AMDGPU][MC][GFX11][NFC] Update disassembler tests for VOP3 instructions

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

2 years ago[AMDGPU][MC][GFX11][NFC] Update disassembler tests for VOP3.DPP8 instructions
Dmitry Preobrazhensky [Wed, 7 Sep 2022 10:51:31 +0000 (13:51 +0300)]
[AMDGPU][MC][GFX11][NFC] Update disassembler tests for VOP3.DPP8 instructions

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

2 years ago[AMDGPU][MC][GFX11][NFC] Update disassembler tests for VOP3.DPP16 instructions
Dmitry Preobrazhensky [Wed, 7 Sep 2022 10:46:38 +0000 (13:46 +0300)]
[AMDGPU][MC][GFX11][NFC] Update disassembler tests for VOP3.DPP16 instructions

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

2 years ago[Bitcode] Fix constexpr autoupgrade for arrays and structs
Nikita Popov [Wed, 7 Sep 2022 10:46:32 +0000 (12:46 +0200)]
[Bitcode] Fix constexpr autoupgrade for arrays and structs

While vectors use insertelement, structs and arrays should use
insertvalue.

2 years ago[AMDGPU][MC][GFX11][NFC] Update assembler tests for VOPD instructions
Dmitry Preobrazhensky [Wed, 7 Sep 2022 10:41:44 +0000 (13:41 +0300)]
[AMDGPU][MC][GFX11][NFC] Update assembler tests for VOPD instructions

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

2 years ago[Bitcode] Convert constexpr-to-instr.ll to use bitcode input (NFC)
Nikita Popov [Wed, 7 Sep 2022 10:28:26 +0000 (12:28 +0200)]
[Bitcode] Convert constexpr-to-instr.ll to use bitcode input (NFC)

We can't use an IR input once the relevant constant expressions
are no longer supported. Use a bitcode file instead, which will
be auto-upgraded (the whole point of this code...)

2 years ago[AMDGPU] Add an operand folding test case from D114232
Jay Foad [Wed, 7 Sep 2022 10:16:40 +0000 (11:16 +0100)]
[AMDGPU] Add an operand folding test case from D114232

2 years ago[AMDGPU] Refactor SIFoldOperands. NFC.
Jay Foad [Wed, 7 Sep 2022 09:49:50 +0000 (10:49 +0100)]
[AMDGPU] Refactor SIFoldOperands. NFC.

Refactor static functions into class methods so they have access to TII, MRI
etc.