platform/upstream/llvm.git
22 months ago[BOLT][NFC] Move out handleExternalReference
Amir Ayupov [Tue, 23 Aug 2022 23:07:52 +0000 (16:07 -0700)]
[BOLT][NFC] Move out handleExternalReference

Move the large lambda out of BinaryFunction::disassemble, reducing its size from
338 to 295 LoC.

Reviewed By: rafauler

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

22 months ago[BOLT][NFC] Move out handlePCRelOperand
Amir Ayupov [Tue, 23 Aug 2022 23:07:46 +0000 (16:07 -0700)]
[BOLT][NFC] Move out handlePCRelOperand

Move the large lambda out of BinaryFunction::disassemble, reducing its size from
377 to 338 LoC.

Reviewed By: rafauler

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

22 months ago[Clang] Avoid using unwind library in the MSVC environment
Petr Hosek [Tue, 23 Aug 2022 07:26:37 +0000 (07:26 +0000)]
[Clang] Avoid using unwind library in the MSVC environment

We're seeing the following warnings with --rtlib=compiler-rt:

  lld-link: warning: ignoring unknown argument '--as-needed'
  lld-link: warning: ignoring unknown argument '-lunwind'
  lld-link: warning: ignoring unknown argument '--no-as-needed'

MSVC doesn't use the unwind library, so just omit it.

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

22 months ago[mlir:Bytecode] Use UNSUPPORTED instead of XFAIL for s390x
River Riddle [Tue, 23 Aug 2022 23:33:47 +0000 (16:33 -0700)]
[mlir:Bytecode] Use UNSUPPORTED instead of XFAIL for s390x

Some tests still pass even though we don't claim big-endian support. Using
UNSUPPORTED is a better indicator than XFAIL that we don't guarantee that
the tests work.

22 months ago[mlir:Bytecode] Add initial support for dialect defined attribute/type encodings
River Riddle [Tue, 23 Aug 2022 19:56:02 +0000 (12:56 -0700)]
[mlir:Bytecode] Add initial support for dialect defined attribute/type encodings

Dialects can opt-in to providing custom encodings by implementing the
`BytecodeDialectInterface`. This interface provides hooks, namely
`readAttribute`/`readType` and `writeAttribute`/`writeType`, that will be used
by the bytecode reader and writer. These hooks are provided a reader and writer
implementation that can be used to encode various constructs in the underlying
bytecode format. A unique feature of this interface is that dialects may choose
to only encode a subset of their attributes and types in a custom bytecode
format, which can simplify adding new or experimental components that aren't
fully baked.

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

22 months ago[mlir:Bytecode][NFC] Cleanup Attribute/Type reading
River Riddle [Tue, 23 Aug 2022 09:20:48 +0000 (02:20 -0700)]
[mlir:Bytecode][NFC] Cleanup Attribute/Type reading

This moves some parsing functionality from BytecodeReader to
AttrTypeReader, and removes some duplication between the attribute/type
code paths.

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

22 months ago[mlir:Bytecode][NFC] Refactor string section writing and reading
River Riddle [Tue, 23 Aug 2022 08:28:10 +0000 (01:28 -0700)]
[mlir:Bytecode][NFC] Refactor string section writing and reading

This extracts the string section writer and reader into dedicated
classes, which better separates the logic and will also simplify future
patches that want to interact with the string section.

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

22 months ago[memprof] Correct max size and access count computations
Teresa Johnson [Tue, 23 Aug 2022 22:59:05 +0000 (15:59 -0700)]
[memprof] Correct max size and access count computations

The existing code resulted in the max size and access counts being equal
to the min. Compute the max instead (max lifetime was already correct).

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

22 months ago[analyzer] Process non-POD array element destructors
isuckatcs [Fri, 29 Jul 2022 00:14:57 +0000 (02:14 +0200)]
[analyzer] Process non-POD array element destructors

The constructors of non-POD array elements are evaluated under
certain conditions. This patch makes sure that in such cases
we also evaluate the destructors.

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

22 months ago[flang] Keep original data type for do-variable value.
Slava Zakharin [Thu, 18 Aug 2022 21:06:19 +0000 (14:06 -0700)]
[flang] Keep original data type for do-variable value.

Keep the original data type of integer do-variables
for structured loops. When do-variable's data type
is an integer type shorter than IndexType, processing
the do-variable separately from the DoLoop's iteration index
allows getting rid of type casts, which can make backend
optimizations easier.

For example,
```
  do i = 2, n-1
    do j = 2, n-1
      ... = a(j-1, i)
    end do
  end do
```

If value of 'j' is computed by casting the DoLoop's iteration
index to 'i32', then Flang will produce the following LLVM IR:
```
  %1 = trunc i64 %iter_index to i32
  %2 = sub i32 %1, 1
  %3 = sext i32 %2 to i64
```

LLVM's InstCombine may try to get rid of the sign extension,
and may transform this into:
```
  %1 = shl i64 %iter_index, 32
  %2 = add i64 %1, -4294967296
  %3 = ashr exact i64 %2, 32
```

The extra computations for the element address applied on top
of this awkward pattern confuse LLVM vectorizer so that
it does not recognize the unit-strided access of 'a'.

Measured performance improvements on `SPEC CPU2000@IceLake`:
```
168.wupwise:    11.96%
171.swim:       11.22%
172.mrgid:      56.38%
178.galgel:      7.29%
301.apsi:        8.32%
```

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

22 months ago[libc++] Extend check for non-ASCII characters to src/, test/ and benchmarks/
Louis Dionne [Thu, 18 Aug 2022 21:41:13 +0000 (17:41 -0400)]
[libc++] Extend check for non-ASCII characters to src/, test/ and benchmarks/

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

22 months ago[libc++] Remove trailing whitespace from libcxx includes, source, tests and benchmarks
Louis Dionne [Thu, 18 Aug 2022 20:49:06 +0000 (16:49 -0400)]
[libc++] Remove trailing whitespace from libcxx includes, source, tests and benchmarks

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

22 months ago[libc][Obvious] Fix typo is chmod implementation.
Siva Chandra [Tue, 23 Aug 2022 20:58:59 +0000 (13:58 -0700)]
[libc][Obvious] Fix typo is chmod implementation.

This now allows enabling the chmod function on aarch64.

22 months agoPrint more information when JSON parsing fails for unittests.
Eli Friedman [Tue, 23 Aug 2022 21:51:32 +0000 (14:51 -0700)]
Print more information when JSON parsing fails for unittests.

Trying to figure out intermittent failure on reverse-iteration buildbot.

22 months ago[SDAG] expand more is-power-of-2 patterns that use popcount
Sanjay Patel [Tue, 23 Aug 2022 21:45:59 +0000 (17:45 -0400)]
[SDAG] expand more is-power-of-2 patterns that use popcount

(ctpop x) == 1 --> (x != 0) && ((x & x-1) == 0)

Adjust the legality check to avoid the poor codegen on AArch64.
We probably only want to use popcount on this pattern when it
is a single instruction.

fixes #57225

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

22 months ago[AArch64] add test for popcount i32; NFC
Sanjay Patel [Tue, 23 Aug 2022 21:44:43 +0000 (17:44 -0400)]
[AArch64] add test for popcount i32; NFC

More coverage for D132237

22 months ago[InstCombine] adjust tests for mul+add common factor; NFC
Sanjay Patel [Tue, 23 Aug 2022 13:09:22 +0000 (09:09 -0400)]
[InstCombine] adjust tests for mul+add common factor; NFC

The existing tests were added with 2880d7b9e4c9a0, but
discussion in D132412 suggests that we should start
with a simpler pattern (the more complicated pattern
may not be a real problem).

22 months ago[symbolizer] Fix build after 342e0eb
Vitaly Buka [Tue, 23 Aug 2022 21:50:51 +0000 (14:50 -0700)]
[symbolizer] Fix build after 342e0eb

342e0eb reverted LLVM_ENABLE_RUNTIMES incompletly and missed /runtimes
part. This target has no issues with LLVM_ENABLE_RUNTIMES, so we can
keep it.

22 months ago[symbolizer] Remove check if it's monorepo
Vitaly Buka [Tue, 23 Aug 2022 21:49:05 +0000 (14:49 -0700)]
[symbolizer] Remove check if it's monorepo

22 months ago[test][openmp] Relax condition in test
Vitaly Buka [Tue, 23 Aug 2022 21:27:41 +0000 (14:27 -0700)]
[test][openmp] Relax condition in test

It runs 8 threads. Sometimes tsan is able to detect more than one of the
same race.

22 months ago[CMake] Move cxx-headers to RUNTIME_DISTRIBUTION_COMPONENTS in Apple-stage2.cmake
Louis Dionne [Tue, 23 Aug 2022 17:27:03 +0000 (13:27 -0400)]
[CMake] Move cxx-headers to RUNTIME_DISTRIBUTION_COMPONENTS in Apple-stage2.cmake

We build libcxx using LLVM_ENABLE_RUNTIMES during Stage2, which requires
cxx-headers to be part of LLVM_RUNTIME_DISTRIBUTION_COMPONENTS instead
of LLVM_DISTRIBUTION_COMPONENTS.

rdar://99028431

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

22 months ago[clang] Create alloca to pass into static lambda
Vitaly Buka [Sat, 20 Aug 2022 04:11:59 +0000 (21:11 -0700)]
[clang] Create alloca to pass into static lambda

"this" parameter of lambda if undef, notnull and differentiable.
So we need to pass something consistent.

Any alloca will work. It will be eliminated as unused later by optimizer.

Otherwise we generate code which Msan is expected to catch.

Reviewed By: efriedma

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

22 months ago[Flang] Make the TODO messages for intrinsics more consistent
Peter Steinfeld [Thu, 18 Aug 2022 21:39:26 +0000 (14:39 -0700)]
[Flang] Make the TODO messages for intrinsics more consistent

This title says it all.

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

22 months ago[slp] Pull out a getOperandInfo variant helper [nfc]
Philip Reames [Tue, 23 Aug 2022 20:45:59 +0000 (13:45 -0700)]
[slp] Pull out a getOperandInfo variant helper [nfc]

22 months ago[llvm] Mark CFGuard fn ptr symbol as DSO local and add tests for mingw
Alvin Wong [Tue, 23 Aug 2022 20:09:50 +0000 (23:09 +0300)]
[llvm] Mark CFGuard fn ptr symbol as DSO local and add tests for mingw

For mingw target, if a symbol is not marked DSO local, a `.refptr` is
generated for it. This makes CFG check calls use an extra pointer
dereference, which adds extra overhead compared to the MSVC version,
so mark the CFG guard check funciton pointer DSO local to stop it.
This should have no effect on MSVC target.

Also adapt the existing cfguard tests to run for mingw targets, so that
this change is checked.

Reviewed By: rnk

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

22 months ago[clang] Add support for __attribute__((guard(nocf)))
Alvin Wong [Tue, 23 Aug 2022 20:08:05 +0000 (23:08 +0300)]
[clang] Add support for __attribute__((guard(nocf)))

To support using Control Flow Guard with mingw-w64, Clang needs to
accept `__declspec(guard(nocf))` also for the GNU target. Since mingw
has `#define __declspec(a) __attribute__((a))` as built-in, the simplest
solution is to accept `__attribute__((guard(nocf)))` to be compatible with
MSVC and Clang's msvc target.

As a side effect, this also adds `[[clang::guard(nocf)]]` for C++.

Reviewed By: aaron.ballman

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

22 months ago[Sample Profile Reader] Fix potential integer overflow/infinite loop bug in sample...
William Huang [Tue, 23 Aug 2022 18:58:31 +0000 (18:58 +0000)]
[Sample Profile Reader] Fix potential integer overflow/infinite loop bug in sample profile reader

Change loop induction variable type to match the type of "SIZE" where it's compared against, to prevent infinite loop caused by overflow wraparound if there are more than 2^32 samples

Reviewed By: wenlei

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

22 months agoRevert "[MLIR]Extend vector.gather to support n-D result"
Mehdi Amini [Tue, 23 Aug 2022 20:26:38 +0000 (20:26 +0000)]
Revert "[MLIR]Extend vector.gather to support n-D result"

This reverts commit 0cbfd6fd1633a075dcfd1bcd8a11e1c6d2785fa8.

A test is crashing with the shared_lib config.

22 months ago[clang-tidy] Skip unions in use-equals-default
Alexander Shaposhnikov [Tue, 23 Aug 2022 20:09:40 +0000 (20:09 +0000)]
[clang-tidy] Skip unions in use-equals-default

For unions constructors with empty bodies behave differently
(in comparison with structs/classes) and clang-tidy's fix
might break the code. This diff adjusts the check to skip unions
for now (it seems to be a relatively rare case).

Test plan: ninja check-all

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

22 months ago[mlir][spirv] Map memory space to OpenCL/Kernel storage class
Stanley Winata [Tue, 23 Aug 2022 19:56:29 +0000 (15:56 -0400)]
[mlir][spirv] Map memory space to OpenCL/Kernel storage class

Reviewed By: antiagainst

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

22 months ago[tools][llvm-lipo] Fix off-by-one error in command-line argument parsing
Alexander Shaposhnikov [Tue, 23 Aug 2022 19:48:11 +0000 (19:48 +0000)]
[tools][llvm-lipo] Fix off-by-one error in command-line argument parsing

makeArrayRef(argv + 1, argc) -> makeArrayRef(argv + 1, argc - 1)
The previous behavior resulted in propagation of the null pointer
into later stages of arguments parsing instead of being automatically
handled by the existing check of MissingArgumentCount.

Test plan: ninja check-all

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

22 months ago[libc] Enable a few entrypoints on aarch64 which are now available on x86_64.
Siva Chandra [Tue, 23 Aug 2022 19:23:13 +0000 (12:23 -0700)]
[libc] Enable a few entrypoints on aarch64 which are now available on x86_64.

22 months ago[DebugInfo] Extend the InstrRef LDV to support DbgValues with many Ops
Stephen Tozer [Mon, 20 Jun 2022 15:39:28 +0000 (16:39 +0100)]
[DebugInfo] Extend the InstrRef LDV to support DbgValues with many Ops

This patch builds on prior support patches to enable support for
variadic debug values in InstrRefLDV, allowing DBG_VALUE_LISTs to
have their ranges extended.

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

22 months ago[OpenMP] Add option to assert no nested OpenMP parallelism on the GPU
Joseph Huber [Wed, 17 Aug 2022 21:39:12 +0000 (17:39 -0400)]
[OpenMP] Add option to assert no nested OpenMP parallelism on the GPU

The OpenMP device runtime needs to support the OpenMP standard. However
constructs like nested parallelism are very uncommon in real application
yet lead to complexity in the runtime that is sometimes difficult to
optimize out. As a stop-gap for performance we should supply an argument
that selectively disables this feature. This patch adds the
`-fopenmp-assume-no-nested-parallelism` argument which explicitly
disables the usee of nested parallelism in OpenMP.

Reviewed By: carlo.bertolli

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

22 months ago[TTI] Add SK_Splice shuffle mask detection and X86 costs
Simon Pilgrim [Tue, 23 Aug 2022 19:00:37 +0000 (20:00 +0100)]
[TTI] Add SK_Splice shuffle mask detection and X86 costs

Enables fixed sized vectors to detect SK_Splice shuffle patterns and provides basic X86 cost support

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

22 months ago[RISCV] Add cost model coverage for trig, log, and exp unary routines
Philip Reames [Tue, 23 Aug 2022 18:54:57 +0000 (11:54 -0700)]
[RISCV] Add cost model coverage for trig, log, and exp unary routines

22 months ago[ADT] Add llvm::has_single_bit helper similar to the c++20 std::has_single_bit implem...
Simon Pilgrim [Tue, 23 Aug 2022 18:50:52 +0000 (19:50 +0100)]
[ADT] Add llvm::has_single_bit helper similar to the c++20 std::has_single_bit implementation

Converted the llvm::isPowerOf2_32/64 helpers into wrappers

22 months ago[Clang] Implement P0848 (Conditionally Trivial Special Member Functions)
Roy Jacobson [Mon, 22 Aug 2022 17:45:03 +0000 (20:45 +0300)]
[Clang] Implement P0848 (Conditionally Trivial Special Member Functions)

This patch implements P0848 in Clang.

During the instantiation of a C++ class, in `Sema::ActOnFields`, we evaluate constraints for all the SMFs and compare the constraints to compute the eligibility. We defer the computation of the type's [copy-]trivial bits from addedMember to the eligibility computation, like we did for destructors in D126194. `canPassInRegisters` is modified as well to better respect the ineligibility of functions.

Note: Because of the non-implementation of DR1734 and DR1496, I treat deleted member functions as 'eligible' for the purpose of [copy-]triviallity. This is unfortunate, but I couldn't think of a way to make this make sense otherwise.

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

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

22 months agoAdding a note about the macro __FLT_EVAL_METHOD__; NFC
Zahira Ammarguellat [Tue, 23 Aug 2022 18:35:57 +0000 (14:35 -0400)]
Adding a note about the macro __FLT_EVAL_METHOD__; NFC

This is to clarify that the macro __FLT_EVAL_METHOD__ is not pre-
defined like other preprocessor macros. It will not appear when
preprocessor macros are dumped.

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

22 months ago[NFC][PowerPC] Clean up a couple of lambdas from the PPCMIPeephole.
Stefan Pintilie [Mon, 22 Aug 2022 16:49:56 +0000 (11:49 -0500)]
[NFC][PowerPC] Clean up a couple of lambdas from the PPCMIPeephole.

There were two sections of code that had a lot of lambdas and in the patch
D40554 it was suggested that we clean them up as a follow-up NFC patch.

Reviewed By: nemanjai, #powerpc

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

22 months agoAMDGPU/MetaData: Restrict address space key to only be emitted for "global_buffer...
Raghav [Tue, 16 Aug 2022 15:08:17 +0000 (11:08 -0400)]
AMDGPU/MetaData: Restrict address space key to only be emitted for "global_buffer" and "dynamic_shared_pointer"

This matches .address_space docs at https://llvm.org/docs/AMDGPUUsage.html#amdgpu-amdhsa-code-object-kernel-argument-metadata-map-table-v3

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

22 months ago[Clang] follow-up D128745, use ClangABICompat15 instead of ClangABICompat14
Yuanfang Chen [Tue, 23 Aug 2022 17:25:02 +0000 (10:25 -0700)]
[Clang] follow-up D128745, use ClangABICompat15 instead of ClangABICompat14

Since the patch missed release 15.x and will be included in release 16.x. Also, simplify related tests.

Reviewed By: aaron.ballman

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

22 months ago[ubsan-minimal][NFC] Use GET_CALLER_PC() to get the return address
Igor Kudrin [Tue, 23 Aug 2022 17:39:27 +0000 (21:39 +0400)]
[ubsan-minimal][NFC] Use GET_CALLER_PC() to get the return address

This is a preparation step for D131914.

22 months ago[Support] MathExtras.h - use llvm::bitcast<> for float-bits cast helpers. NFCI.
Simon Pilgrim [Tue, 23 Aug 2022 17:27:03 +0000 (18:27 +0100)]
[Support] MathExtras.h - use llvm::bitcast<> for float-bits cast helpers. NFCI.

22 months ago[libc] Add Linux implementations of POSIX chdir, fchdir, chmod and fchmod.
Siva Chandra Reddy [Mon, 22 Aug 2022 19:02:25 +0000 (19:02 +0000)]
[libc] Add Linux implementations of POSIX chdir, fchdir, chmod and fchmod.

Reviewed By: michaelrj

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

22 months ago[mlir][LLVMIR] Add `sym_name` attribute to LLVMFuncOp in ODS
Jeff Niu [Tue, 23 Aug 2022 17:00:10 +0000 (10:00 -0700)]
[mlir][LLVMIR] Add `sym_name` attribute to LLVMFuncOp in ODS

This is a required attribute for FunctionOpInterface. Add an ODS
definition so that a more efficient accessor is generated.

22 months ago[MLIR]Extend vector.gather to support n-D result
Che-Yu Wu [Tue, 23 Aug 2022 16:45:43 +0000 (16:45 +0000)]
[MLIR]Extend vector.gather to support n-D result

Currently vector.gather only supports reading memory into a 1-D result vector.
This patch extends it to support an n-D result vector with the indices, masks,
and passthroughs in n-D vectors.

As we are trying to vectorize tensor.extract with vector.gather
(https://github.com/iree-org/iree/issues/9198), it will need to gather the
elements into an n-D vector. Having vector.gather with n-D results allows us
to avoid flatten and reshape at the vectorization stage. The backends can then
decide the optimal ways to lower the vector.gather op.

Note that this is different from n-D gathering, which is about reading n-D
memory with the n-D indices. The indices here are still only 1-D offsets on
the base.

Reviewed By: dcaballe

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

22 months ago[analyzer] Drop deprecated flags
Balazs Benics [Tue, 23 Aug 2022 16:39:21 +0000 (18:39 +0200)]
[analyzer] Drop deprecated flags

As proposed in D126215 (ffe7950ebc62380c3afc7c71f454a1db3f6f5c76),
I'm dropping the `-analyzer-store` and
`-analyzer-opt-analyze-nested-blocks` clang frontend flags.
I'm also dropping the corresponding commandline handlers of `scanbuild`.

This behavior is planned to be part of `clang-16`.

Reviewed By: xazax.hun

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

22 months ago[analyzer] Deadstore static analysis: Fix false positive on C++17 assignments
Fred Tingaud [Tue, 23 Aug 2022 16:33:26 +0000 (18:33 +0200)]
[analyzer] Deadstore static analysis: Fix false positive on C++17 assignments

Dead store detection automatically checks that an expression is a
CXXConstructor and skips it because of potential side effects. In C++17,
with guaranteed copy elision, this check can fail because we actually
receive the implicit cast of a CXXConstructor.
Most checks in the dead store analysis were already stripping all casts
and parenthesis and those that weren't were either forgotten (like the
constructor) or would not suffer from it, so this patch proposes to
factorize the stripping.
It has an impact on where the dead store warning is reported in the case
of an explicit cast, from

  auto a = static_cast<B>(A());
           ^~~~~~~~~~~~~~~~~~~

to

  auto a = static_cast<B>(A());
                          ^~~

which we think is an improvement.

Patch By: frederic-tingaud-sonarsource

Reviewed By: steakhal

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

22 months ago[clangd] Bump timeout for a flaky test
Kadir Cetinkaya [Tue, 23 Aug 2022 16:17:44 +0000 (18:17 +0200)]
[clangd] Bump timeout for a flaky test

This has been failing on some build bots with timeout, increasing it to
5 seconds.

22 months ago[NFC][AMDGPU] Some cleanups in the SIOptimizeExecMasking pass.
Thomas Symalla [Sat, 20 Aug 2022 13:09:17 +0000 (15:09 +0200)]
[NFC][AMDGPU] Some cleanups in the SIOptimizeExecMasking pass.

Fix typos and remove an unused argument.

Reviewed By: foad

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

22 months ago[FastISel] Respect musttail over "disable-tail-calls"
Arthur Eubanks [Fri, 19 Aug 2022 00:59:38 +0000 (17:59 -0700)]
[FastISel] Respect musttail over "disable-tail-calls"

musttail should be honored even in the presence of attributes like "disable-tail-calls". SelectionDAG properly handles this.

Update LangRef to explicitly mention that this is the semantics of musttail.

Reviewed By: rnk

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

22 months ago[TTI] Kill last couple uses of OperandValueKind in targets [nfc]
Philip Reames [Tue, 23 Aug 2022 15:45:01 +0000 (08:45 -0700)]
[TTI] Kill last couple uses of OperandValueKind in targets [nfc]

Use the accessor methods on the containing class instead so that we can change the representation.

22 months ago[ADT] Deprecate is_splat and replace all uses with all_equal
Jakub Kuderski [Tue, 23 Aug 2022 15:36:12 +0000 (11:36 -0400)]
[ADT] Deprecate is_splat and replace all uses with all_equal

See the discussion thread for more details:
https://discourse.llvm.org/t/adt-is-splat-and-empty-ranges/64692

Reviewed By: dblaikie

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

22 months ago[SPIRV] Fix the wrong patch from https://reviews.llvm.org/D131886
Michael Liao [Tue, 23 Aug 2022 15:13:10 +0000 (11:13 -0400)]
[SPIRV] Fix the wrong patch from https://reviews.llvm.org/D131886

- The body of that predicate lambda is removed by mistake.

22 months ago[clang] Pull some utility functions into CompilerInvocation NFC
Ben Langmuir [Mon, 22 Aug 2022 22:42:52 +0000 (15:42 -0700)]
[clang] Pull some utility functions into CompilerInvocation NFC

Move copying compiler arguments to a vector<string> and modifying
common module-related options into CompilerInvocation in preparation for
using some of them in more places and to avoid duplicating this code
accidentally in the future.

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

22 months ago[OffloadPackager] Resolve copy elision warnings
Joseph Huber [Tue, 23 Aug 2022 15:00:53 +0000 (10:00 -0500)]
[OffloadPackager] Resolve copy elision warnings

Summary:
The buildbots are giving failures on the explicit move operations here.
Previously I had problems where not perfomring an explicit move would
cause problems with older compilers so we'll see if this works as
expected.

22 months ago[Clang][OpenMP] Make copyin clause on combined and composite construct work (patch...
utsumi [Tue, 23 Aug 2022 14:18:23 +0000 (07:18 -0700)]
[Clang][OpenMP] Make copyin clause on combined and composite construct work (patch by Yuichiro Utsumi (utsumi.yuichiro@fujitsu.com))

Make copyin clause on the following constructs work.

- parallel for
- parallel for simd
- parallel sections

Fixes https://github.com/llvm/llvm-project/issues/55547

Patch by Yuichiro Utsumi (utsumi.yuichiro@fujitsu.com)

Reviewed By: ABataev

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

22 months ago[TTI] Plumb through OperandValueInfo in getMemoryOpCost [NFC]
Philip Reames [Mon, 22 Aug 2022 22:26:36 +0000 (15:26 -0700)]
[TTI] Plumb through OperandValueInfo in getMemoryOpCost [NFC]

This has the effect of exposing the power-of-two property for use in memory op costing, but no target actually uses it yet.  The main point of this change is simple consistency with the recently changes getArithmeticInstrCost, and to remove the last (interface) use of OperandValueKind.

22 months ago[clang-cl] Expose the /volatile:{iso,ms} choice via _ISO_VOLATILE
David Majnemer [Tue, 23 Aug 2022 14:18:24 +0000 (14:18 +0000)]
[clang-cl] Expose the /volatile:{iso,ms} choice via _ISO_VOLATILE

MSVC allows interpreting volatile loads and stores, when combined with
/volatile:iso, as having acquire/release semantics. MSVC also exposes a
define, _ISO_VOLATILE, which allows users to enquire if this feature is
enabled or disabled.

22 months ago[flang] Allow configuring building the flang runtime standalone
Martin Storsjö [Tue, 19 Jul 2022 21:47:02 +0000 (00:47 +0300)]
[flang] Allow configuring building the flang runtime standalone

This allows building the flang runtime and libFortranDecimal standalone,
without setting up the full llvm build, by pointing cmake to these
directories.

This is the other one out of two essential steps for building the flang runtimes
for a foreign target, i.e. setting up cross compiling with flang.

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

22 months ago[flang] Make runtimes headers independent of the main llvm headers
Martin Storsjö [Wed, 20 Jul 2022 13:32:31 +0000 (16:32 +0300)]
[flang] Make runtimes headers independent of the main llvm headers

llvm/Support/Compiler.h requires llvm-config.h, i.e. to include it,
you'd need to actually set up building llvm for that target.

If using flang to cross compile code for a different target, we need
the runtimes built for that target, but we might not want to build
llvm itself for that target.

This is one out of two essential steps for building the flang runtimes
for a foreign target, i.e. setting up cross compiling with flang.

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

22 months ago[clang/test] Correctly specify simulator env in target flag in fsanitize.c
Nico Weber [Mon, 22 Aug 2022 17:34:42 +0000 (13:34 -0400)]
[clang/test] Correctly specify simulator env in target flag in fsanitize.c

Putting "simulator" in the `-target` flag requires putting it in the
"environment" part of the triple, which is the 4th `-`-separated component.

Some places in the tests currently use "iossimulator" which puts it in the
OS field. The triple parsing code in llvm::Triple uses startswith("ios")
in parseOS(), so that successfully sets the OS to "iOS", and all these
triples use an intel arch, and iOS + intel triple implicitly make the
driver convert the environment to "simulator", so this happened to work --
but it led to the somewhat strange "simulator-simulator" in the diag
in the test.

No behavior change.

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

22 months ago[clang] Remove a FIXME that we can't fix
Nico Weber [Mon, 22 Aug 2022 17:42:46 +0000 (13:42 -0400)]
[clang] Remove a FIXME that we can't fix

I added this recently, but it looks like several tests very intentionally
check that `-mios-version-min=foo --target=x86_64-apple-ios` does simulator
builds. So we can't easily remove this hack, even though it makes little
sense in an arm mac world. (Here, you _have_ to say
`-mios-simulator-version-min=` or `--target=arm64-apple-ios-simulator`.)

The tests that check this:
  Clang :: Driver/darwin-ld.c
  Clang :: Driver/darwin-simulator-macro.c
  Clang :: Driver/darwin-version.c

No behavior change.

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

22 months ago[NFC] LoopAccess: Move expressions close to usage
Aditya Kumar [Mon, 22 Aug 2022 00:19:37 +0000 (17:19 -0700)]
[NFC] LoopAccess: Move expressions close to usage

Avoids useless evaluation of these expressions.

Reviewed By: michaelmaitland, fhahn

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

22 months ago[libc++] Update oss-fuzz.sh to use LLVM_ENABLE_RUNTIMES
Louis Dionne [Tue, 23 Aug 2022 14:06:15 +0000 (10:06 -0400)]
[libc++] Update oss-fuzz.sh to use LLVM_ENABLE_RUNTIMES

22 months ago[DebugInfo][InstrRef] Handle transfers of variadic debug values in LDV
Stephen Tozer [Mon, 20 Jun 2022 11:06:00 +0000 (12:06 +0100)]
[DebugInfo][InstrRef] Handle transfers of variadic debug values in LDV

This patch adds the last of the changes required to enable
DBG_VALUE_LIST handling in InstrRefLDV, handling variadic debug values
during the transfer tracking step. Most of the changes are fairly
straightforward, and based around tracking multiple locations per
variable in TransferTracker::VLocTracker.

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

22 months agoRevert the removal of LLVM_ENABLE_PROJECTS for libc++ and libc++abi
Louis Dionne [Tue, 23 Aug 2022 13:48:36 +0000 (09:48 -0400)]
Revert the removal of LLVM_ENABLE_PROJECTS for libc++ and libc++abi

This commit reverts the following commits:

952f90b72b3546d6b6b038d410f07ce520c59b48
e6a0800532bb409f6d1c62f3698bdd6994a877dc (D132298)
176db3b3ab25ff8a9b2405f50ef5a8bd9304a6d5 (D132324)

These commits caused CI instability and need to be reverted in order
to figure things out again. See the discussion in https://llvm.org/D132324
for more information.

22 months ago[PowerPC] Autogenerate crbits.ll . NFC
Amaury Séchet [Tue, 23 Aug 2022 13:40:01 +0000 (13:40 +0000)]
[PowerPC] Autogenerate crbits.ll . NFC

22 months ago[lldb] [gdb-remote] Use Communication::WriteAll() over Write()
Michał Górny [Mon, 22 Aug 2022 16:59:08 +0000 (18:59 +0200)]
[lldb] [gdb-remote] Use Communication::WriteAll() over Write()

Replace the uses of Communication::Write() with WriteAll() to avoid
partial writes.  None of the call sites actually accounted for that
possibility and even if it is unlikely to actually happen, there doesn't
seem to be any real harm from using WriteAll() instead.

Ideally, we'd remove Write() from the public API.  However, that would
change the API of SBCommunication.  The alternative would be to alias it
to WriteAll().

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

22 months ago[llvm][Cmake] Expand "all" in LLVM_ENABLE_PROJECTS before other checks
Kadir Cetinkaya [Tue, 23 Aug 2022 09:04:44 +0000 (11:04 +0200)]
[llvm][Cmake] Expand "all" in LLVM_ENABLE_PROJECTS before other checks

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

22 months ago[OffloadPackager] Add necessary move statement on returned value
Joseph Huber [Tue, 23 Aug 2022 13:44:13 +0000 (08:44 -0500)]
[OffloadPackager] Add necessary move statement on returned value

Summary:
Some older compilers cannot automatically elide the returned vector of
unique pointers, causing build errors. This patch explicitly moves the
returned value instead which should solve the problem.

22 months ago[pseudo] Eliminate a false parse of structured binding declaration.
Haojian Wu [Fri, 19 Aug 2022 19:55:39 +0000 (21:55 +0200)]
[pseudo] Eliminate a false parse of structured binding declaration.

Using the guard to implement part of the rule https://eel.is/c++draft/dcl.pre#6.

```
void foo() {
  // can be parsed as
  //   - structured-binding declaration (a false parse)
  //   - assignment expression
  array[index] = value;
}
```

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

22 months ago[NFC] Fix typo in dbg message in RegisterCoalescer.
Thomas Symalla [Tue, 23 Aug 2022 13:14:45 +0000 (15:14 +0200)]
[NFC] Fix typo in dbg message in RegisterCoalescer.

funcion => function

22 months ago[pseudo] Fix HeadsPartition is not initialized correctly.
Haojian Wu [Tue, 23 Aug 2022 13:08:26 +0000 (15:08 +0200)]
[pseudo] Fix HeadsPartition is not initialized correctly.

The bug was that if we recover from the token 0, we will make the
Heads empty (Line646), which results no recovery being applied.

Reviewed By: sammccall

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

22 months ago[MLIR] Harden gpu.func verification
Christian Sigg [Tue, 23 Aug 2022 10:45:49 +0000 (12:45 +0200)]
[MLIR] Harden gpu.func verification

GPUFuncOpLowering moves the body out of gpu.func op and erases it. An empty gpu.func may fail verification but should not crash it. Verification of an erased op is triggered e.g. with debug printing on.

Reviewed By: akuegel

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

22 months ago[OffloadPackager] Add option to extract files from images
Joseph Huber [Wed, 17 Aug 2022 18:10:04 +0000 (14:10 -0400)]
[OffloadPackager] Add option to extract files from images

We use the `clang-offload-packager` too bundle many files into a single
binary format containing metadata. This is used for offloading
compilation which may contain multiple device binaries of different
types and architectures in a single file. We use this special binary
format to store these files along with some necessary metadata around
them. We use this format because of the difficulty of determining the
filesize of the various binary inputs that will be passed to the
offloading toolchain rather than engineering a solution for each input.

Previously we only support packaing many files into a single binary.
This patch adds support for doing the reverse by using the same
`--image=` syntax. To unpackage a binary we now present an input file
instead of an output.

Reviewed By: tra

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

22 months ago[runtimes] Handle interface targets in runtimes distribution components
Louis Dionne [Mon, 22 Aug 2022 16:00:40 +0000 (12:00 -0400)]
[runtimes] Handle interface targets in runtimes distribution components

As reported in [1], cxx-headers is not a valid distribution target
because it is an interface target in CMake. This breaks the most
basic MultiDistributionExample of the runtimes build.

This patch handles interface targets by getting rid of the assumption
that all distribution components have a target associated to them. It
is valid for a distribution component to only have a `install-FOO`
target.

In the case where only `cxx-headers` is provided as a distribution
component, `ninja toolchain-distribution` will not build anything
after this patch, since there is effectively nothing to build for
the `cxx-headers` target. However, running `ninja install-toolchain-distribution`
will build everything, as expected.

[1]: https://discord.com/channels/636084430946959380/636732894974312448/1010013287464828968

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

22 months ago[Globals] Treat nobuiltin fns as maybe-derefined.
Florian Hahn [Tue, 23 Aug 2022 12:44:59 +0000 (13:44 +0100)]
[Globals] Treat nobuiltin fns as maybe-derefined.

Callsites could be marked as `builtin` while calling `nobuiltin`
functions. This can lead to problems, if local optimizations apply
transformations based on the semantics of the builtin, but then IPO
treats the function as `nobuiltin` and applies a transform that breaks
builtin semantics (assumed earlier).

To avoid this, mark such functions as maybey-derefined, to avoid IPO
transforms on them that may break assumptions of earlier calls.

Fixes #57075
Fixes #48366

Reviewed By: ychen

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

22 months ago[reland][NFC][libc] standardize string_view
Guillaume Chatelet [Tue, 23 Aug 2022 09:56:57 +0000 (09:56 +0000)]
[reland][NFC][libc] standardize string_view

22 months agoRevert "[reland][NFC][libc] standardize string_view"
Guillaume Chatelet [Tue, 23 Aug 2022 12:40:07 +0000 (12:40 +0000)]
Revert "[reland][NFC][libc] standardize string_view"

This reverts commit df99774ef7d9c910941fe915689f9126258800ee.

22 months agobuffer-deallocation: consider aliases introduced by arith.select.
Johannes Reifferscheid [Tue, 23 Aug 2022 12:21:40 +0000 (14:21 +0200)]
buffer-deallocation: consider aliases introduced by arith.select.

Currently, buffer deallocation considers arith.select to be
non-aliasing, which results in deallocs being inserted incorrectly. Since
arith.select doesn't implement any useful interfaces, this change just handles
it explicitly. Eventually this should probably be fixed properly, if this pass
is going to be used long term.

Reviewed By: springerm

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

22 months ago[DebugInfo][InstrRef][NFC] Emit variadic debug values from InstrRefLDV
Stephen Tozer [Mon, 20 Jun 2022 11:46:08 +0000 (12:46 +0100)]
[DebugInfo][InstrRef][NFC] Emit variadic debug values from InstrRefLDV

In preparation for supporting DBG_VALUE_LIST in InstrRefLDV, this patch
adds the logic for emitting DBG_VALUE_LIST instructions from
InstrRefLDV. The logical changes here are fairly simple, with the main
change being that instead of directly prepending offsets to the DIExpr,
we use appendOpsToArg to modify the expression for individual debug
operands in the expression. The function emitLoc is also changed to take
a list of debug ops, with an empty list meaning an undef value.

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

22 months ago[mlir][Bufferization] Use DestinationStyleOpInterface where possible.
Adrian Kuegel [Tue, 23 Aug 2022 11:42:19 +0000 (13:42 +0200)]
[mlir][Bufferization] Use DestinationStyleOpInterface where possible.

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

22 months ago[reland][NFC][libc] standardize string_view
Guillaume Chatelet [Tue, 23 Aug 2022 09:56:57 +0000 (09:56 +0000)]
[reland][NFC][libc] standardize string_view

22 months ago[DeadArgElim] Add test case for #48366, #57075
Florian Hahn [Tue, 23 Aug 2022 12:08:38 +0000 (13:08 +0100)]
[DeadArgElim] Add test case for #48366, #57075

22 months agoRevert "[reland][NFC][libc] standardize string_view"
Guillaume Chatelet [Tue, 23 Aug 2022 11:50:56 +0000 (11:50 +0000)]
Revert "[reland][NFC][libc] standardize string_view"

This reverts commit 522d29a6a745e38d635739b05383770804bac311.

22 months ago[reland][NFC][libc] standardize string_view
Guillaume Chatelet [Tue, 23 Aug 2022 09:56:57 +0000 (09:56 +0000)]
[reland][NFC][libc] standardize string_view

22 months ago[gn build] Port 134d017b88ca
LLVM GN Syncbot [Tue, 23 Aug 2022 11:31:54 +0000 (11:31 +0000)]
[gn build] Port 134d017b88ca

22 months ago[ADT] Add unittest coverage for ADT/bit.h header
Simon Pilgrim [Tue, 23 Aug 2022 11:23:11 +0000 (12:23 +0100)]
[ADT] Add unittest coverage for ADT/bit.h header

22 months ago[mlir] Extract DestinationStyleOpInterface from LinalgStructuredInterface.
Adrian Kuegel [Tue, 23 Aug 2022 10:34:58 +0000 (12:34 +0200)]
[mlir] Extract DestinationStyleOpInterface from LinalgStructuredInterface.

There are several use cases where a destination style operation needs an interface
that contains a subset of the methods from LinalgStructuredInterface.
In this change, we move all such methods to a new interface, and add forwarding
methods to LinalgStructuredInterface to make the change the less invasive.
It may be possible to refactor the code later to get rid of (some or all) of the
forwarding methods.
This change also removes the cloneWithMapper interface methods, as it is not used anywhere.

RFC:
https://discourse.llvm.org/t/rfc-interface-for-destination-style-ops/64056

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

22 months agoRevert "[reland][NFC][libc] standardize string_view"
Guillaume Chatelet [Tue, 23 Aug 2022 11:00:22 +0000 (11:00 +0000)]
Revert "[reland][NFC][libc] standardize string_view"

This reverts commit 187099da1c415bd8f717eb5adc75bb1d73c7a0ba.

22 months ago[reland][NFC][libc] standardize string_view
Guillaume Chatelet [Tue, 23 Aug 2022 09:56:57 +0000 (09:56 +0000)]
[reland][NFC][libc] standardize string_view

22 months ago[CodeGen][InstrRef] Remove unused variables from test case
Stephen Tozer [Tue, 23 Aug 2022 09:59:14 +0000 (10:59 +0100)]
[CodeGen][InstrRef] Remove unused variables from test case

22 months agoRevert "[NFC][libc] standardize string_view"
Guillaume Chatelet [Tue, 23 Aug 2022 10:43:11 +0000 (10:43 +0000)]
Revert "[NFC][libc] standardize string_view"

This reverts commit abe0fa6b17d866ef21e7c2abb799658c490b8508.

22 months ago[AArch64] Fix list of features for Cortex-X1C
Lucas Prates [Thu, 18 Aug 2022 09:21:22 +0000 (10:21 +0100)]
[AArch64] Fix list of features for Cortex-X1C

This patch fixes the list of subtarget features enabled for the
Cortex-X1C processor, including the following:

* Fix incorrect version used for FeatureRCPC:
  * Use FEAT_LRCPC2 instead of FEAT_LRCPC.
* Add missing v8.4-A features included in the TRM:
  * Flag Manipulation Instructions - FeatureFlagM (FEAT_FlagM)
  * Large System Extension 2 - FeatureLSE2 (FEAT_LSE2)

Reviewed By: vhscampos

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

22 months ago[StructurizeCFG] Autogenerate checks
Jay Foad [Tue, 23 Aug 2022 10:22:14 +0000 (11:22 +0100)]
[StructurizeCFG] Autogenerate checks

22 months ago[AMDGPU][MC][GFX9][NFC] Consolidate tests by encoding
Dmitry Preobrazhensky [Tue, 23 Aug 2022 10:09:47 +0000 (13:09 +0300)]
[AMDGPU][MC][GFX9][NFC] Consolidate tests by encoding

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

22 months ago[NFC][libc] standardize string_view
Guillaume Chatelet [Tue, 23 Aug 2022 09:56:57 +0000 (09:56 +0000)]
[NFC][libc] standardize string_view

22 months ago[tensor][bufferize] Use affine.apply instead of arith.addi in PadOp lowering
Matthias Springer [Tue, 23 Aug 2022 09:38:54 +0000 (11:38 +0200)]
[tensor][bufferize] Use affine.apply instead of arith.addi in PadOp lowering

Affine exprs compose better than arith ops.

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