platform/upstream/llvm.git
2 years agoRemove unneeded cl::ZeroOrMore for cl::opt options
Fangrui Song [Sat, 4 Jun 2022 07:10:42 +0000 (00:10 -0700)]
Remove unneeded cl::ZeroOrMore for cl::opt options

Similar to 557efc9a8b68628c2c944678c6471dac30ed9e8e.
This commit handles options where cl::ZeroOrMore is more than one line below
cl::opt.

2 years ago[MLIR][GPU] Replace fdiv on fp16 with promoted (fp32) multiplication with reciprocal...
Christian Sigg [Fri, 3 Jun 2022 21:15:52 +0000 (23:15 +0200)]
[MLIR][GPU] Replace fdiv on fp16 with promoted (fp32) multiplication with reciprocal plus one (conditional) Newton iteration.

This is correct for all values, i.e. the same as promoting the division to fp32 in the NVPTX backend. But it is faster (~10% in average, sometimes more) because:

- it performs less Newton iterations
- it avoids the slow path for e.g. denormals
- it allows reuse of the reciprocal for multiple divisions by the same divisor

Test program:
```
#include <stdio.h>
#include "cuda_fp16.h"

// This is a variant of CUDA's own __hdiv which is fast than hdiv_promote below
// and doesn't suffer from the perf cliff of div.rn.fp32 with 'special' values.
__device__ half hdiv_newton(half a, half b) {
  float fa = __half2float(a);
  float fb = __half2float(b);

  float rcp;
  asm("{rcp.approx.ftz.f32 %0, %1;\n}" : "=f"(rcp) : "f"(fb));

  float result = fa * rcp;
  auto exponent = reinterpret_cast<const unsigned&>(result) & 0x7f800000;
  if (exponent != 0 && exponent != 0x7f800000) {
    float err = __fmaf_rn(-fb, result, fa);
    result = __fmaf_rn(rcp, err, result);
  }

  return __float2half(result);
}

// Surprisingly, this is faster than CUDA's own __hdiv.
__device__ half hdiv_promote(half a, half b) {
  return __float2half(__half2float(a) / __half2float(b));
}

// This is an approximation that is accurate up to 1 ulp.
__device__ half hdiv_approx(half a, half b) {
  float fa = __half2float(a);
  float fb = __half2float(b);

  float result;
  asm("{div.approx.ftz.f32 %0, %1, %2;\n}" : "=f"(result) : "f"(fa), "f"(fb));
  return __float2half(result);
}

__global__ void CheckCorrectness() {
  int i = threadIdx.x + blockIdx.x * blockDim.x;
  half x = reinterpret_cast<const half&>(i);
  for (int j = 0; j < 65536; ++j) {
    half y = reinterpret_cast<const half&>(j);
    half d1 = hdiv_newton(x, y);
    half d2 = hdiv_promote(x, y);
    auto s1 = reinterpret_cast<const short&>(d1);
    auto s2 = reinterpret_cast<const short&>(d2);
    if (s1 != s2) {
      printf("%f (%u) / %f (%u), got %f (%hu), expected: %f (%hu)\n",
             __half2float(x), i, __half2float(y), j, __half2float(d1), s1,
             __half2float(d2), s2);
      //__trap();
    }
  }
}

__device__ half dst;

__global__ void ProfileBuiltin(half x) {
  #pragma unroll 1
  for (int i = 0; i < 10000000; ++i) {
    x = x / x;
  }
  dst = x;
}

__global__ void ProfilePromote(half x) {
  #pragma unroll 1
  for (int i = 0; i < 10000000; ++i) {
    x = hdiv_promote(x, x);
  }
  dst = x;
}

__global__ void ProfileNewton(half x) {
  #pragma unroll 1
  for (int i = 0; i < 10000000; ++i) {
    x = hdiv_newton(x, x);
  }
  dst = x;
}

__global__ void ProfileApprox(half x) {
  #pragma unroll 1
  for (int i = 0; i < 10000000; ++i) {
    x = hdiv_approx(x, x);
  }
  dst = x;
}

int main() {
  CheckCorrectness<<<256, 256>>>();
  half one = __float2half(1.0f);
  ProfileBuiltin<<<1, 1>>>(one);  // 1.001s
  ProfilePromote<<<1, 1>>>(one);  // 0.560s
  ProfileNewton<<<1, 1>>>(one);   // 0.508s
  ProfileApprox<<<1, 1>>>(one);   // 0.304s
  auto status = cudaDeviceSynchronize();
  printf("%s\n", cudaGetErrorString(status));
}
```

Reviewed By: herhut

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

2 years ago[flang][runtime] Signal new I/O error on floating-point input overflow
Peter Klausler [Fri, 3 Jun 2022 20:26:28 +0000 (13:26 -0700)]
[flang][runtime] Signal new I/O error on floating-point input overflow

Besides raising the IEEE floating-point overflow exception, treat
a floating-point overflow on input as an I/O error catchable with
ERR=, IOSTAT=, &/or IOMSG=.

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

2 years ago[BOLT][UTILS] Usability improvements for nfc-check-setup
Amir Ayupov [Sat, 4 Jun 2022 05:54:32 +0000 (22:54 -0700)]
[BOLT][UTILS] Usability improvements for nfc-check-setup

# Stash local changes before checkout.
# Print a message that the source repository revision has been changed, with
  instructions to switch back.
# Make the script executable.
# Print sample instructions how to run bolt tests.
# Assume that llvm-bolt-wrapper script is in the same source directory.

Reviewed By: rafauler

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

2 years ago[flang] Don't discard lower bounds of implicit-shape named constants
Peter Klausler [Mon, 30 May 2022 23:27:49 +0000 (16:27 -0700)]
[flang] Don't discard lower bounds of implicit-shape named constants

F18 preserves lower bounds of explicit-shape named constant arrays, but
failed to also do so for implicit-shape named constants.  Fix.

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

2 years ago[flang][runtime] Ensure that 0. <= RANDOM_NUMBER() < 1.
Peter Klausler [Mon, 30 May 2022 23:13:48 +0000 (16:13 -0700)]
[flang][runtime] Ensure that 0. <= RANDOM_NUMBER() < 1.

It was possible for RANDOM_NUMBER() to return 1.0.

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

2 years agoRevert D126950 "[lld][WebAssembly] Retain data segments referenced via __start/__stop"
Fangrui Song [Sat, 4 Jun 2022 05:18:06 +0000 (22:18 -0700)]
Revert D126950 "[lld][WebAssembly] Retain data segments referenced via __start/__stop"

This reverts commit dcf3368e33c3a01bd21b692d3be5dc1ecee587f4.

It breaks -DLLVM_ENABLE_ASSERTIONS=on builds. In addition, the description is
incorrect about ld.lld behavior. For wasm, there should be justification to add
the new mode.

2 years ago[flang] Distinguish intrinsic module USE in module files; correct search paths
Peter Klausler [Mon, 30 May 2022 19:47:32 +0000 (12:47 -0700)]
[flang] Distinguish intrinsic module USE in module files; correct search paths

In the USE statements that f18 emits to module files, ensure that symbols
from intrinsic modules are marked as such on their USE statements.  And
ensure that the current working directory (".") cannot override the intrinsic
module search path when trying to locate an intrinsic module.

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

2 years ago[Hexagon][bolt] Remove unneeded cl::ZeroOrMore for cl::opt options. NFC
Fangrui Song [Sat, 4 Jun 2022 05:04:57 +0000 (22:04 -0700)]
[Hexagon][bolt] Remove unneeded cl::ZeroOrMore for cl::opt options. NFC

Similar to 557efc9a8b68628c2c944678c6471dac30ed9e8e

2 years ago[clang-link-wrapper] Remove unneeded cl::ZeroOrMore for cl::opt options. NFC
Fangrui Song [Sat, 4 Jun 2022 05:02:11 +0000 (22:02 -0700)]
[clang-link-wrapper] Remove unneeded cl::ZeroOrMore for cl::opt options. NFC

Similar to 557efc9a8b68628c2c944678c6471dac30ed9e8e

2 years ago[llvm] Remove unneeded cl::ZeroOrMore for cl::opt options. NFC
Fangrui Song [Sat, 4 Jun 2022 04:59:05 +0000 (21:59 -0700)]
[llvm] Remove unneeded cl::ZeroOrMore for cl::opt options. NFC

Some cl::ZeroOrMore were added to avoid the `may only occur zero or one times!`
error. More were added due to cargo cult. Since the error has been removed,
cl::ZeroOrMore is unneeded.

Also remove cl::init(false) while touching the lines.

2 years ago[RISCV] Add more patterns for FNMADD
LiaoChunyu [Thu, 2 Jun 2022 03:50:54 +0000 (11:50 +0800)]
[RISCV] Add more patterns for FNMADD

D54205 handles fnmadd: -rs1 * rs2 - rs3
This patch add fnmadd: -(rs1 * rs2 + rs3) (the nsz flag on the FMA)

Reviewed By: craig.topper

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

2 years ago[libc++][ranges][NFC] Fix a patch link in ranges status.
varconst [Sat, 4 Jun 2022 03:39:00 +0000 (20:39 -0700)]
[libc++][ranges][NFC] Fix a patch link in ranges status.

2 years ago[libc++][ranges][NFC] Mark range algorithms that are in progress.
varconst [Sat, 4 Jun 2022 03:02:46 +0000 (20:02 -0700)]
[libc++][ranges][NFC] Mark range algorithms that are in progress.

2 years ago[lld][WebAssembly] Retain data segments referenced via __start/__stop
Yuta Saito [Sat, 4 Jun 2022 02:28:31 +0000 (02:28 +0000)]
[lld][WebAssembly] Retain data segments referenced via __start/__stop

As well as ELF linker does, retain all data segments named X referenced
through `__start_X` or `__stop_X`.

For example, `FOO_MD` should not be stripped in the below case, but it's currently mis-stripped

```llvm
@FOO_MD  = global [4 x i8] c"bar\00", section "foo_md", align 1
@__start_foo_md = external constant i8*
@__stop_foo_md = external constant i8*
@llvm.used = appending global [1 x i8*] [i8* bitcast (i32 ()* @foo_md_size to i8*)], section "llvm.metadata"

define i32 @foo_md_size()  {
entry:
  ret i32 sub (
    i32 ptrtoint (i8** @__stop_foo_md to i32),
    i32 ptrtoint (i8** @__start_foo_md to i32)
  )
}
```

This fixes https://github.com/llvm/llvm-project/issues/55839

Reviewed By: sbc100

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

2 years ago[flang] Correct folding of CSHIFT and EOSHIFT for DIM>1
Peter Klausler [Sun, 29 May 2022 21:18:51 +0000 (14:18 -0700)]
[flang] Correct folding of CSHIFT and EOSHIFT for DIM>1

The algorithm was wrong for higher dimensions, and so were
the expected test results.  Rework.

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

2 years ago[pseudo] Fix leaks after D126731
Fangrui Song [Sat, 4 Jun 2022 01:43:15 +0000 (18:43 -0700)]
[pseudo] Fix leaks after D126731

Array Operator new Cookies help lsan find allocations, while std::array
can't.

2 years ago[flang][runtime] Signal format error when input field width is zero
Peter Klausler [Sun, 29 May 2022 17:12:57 +0000 (10:12 -0700)]
[flang][runtime] Signal format error when input field width is zero

A data edit descriptor for input may not have a zero field width.

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

2 years ago[flang][runtime] OPEN write-only files
Peter Klausler [Sun, 29 May 2022 15:36:57 +0000 (08:36 -0700)]
[flang][runtime] OPEN write-only files

If a file being opened with no ACTION= is write-only then cope with
it rather than defaulting prematurely to treating it as read-only.

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

2 years ago[RISCV] Support LUI+ADDIW in doPeepholeLoadStoreADDI.
Craig Topper [Sat, 4 Jun 2022 00:58:22 +0000 (17:58 -0700)]
[RISCV] Support LUI+ADDIW in doPeepholeLoadStoreADDI.

This fixes an inconsistency between RV32 and RV64. Still considering
trying to do this peephole during isel, but wanted to fix the
inconsistency first.

Reviewed By: reames

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

2 years ago[flang][runtime] INQUIRE(FILE="...",SIZE=nbytes)
Peter Klausler [Sun, 29 May 2022 15:21:59 +0000 (08:21 -0700)]
[flang][runtime] INQUIRE(FILE="...",SIZE=nbytes)

Implement inquire-by-file SIZE= specifier.

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

2 years ago[clang][test] Mark test arm-float-abi-lto.c unsupported on AIX
Jake Egan [Sat, 4 Jun 2022 01:00:47 +0000 (21:00 -0400)]
[clang][test] Mark test arm-float-abi-lto.c unsupported on AIX

This test is failing after the introduction of opaque pointers (https://reviews.llvm.org/D125847). The test is flaky and fails from segmentation fault, but it's unclear why. So, mark this test unsupported while it's investigated.

2 years ago[test] Modify test to verify D126396 (Clean "./" from __FILE__ expansion)
Paul Pluzhnikov [Sat, 4 Jun 2022 00:54:02 +0000 (17:54 -0700)]
[test] Modify test to verify D126396 (Clean "./" from __FILE__ expansion)

Reviewed By: MaskRay

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

2 years ago[flang][runtime] Allow extra character for E0.0 output editing
Peter Klausler [Sat, 28 May 2022 23:11:43 +0000 (16:11 -0700)]
[flang][runtime] Allow extra character for E0.0 output editing

When the digit count ('d') is zero in E0 editing, allow for one more
output character; otherwise, any - or + sign in the output causes
an output field overflow.

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

2 years ago[mlir][sparse] Adding IsSparseTensorPred and updating ops to use it
wren romano [Fri, 3 Jun 2022 23:41:02 +0000 (16:41 -0700)]
[mlir][sparse] Adding IsSparseTensorPred and updating ops to use it

Reviewed By: aartbik

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

2 years ago[flang][runtime] Fix bug with extra leading zero in octal output
Peter Klausler [Sat, 28 May 2022 22:36:02 +0000 (15:36 -0700)]
[flang][runtime] Fix bug with extra leading zero in octal output

Octal (O) output editing often emits an extra leading 0 digit
due to the total digit count being off by one since word sizes
aren't multiples of three bits.

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

2 years ago[flang] Fix crash in IsSaved()
Peter Klausler [Sat, 28 May 2022 18:54:57 +0000 (11:54 -0700)]
[flang] Fix crash in IsSaved()

Code was accessing ProcEntityDetails in a symbol that didn't have them.

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

2 years ago[NFC] [libunwind] turn assert into static_assert
Florian Mayer [Fri, 3 Jun 2022 18:45:04 +0000 (11:45 -0700)]
[NFC] [libunwind] turn assert into static_assert

Reviewed By: #libunwind, MaskRay

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

2 years ago[tools] Forward declare classes & remove includes
Clemens Wasser [Fri, 3 Jun 2022 23:32:04 +0000 (16:32 -0700)]
[tools] Forward declare classes & remove includes

Reviewed By: MaskRay

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

2 years ago[mlir][linalg] fix crash in vectorization of elementwise operations
Christopher Bate [Fri, 3 Jun 2022 20:23:45 +0000 (14:23 -0600)]
[mlir][linalg] fix crash in vectorization of elementwise operations

The current vectorization logic implicitly expects "elementwise"
linalg ops to have projected permutations for indexing maps, but
the precondition logic misses this check. This can result in a
crash when executing the generic vectorization transform on an op
with a non-projected permutation input indexing map. This change
fixes the logic and adds a test (which crashes without this fix).

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

2 years ago[DWARF] Show which augmentation character was unrecognized.
Florian Mayer [Fri, 3 Jun 2022 21:09:34 +0000 (14:09 -0700)]
[DWARF] Show which augmentation character was unrecognized.

Reviewed By: MaskRay

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

2 years ago[Hexagon] Enable IAS in the Hexagon backend
Brad Smith [Fri, 3 Jun 2022 22:15:12 +0000 (18:15 -0400)]
[Hexagon] Enable IAS in the Hexagon backend

Reviewed By: kparzysz

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

2 years ago[clang] Allow const variables with weak attribute to be overridden
Anders Waldenborg [Tue, 24 May 2022 19:46:32 +0000 (21:46 +0200)]
[clang] Allow const variables with weak attribute to be overridden

A variable with `weak` attribute signifies that it can be replaced with
a "strong" symbol link time. Therefore it must not emitted with
"weak_odr" linkage, as that allows the backend to use its value in
optimizations.

The frontend already considers weak const variables as
non-constant (note_constexpr_var_init_weak diagnostic) so this change
makes frontend and backend consistent.

This commit reverses the
  f49573d1 weak globals that are const should get weak_odr linkage.
commit from 2009-08-05 which introduced this behavior. Unfortunately
that commit doesn't provide any details on why the change was made.

This was discussed in
https://discourse.llvm.org/t/weak-attribute-semantics-on-const-variables/62311

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

2 years ago[Clang] Change the offload packager build to be a clang tool
Joseph Huber [Fri, 3 Jun 2022 21:33:56 +0000 (17:33 -0400)]
[Clang] Change the offload packager build to be a clang tool

Summary:
This patch changes the CMake build configruation for the
`clang-offload-packager` to be a clang tool rather than an executable.

2 years ago[mlir] Add peeling xform to Codegen Strategy
Diego Caballero [Fri, 3 Jun 2022 21:31:43 +0000 (21:31 +0000)]
[mlir] Add peeling xform to Codegen Strategy

This patch adds the knobs to use peeling in the codegen strategy
infrastructure.

Reviewed By: springerm

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

2 years ago[BOLT][NFC] Warning for deprecated option '-reorder-blocks=cache+'
Huan Nguyen [Fri, 3 Jun 2022 21:16:24 +0000 (14:16 -0700)]
[BOLT][NFC] Warning for deprecated option '-reorder-blocks=cache+'

Emit warning when using deprecated option '-reorder-blocks=cache+'.
Auto switch to option '-reorder-blocks=ext-tsp'.

Test Plan:
```
ninja check-bolt
```
Added a new test cache+-deprecated.test.
Run and verify that the upstream tests are passed.

Reviewed By: rafauler, Amir, maksfb

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

2 years agoAMDGPU: allow reordering of functions in AMDGPUResourceUsageAnalysis
Jacob Weightman [Fri, 3 Jun 2022 20:52:55 +0000 (15:52 -0500)]
AMDGPU: allow reordering of functions in AMDGPUResourceUsageAnalysis

The AMDGPUResourceUsageAnalysis was previously a CGSCC pass, and assumed
that a function's callees were always analyzed prior to their callees.
When it was refactored into a module pass, this assumption no longer
always holds. This results in calls being erroneously identified as
indirect, and reserving private segment space for them. This results in
significantly slower kernel launch latency.

This patch changes the order in which the module's functions are analyzed
from the order in which they occur in the module to a post-order traversal
of the call graph. Perhaps Clang always generates the module's functions
in such an order, but this is not the case for the Cray Fortran compiler.

Reviewed By: #amdgpu, arsenm

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

2 years ago[RISCV] Pre-commit test cases for D126986. NFC
Craig Topper [Fri, 3 Jun 2022 20:29:46 +0000 (13:29 -0700)]
[RISCV] Pre-commit test cases for D126986. NFC

2 years ago[bazel] Update build for config.h.cmake change
Reid Kleckner [Fri, 3 Jun 2022 19:56:48 +0000 (12:56 -0700)]
[bazel] Update build for config.h.cmake change

2 years ago[libc] Make expm1f correctly rounded when the targets have no FMA instructions.
Tue Ly [Sat, 9 Apr 2022 04:12:50 +0000 (00:12 -0400)]
[libc] Make expm1f correctly rounded when the targets have no FMA instructions.

Add another exceptional value and fix the case when |x| is small.

Performance tests with CORE-MATH project scripts:
With FMA instructions on Ryzen 1700:
```
$ ./perf.sh expm1f
LIBC-location: /home/lnt/experiment/llvm/llvm-project/build/projects/libc/lib/libllvmlibc.a
CORE-MATH reciprocal throughput   : 15.362
System LIBC reciprocal throughput : 53.194
LIBC reciprocal throughput        : 14.595
$ ./perf.sh expm1f --latency
LIBC-location: /home/lnt/experiment/llvm/llvm-project/build/projects/libc/lib/libllvmlibc.a
CORE-MATH latency   : 57.755
System LIBC latency : 147.020
LIBC latency        : 60.269
```
Without FMA instructions:
```
$ ./perf.sh expm1f
LIBC-location: /home/lnt/experiment/llvm/llvm-project/build/projects/libc/lib/libllvmlibc.a
CORE-MATH reciprocal throughput   : 15.362
System LIBC reciprocal throughput : 53.300
LIBC reciprocal throughput        : 18.020
$ ./perf.sh expm1f --latency
LIBC-location: /home/lnt/experiment/llvm/llvm-project/build/projects/libc/lib/libllvmlibc.a
CORE-MATH latency   : 57.758
System LIBC latency : 147.025
LIBC latency        : 70.304
```

Reviewed By: michaelrj

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

2 years ago[libc++][test] Skip string_view tests for other vendors on older modes
Joe Loser [Thu, 2 Jun 2022 03:22:17 +0000 (21:22 -0600)]
[libc++][test] Skip string_view tests for other vendors on older modes

`string_view` is supported all the way back to C++03 as an extension in
`libc++`, and so many of the tests run in all standards modes for all vendors.
This is unlikely desired by other standard library vendors using our test suite.
So, disable the tests for vendors other than `libc++` in these older standards
modes.

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

2 years ago[lld-macho] Addressed additional post-commit comments from D126046
Vy Nguyen [Wed, 1 Jun 2022 16:54:41 +0000 (12:54 -0400)]
[lld-macho] Addressed additional post-commit comments from  D126046

- fixed newlines
- renamed helper function for clarity
- added additional comment

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

2 years ago[ARM] Make a narrow tMOVi8 where possible in SEH prologues
Martin Storsjö [Wed, 1 Jun 2022 21:12:16 +0000 (00:12 +0300)]
[ARM] Make a narrow tMOVi8 where possible in SEH prologues

We intentionally disable Thumb2SizeReduction for SEH
prologues/epilogues, to avoid needing to guess what will happen with
the instructions in a potential future pass in frame lowering.

But for this specific case, where we know we can express the
intent with a narrow instruction, change to that instruction form
directly in frame lowering.

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

2 years ago[ARM] Make narrow push/pop in SEH prologues/epilogues where applicable
Martin Storsjö [Wed, 1 Jun 2022 19:38:41 +0000 (22:38 +0300)]
[ARM] Make narrow push/pop in SEH prologues/epilogues where applicable

We intentionally disable Thumb2SizeReduction for SEH
prologues/epilogues, to avoid needing to guess what will happen with
the instructions in a potential future pass in frame lowering.

But for this specific case, where we know we can express the
intent with a narrow instruction, change to that instruction form
directly in frame lowering.

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

2 years agoRevert "[X86] combineConcatVectorOps - add support for concatenation VSELECT/BLENDV...
Eric Christopher [Fri, 3 Jun 2022 19:07:58 +0000 (12:07 -0700)]
Revert "[X86] combineConcatVectorOps - add support for concatenation VSELECT/BLENDV nodes"

See the original commit for a testcase.

This reverts commit ea8fb3b6019642a3a032fd65588eb8460439d2f9.

2 years ago[OpenMP] allow loc to be NULL in __kmp_determine_reduction_method for MSVC
Vadim Paretsky [Fri, 3 Jun 2022 19:10:25 +0000 (14:10 -0500)]
[OpenMP] allow loc to be NULL in __kmp_determine_reduction_method for MSVC

MSVC may not supply source location information to kmpc_reduce passing
NULL for the value. The patch adds a check for the loc value being NULL
in kmp_determine_reduction_method.

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

2 years ago[Matrix] Add dot product tests
Vir Narula [Fri, 3 Jun 2022 19:02:42 +0000 (20:02 +0100)]
[Matrix] Add dot product tests

LLVM LIT tests for our upcoming dot product lowering change

Reviewed By: fhahn

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

2 years ago[clang][dataflow] Modify `optional` model to handle type aliases.
Yitzhak Mandelbaum [Fri, 3 Jun 2022 16:21:27 +0000 (16:21 +0000)]
[clang][dataflow] Modify `optional` model to handle type aliases.

Previously, type aliases were not handled (and resulted in an assertion
firing). This patch generalizes the model to consider aliases everywhere (a
previous patch already considered aliases for optional-returning functions).

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

2 years ago[pseudo] Add CLANG_PSEUDO_GEN cmake cache variable to avoid nested CMake invocation
Sam McCall [Tue, 31 May 2022 19:10:13 +0000 (21:10 +0200)]
[pseudo] Add CLANG_PSEUDO_GEN cmake cache variable to avoid nested CMake invocation

Similar to LLVM_TABLEGEN, CLANG_TABLEGEN variables

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

2 years ago[pseudo] rename pseudo-gen -> clang-pseudo-gen. NFC
Sam McCall [Tue, 31 May 2022 22:07:30 +0000 (00:07 +0200)]
[pseudo] rename pseudo-gen -> clang-pseudo-gen. NFC

This name is not namespaced. Requested in D126717

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

2 years ago[lld][WebAssembly] Remove unnecessary accessor methods. NFC
Sam Clegg [Fri, 3 Jun 2022 17:47:53 +0000 (10:47 -0700)]
[lld][WebAssembly] Remove unnecessary accessor methods. NFC

This is less code, and matches more closely the ELF linker.

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

2 years ago[bazel] Port 95aff23e2921
Benjamin Kramer [Fri, 3 Jun 2022 18:43:02 +0000 (20:43 +0200)]
[bazel] Port 95aff23e2921

2 years ago[pseudo] Eliminate dependencies from clang-pseudo-gen. NFC
Sam McCall [Tue, 31 May 2022 23:02:47 +0000 (01:02 +0200)]
[pseudo] Eliminate dependencies from clang-pseudo-gen. NFC

ClangBasic dependency eliminated by replacing our usage of
tok::getPunctuatorSpelling etc with direct use of the *.def file.

Implicit dependencies on clang-tablegen-targets removed as we manage to avoid
any transitive tablegen deps.

After these changes, `ninja clean; ninja pseudo-gen` runs 169 actions only
(basically Support and Demangle).

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

2 years agoCommandObjectRegexCommand shouldn't put two commands on the history stack.
Jim Ingham [Fri, 3 Jun 2022 18:32:43 +0000 (11:32 -0700)]
CommandObjectRegexCommand shouldn't put two commands on the history stack.

It was putting the command the user typed, and then the resolved command in the
command history.  That caused up-arrow not to work correctly when the regex command
was invoked from a Python-command.  Plus it's just weird.

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

2 years ago[libc++] Forward more often to memmove in copy
Nikolas Klauser [Fri, 3 Jun 2022 10:50:39 +0000 (12:50 +0200)]
[libc++] Forward more often to memmove in copy

In D122982 I accidentally disabled the memmove optimization. This re-enables it and adds more cases where copy forwards to memmove.
Fixes https://github.com/llvm/llvm-project/issues/33687

Reviewed By: var-const, #libc, ldionne

Spies: pkasting, ayzhao, dcheng, xbolva00, libcxx-commits

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

2 years ago[MSAN] Exclude dn_expand test from Android.
Kevin Athey [Fri, 3 Jun 2022 18:14:59 +0000 (11:14 -0700)]
[MSAN] Exclude dn_expand test from Android.

Depends on 1a729bce8617

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

2 years ago[NFC] Fix issue on CMake Xcode build configuration.
python3kgae [Thu, 2 Jun 2022 16:39:01 +0000 (09:39 -0700)]
[NFC] Fix issue on CMake Xcode build configuration.

add missing dependency for hlsl-resource-headers and clang-resource-headers.

Reviewed By: rastogishubham

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

2 years ago[RISCV] Use SelectionDAG::isBaseWithConstantOffset in scalar load/store address matching.
Craig Topper [Fri, 3 Jun 2022 17:53:39 +0000 (10:53 -0700)]
[RISCV] Use SelectionDAG::isBaseWithConstantOffset in scalar load/store address matching.

Test changes are because isBaseWithConstantOffset uses computeKnownBits
and that is able to see that an earlier AND instruction guaranteed
alignment so that we can treat an OR as an ADD.

Reviewed By: reames

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

2 years ago[config] Remove LLVM_DEFAULT_TARGET_TRILE from config.h
Reid Kleckner [Fri, 3 Jun 2022 17:08:53 +0000 (10:08 -0700)]
[config] Remove LLVM_DEFAULT_TARGET_TRILE from config.h

It is redundant with llvm-config.h, which is always included by
config.h.

Port D12660 / d178f4fc895b432008fcd8a0a49a13d951fecfe4 from config.h to
llvm-config.h.

Update the gn build accordingly.

NFCI

2 years agoRe-land "[mlir] Add integer range inference analysis""
Krzysztof Drewniak [Thu, 2 Jun 2022 21:45:52 +0000 (21:45 +0000)]
Re-land "[mlir] Add integer range inference analysis""

This reverts commit 4e5ce2056e3e85f109a074e80bdd23a10ca2bed9.

This relands commit 1350c9887dca5ba80af8e3c1e61b29d6696eb240.

Reinstates the range analysis with the build issue fixed.

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

2 years ago[LLVM] [NFC] remove unnecessary, confusing scope
Florian Mayer [Fri, 3 Jun 2022 01:11:42 +0000 (18:11 -0700)]
[LLVM] [NFC] remove unnecessary, confusing scope

Reviewed By: dmgreen

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

2 years ago[MSAN] add dn_expand intercept.
Kevin Athey [Thu, 2 Jun 2022 21:18:00 +0000 (14:18 -0700)]
[MSAN] add dn_expand intercept.

This interceptor only addresses writes to inputs.  Reads of inputs are not checked.

Reviewed By: vitalybuka

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

2 years agollvm: cmake: set CMP0114 to OLD to avoid warning
Nick Desaulniers [Fri, 3 Jun 2022 16:33:04 +0000 (09:33 -0700)]
llvm: cmake: set CMP0114 to OLD to avoid warning

Building with cmake 3.23.2+ produces warnings when using
LLVM_ENABLE_RUNTIMES. Set this policy to the existing behavior for now
to silence the warnings.

Fixes: https://github.com/llvm/llvm-project/issues/50122
Fixes: https://github.com/llvm/llvm-project/issues/54944

Reviewed By: phosek, penzn

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

2 years ago[Attributes] Remove AttrSyntax and migrate uses to AttributeCommonInfo::Syntax (NFC)
Leonard Grey [Thu, 2 Jun 2022 17:30:43 +0000 (13:30 -0400)]
[Attributes] Remove AttrSyntax and migrate uses to AttributeCommonInfo::Syntax (NFC)

This is setup for allowing hasAttribute to work for plugin-provided attributes

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

2 years ago[BOLT] Cache-Aware Tail Duplication
spupyrev [Fri, 3 Jun 2022 16:08:45 +0000 (09:08 -0700)]
[BOLT] Cache-Aware Tail Duplication

A new "cache-aware" strategy for tail duplication.

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

2 years ago[RISCV] Reduce scalar load/store isel patterns to a single ComplexPattern. NFCI
Craig Topper [Fri, 3 Jun 2022 05:08:51 +0000 (22:08 -0700)]
[RISCV] Reduce scalar load/store isel patterns to a single ComplexPattern. NFCI

Previously we had 3 different isel patterns for every scalar load
store instruction.

This reduces them to a single ComplexPattern that returns the Base
and Offset. Or an offset of 0 if there was no offset identified

I've done a similar thing for the 2 isel patterns that match add/or
with FrameIndex and immediate. Using the offset of 0, I was also
able to remove the custom handler for FrameIndex. Happy to split that
to another patch.

We might be able to enhance in the future to remove the post-isel
peephole or the special handling for ADD with constant added by D126576.

A nice side effect is that this removes nearly 3000 bytes from the isel
table.

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

2 years ago[COFF] Fix -Wredundant-move
Benjamin Kramer [Fri, 3 Jun 2022 15:39:08 +0000 (17:39 +0200)]
[COFF] Fix -Wredundant-move

2 years ago[COFF] Check table ptr more thoroughly and ignore empty sections
Alvin Wong [Fri, 3 Jun 2022 14:57:57 +0000 (17:57 +0300)]
[COFF] Check table ptr more thoroughly and ignore empty sections

When loading split debug files for PE/COFF executables (produced with
`objcopy --only-keep-debug`), the tables or directories in such files
may point to data inside sections that may have been stripped.
COFFObjectFile shall detect and gracefully handle this, to allow the
object file be loaded without considering these tables or directories.
This is required for LLDB to load these files for use as debug symbols.

COFFObjectFile shall also check these pointers more carefully to account
for cases in which the section contains less raw data than the size
given by VirtualSize, to prevent going out of bounds.

This commit also changes COFFDump in llvm-objdump to reuse the pointers
that are already range-checked in COFFObjectFile. This fixes a crash
when trying to dump the TLS directory from a stripped file.

Fixes https://github.com/mstorsjo/llvm-mingw/issues/284

Reviewed By: rnk

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

2 years ago[SLP]Improve shuffles cost estimation where possible.
Alexey Bataev [Thu, 9 Dec 2021 18:34:08 +0000 (10:34 -0800)]
[SLP]Improve shuffles cost estimation where possible.

Improved/fixed cost modeling for shuffles by providing masks, improved
cost model for non-identity insertelements.

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

2 years ago[docs] Remove a link to an outdated Go docs
Yuki Okushi [Thu, 2 Jun 2022 11:50:26 +0000 (20:50 +0900)]
[docs] Remove a link to an outdated Go docs

That link returns 404, we have bindings code on https://github.com/llvm/llvm-project/tree/main/llvm/bindings/go
but it seems we haven't published it and there are no docs yet.

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

2 years ago[gn build] Extract compiled_action.gni from tablegen.gni
Nico Weber [Fri, 3 Jun 2022 14:02:06 +0000 (10:02 -0400)]
[gn build] Extract compiled_action.gni from tablegen.gni

After years of tablegen being the only host binary we run as part
of the build, we're now in the process of growing at least two more:
- make_confusable_table (https://reviews.llvm.org/rG180bae08a04d)
- pseudo-gen (not yet fully hooked up in the GN build, but I have
  a local branch that hooks it up)

Factor out the few lines we need for running a host binary as part of the
build.

No behavior change.

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

2 years agoOnly issue warning for subtraction involving null pointers on live code paths
Jamie Schmeiser [Fri, 3 Jun 2022 14:10:37 +0000 (10:10 -0400)]
Only issue warning for subtraction involving null pointers on live code paths

Summary:
Change the warning produced for subtraction from (or with) a null pointer
to only be produced when the code path is live.
https://github.com/llvm/llvm-project/issues/54570

Author: Jamie Schmeiser <schmeise@ca.ibm.com>
Reviewed By: anarazel (Andres Freund)
Differential Revision: https://reviews.llvm.org/D126816

2 years ago[coro async] Add code to support dynamic aligment of over-aligned types in async...
Arnold Schwaighofer [Fri, 27 May 2022 21:34:55 +0000 (14:34 -0700)]
[coro async] Add code to support dynamic aligment of over-aligned types in async frames

Async context frames are allocated with a maximum alignment. If a type
requests an alignment bigger than that dynamically align the address
in the frame.

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

2 years ago[clang][dataflow] Model calls returning optionals
Stanislav Gatev [Wed, 1 Jun 2022 08:43:30 +0000 (08:43 +0000)]
[clang][dataflow] Model calls returning optionals

Model calls returning optionals

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

Reviewed-by: ymandel, xazax.hun
2 years agoRevert "[clang-tidy] Confusable identifiers detection"
Nico Weber [Fri, 3 Jun 2022 13:29:10 +0000 (09:29 -0400)]
Revert "[clang-tidy] Confusable identifiers detection"

This reverts commit b94db7ed7eaf4a3b21f600653a09c55cab77b79f.
See comments on https://reviews.llvm.org/D112916:
- breaks `check-clangd`, and makes clang-tidy crash on simple inputs
- likely does the wrong thing in cross builds

Also revert follow-up "[gn build] (manually) port b94db7ed7eaf (Confusables.inc)"
This reverts commit 180bae08a04d4dc724cb5e6f2ea9df8641a3f657.

2 years agocheck_clang_tidy.py: Update run line to python3
Nico Weber [Fri, 3 Jun 2022 13:28:07 +0000 (09:28 -0400)]
check_clang_tidy.py: Update run line to python3

`python` no longer exists on several systems, and the script
runs under python3 when run as part of lit.

2 years ago[lldb] [Process/FreeBSD] Do not send SIGSTOP to stopped process
Michał Górny [Wed, 1 Jun 2022 11:00:43 +0000 (13:00 +0200)]
[lldb] [Process/FreeBSD] Do not send SIGSTOP to stopped process

Do not send SIGSTOP when requested to halt a process that's already
stopped.  This results in the signal being queued for delivery once
the process is resumed, and unexpectedly stopping it again.

This is necessary for non-stop protocol patches to land.

Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.llvm.org/D126770

2 years agoCorrect the behavior of this test for non-Windows targets
Aaron Ballman [Fri, 3 Jun 2022 12:59:00 +0000 (08:59 -0400)]
Correct the behavior of this test for non-Windows targets

This should address build failures like:
https://lab.llvm.org/buildbot/#/builders/188/builds/14980
https://lab.llvm.org/buildbot/#/builders/171/builds/15515
https://lab.llvm.org/buildbot/#/builders/91/builds/9877

2 years ago[SCCP] Regenerate test checks with function signature (NFC)
Nikita Popov [Fri, 3 Jun 2022 12:36:47 +0000 (14:36 +0200)]
[SCCP] Regenerate test checks with function signature (NFC)

The previous checks were manually modified to avoid the label
clash. Use the --function-signature flag that exists for this
purpose.

2 years agoUpdating more entries in the C DR Status page
Aaron Ballman [Fri, 3 Jun 2022 12:28:16 +0000 (08:28 -0400)]
Updating more entries in the C DR Status page

Adds test coverage or information for ~25 more C DRs.

2 years ago[SCCP] Regenerate test checks (NFC)
Nikita Popov [Fri, 3 Jun 2022 12:27:20 +0000 (14:27 +0200)]
[SCCP] Regenerate test checks (NFC)

2 years agoUpdate old mailing list link in the nullability doc
Hans Wennborg [Fri, 3 Jun 2022 12:23:41 +0000 (14:23 +0200)]
Update old mailing list link in the nullability doc

2 years ago[VPlan] Silence another unused variable warning in release builds
Benjamin Kramer [Fri, 3 Jun 2022 12:07:56 +0000 (14:07 +0200)]
[VPlan] Silence another unused variable warning in release builds

2 years ago[mlir][complex] Check the correctness of tanh in complex dialect
lewuathe [Fri, 3 Jun 2022 12:04:04 +0000 (14:04 +0200)]
[mlir][complex] Check the correctness of tanh in complex dialect

Correctness check for tanh operation in complex dialect.

Ref: https://reviews.llvm.org/D126858

Reviewed By: pifon2a

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

2 years ago[VPlan] Inline variable into assertion. NFC.
Benjamin Kramer [Fri, 3 Jun 2022 11:59:48 +0000 (13:59 +0200)]
[VPlan] Inline variable into assertion. NFC.

Avoids a warning in release builds
llvm/lib/Transforms/Vectorize/VPlanHCFGBuilder.cpp:311:14: warning: unused variable 'BrCond' [-Wunused-variable]
      Value *BrCond = Br->getCondition();

2 years ago[gn build] (manually) port b94db7ed7eaf (Confusables.inc)
Nico Weber [Fri, 3 Jun 2022 11:49:28 +0000 (07:49 -0400)]
[gn build] (manually) port b94db7ed7eaf (Confusables.inc)

2 years ago[pp-trace] Print HashLoc in InclusionDirective callback
CHIANG, YU-HSUN (Tommy Chiang, oToToT) [Tue, 10 May 2022 01:53:16 +0000 (09:53 +0800)]
[pp-trace] Print HashLoc in InclusionDirective callback

The HashLoc in InclusionDirective callback is an unused parameter.
Since pp-trace is also used as a test of Clang’s PPCallbacks interface,
add it to the output of pp-trace could avoid some unintended change on
it.

This shuold resolves PR52673

Reviewed By: aaron.ballman

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

2 years ago[DAGCombiner] Add bf16 to the matrix of types that we don't promote to integer stores
Benjamin Kramer [Fri, 3 Jun 2022 11:25:40 +0000 (13:25 +0200)]
[DAGCombiner] Add bf16 to the matrix of types that we don't promote to integer stores

Remove a few stray semicolons while there.

2 years ago[SVE] Refactor sve-bitcast.ll to include all combinations for legal types.
Paul Walker [Tue, 31 May 2022 09:57:15 +0000 (10:57 +0100)]
[SVE] Refactor sve-bitcast.ll to include all combinations for legal types.

Patch enables custom lowering for MVT::nxv4bf16 because otherwise
the refactored test file triggers a selection failure.

The reason for the refactoring it to highlight cases where the
generated code is wrong.

2 years ago[VPlan] Update failing HCFG unit tests after a5bb4a3b4d3db.
Florian Hahn [Fri, 3 Jun 2022 11:05:00 +0000 (12:05 +0100)]
[VPlan] Update failing HCFG unit tests after a5bb4a3b4d3db.

2 years ago[VPlan] Replace CondBit with BranchOnCond VPInstruction.
Florian Hahn [Fri, 3 Jun 2022 10:47:16 +0000 (11:47 +0100)]
[VPlan] Replace CondBit with BranchOnCond VPInstruction.

This patch removes CondBit and Predicate from VPBasicBlock. To do so,
the patch introduces a new branch-on-cond VPInstruction opcode to model
a branch on a condition explicitly.

This addresses a long-standing TODO/FIXME that blocks shouldn't be users
of VPValues. Those extra users can cause issues for VPValue-based
analyses that don't expect blocks. Addressing this fixme should allow us
to re-introduce 266ea446ab7476.

The generic branch opcode can also be used in follow-up patches.

Depends on D123005.

Reviewed By: Ayal

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

2 years ago[mlir] Fix ClangTidy warning (NFC).
Adrian Kuegel [Fri, 3 Jun 2022 10:46:14 +0000 (12:46 +0200)]
[mlir] Fix ClangTidy warning (NFC).

virtual is redundant since the function is already declared 'override'.

2 years ago[AArch64] Add extra addp codegen tests. NFC
David Green [Fri, 3 Jun 2022 10:36:40 +0000 (11:36 +0100)]
[AArch64] Add extra addp codegen tests. NFC

2 years ago[clang-tidy] Confusable identifiers detection
serge-sans-paille [Fri, 15 Oct 2021 13:20:22 +0000 (15:20 +0200)]
[clang-tidy] Confusable identifiers detection

Detect identifiers that are confusable according to Unicode definition

        http://www.unicode.org/reports/tr39/#Confusable_Detection

and have conflicting scopes.

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

2 years ago[docs] Fix RST code-block syntax in HowToSetUpLLVMStyleRTTI.rst
Kristof Beyls [Fri, 3 Jun 2022 09:24:49 +0000 (11:24 +0200)]
[docs] Fix RST code-block syntax in HowToSetUpLLVMStyleRTTI.rst

2 years ago[gn build] Port a29a1a33ac7b
LLVM GN Syncbot [Fri, 3 Jun 2022 08:36:05 +0000 (08:36 +0000)]
[gn build] Port a29a1a33ac7b

2 years ago[clang-tidy] Add missing close quote in release notes.
Martin Boehme [Fri, 3 Jun 2022 08:27:36 +0000 (10:27 +0200)]
[clang-tidy] Add missing close quote in release notes.

Sorry for the breakage.

2 years ago[libc++] Fix conjunction/disjunction and mark a few LWG issues as complete
Nikolas Klauser [Fri, 3 Jun 2022 08:31:30 +0000 (10:31 +0200)]
[libc++] Fix conjunction/disjunction and mark a few LWG issues as complete

Fixes #54803
Fixes #53133

Reviewed By: ldionne, #libc

Spies: libcxx-commits, mgorny

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

2 years ago[cmake] Fix typo in CrossCompile.cmake
Jonas Hahnfeld [Fri, 3 Jun 2022 08:17:10 +0000 (10:17 +0200)]
[cmake] Fix typo in CrossCompile.cmake

2 years ago[flang][test-suite] Document need for NO_STOP_MESSAGE environment variable. NFC
Diana Picus [Wed, 25 May 2022 08:42:38 +0000 (08:42 +0000)]
[flang][test-suite] Document need for NO_STOP_MESSAGE environment variable. NFC

When running the llvm-test-suite with flang, we get a lot of failures
because of the output of the `STOP` statement. We can workaround them by
setting `NO_STOP_MESSAGE=1` in the environment. This patch adds a few
words about it to the docs about the Fortran part of the llvm-test-suite.

See also https://reviews.llvm.org/D126360