platform/upstream/llvm.git
2 years ago[AArch64] Lower scalar sqxtn intrinsics to use fp registers
David Green [Wed, 21 Sep 2022 09:46:43 +0000 (10:46 +0100)]
[AArch64] Lower scalar sqxtn intrinsics to use fp registers

The llvm.aarch64.neon.scalar.sqxtn.i32.i64 intrinsics take and return
integer types, but operate on fp registers. This can create some
inefficiencies in their lowering, where the registers are converted to
fp a little too late. This patch adds lowering for the intrinsics,
creating bitcasts to/from fp types to allow nicer folding later when the
instructions are selected, especially around insert/extracts.

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

2 years ago[AMDGPU] Update checks in mad_u64_u32.ll. NFC.
Jay Foad [Wed, 21 Sep 2022 09:42:23 +0000 (10:42 +0100)]
[AMDGPU] Update checks in mad_u64_u32.ll. NFC.

2 years ago[mlir][tensor][bufferize] Implement getBufferType for Expand/CollapseShapeOp
Matthias Springer [Wed, 21 Sep 2022 02:20:23 +0000 (11:20 +0900)]
[mlir][tensor][bufferize] Implement getBufferType for Expand/CollapseShapeOp

This function must be implemented for all ops, where the result memref type is different from the input memref type.

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

2 years ago[LAA] Fix ICE with scAddExpr in forked pointers
Graham Hunter [Wed, 21 Sep 2022 08:54:14 +0000 (09:54 +0100)]
[LAA] Fix ICE with scAddExpr in forked pointers

The IR from https://github.com/llvm/llvm-project/issues/57368 results
in an assert firing when trying to create a runtime check for the
forked pointer. One of the forks is fine since it's loop invariant,
but the other is a scAddExpr (containing a scAddRecExpr, so not
invariant) when RtCheck::insert expects a scAddRecExpr.

This is a simple fix to just avoid forks which aren't AddRec or
loop invariant. We can allow it as a forked pointer later with
more work.

Reviewed By: fhahn

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

2 years ago[flang] Handle parent component of extended derived-type
Valentin Clement [Wed, 21 Sep 2022 09:19:13 +0000 (11:19 +0200)]
[flang] Handle parent component of extended derived-type

Parent component refers to the parent derived-type of an extended type.
The parent component is skipped when a specififc component is
referred to. This is fine since all the components in extended type
are available in the type itself. When the parent component is referred,
it need to be taken into account correctly.
This patch fixes the case when the parent component is referred. In a
box, an approriate slice is created or updated to point to the first
component of the parent component. For scalar, a simple conversion to
the parent component type is done.

Reviewed By: jeanPerier

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

2 years ago[NFC][Scalarizer] Let testcase be auto-generated from update_test_check
eopXD [Wed, 21 Sep 2022 09:04:27 +0000 (02:04 -0700)]
[NFC][Scalarizer] Let testcase be auto-generated from update_test_check

The current `CHECK` lines are hand-written. Changing them to auto-generated lines.

Reviewed By: nikic

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

2 years ago[VE][NFC] Change to use l2i/i2l to simplify code
Kazushi (Jam) Marukawa [Sun, 18 Sep 2022 01:26:07 +0000 (10:26 +0900)]
[VE][NFC] Change to use l2i/i2l to simplify code

We previously added l2i/i2l macros to simpily EXTRACT_SUBREG/INSERT_SUBREG
conversions.  This patch changes VEInstrInfo.td to use such macros to
simplify existing code.

Reviewed By: efocht

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

2 years ago[VE] Add maxnum and minnum
Kazushi (Jam) Marukawa [Sat, 17 Sep 2022 09:04:06 +0000 (18:04 +0900)]
[VE] Add maxnum and minnum

Add maxnum and minnum for float and double.  Lowering is already
implemented, so this patch changes them legal and adds regression
tests.

Reviewed By: efocht

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

2 years ago[VE] Change to expand FMA
Kazushi (Jam) Marukawa [Sat, 17 Sep 2022 09:04:06 +0000 (18:04 +0900)]
[VE] Change to expand FMA

VE has fused multiply-add instruction for only vector calculations.  This
patch forces to expand scalar FMA to multiply and add instructions.
This patch also adds regression test.

Reviewed By: efocht

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

2 years ago[AArch64] Insert/Extract of bitcast patterns
David Green [Wed, 21 Sep 2022 08:54:17 +0000 (09:54 +0100)]
[AArch64] Insert/Extract of bitcast patterns

This adds some quick tablegen patterns for vector_insert(bitcast(..))
and bitcast(vector_extract(..)), allowing us to avoid a round-trip
through GPRs.

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

2 years ago[AArch64][SME] Disable inlining when SME attributes require smstart/smstop or lazy...
David Sherwood [Tue, 20 Sep 2022 15:28:34 +0000 (16:28 +0100)]
[AArch64][SME] Disable inlining when SME attributes require smstart/smstop or lazy-save.

Inlining must be disabled when the call-site needs to toggle PSTATE.SM or
when the callee's function body is executed in a different streaming mode than
its caller. This is needed because function calls are the boundaries for
streaming mode changes.

More details about the SME attributes and design can be found
in D131562.

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

2 years ago[MemorySSA] Remove PerformedPhiTranslation flag
Nikita Popov [Wed, 7 Sep 2022 08:20:20 +0000 (10:20 +0200)]
[MemorySSA] Remove PerformedPhiTranslation flag

I believe this is no longer necessary, as the underlying problem
has been fixed in a different way: Nowadays, we will adjust the
location size to beforeOrAfterPointer() if the pointer is not loop
invariant. This makes merging results translated across loop
backedges safe.

The two tests in phi-translation.ll show an improvement while still
being correct: The loads in the loop no longer alias with noalias
pointers, but still alias with the store in the entry block (which
they originally did not -- this is the bug that
PerformedPhiTranslation originally fixed).

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

2 years ago[flang] Limit shape inquiries rewrite to associate construct entity
Jean Perier [Wed, 21 Sep 2022 08:23:45 +0000 (10:23 +0200)]
[flang] Limit shape inquiries rewrite to associate construct entity

The previous code was rewriting all shape inquires on associate
construct entities to inquires on the associated expression or variable.

This is is incorrect because at the point of inquiry, some statement
between the association and the inquiry may have modified the expression
operands or variable in a way that changes its shapes or bounds.

For instance, in the example below, expression rewrites was previously
replacing `size(x, 1)` by `size(p, 1)` which is invalid if p is a
pointer.

```
associate(x => p + 1)
 call call_that_may_modify_p_shape()
 print *, size(x, 1)
end associate
```

This change restricts rewrites of shape inquiries on associate construct entity
to use the associated expression shape and bounds if and only if the
shape/bounds are compile time constant. Otherwise, this may be invalid.

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

2 years ago[NFC][AMDGPU] Pre-commit test for D132837.
Thomas Symalla [Wed, 21 Sep 2022 08:15:55 +0000 (10:15 +0200)]
[NFC][AMDGPU] Pre-commit test for D132837.

Pre-commit an additional fmac test for D132837.

2 years ago[SROA] Check typeSizeEqualsStoreSize in isVectorPromotionViable
Bjorn Pettersson [Fri, 16 Sep 2022 12:54:40 +0000 (14:54 +0200)]
[SROA] Check typeSizeEqualsStoreSize in isVectorPromotionViable

Commit de3445e0ef15c4209 (https://reviews.llvm.org/D132096) made
changes to isVectorPromotionViable basically doing

  // Create Vector with size of V, and each element of type Ty
  ...
  uint64_t ElementSize = DL.getTypeStoreSizeInBits(Ty).getFixedSize();
  uint64_t VectorSize = DL.getTypeSizeInBits(V).getFixedSize();
  ...
  VectorType *VTy = VectorType::get(Ty, VectorSize / ElementSize, false);

Not quite sure why it uses the TypeStoreSize for the ElementSize,
but the new vector would only match in size with the old vector in
situations when the TypeStoreSize equals the TypeSize for Ty.
Therefore this patch adds a typeSizeEqualsStoreSize check as yet
another condition for allowing the the new type as a promotion
candidate.

Without this fix the new @test15 test would fail with an assert
like this:

opt: ../lib/Transforms/Scalar/SROA.cpp:1966:
  auto isVectorPromotionViable(llvm::sroa::Partition &,
                               const llvm::DataLayout &)
       ::(anonymous class)::operator()(llvm::VectorType *,
                                       llvm::VectorType *) const:
  Assertion `DL.getTypeSizeInBits(RHSTy).getFixedSize() ==
             DL.getTypeSizeInBits(LHSTy).getFixedSize() &&
             "Cannot have vector types of different sizes!"' failed.
 ...
 #8  isVectorPromotionViable(...)::$_10::operator()...
 #9  llvm::SROAPass::rewritePartition(...)
#10  llvm::SROAPass::splitAlloca(...)
#11  llvm::SROAPass::runOnAlloca(...)
#12  llvm::SROAPass::runImpl(...)
#13  llvm::SROAPass::run(...)

Reviewed By: MatzeB

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

2 years ago[mlir] Update tests to use kEmitAccessorPrefix_Prefixed
River Riddle [Wed, 21 Sep 2022 01:11:08 +0000 (18:11 -0700)]
[mlir] Update tests to use kEmitAccessorPrefix_Prefixed

These aren't user facing, so just flip them directly to prefixed.

2 years ago[mlir][NFC] Tidy up the doc comment on CastInfo for Types
River Riddle [Wed, 21 Sep 2022 01:12:32 +0000 (18:12 -0700)]
[mlir][NFC] Tidy up the doc comment on CastInfo for Types

This had quite a few grammatical errors and typos.

2 years ago[mlir] Update Attributes to use the new casting infra
River Riddle [Tue, 20 Sep 2022 23:42:59 +0000 (16:42 -0700)]
[mlir] Update Attributes to use the new casting infra

This allows for using the llvm namespace cast methods instead
of the ones on the Attribute class. The Attribute class methods
are kept for now, but we'll want to remove these eventually
(with a really long lead time).

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

2 years ago[mlir][Bazel] Port f5fe92f69385
Adrian Kuegel [Wed, 21 Sep 2022 05:51:36 +0000 (07:51 +0200)]
[mlir][Bazel] Port f5fe92f69385

2 years ago[libc++] Use Clang-16 for c++17.
Mark de Wever [Sat, 27 Aug 2022 11:43:51 +0000 (13:43 +0200)]
[libc++] Use Clang-16 for c++17.

Reviewed By: ldionne, #libc

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

2 years ago[MachineCycle][NFC] add a cache for block and its top level cycle
Chen Zheng [Fri, 16 Sep 2022 05:48:44 +0000 (01:48 -0400)]
[MachineCycle][NFC] add a cache for block and its top level cycle

This solves https://github.com/llvm/llvm-project/issues/57664

Reviewed By: sameerds

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

2 years ago[clang] [docs] Improve formatting & fix typo in config docs
Michał Górny [Tue, 20 Sep 2022 09:29:19 +0000 (11:29 +0200)]
[clang] [docs] Improve formatting & fix typo in config docs

Fix teletype formatting in configuration file documentation to use
double backticks rather than single backticks.  Cover some more names
with this formatting.  Correct the name of config file for `clang-cl`
invocation.

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

2 years ago[Clang][OpenMP] Codegen generation for has_device_addr claues.
Jennifer Yu [Tue, 20 Sep 2022 08:38:34 +0000 (01:38 -0700)]
[Clang][OpenMP] Codegen generation for has_device_addr claues.

This patch add codegen support for the has_device_addr clause. It use
the same logic of is_device_ptr. But passing &var instead pointer to var
to kernal.

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

2 years agoRevert "[mlir][tensor] Support more cases in MergeConsecutiveExtractSlice"
Mehdi Amini [Wed, 21 Sep 2022 03:54:32 +0000 (03:54 +0000)]
Revert "[mlir][tensor] Support more cases in MergeConsecutiveExtractSlice"

This reverts commit 5d4603a02d0c3e0106b10d245322b1d2072c0c3d.

The Dialect/Tensor/fold-consecutive-insert-extract-slice.mlir test is
failing when built with GCC

2 years agoFix -fuse-ld to be linker flag in feature detection check
Kevin Gleason [Tue, 20 Sep 2022 21:49:08 +0000 (21:49 +0000)]
Fix -fuse-ld to be linker flag in feature detection check

Discovered an issue working in StableHLO when attempting to build with `-Wall -Werror`:
https://github.com/openxla/stablehlo/pull/137

Currently, if `LLVM_USE_LLD` and `-DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -Wall -Werror"`
are both specified for build, the build will error with:

```
-- Performing Test CXX_SUPPORTS_CUSTOM_LINKER - Failed
CMake Error at /usr/local/google/home/gleasonk/Coding/llvm-build/lib/cmake/llvm/HandleLLVMOptions.cmake:309 (message):
  Host compiler does not support '-fuse-ld=lld'
...

$ cat <build_dir>/CMakeFiles/CMakeError.log
...
clang: error: argument unused during compilation: '-fuse-ld=lld' [-Werror,-Wunused-command-line-argument]
```

It looks like other repos have hit this same issue:
- https://github.com/golang/go/issues/41527 (mentioned in comment)
- https://github.com/iree-org/iree/pull/7450

This can be reproduced in llvm-project with the following build command:

```
# Compile command taken from https://mlir.llvm.org/getting_started/
# and modified for use case
cmake -G Ninja ../llvm \
   -DLLVM_ENABLE_PROJECTS=mlir \
   -DLLVM_BUILD_EXAMPLES=ON \
   -DLLVM_TARGETS_TO_BUILD="X86;NVPTX;AMDGPU" \
   -DCMAKE_BUILD_TYPE=Release \
   -DLLVM_ENABLE_ASSERTIONS=ON \
   -DCMAKE_CXX_COMPILER=clang++ \
   -DCMAKE_C_COMPILER=clang \
   -DLLVM_ENABLE_LLD=ON \
   -DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -Wall -Werror"
```

Reviewed By: mehdi_amini

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

2 years ago[mlir][SCF] Fix loop pipelining unable to handle ops with regions
Christopher Bate [Tue, 20 Sep 2022 20:54:35 +0000 (14:54 -0600)]
[mlir][SCF] Fix loop pipelining unable to handle ops with regions

This change allows the SCF LoopPipelining transform to handle ops with
nested regions within the pipelined `scf.for` body. The op and nested
regions are treated as a single unit from the transform's perspective.
This change also makes explicit the requirement that only ops whose
parent Block is the loop body Block are allowed to be scheduled by the
caller.

Reviewed By: ThomasRaoux, nicolasvasilache

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

2 years ago[LLDB][RISCV] Fix UndefinedBehaviorSanitizer in RISCVEmulatorTester
Emmmer [Wed, 21 Sep 2022 03:52:04 +0000 (11:52 +0800)]
[LLDB][RISCV] Fix UndefinedBehaviorSanitizer in RISCVEmulatorTester

2 years ago[RISCV] Remove support for the unratified Zbt extension.
Craig Topper [Wed, 21 Sep 2022 03:26:48 +0000 (20:26 -0700)]
[RISCV] Remove support for the unratified Zbt extension.

This extension does not appear to be on its way to ratification.

Out of the unratified bitmanip extensions, this one had the
largest impact on the compiler.

Posting this patch to start a discussion about whether we should
remove these extensions. We'll talk more at the RISC-V sync meeting this
Thursday.

Reviewed By: asb, reames

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

2 years ago[Driver] Fix -f[no-]unwind-tables -Wunused-command-line-argument after 4388b56d525c08...
Fangrui Song [Wed, 21 Sep 2022 03:13:30 +0000 (20:13 -0700)]
[Driver] Fix -f[no-]unwind-tables -Wunused-command-line-argument after 4388b56d525c08ce3cf941cfbad2428b0e1695b0

2 years ago[RISCV] Support peephole optimization to fold vmerge.vvm that has tail agnostic polic...
jacquesguan [Tue, 30 Aug 2022 09:17:55 +0000 (17:17 +0800)]
[RISCV] Support peephole optimization to fold vmerge.vvm that has tail agnostic policy and unmasked intrinsics.

This patch supports the tail agnostic part of D130442.

Reviewed By: fakepaper56

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

2 years ago[PowerPC][NFC] Add virtual call to show redundant spill of vector registers
Ting Wang [Wed, 21 Sep 2022 01:21:06 +0000 (21:21 -0400)]
[PowerPC][NFC] Add virtual call to show redundant spill of vector registers

Reviewed By: lkail

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

2 years ago[modules] Fix error "malformed or corrupted AST file: 'SourceLocation remap refers...
Volodymyr Sapsai [Tue, 20 Sep 2022 00:46:01 +0000 (17:46 -0700)]
[modules] Fix error "malformed or corrupted AST file: 'SourceLocation remap refers to unknown module...'".

When a framework can be found at a new location, all references to it in
the module cache become outdated. When we try to load such outdated .pcm
file, we shouldn't change any already loaded and processed modules.

If `Module` has `ASTFile`, it means we've read its AST block already and
it is too late to undo that. If `ASTFile` is `None`, there is no value
in setting it to `None` again. So we don't reset `ASTFile` in
`ModuleManager::removeModules` at all.

rdar://97216258

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

2 years ago[clang] Fix an unused variable warning
Kazu Hirata [Wed, 21 Sep 2022 00:41:58 +0000 (17:41 -0700)]
[clang] Fix an unused variable warning

This patch fixes:

  clang/lib/Driver/ToolChains/PS4CPU.cpp:159:14: error: unused
  variable 'IsPS5' [-Werror,-Wunused-variable]

2 years ago AMDGPU: Implicit kernel arguments related optimization when uniform-workgroup-size...
Changpeng Fang [Wed, 21 Sep 2022 00:25:52 +0000 (17:25 -0700)]
 AMDGPU: Implicit kernel arguments related optimization when uniform-workgroup-size=true

 Summary:
   Under code object version 5, ockl_get_local_size returns the value computed by the expression:
workgroup_id < hidden_block_count ? hidden_group_size : hidden_remainder
For functions with the attribute uniform-work-group-size=true. we can evaluate workgroup_id < hidden_block_count
as true, and thus hidden_group_size is returned for ockl_get_local_size.
  With uniform-workgroup-size=true, this work also set all remainders to zero, and if there
is reqd_work_group_size, we also set work-group-size to the required value from the metadata.

Reviewers:
  arsenm and bcahoon

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

2 years ago[mlir][tensor] NFC: name various Transforms/ files consistently
Lei Zhang [Wed, 21 Sep 2022 00:16:42 +0000 (20:16 -0400)]
[mlir][tensor] NFC: name various Transforms/ files consistently

Use a suffix to make clear what the contents inside each file
are.

Reviewed By: ThomasRaoux

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

2 years ago[mlir][tensor] Support more cases in MergeConsecutiveExtractSlice
Lei Zhang [Wed, 21 Sep 2022 00:00:49 +0000 (20:00 -0400)]
[mlir][tensor] Support more cases in MergeConsecutiveExtractSlice

This commit adds utility functions to perform general merging of
OffsetSizeAndStrideOpInterface by supporting producer rank
reducing and non-unit strides.

With it we can extend MergeConsecutiveExtractSlice to support
more cases.

Co-authored-by: Mahesh Ravishankar <ravishankarm@google.com>
Reviewed By: ThomasRaoux

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

2 years ago[ELF] Make -V an alias for -v
Fangrui Song [Wed, 21 Sep 2022 00:12:44 +0000 (17:12 -0700)]
[ELF] Make -V an alias for -v

In GNU ld,

* --version skips linker input processing.
* -v and -V keep processing if there is any input file. -V has more
  information we don't support.

We currently make -V an alias for --version which skips input processing.
On many `*-freebsd` and `powerpc-*` targets, `gcc -v` passes `-V` to ld
and expects to process input. Make -V an alias for -v to provide
compatibility.

Fix https://github.com/llvm/llvm-project/issues/57859

2 years ago[ELF][test] Improve -v and --version tests
Fangrui Song [Wed, 21 Sep 2022 00:05:35 +0000 (17:05 -0700)]
[ELF][test] Improve -v and --version tests

2 years agoChange isLittleEndian to follow llvm style and add an accessor
Shubham Sandeep Rastogi [Tue, 20 Sep 2022 23:58:14 +0000 (16:58 -0700)]
Change isLittleEndian to follow llvm style and add an accessor

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

2 years ago[mlir][tensor] Merge consecutive insert_slice/extract_slice ops
Lei Zhang [Tue, 20 Sep 2022 23:52:19 +0000 (19:52 -0400)]
[mlir][tensor] Merge consecutive insert_slice/extract_slice ops

Consecutive tensor.insert_slice/tensor.extract_slice can be
created for the case like tiling convolution and then downsizing
2-D convolutions into 1-D ones. It hinders further transformations.
So adding these patterns to clean it up.

Given that bufferization is sensitive and have requirements over
the IR structure (see https://reviews.llvm.org/D132666),
these patterns are put in Transforms/ with separate entry points
for explicit collection.

Reviewed By: ThomasRaoux, mravishankar

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

2 years ago[libc] add strerror
Michael Jones [Fri, 16 Sep 2022 18:19:38 +0000 (11:19 -0700)]
[libc] add strerror

Strerror maps error numbers to strings. Additionally, a utility for
mapping errors to strings was added so that it could be reused for
perror and similar.

Reviewed By: sivachandra

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

2 years ago[mlir][arith] Fix constant naming in integration tests. NFC.
Jakub Kuderski [Tue, 20 Sep 2022 23:00:32 +0000 (19:00 -0400)]
[mlir][arith] Fix constant naming in integration tests. NFC.

Suggested by @antiagainst in D134321.

2 years ago[mlir][arith] Add integration tests for addi emulation
Jakub Kuderski [Tue, 20 Sep 2022 22:51:20 +0000 (18:51 -0400)]
[mlir][arith] Add integration tests for addi emulation

This includes tests with the exact expected values and comparison-based tests.

Reviewed By: antiagainst

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

2 years ago[DSE] Add value type info checks for masked store candidates in Dead Store Elimination.
Michael Berg [Tue, 20 Sep 2022 22:54:16 +0000 (15:54 -0700)]
[DSE] Add value type info checks for masked store candidates in Dead Store Elimination.

The type information of the store values can diverge when checking for valid
mask store candidates to eliminate via DSE. This patch checks for equivalence
wrt to size and element count.

Reviewed By: fhahn, rui.zhang

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

2 years ago[clang] Fix missing template arguments in AST of access to member variable template
Matheus Izvekov [Tue, 20 Sep 2022 13:18:20 +0000 (15:18 +0200)]
[clang] Fix missing template arguments in AST of access to member variable template

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>
Differential Revision: https://reviews.llvm.org/D134295

2 years ago[mlir][spirv] Query target environment for mapping memory space
Stanley Winata [Tue, 20 Sep 2022 22:28:40 +0000 (15:28 -0700)]
[mlir][spirv] Query target environment for mapping memory space

Checks spirv::TargetEnv from op to see if it contains either Kernel or Shader capabilities.
If it does, then it will set the memory space mapping accordingly.

Reviewed By: antiagainst

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

2 years ago[HLSL] Support PCH for cc1 mode
Xiang Li [Mon, 22 Aug 2022 23:57:48 +0000 (16:57 -0700)]
[HLSL] Support PCH for cc1 mode

Add HLSLExternalSemaSource as ExternalSemaSource instead of ASTContext::ExternalSource when PCH is included.

This allows a different external source to be set for the AST context.

Reviewed By: beanz

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

2 years ago[mlir][spirv] Add casting ops to/from generic storage space
Nirvedh Meshram [Mon, 19 Sep 2022 18:05:58 +0000 (11:05 -0700)]
[mlir][spirv] Add casting ops to/from generic storage space

Reviwed By: antiagainst

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

2 years ago[PS4] Always enable the .debug_aranges section when using LTO
Matthew Voss [Tue, 20 Sep 2022 21:44:56 +0000 (14:44 -0700)]
[PS4] Always enable the .debug_aranges section when using LTO

This flag enables the .debug_aranges section by passing a flag to LLD
and our internal linker. This also adds a new routine that will generate
the correct flag for our internal linker or set of flags for LLD when
given a list of LLVM options. That ensures multiple LLVM codegen options
can be passed to either linker consistently.

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

2 years ago[LLD][COFF] Support /MAPINFO flag
Pengxuan Zheng [Tue, 20 Sep 2022 00:21:21 +0000 (17:21 -0700)]
[LLD][COFF] Support /MAPINFO flag

This patch adds support for link.exe's /MAPINFO flag to lld-link.exe.

Here is a description of the flag from Microsoft
(https://learn.microsoft.com/en-us/cpp/build/reference/mapinfo-include-information-in-mapfile?view=msvc-170):

 The /MAPINFO option tells the linker to include the specified information in a
 mapfile, which is created if you specify the /MAP option. EXPORTS tells the
 linker to include exported functions.

Reviewed By: rnk

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

2 years ago[mlir][linalg] Swap tensor.extract_slice(linalg.fill)
Lei Zhang [Tue, 20 Sep 2022 21:31:16 +0000 (17:31 -0400)]
[mlir][linalg] Swap tensor.extract_slice(linalg.fill)

This commit adds a pattern to swap

```
tensor.extract_slice(linalg.fill(%cst, %init))
```
into
```
linalg.fill(%cst, tensor.extract_slice(%init))
```
when the linalg.fill op have no other users.
This helps to reduce the fill footprint.

Reviewed By: mravishankar

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

2 years ago[mlir][spirv] Lower max/min vector.reduction for OpenCL
Stanley Winata [Tue, 20 Sep 2022 21:16:52 +0000 (17:16 -0400)]
[mlir][spirv] Lower max/min vector.reduction for OpenCL

Templatizing vector reduction to enable lowering from
vector.reduction max/min to CL ops.

Reviewed By: antiagainst

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

2 years ago[NFC] Fix typo in comment
Louis Dionne [Tue, 20 Sep 2022 21:22:00 +0000 (17:22 -0400)]
[NFC] Fix typo in comment

2 years ago[flang] Add semantics test for atomic_add subroutine
Naje George [Tue, 9 Aug 2022 00:07:42 +0000 (17:07 -0700)]
[flang] Add semantics test for atomic_add subroutine

Reviewed By: ktras

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

2 years ago[HLSL] remove unnecessary abs attributes
Joshua Batista [Tue, 20 Sep 2022 21:04:08 +0000 (16:04 -0500)]
[HLSL] remove unnecessary abs attributes

remove abs non-elementwise attribute statements, stick to elementwise.

Reviewed By: beanz

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

2 years ago[GISel] TreeMatcher: always skip leaves if they don't care
Kai Nacke [Mon, 19 Sep 2022 16:03:32 +0000 (16:03 +0000)]
[GISel] TreeMatcher: always skip leaves if they don't care

In `GIMatchTreeOpcodePartitioner::applyForPartition()`, the loop over
the possible leaves skip a leaf if the instruction does not care
about the instruction.
When processing the referenced operands in the next loop the same
leaves need to be skipped.

Later, when these leaves are added to all partitions, the bit vector
must be resized first before the bit representing the leaf is set.

This fixes a crash in llvm-tblgen.

Reviewed By: arsenm

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

2 years agoAtomicExpand: Use correct pointer size for integer
Matt Arsenault [Tue, 20 Sep 2022 18:58:52 +0000 (14:58 -0400)]
AtomicExpand: Use correct pointer size for integer

This was using the default address space.

2 years agoAMDGPU: Add baseline test for expansion of 16-bit local atomics
Matt Arsenault [Tue, 20 Sep 2022 18:51:33 +0000 (14:51 -0400)]
AMDGPU: Add baseline test for expansion of 16-bit local atomics

The expansion is currently using the wrong pointer size.

2 years agoAtomicExpand: Switch test to generated checks
Matt Arsenault [Tue, 20 Sep 2022 20:03:13 +0000 (16:03 -0400)]
AtomicExpand: Switch test to generated checks

2 years agoVE: Use generated checks for a copy-pasted output test
Matt Arsenault [Tue, 20 Sep 2022 20:32:08 +0000 (16:32 -0400)]
VE: Use generated checks for a copy-pasted output test

2 years ago[clangd] Return earlier when snippet is empty
Tom Praschan [Sun, 18 Sep 2022 16:48:11 +0000 (18:48 +0200)]
[clangd] Return earlier when snippet is empty

Fixes github.com/clangd/clangd/issues/1216

If the Snippet string is empty, Snippet.front() would trigger a crash.
Move the Snippet->empty() check up a few lines to avoid this. Should not
break any existing behavior.

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

2 years ago[HLSL] add sqrt library function
Joshua Batista [Tue, 20 Sep 2022 19:46:06 +0000 (14:46 -0500)]
[HLSL] add sqrt library function

This change exposes the sqrt library function for HLSL scalar types,
excluding long and long long doubles. Sqrt is supported for all scalar, vector,
and matrix types. This patch only adds a subset of scalar type support.

Long and long long double support is missing in this patch because that type
doesn't exist in HLSL.

The full documentation of the HLSL asin function is available here:
https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-sqrt

Reviewed By: beanz

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

2 years ago[LLDB][NativePDB] Pass register_kind as reference (an oversight in 71d778f).
Zequan Wu [Tue, 20 Sep 2022 20:38:18 +0000 (13:38 -0700)]
[LLDB][NativePDB] Pass register_kind as reference (an oversight in 71d778f).

Fix #57799

2 years ago[NFC][AMDGPU] Refactor AMDGPUDisassembler
Scott Linder [Tue, 20 Sep 2022 20:05:19 +0000 (20:05 +0000)]
[NFC][AMDGPU] Refactor AMDGPUDisassembler

Clean up ahead of a patch to fix bugs in the AMDGPUDisassembler.

Use lit.local.cfg substitutions and more idiomatic use of split-file to
simplify and extend existing kernel-descriptor disassembly tests.

Add a comment to AMDHSAKernelDescriptor.h, as at least one small set
towards keeping all kernel-descriptor sensitive code in sync.

Reviewed By: kzhuravl, arsenm

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

2 years ago[RISCV] Support -mno-implicit-float.
Craig Topper [Tue, 20 Sep 2022 19:13:01 +0000 (12:13 -0700)]
[RISCV] Support -mno-implicit-float.

This can be used to disable vectorization and memcpy/memset
expansion for things like OS kernels. It also disables implicit
uses of scalar FP, but I don't know if we have any of those for
RISC-V.

NOTE: Without this patch you can still do -Xclang -no-implicit-float

Reviewed By: rui.zhang

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

2 years ago[AMDGPU] Fix size of SOPK instructions to 4 bytes
Anshil Gandhi [Tue, 20 Sep 2022 20:23:46 +0000 (14:23 -0600)]
[AMDGPU] Fix size of SOPK instructions to 4 bytes

Instructions in SOPK format may not have 32-bit
literal constants following the instruction.

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

2 years ago[InstCombine] Handle integer extension in `select` patterns using the condition as...
Markus Böck [Tue, 20 Sep 2022 20:12:10 +0000 (22:12 +0200)]
[InstCombine] Handle integer extension in `select` patterns using the condition as value

These patterns were previously only implemented for i1 type but can be extended for any integer type by also handling zext and sext operands.

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

2 years ago[clangd] Remove second tracer (which breaks threading contract)
Sam McCall [Tue, 20 Sep 2022 20:17:02 +0000 (22:17 +0200)]
[clangd] Remove second tracer (which breaks threading contract)

2 years ago[mlir][standalone] Specify python path when configuring
rkayaith [Tue, 20 Sep 2022 02:14:45 +0000 (22:14 -0400)]
[mlir][standalone] Specify python path when configuring

Specifying the python path here ensures that the python binary used matches the
one used by the main MLIR tests. This is useful when cmake's automatic detection
has to be overridden.

Reviewed By: stellaraccident, bondhugula

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

2 years ago[MLIR] Update bazel build files after 242d558658cd5a480b02883e2982d7246342e0d0
Frederik Gossen [Tue, 20 Sep 2022 19:11:12 +0000 (15:11 -0400)]
[MLIR] Update bazel build files after 242d558658cd5a480b02883e2982d7246342e0d0

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

2 years ago[LLDB]Initialize accept_socket with nullptr
George Hu [Tue, 20 Sep 2022 17:56:16 +0000 (10:56 -0700)]
[LLDB]Initialize accept_socket with nullptr

Fix high impact issue of illegal access of memory.
Initialize accept_socket with nullptr.

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

2 years ago[clang-format] Wrap inserted braces only if preceded by comments
owenca [Mon, 19 Sep 2022 22:28:18 +0000 (15:28 -0700)]
[clang-format] Wrap inserted braces only if preceded by comments

Fixes #57805.

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

2 years ago[InstCombine] Matrix multiplication negation optimisation
Zain Jaffal [Tue, 20 Sep 2022 18:45:02 +0000 (19:45 +0100)]
[InstCombine] Matrix multiplication negation optimisation

If one of the operands in a matrix multiplication is negated we can optimise the equation by moving the negation to the smallest element of the operands or the result.

Reviewed By: spatel, fhahn

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

2 years agoAMDGPU: Fix expansion of 16-bit atomicrmw
Matt Arsenault [Mon, 19 Sep 2022 21:50:36 +0000 (17:50 -0400)]
AMDGPU: Fix expansion of 16-bit atomicrmw

Fixes issue 57830

2 years agoAdd explicit tests for the PS4/PS5 C/C++ standards version defaults.
Douglas Yung [Tue, 20 Sep 2022 18:23:47 +0000 (11:23 -0700)]
Add explicit tests for the PS4/PS5 C/C++ standards version defaults.

2 years ago[Driver] Make --execute-only the default for aarch64-fuchsia
Alex Brachet [Tue, 20 Sep 2022 18:25:16 +0000 (18:25 +0000)]
[Driver] Make --execute-only the default for aarch64-fuchsia

Clang already generates code that doesn't use writeable data in executable
sections so the linker flag is all that is necessary.

-Wl,--no-execute-only can be used to turn this default off.

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

2 years ago[flang] Write semantics test for atomic_or
Katherine Rasmussen [Mon, 19 Sep 2022 17:53:10 +0000 (10:53 -0700)]
[flang] Write semantics test for atomic_or

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

Reviewed By: rouson

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

2 years ago[ELF] Name ctx->objectFiles[0] in the EF_RISCV_FLOAT_ABI mismatch error
Fangrui Song [Tue, 20 Sep 2022 18:14:04 +0000 (11:14 -0700)]
[ELF] Name ctx->objectFiles[0] in the EF_RISCV_FLOAT_ABI mismatch error

Reviewed By: compnerd

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

2 years ago[mlir][scf] Support simple symbolic expression without depending on AffineDialect...
Peiming Liu [Tue, 20 Sep 2022 17:50:34 +0000 (17:50 +0000)]
[mlir][scf] Support simple symbolic expression without depending on AffineDialect to simply trivial loops.

Remove dependence of AffineDialect

Reviewed By: mehdi_amini

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

2 years ago[mlir][ods] Allow empty array ref parameter
Jeff Niu [Wed, 14 Sep 2022 00:19:19 +0000 (17:19 -0700)]
[mlir][ods] Allow empty array ref parameter

This patch "fixes" a longstanding issue where the assembly format for
ArrayRefParameter could not handle an empty list. This is because there
was no way to generically optionally parse the first element of the
array. The only solution was to write a (relatively simple) custom parser.

This patch implements "empty" ArrayRefParameters by using
inverted optional groups and an optional ArrayRefParameter.

Depends on D133816

Reviewed By: rriddle

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

2 years ago[mlir][ods] Generalize default/optional parameters
Jeff Niu [Tue, 13 Sep 2022 23:16:20 +0000 (16:16 -0700)]
[mlir][ods] Generalize default/optional parameters

This patch consolidates the notions of an optional parameter and a
default parameter. An optional parameter is a parameter equal to its
default value, which for a "purely optional" parameter is its "null"
value.

This allows the existing `comparator` and `defaultValue` fields to be
used enabled more complex "optional" parameters, such as empty arrays.

Depends on D133812

Reviewed By: rriddle

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

2 years ago[mlir][ods] Format: allow anchors in the else elements
Jeff Niu [Tue, 13 Sep 2022 22:08:39 +0000 (15:08 -0700)]
[mlir][ods] Format: allow anchors in the else elements

This patch changes optional groups to allow anchors in the 'else'
element group. When printing, the optional condition is inverted to
decide which group to print. This is useful for parsing concrete
optional elements that don't have a `parseOptional*` method or some
other way to test whether it's present.

Depends on D133805

Reviewed By: rriddle

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

2 years ago[mlir][ods] Store the pointer to the anchor element (NFC)
Jeff Niu [Tue, 13 Sep 2022 20:15:06 +0000 (13:15 -0700)]
[mlir][ods] Store the pointer to the anchor element (NFC)

Instead of its index. There is no benefit to storing the index instead
of the pointer.

Reviewed By: rriddle

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

2 years ago[clang-doc] Centralize TypeInfo creation.
Brett Wilson [Tue, 20 Sep 2022 17:54:28 +0000 (17:54 +0000)]
[clang-doc] Centralize TypeInfo creation.

Several different places in the code had similar computations for the parameters that were eventually passed to the TypeInfo constructor.

This centralizes that code in one function, and allows passing TypeInfo to the various other *Info structures that need it.

Remove some "auto" types and replace with the real type for getting declarations. This was making some duplicate checking difficult to see.

Reviewed By: paulkirth

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

2 years ago[NFCI] Clean up enum FormatCategoryItem.
Jorge Gorbe Moya [Mon, 19 Sep 2022 23:35:24 +0000 (16:35 -0700)]
[NFCI] Clean up enum FormatCategoryItem.

- Merge pairs like `eFormatCategoryItemSummary` and
  `eFormatCategoryItemRegexSummary` into a single value. See explanation
  below.

- Rename `eFormatCategoryItemValue` to `eFormatCategoryItemFormat`. This
  makes the enum match the names used elsewhere for formatter kinds
  (format, summary, filter, synth).

- Delete unused values `eFormatCategoryItemValidator` and
  `eFormatCategoryItemRegexValidator`.

This enum is only used to reuse some code in CommandObjectType.cpp.  For
example, instead of having separate implementations for `type summary
delete`, `type format delete`, and so on, there's a single generic
implementation that takes an enum value, and then the specific commands
derive from it and set the right flags for the specific kind of
formatter.

Even though the enum distinguishes between regular and regex matches for
every kind of formatter, this distinction is never used: enum values are
always specified in pairs like
`eFormatCategoryItemSummary | eFormatCategoryItemRegexSummary`.

This causes some ugly code duplication in TypeCategory.cpp. In order to
handle every flag combination some code appears 8 times:

{format, summary, synth, filter} x {exact, regex}

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

2 years ago[NFC][RISCV] Move calculations of SDNode policy operand idx to a separate function
Anton Sidorenko [Tue, 20 Sep 2022 17:22:16 +0000 (10:22 -0700)]
[NFC][RISCV] Move calculations of SDNode policy operand idx to a separate function

Since there is no guaranteed correspondence of SDNode and MI operands, we need
getters simular to RISCVII::get*OpNum for SDNodes.

More uses of getVecPolicyOpIdx will be added in D130895.

Reviewed By: craig.topper, arcbbb

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

2 years ago[RISCV][MC] Add support for experimental Zawrs extension
Philip Reames [Tue, 20 Sep 2022 17:01:37 +0000 (10:01 -0700)]
[RISCV][MC] Add support for experimental Zawrs extension

This implements experimental support for the Zawrs extension as specified here: https://github.com/riscv/riscv-zawrs/releases/download/V1.0-rc3/Zawrs.pdf. Despite the 1.0 version name, this has not been ratified and there was a major change to proposed specification between rc2 and rc3.  Once this is ratified, it'll move out of experimental status.

This change adds assembly support, but does not include C language or IR intrinsics. We can decide if we want them, and handle that in a separate patch.

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

2 years ago[gn build] Port 00798e500644
LLVM GN Syncbot [Tue, 20 Sep 2022 17:07:57 +0000 (17:07 +0000)]
[gn build] Port 00798e500644

2 years ago[AArch64] Define __ARM_FEATURE_RCPC
Mingming Liu [Tue, 14 Jun 2022 21:04:49 +0000 (14:04 -0700)]
[AArch64] Define __ARM_FEATURE_RCPC

This patch implements the definition of __ARM_FEATURE_RCPC when clang
command specifies +rcpc.

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

2 years ago[libc++] Applies P0602R4 retro-actively.
Mark de Wever [Mon, 5 Sep 2022 17:01:50 +0000 (19:01 +0200)]
[libc++] Applies P0602R4 retro-actively.

While testing a test failure of C++17 with Clang ToT it was noticed the
paper
  P0602R4 variant and optional should propagate copy/move triviality
was not applied as a DR in libc++.

This was discovered while investigating the issue "caused by" D131479.

Reviewed By: #libc, ldionne

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

2 years ago[InstrProfiling] Emit runtime hook only once
Gulfem Savrun Yeniceri [Fri, 16 Sep 2022 18:19:06 +0000 (18:19 +0000)]
[InstrProfiling] Emit runtime hook only once

This patch fixes the issue about calling emitRuntimeHook() twice
when we need to unconditionally emit runtime hook as discussed in
https://reviews.llvm.org/rGd6aed77f0d19.

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

2 years ago[NFC][libc++][format] Uses ranges algorithm.
Mark de Wever [Fri, 16 Sep 2022 18:47:01 +0000 (20:47 +0200)]
[NFC][libc++][format] Uses ranges algorithm.

Reviewed By: #libc, ldionne

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

2 years ago[libc++][test] Adds format string helper.
Mark de Wever [Thu, 5 May 2022 06:03:58 +0000 (08:03 +0200)]
[libc++][test] Adds format string helper.

Update the formatter day tests to the new style.
Other test will be done separately.

Reviewed By: #libc, ldionne

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

2 years ago[libc++][chrono] Removes format include.
Mark de Wever [Tue, 13 Sep 2022 18:10:26 +0000 (20:10 +0200)]
[libc++][chrono] Removes format include.

Switch to the new granular format_functions header. Since the chrono's
format dependency in C++20 hasn't been in a release it's save to remove
it.

Depends on D133665

Reviewed By: #libc, ldionne

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

2 years ago[libc++][format] Granularizes the format header.
Mark de Wever [Sun, 11 Sep 2022 11:05:26 +0000 (13:05 +0200)]
[libc++][format] Granularizes the format header.

Moves the last pieces of code to its own header.

Reviewed By: ldionne, #libc

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

2 years ago[AMDGPU] Disable fp atomic to s_denorm_mode hazard for GFX11
Jay Foad [Tue, 20 Sep 2022 12:29:39 +0000 (13:29 +0100)]
[AMDGPU] Disable fp atomic to s_denorm_mode hazard for GFX11

This hazard only exists on GFX10.

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

2 years agoFix __builtin_assume_aligned incorrect type descriptor and C++ object polymorphic...
yronglin [Tue, 20 Sep 2022 16:35:18 +0000 (12:35 -0400)]
Fix __builtin_assume_aligned incorrect type descriptor and C++ object polymorphic address

Fix __builtin_assume_aligned incorrect type descriptor

example from @rsmith

struct A { int n; };
struct B { int n; };
struct C : A, B {};

void *f(C *c) {
  // Incorrectly returns `c` rather than the address of the B base class.
  return __builtin_assume_aligned((B*)c, 8);
}

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

2 years ago[IPO] Reorder parameters of InlineFunction (NFC)
Kazu Hirata [Tue, 20 Sep 2022 16:09:38 +0000 (09:09 -0700)]
[IPO] Reorder parameters of InlineFunction (NFC)

With the recent addition of new parameter MergeAttributes (D134117),
callers need to specify several default parameters before getting to
specify the new parameter.

This patch reorders the parameters so that callers do not have to
specify as many default parameters.

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

2 years ago[AArch64] Enable LSLFast for modern OoO cpus
David Green [Tue, 20 Sep 2022 16:09:14 +0000 (17:09 +0100)]
[AArch64] Enable LSLFast for modern OoO cpus

This patch enables the LSLFast feature for Cortex-A76, Cortex-A77,
Cortex-A78, Cortex-A78C, Cortex-A710, Cortex-X1, Cortex-X2, Neoverse N1,
Neoverse N2, Neoverse V1 and the Neoverse 512TB pseudo-cpu, in-line with
the software optimization guides for those CPUs.

Differntial revision: https://reviews.llvm.org/D134273

2 years ago[HLSL] Pass flags to cc1 based on language
Chris Bieneman [Tue, 20 Sep 2022 15:41:43 +0000 (10:41 -0500)]
[HLSL] Pass flags to cc1 based on language

Having the flags only pass through if you're using the dxc-driver means
that the clang driver doesn't work for HLSL, which is undesirable. This
change switches to instead passing flags based on the language mode
similar to how OpenCL does it. This allows the clang driver to be used
for HLSL source files as well.

Reviewed By: python3kgae

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