platform/upstream/llvm.git
22 months ago[AMDGPU][MC][GFX11][NFC] Split tests for SOP formats
Dmitry Preobrazhensky [Wed, 24 Aug 2022 10:57:48 +0000 (13:57 +0300)]
[AMDGPU][MC][GFX11][NFC] Split tests for SOP formats

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

22 months ago[AMDGPU][MC][GFX11][NFC] Add missing tests for SOP instructions
Dmitry Preobrazhensky [Wed, 24 Aug 2022 10:45:20 +0000 (13:45 +0300)]
[AMDGPU][MC][GFX11][NFC] Add missing tests for SOP instructions

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

22 months ago[AMDGPU][MC][GFX11][NFC] Update tests for FLAT instructions
Dmitry Preobrazhensky [Wed, 24 Aug 2022 10:38:09 +0000 (13:38 +0300)]
[AMDGPU][MC][GFX11][NFC] Update tests for FLAT instructions

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

22 months ago[AMDGPU][MC][NFC] Rename disassembler tests
Dmitry Preobrazhensky [Wed, 24 Aug 2022 10:26:57 +0000 (13:26 +0300)]
[AMDGPU][MC][NFC] Rename disassembler tests

Make test names more uniform.

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

22 months ago[AMDGPU][MC][GFX8][NFC] Consolidate tests by encoding
Dmitry Preobrazhensky [Wed, 24 Aug 2022 10:11:31 +0000 (13:11 +0300)]
[AMDGPU][MC][GFX8][NFC] Consolidate tests by encoding

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

22 months ago[DAG] matchRotateHalf - constify SelectionDAG arg. NFC.
Simon Pilgrim [Wed, 24 Aug 2022 09:57:30 +0000 (10:57 +0100)]
[DAG] matchRotateHalf - constify SelectionDAG arg. NFC.

Based off Issue #57283 - we need to try harder to ensure we're not creating nodes on-the-fly - so make sure we're just using SelectionDAG for analysis where possible

22 months ago[RISCV] : Add support for immediate operands.
MarkGoncharovAl [Wed, 24 Aug 2022 09:34:24 +0000 (17:34 +0800)]
[RISCV] : Add support for immediate operands.

llvm-exegesis uses operand type information provided in tablegen files to initialize
immediate arguments of the instruction. Some of them simply don't have such information.
Thus we should set into relevant immediate operands their specific type.
Also create verification methods for them.

Reviewed By: craig.topper
Differential Revision: https://reviews.llvm.org/D131771

22 months agoRevert "[Pipelines] Introduce DAE after ArgumentPromotion"
Pavel Samolysov [Wed, 24 Aug 2022 09:44:13 +0000 (12:44 +0300)]
Revert "[Pipelines] Introduce DAE after ArgumentPromotion"

This reverts commit 3f20dcbf708cb23f79c4866d8285a8ae7bd885de.

22 months ago[NVPTX] SHL.64 $r, 31 cannot be converted to a mulwide.s32
Dmitry Vassiliev [Wed, 24 Aug 2022 09:39:41 +0000 (11:39 +0200)]
[NVPTX] SHL.64 $r, 31 cannot be converted to a mulwide.s32

In order to convert to mulwide.s32, we compute the 2nd operand as MulWide.32 $r, (1 << 31).
(1 << 31) is interpreted as a negative number, and is not equivalent to the original instruction.
The code `int64_t r = (int64_t)a << 31;` incorrectly compiled to `mul.wide.s32 %rd7, %r1, -2147483648;`

Reviewed By: jchlanda

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

22 months ago[LoongArch] Implement TargetLowering::hasAndNot() for more optimization chances
gonglingqin [Wed, 24 Aug 2022 09:12:59 +0000 (17:12 +0800)]
[LoongArch] Implement TargetLowering::hasAndNot() for more optimization chances

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

22 months ago[AMDGPU] Remove unused S_ADD_U64_CO_PSEUDO and S_SUB_U64_CO_PSEUDO
Jay Foad [Wed, 24 Aug 2022 09:28:07 +0000 (10:28 +0100)]
[AMDGPU] Remove unused S_ADD_U64_CO_PSEUDO and S_SUB_U64_CO_PSEUDO

22 months ago[clang] Allow using -rtlib=platform to switching to the default rtlib on all targets
Martin Storsjö [Mon, 28 Mar 2022 20:23:36 +0000 (23:23 +0300)]
[clang] Allow using -rtlib=platform to switching to the default rtlib on all targets

Normally, passing -rtlib=platform overrides any earlier -rtlib
options, and overrides any hardcoded CLANG_DEFAULT_RTLIB option.
However, some targets, MSVC and Darwin, have custom logic for
disallowing specific -rtlib= option values; amend these checks for
allowing the -rtlib=platform option.

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

22 months ago[mlir] Apply ClangTidy readability fix.
Adrian Kuegel [Wed, 24 Aug 2022 08:34:26 +0000 (10:34 +0200)]
[mlir] Apply ClangTidy readability fix.

Use .empty() instead of checking for size() == 0.

22 months agoRevert "[Clang] Avoid using unwind library in the MSVC environment"
Petr Hosek [Wed, 24 Aug 2022 08:24:18 +0000 (08:24 +0000)]
Revert "[Clang] Avoid using unwind library in the MSVC environment"

This reverts commit eca29d4a37b8d1c93fe99be6289a60bb11cf789d since
the test fails in the per-target-runtime-dir layout.

22 months ago[mlir][Bazel] Fix bazel build.
Adrian Kuegel [Wed, 24 Aug 2022 08:13:28 +0000 (10:13 +0200)]
[mlir][Bazel] Fix bazel build.

22 months ago[runtimes] Use a response file for runtimes test suites
Petr Hosek [Thu, 18 Aug 2022 08:25:13 +0000 (08:25 +0000)]
[runtimes] Use a response file for runtimes test suites

We don't know which test suites are going to be included by runtimes
builds so we cannot include those before running the sub-build, but
that's not possible during the LLVM build configuration. We instead use
a response file that's populated by the runtimes build as a level of
indirection.

This addresses the issue described in:
https://discourse.llvm.org/t/cmake-regeneration-is-broken/62788

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

22 months ago[lit] Support reading arguments from a file
Petr Hosek [Mon, 15 Aug 2022 17:59:39 +0000 (17:59 +0000)]
[lit] Support reading arguments from a file

This allows reading arguments from file using the response file syntax.
We would like to use this in the LLVM build to pass test suites from
subbuilds.

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

22 months ago[MLIR] Split autogenerated pass declarations & C++ controllable pass options
Michele Scuttari [Wed, 24 Aug 2022 07:59:50 +0000 (09:59 +0200)]
[MLIR] Split autogenerated pass declarations & C++ controllable pass options

The pass tablegen backend has been reworked to remove the monolithic nature of the autogenerated declarations.
The pass public header can be generated with the -gen-pass-decls option. It contains options structs and registrations: the inclusion of options structs can be controlled individually for each pass by defining the GEN_PASS_DECL_PASSNAME macro; the declaration of the registrations have been kept together and can still be included by defining the GEN_PASS_REGISTRATION macro.
The private code used for the pass implementation (i.e. the pass base class and the constructors definitions, if missing from tablegen) can be generated with the -gen-pass-defs option. Similarly to the declarations file, the definitions of each pass can be enabled by defining the GEN_PASS_DEF_PASNAME variable.
While doing so, the pass base class has been enriched to also accept a the aformentioned struct of options and copy them to the actual pass options, thus allowing each pass to also be configurable within C++ and not only through command line.

Reviewed By: rriddle, mehdi_amini, Mogball, jpienaar

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

22 months ago[Pipelines] Introduce DAE after ArgumentPromotion
Pavel Samolysov [Wed, 29 Jun 2022 10:46:10 +0000 (13:46 +0300)]
[Pipelines] Introduce DAE after ArgumentPromotion

The ArgumentPromotion pass uses Mem2Reg promotion at the end to cutting
down generated `alloca` instructions as well as meaningless `store`s and
this behavior can leave unused (dead) arguments. To eliminate the dead
arguments and therefore let the DeadCodeElimination remove becoming dead
inserted `GEP`s as well as `load`s and `cast`s in the callers, the
DeadArgumentElimination pass should be run after the ArgumentPromotion
one.

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

22 months ago[docs] Add LICENSE.txt to the root of the mono-repo
Tobias Hieta [Wed, 24 Aug 2022 07:33:58 +0000 (09:33 +0200)]
[docs] Add LICENSE.txt to the root of the mono-repo

This will make it easier to find the LICENSE and some
software also looks in the root to automatically find it.

Reviewed By: kristof.beyls, lattner

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

22 months ago[AArch64][X86] Add some fixed-order-recurrence tests to check the costmodel of fixed...
David Green [Wed, 24 Aug 2022 07:18:01 +0000 (08:18 +0100)]
[AArch64][X86] Add some fixed-order-recurrence tests to check the costmodel of fixed order recurrences. NFC

22 months ago[AArch64][SVE] Remove -O1 from SVE intrinsic tests.
David Green [Wed, 17 Aug 2022 10:16:59 +0000 (11:16 +0100)]
[AArch64][SVE] Remove -O1 from SVE intrinsic tests.

This removes -O1 from the SVE ACLE intrinsics tests and replaces it with
-O0 and "opt -mem2reg -instcombine -tailcallelim". Instrcombine and
TailCallElim are only added to keep the differences smaller and can be
removed in a followup patches. The only remaining differences in the
tests are tbaa nodes not being emitted under -O0, and the removable of
some tailcall flags.

22 months ago[mlir][Bazel] Fix bazel build.
Adrian Kuegel [Wed, 24 Aug 2022 06:51:44 +0000 (08:51 +0200)]
[mlir][Bazel] Fix bazel build.

To avoid a dependency cycle, add BytecodeImplementation.h header to the
"IR" target.

22 months agoFix warning from a7bfdc23ab3ade54da99f0f59dababe4d71ae75b
Mahesh Ravishankar [Wed, 24 Aug 2022 06:36:40 +0000 (06:36 +0000)]
Fix warning from a7bfdc23ab3ade54da99f0f59dababe4d71ae75b

22 months ago[RISCV] Add zihintntl compressed instructions
Alex [Mon, 22 Aug 2022 09:50:19 +0000 (17:50 +0800)]
[RISCV] Add zihintntl compressed instructions

Add zihintntl compressed instructions and some files related to zihintntl.
This patch is base on {D121670}.

Reviewed By: kito-cheng

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

22 months ago[DAGCombine] Add more tests for cmp to sbb combination; NFC
Paweł Bylica [Tue, 23 Aug 2022 11:35:40 +0000 (13:35 +0200)]
[DAGCombine] Add more tests for cmp to sbb combination; NFC

Add 2 more tests for potential DAG combine of cmp into sbb.

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

22 months ago[mlir][Linalg] Handle multi-result operations in Elementwise op fusion.
Mahesh Ravishankar [Wed, 24 Aug 2022 05:56:13 +0000 (05:56 +0000)]
[mlir][Linalg] Handle multi-result operations in Elementwise op fusion.

This drops the artificial requirement of producers having a single
result value to be able to fuse with consumers.

The current default also only fuses producer with consumer when the
producer has a single use. This is a simplifying assumption. There are
legitimate use cases where a producer can be fused with consumer and
the fused o pcould be used to replace the uses of the producer as
well. This needs to be done with care to avoid use-def violations. To
allow for downstream users to explore more fusion opportunities, the
core transformation method is exposed as a utility function.

This patch also modifies the control function to take just the fused
operand as the argument. This is enough information for the callers to
get the producer and the consumer operations being considered to
fuse. It also provides information of which producer result is used.

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

22 months ago[AIX] use the original name as the input to create the new symbol for TLS symbol.
esmeyi [Wed, 24 Aug 2022 05:36:40 +0000 (01:36 -0400)]
[AIX] use the original name as the input to create the new symbol for TLS symbol.

Summary: Currently, an error was reported when a thread local symbol has an invalid name. D100956 create a new symbol to prefix the TLS symbol name with a dot. When the symbol name is renamed, the error occurs. This patch uses the original symbol name (name in the symbol table) as the input for the symbol for TOC entry.

Reviewed By: shchenz, lkail

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

22 months ago[RISCV] Handle register spill in branch relaxation
ZHU Zijia [Wed, 24 Aug 2022 05:27:56 +0000 (13:27 +0800)]
[RISCV] Handle register spill in branch relaxation

In branch relaxation pass, `j`'s with offset over 1MiB will be relaxed
to `jump` pseudo-instructions.

This patch allocates a stack slot for functions with a size greater than
1MiB. If the register scavenger cannot find a scratch register for
`jump`, spill a register to the slot before the jump and restore it
after the jump.

.mbb:
        foo
        j       .dest_bb
        bar
        bar
        bar
.dest_bb:
        baz

The above code will be relaxed to the following code.

.mbb:
        foo
        sd      s11, 0(sp)
        jump    .restore_bb, s11
        bar
        bar
        bar
        j       .dest_bb
.restore_bb:
        ld      s11, 0(sp)
.dest_bb:
        baz

Depends on D129999.

Reviewed By: StephenFan

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

22 months ago[RISCV][TableGen] Mark MachineInstr with FrameIndex as not compressible
ZHU Zijia [Wed, 24 Aug 2022 05:23:38 +0000 (13:23 +0800)]
[RISCV][TableGen] Mark MachineInstr with FrameIndex as not compressible

If a MachineInstr's operand should be Reg in compiler's output but is
currently FrameIndex, `isCompressibleInst()` will terminate at
`MachineOperandType::getReg()`.

This patch adds `.isReg()` checks to make `isCompressibleInst()` return
false for these MachineInstr, allowing `getInstSizeInBytes()` to return
a value and `EstimateFunctionSizeInBytes()` to work as intended.

See https://reviews.llvm.org/D129999#3694222 for details.

Reviewed By: luismarques

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

22 months ago[mlir][math] Lower math.floor,ceil to libm
Kai Sasaki [Wed, 24 Aug 2022 01:58:01 +0000 (10:58 +0900)]
[mlir][math] Lower math.floor,ceil to libm

Lower math.floor and math.ceil to libm

Reviewed By: ftynse

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

22 months agoReland "[MLIR]Extend vector.gather to support n-D result"
Che-Yu Wu [Wed, 24 Aug 2022 04:12:50 +0000 (04:12 +0000)]
Reland "[MLIR]Extend vector.gather to support n-D result"

Reviewed By: dcaballe

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

22 months ago[MSAN] Handle array alloca with non-i64 size specification
Keno Fischer [Wed, 24 Aug 2022 03:23:36 +0000 (03:23 +0000)]
[MSAN] Handle array alloca with non-i64 size specification

The array size specification of the an alloca can be any integer,
so zext or trunc it to intptr before attempting to multiply it
with an intptr constant.

Reviewed By: eugenis

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

22 months ago[MSAN] Correct shadow type for atomicrmw instrumentation
Keno Fischer [Wed, 24 Aug 2022 03:23:31 +0000 (03:23 +0000)]
[MSAN] Correct shadow type for atomicrmw instrumentation

We were passing the type of `Val` to `getShadowOriginPtr`, rather
than the type of `Val`'s shadow resulting in broken IR. The fix
is simple.

Reviewed By: eugenis

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

22 months ago[Polly] Don't use `llvm-config` anymore (in CMake sad path)
John Ericson [Sat, 20 Aug 2022 21:38:05 +0000 (17:38 -0400)]
[Polly] Don't use `llvm-config` anymore (in CMake sad path)

If `LLVM_BUILD_MAIN_SRC_DIR` is not defined, just assume we are in
regular monorepo layout. Non-standard (and not really supported) layouts
can still be configured manually.

Reviewed By: beanz

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

22 months ago[X86] Emulate _rdrand64_step with two rdrand32 if it is 32bit
Bing1 Yu [Wed, 24 Aug 2022 01:41:40 +0000 (09:41 +0800)]
[X86] Emulate _rdrand64_step with two rdrand32 if it is 32bit

Reviewed By: RKSimon

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

22 months ago[DAG] MatchRotate - bail if we fail to match a shl/srl pair
Simon Pilgrim [Wed, 24 Aug 2022 02:04:59 +0000 (03:04 +0100)]
[DAG] MatchRotate - bail if we fail to match a shl/srl pair

extractShiftForRotate may fail to return canonicalized shifts due to constant folding or other simplification that can occur in getNode()

Fixes Issue #57283

22 months ago[HLSL] Infer language from file extension
Chris Bieneman [Wed, 24 Aug 2022 01:52:29 +0000 (20:52 -0500)]
[HLSL] Infer language from file extension

This allows the language mode for HLSL to be inferred from the file
extension.

22 months ago[NFC] Fix warning
Chris Bieneman [Wed, 24 Aug 2022 01:49:56 +0000 (20:49 -0500)]
[NFC] Fix warning

This change came in a few hours ago and introduced a warning. The fix
is trivial, so I'm providing it. The original change was reviewed here:

https://reviews.llvm.org/D132331

22 months agoRevert "[X86] Emulate _rdrand64_step with two rdrand32 if it is 32bit"
Bing1 Yu [Wed, 24 Aug 2022 01:38:46 +0000 (09:38 +0800)]
Revert "[X86] Emulate _rdrand64_step with two rdrand32 if it is 32bit"

This reverts commit 07e34763b02728857e1d6e8ccd2b82820eb3c0cc.

22 months ago[X86] Emulate _rdrand64_step with two rdrand32 if it is 32bit
Bing1 Yu [Tue, 23 Aug 2022 08:25:48 +0000 (16:25 +0800)]
[X86] Emulate _rdrand64_step with two rdrand32 if it is 32bit

Reviewed By: RKSimon

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

22 months ago[mlir:Bytecode] Move variable to inside of the lambda to fix MSVC build
River Riddle [Wed, 24 Aug 2022 00:43:41 +0000 (17:43 -0700)]
[mlir:Bytecode] Move variable to inside of the lambda to fix MSVC build

MSVC is not picking up a variable capture somehow, try moving it inside.

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

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

Reviewed By: rafauler

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

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

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

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

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