platform/upstream/llvm.git
2 years ago[unittests] [DWARF] Generalize path separator expectations
Martin Storsjö [Thu, 7 Oct 2021 11:31:32 +0000 (11:31 +0000)]
[unittests] [DWARF] Generalize path separator expectations

This fixes unit tests if running on Windows with a build configured
to prefer forward slashes.

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

2 years ago[DebugInfo] [PDB] Force injected source paths to use backslashes
Martin Storsjö [Thu, 7 Oct 2021 10:36:46 +0000 (10:36 +0000)]
[DebugInfo] [PDB] Force injected source paths to use backslashes

This fixes lld/COFF/pdb-natvis.test (which only is run on Windows)
when using paths with forward slashes on Windows.

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

2 years ago[fir] Remove getModel<Fortran::ISO::CFI_dim_t> in DescriptorModel.h
Valentin Clement [Fri, 5 Nov 2021 19:49:09 +0000 (20:49 +0100)]
[fir] Remove getModel<Fortran::ISO::CFI_dim_t> in DescriptorModel.h

A windows buildbot complains about previous definiton after D112961.

Remove the extra definition until we can figure out if really needed.

2 years agoAutogen tests for ease of future update
Philip Reames [Fri, 5 Nov 2021 19:34:08 +0000 (12:34 -0700)]
Autogen tests for ease of future update

2 years ago[libcxx] [test] Narrow down XFAILs regarding a MSVC mode specific bug to "windows...
Martin Storsjö [Fri, 22 Oct 2021 21:48:54 +0000 (00:48 +0300)]
[libcxx] [test] Narrow down XFAILs regarding a MSVC mode specific bug to "windows-dll && msvc"

These tests don't fail when only windows-dll is set in mingw mode, as the
bug is specific to MSVC mode.

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

2 years ago[DAGCombiner] add fold for vselect based on mask of signbit, part 2
Sanjay Patel [Fri, 5 Nov 2021 17:28:35 +0000 (13:28 -0400)]
[DAGCombiner] add fold for vselect based on mask of signbit, part 2

This is the 'or' sibling for the fold added with:
D113212

https://alive2.llvm.org/ce/z/tgnp7K

Note that neither of these transforms is poison-safe,
but it does not seem to matter at this level. We have
had the scalar version of D113212 for a long time, so
this is just making optimizer behavior consistent.

We do not have the scalar version of *this* fold,
however, so that is another follow-up.

2 years ago[AArch] add tests for vselect; NFC
Sanjay Patel [Fri, 5 Nov 2021 16:46:56 +0000 (12:46 -0400)]
[AArch] add tests for vselect; NFC

These are copy/pasted from the related test patterns in D113212.

2 years ago[x86] add tests for vector select; NFC
Sanjay Patel [Fri, 5 Nov 2021 16:42:22 +0000 (12:42 -0400)]
[x86] add tests for vector select; NFC

2 years ago[mlir][DialectConversion] Legalize all live argument conversions
River Riddle [Fri, 5 Nov 2021 18:43:26 +0000 (18:43 +0000)]
[mlir][DialectConversion] Legalize all live argument conversions

Previously we didn't materialize conversions for arguments in certain
cases as the implicit type propagation was being heavily relied on
by many patterns. Now that those patterns have been fixed to
properly handle type conversions, we can drop the special behavior.

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

2 years agoReland "[Attr] support btf_type_tag attribute"
Yonghong Song [Fri, 5 Nov 2021 18:01:31 +0000 (11:01 -0700)]
Reland "[Attr] support btf_type_tag attribute"

This is to revert commit f95bd18b5faa (Revert "[Attr] support
btf_type_tag attribute") plus a bug fix.

Previous change failed to handle cases like below:
    $ cat reduced.c
    void a(*);
    void a() {}
    $ clang -c reduced.c -O2 -g

In such cases, during clang IR generation, for function a(),
CGCodeGen has numParams = 1 for FunctionType. But for
FunctionTypeLoc we have FuncTypeLoc.NumParams = 0. By using
FunctionType.numParams as the bound to access FuncTypeLoc
params, a random crash is triggered. The bug fix is to
check against FuncTypeLoc.NumParams before accessing
FuncTypeLoc.getParam(Idx).

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

2 years ago[AArch64][GISel] Optimize 8 and 16 bit variants of uaddo.
Florian Hahn [Fri, 5 Nov 2021 16:45:49 +0000 (17:45 +0100)]
[AArch64][GISel] Optimize 8 and 16 bit variants of uaddo.

Try simplify G_UADDO with 8 or 16 bit operands to wide G_ADD and TBNZ if
result is only used in the no-overflow case. It is restricted to cases
where we know that the high-bits of the operands are 0. If there's an
overflow, then the the 9th or 17th bit must be set, which can be checked
using TBNZ.

Reviewed By: paquette

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

2 years ago[mlir] Add callback to provide a pass pipeline to MlirOptMain
Deepak Panickal [Fri, 5 Nov 2021 17:39:57 +0000 (17:39 +0000)]
[mlir] Add callback to provide a pass pipeline to MlirOptMain

The callback can be used to provide a default pass pipeline.

Reviewed By: mehdi_amini, rriddle

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

2 years ago[RISCV] Support Zfhmin extension
Shao-Ce SUN [Fri, 5 Nov 2021 17:39:14 +0000 (01:39 +0800)]
[RISCV] Support Zfhmin extension

According to RISC-V Unprivileged ISA 15.6.

Reviewed By: asb

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

2 years ago[libomptarget] Drop remote plugin cmake version requirement to match llvm
Jon Chesterfield [Fri, 5 Nov 2021 17:34:27 +0000 (17:34 +0000)]
[libomptarget] Drop remote plugin cmake version requirement to match llvm

LLVM docs at https://llvm.org/docs/CMake.html#quick-start state 3.13.4

Reviewed By: atmnpatel

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

2 years ago[AIX][Clang] Fix XL product name in AIX XL compatibility warning
Zarko Todorovski [Fri, 5 Nov 2021 16:37:42 +0000 (12:37 -0400)]
[AIX][Clang] Fix XL product name in AIX XL compatibility warning

Correct the XLC/C++ version in the warning message to use the information from
XL's -qversion output.

Reviewed By: rzurob

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

2 years ago[mlir][sparse] test for SIMD reduction chaining in consecutive vector loops
Aart Bik [Thu, 4 Nov 2021 16:22:34 +0000 (09:22 -0700)]
[mlir][sparse] test for SIMD reduction chaining in consecutive vector loops

Reviewed By: bixia

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

2 years agosanitizer: Fix -Wpedantic GCC warning
Martin Liska [Fri, 5 Nov 2021 16:04:12 +0000 (17:04 +0100)]
sanitizer: Fix -Wpedantic GCC warning

Fixes:
sanitizer_stacktrace.h:212:5: warning: ISO C++ forbids braced-groups within expressions [-Wpedantic]

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

2 years ago[llvm-readobj] Display DT_RELRSZ/DT_RELRENT as " (bytes)"
Fangrui Song [Fri, 5 Nov 2021 17:02:49 +0000 (10:02 -0700)]
[llvm-readobj] Display DT_RELRSZ/DT_RELRENT as " (bytes)"

to match RELSZ/RELENT.

Reviewed By: jhenderson

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

2 years ago[gn build] Use `=` for of -fdebug-compilation-dir
Nico Weber [Fri, 5 Nov 2021 16:43:06 +0000 (12:43 -0400)]
[gn build] Use `=` for of -fdebug-compilation-dir

-f flags usually use the `=` form. -fdebug-compilation-dir= has been
around for a few months now (since 0c2bb6b446c584ab, both LLVM 12.0
and 13.0 have it), so using it shouldn't be a big problem -- especially
since use_relative_paths_in_debug_info is opt-in anyways.

2 years ago[polly] Properly create and initialize new PM analysis managers
Arthur Eubanks [Fri, 5 Nov 2021 16:31:14 +0000 (09:31 -0700)]
[polly] Properly create and initialize new PM analysis managers

If we don't properly initialize all the analysis managers, we may be
missing analyses that other analyses depend on.

Fixes broken polly test, e.g.
https://lab.llvm.org/buildbot/#/builders/10/builds/7501.

2 years ago[clang] [Objective C] Inclusive language: use objcmt-allowlist-dir-path=<arg> instead...
Zarko Todorovski [Fri, 5 Nov 2021 15:27:59 +0000 (11:27 -0400)]
[clang] [Objective C] Inclusive language: use objcmt-allowlist-dir-path=<arg> instead of objcmt-white-list-dir-path=<arg>

Trying to update some options that don't at least have an inclusive language version.
This patch adds `objcmt-allowlist-dir-path` as a default alternative.

Reviewed By: akyrtzi

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

2 years ago[NFCI] InstructionTest: trim `InstructionsTest.ShuffleMaskIsReplicationMask_*` complexity
Roman Lebedev [Fri, 5 Nov 2021 16:22:27 +0000 (19:22 +0300)]
[NFCI] InstructionTest: trim `InstructionsTest.ShuffleMaskIsReplicationMask_*` complexity

These tests have pretty high O() complexity due to their nature,
which leads to potentially-long runtimes.

While in release build for me they took ~1 and ~2 sec,
as noted in https://reviews.llvm.org/D113214#inline-1080479
they take minutes in debug build.

Fine-tune the amount of permutations they deal with,
without affecting the test coverage. After this,
they take <~10ms each for me (in release build),
hopefully that is good-enough for debug build too.

2 years ago[NFC] Fix typo in comment for `isReplicationMask()`
Roman Lebedev [Fri, 5 Nov 2021 16:13:06 +0000 (19:13 +0300)]
[NFC] Fix typo in comment for `isReplicationMask()`

This was mentioned in https://reviews.llvm.org/D113214#inline-1080385
but i forgot to stage the change before committing.

2 years ago[Target] Use make_early_inc_range (NFC)
Kazu Hirata [Fri, 5 Nov 2021 16:14:32 +0000 (09:14 -0700)]
[Target] Use make_early_inc_range (NFC)

2 years agoAdd NoOpLoopNestPass and LOOPNEST_PASS macro
Whitney Tsang [Fri, 5 Nov 2021 15:19:56 +0000 (15:19 +0000)]
Add NoOpLoopNestPass and LOOPNEST_PASS macro

Having a NoOpLoopNestPass can ensure that only outermost loop is invoked
for a LoopNestPass with a lit test.

There are some existing passes that are implemented as LoopNestPass, but
they are still using LOOP_PASS macro.
It would be easier to identify LoopNestPasses with a LOOPNEST_PASS
macro.

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

2 years ago[RISCV] Enable FP extensions and ABI on fixed-vectors-bitcast.ll.
Craig Topper [Thu, 4 Nov 2021 21:55:22 +0000 (14:55 -0700)]
[RISCV] Enable FP extensions and ABI on fixed-vectors-bitcast.ll.

This improves our type coverage. We were only testing integer
insert and extract before due to the FP types not being enabled for
arguments and returns.

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

2 years ago[BranchRelaxation] Fix warning on unused variable. NFC.
Michael Liao [Fri, 5 Nov 2021 14:47:10 +0000 (10:47 -0400)]
[BranchRelaxation] Fix warning on unused variable. NFC.

2 years ago[InstCombine] Generalize sadd.sat combine to compute sign bits.
David Green [Fri, 5 Nov 2021 15:05:09 +0000 (15:05 +0000)]
[InstCombine] Generalize sadd.sat combine to compute sign bits.

There is a combine in instcombine to transform a saturated add/sub into
a saddsat/ssubsat, currently handling inputs which are both sign
extended (https://alive2.llvm.org/ce/z/68qpTn). This can generalize to,
for example ashr of at least the bitwidth (https://alive2.llvm.org/ce/z/4TFyX-
and https://alive2.llvm.org/ce/z/qDWzFs for example). Which means it
generalizes further to "the number of sign bits", needing to be enough
to truncate to the size of the saturate. (An example using `or` for
instance: https://alive2.llvm.org/ce/z/EI_h_A).

So this patch makes use of ComputeNumSignBits (with the newly added
ComputeMinSignedBits) in matchSAddSubSat to generalize the fold to any
inputs with enough sign bits known, truncating the inputs to the new
size of the saturate.

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

2 years ago[fir] Add fir.extract_value and fir.insert_value conversion
Valentin Clement [Fri, 5 Nov 2021 14:52:50 +0000 (15:52 +0100)]
[fir] Add fir.extract_value and fir.insert_value conversion

This patch add the conversion pattern for fir.extract_value
and fir.insert_value. fir.extract_value is lowered to llvm.extractvalue
anf fir.insert_value is lowered to llvm.insertvalue.
This patch also adds the type conversion for the BoxType and RecordType
needed to have some comprehensive tests.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: awarzynski

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2 years ago[gn build] Reformat all files
Nico Weber [Fri, 5 Nov 2021 14:50:24 +0000 (10:50 -0400)]
[gn build] Reformat all files

Ran `git ls-files '*.gn' '*.gni' | xargs llvm/utils/gn/gn.py format`.
No behavior change.

2 years ago[clang] 'unused-but-set-variable' warning should not apply to __block objective-c...
Alex Lorenz [Fri, 5 Nov 2021 05:01:33 +0000 (22:01 -0700)]
[clang] 'unused-but-set-variable' warning should not apply to __block objective-c pointers

The __block Objective-C pointers can be set but not used due to a commonly used lifetime extension pattern in Objective-C.

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

2 years ago[gn build] Use build-machine-independent paths in coverage information
Nico Weber [Fri, 5 Nov 2021 14:42:07 +0000 (10:42 -0400)]
[gn build] Use build-machine-independent paths in coverage information

This is possible after D106314 / 8773822c578a.

Makes the required prepare-code-coverage-artifact.py invocation a bit longer,
but that seems like a good tradeoff.

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

2 years agoExtend timeout of llvm/unittests:ir_tests
Tres Popp [Fri, 5 Nov 2021 14:42:47 +0000 (15:42 +0100)]
Extend timeout of llvm/unittests:ir_tests

This test became much slower after 01d8759ac9

2 years ago[ValueTracking][InstCombine] Introduce and use ComputeMinSignedBits
David Green [Fri, 5 Nov 2021 14:41:37 +0000 (14:41 +0000)]
[ValueTracking][InstCombine] Introduce and use ComputeMinSignedBits

This introduces a new ComputeMinSignedBits method for ValueTracking that
returns the BitWidth - SignBits + 1 from ComputeSignBits, and represents
the minimum bit size for the value as a signed integer.  Similar to the
existing APInt::getMinSignedBits method, this can make some of the
reasoning around ComputeSignBits more natural.

See https://reviews.llvm.org/D112298

2 years ago[DAG] FoldConstantVectorArithmetic - remove SDNodeFlags argument
Simon Pilgrim [Fri, 5 Nov 2021 14:36:17 +0000 (14:36 +0000)]
[DAG] FoldConstantVectorArithmetic - remove SDNodeFlags argument

Another minor step towards merging FoldConstantVectorArithmetic into FoldConstantArithmetic.

We don't use SDNodeFlags in any constant folding inside DAG, so passing the Flags argument is a waste of time - an alternative would be to wire up FoldConstantArithmetic to take SDNodeFlags just-in-case we someday start using it, but we don't have any way to test it and I'd prefer to avoid dead code.

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

2 years ago[X86] `X86TTIImpl::getInterleavedMemoryOpCostAVX512()`: mask is i8 not i1
Roman Lebedev [Fri, 5 Nov 2021 14:26:21 +0000 (17:26 +0300)]
[X86] `X86TTIImpl::getInterleavedMemoryOpCostAVX512()`: mask is i8 not i1

Even though AVX512's masked mem ops (unlike AVX1/2) have a mask
that is a `VF x i1`, replication of said masks happens after
promotion of it to `VF x i8`, so we should use `i8`, not `i1`,
when calculating the cost of mask replication.

2 years ago[DAGCombiner] add fold for vselect based on mask of signbit
Sanjay Patel [Fri, 5 Nov 2021 13:25:54 +0000 (09:25 -0400)]
[DAGCombiner] add fold for vselect based on mask of signbit

(X s< 0) ? Y : 0 --> (X s>> BW-1) & Y

We canonicalize to the icmp+select form in IR, and we already have this fold
for scalar select in SDAG, so I think it's an oversight that we don't have
the fold for vectors. It seems neutral for AArch64 and saves some instructions
on x86.

Whether we should also have the sibling folds for the inverse condition or
all-ones true value may depend on target-specific factors such as whether
there's an "and-not" instruction.

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

2 years ago[AArch64] add tests for vector select; NFC
Sanjay Patel [Thu, 4 Nov 2021 18:22:41 +0000 (14:22 -0400)]
[AArch64] add tests for vector select; NFC

2 years ago[x86] add tests for vector select; NFC
Sanjay Patel [Thu, 4 Nov 2021 17:58:41 +0000 (13:58 -0400)]
[x86] add tests for vector select; NFC

2 years ago[InstCombine] add signbit tests for icmp with trunc; NFC
Sanjay Patel [Wed, 3 Nov 2021 18:50:17 +0000 (14:50 -0400)]
[InstCombine] add signbit tests for icmp with trunc; NFC

2 years ago[gn build] Port 7a98761d74db
LLVM GN Syncbot [Fri, 5 Nov 2021 13:54:25 +0000 (13:54 +0000)]
[gn build] Port 7a98761d74db

2 years ago[IR][ShuffleVector] Introduce `isReplicationMask()` matcher
Roman Lebedev [Fri, 5 Nov 2021 13:50:24 +0000 (16:50 +0300)]
[IR][ShuffleVector] Introduce `isReplicationMask()` matcher

Avid readers of this saga may recall from previous installments,
that replication mask replicates (lol) each of the `VF` elements
in a vector `ReplicationFactor` times. For example, the mask for
`ReplicationFactor=3` and `VF=4` is: `<0,0,0,1,1,1,2,2,2,3,3,3>`.
More importantly, replication mask is used by LoopVectorizer
when using masked interleaved memory operations.

As discussed in previous installments, while it is used by LV,
and we **seem** to support masked interleaved memory operations on X86,
it's support in cost model leaves a lot to be desired:
until basically yesterday even for AVX512 we had no cost model for it.

As it has been witnessed in the recent
AVX2 `X86TTIImpl::getInterleavedMemoryOpCost()`
costmodel patches, while it is hard-enough to query the cost
of a particular assembly sequence [from llvm-mca],
afterwards the check lines LV costmodel tests must be updated manually.
This is, at the very least, boring.

Okay, now we have decent costmodel coverage for interleaving shuffles,
but now basically the same mind-killing sequence has to be performed
for replication mask. I think we can improve at least the second half
of the problem, by teaching
the `TargetTransformInfoImplCRTPBase::getUserCost()` to recognize
`Instruction::ShuffleVector` that are repetition masks,
adding exhaustive test coverage
using `-cost-model -analyze` + `utils/update_analyze_test_checks.py`

This way we can have good exhaustive coverage for cost model,
and only basic coverage for the LV costmodel.

This patch adds precise undef-aware `isReplicationMask()`,
with exhaustive test coverage.
* `InstructionsTest.ShuffleMaskIsReplicationMask` shows that
   it correctly detects all the known masks.
* `InstructionsTest.ShuffleMaskIsReplicationMask_undef`
  shows that replacing some mask elements in a known replication mask
  still allows us to recognize it as a replication mask.
  Note, with enough undef elts, we may detect a different tuple.
* `InstructionsTest.ShuffleMaskIsReplicationMask_Exhaustive_Correctness`
  shows that if we detected the replication mask with given params,
  then if we actually generate a true replication mask with said params,
  it matches element-wise ignoring undef mask elements.

Reviewed By: spatel

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

2 years ago[NFC] Move CombinationGenerator from Exegesis to ADT
Roman Lebedev [Fri, 5 Nov 2021 13:50:23 +0000 (16:50 +0300)]
[NFC] Move CombinationGenerator from Exegesis to ADT

Reviewed By: courbet

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

2 years ago[AArch64] Add target DAG combine for UUNPKHI/LO
David Sherwood [Thu, 4 Nov 2021 15:20:16 +0000 (15:20 +0000)]
[AArch64] Add target DAG combine for UUNPKHI/LO

When created a UUNPKLO/HI node with an undef input then the
output should also be undef. I've added a target DAG combine
function to ensure we avoid creating an unnecessary uunpklo/hi
instruction.

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

2 years ago[NFC] Inclusive language: Remove instances of master in URLs
Quinn Pham [Wed, 3 Nov 2021 19:41:24 +0000 (14:41 -0500)]
[NFC] Inclusive language: Remove instances of master in URLs

[NFC] This patch fixes URLs containing "master". Old URLs were either broken or
redirecting to the new URL.

Reviewed By: #libc, ldionne, mehdi_amini

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

2 years ago[DAG] FoldConstantArithmetic - rename NumOps -> NumElts. NFC.
Simon Pilgrim [Fri, 5 Nov 2021 13:18:53 +0000 (13:18 +0000)]
[DAG] FoldConstantArithmetic - rename NumOps -> NumElts. NFC.

NumOps represents the number of elements for vector constant folding, rename this NumElts so in future we can the consistently use NumOps to represent the number of operands of the opcode.

Minor cleanup before trying to begin generalizing FoldConstantArithmetic to support opcodes other than binops.

2 years ago[gn build] (manually) port df0ba47c36f
Nico Weber [Fri, 5 Nov 2021 13:17:59 +0000 (09:17 -0400)]
[gn build] (manually) port df0ba47c36f

2 years ago[AArch64] Fix a bug from a pattern for uaddv(uaddlp(x)) ==> uaddlv
Jingu Kang [Fri, 5 Nov 2021 10:59:42 +0000 (10:59 +0000)]
[AArch64] Fix a bug from a pattern for uaddv(uaddlp(x)) ==> uaddlv

A pattern has selected wrong uaddlv MI. It should be as below.

uaddv(uaddlp(v8i8)) ==> uaddlv(v8i8)

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

2 years ago[FreeBSD] Do not mark __stack_chk_guard as dso_local
Alfredo Dal'Ava Junior [Fri, 5 Nov 2021 12:23:24 +0000 (07:23 -0500)]
[FreeBSD] Do not mark __stack_chk_guard as dso_local

This symbol is defined in libc.so so it is definitely not DSO-Local.
Marking it as such causes problems on some platforms (such as PowerPC).

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

2 years agoEnable -Wformat-pedantic and fix fallout.
Martin Liska [Thu, 4 Nov 2021 07:54:14 +0000 (08:54 +0100)]
Enable -Wformat-pedantic and fix fallout.

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

2 years ago[DAG] FoldConstantArithmetic - fold bitlogic(bitcast(x),bitcast(y)) -> bitcast(bitlog...
Simon Pilgrim [Fri, 5 Nov 2021 12:00:47 +0000 (12:00 +0000)]
[DAG] FoldConstantArithmetic - fold bitlogic(bitcast(x),bitcast(y)) -> bitcast(bitlogic(x,y))

To constant fold bitwise logic ops where we've legalized constant build vectors to a different type (e.g. v2i64 -> v4i32), this patch adds a basic ability to peek through the bitcasts and perform the constant fold on the inner operands.

The MVE predicate v2i64 regressions will be addressed by future support for basic v2i64 type support.

One of the yak shaving fixes for D113192....

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

2 years ago[InstCombine] Add additional tests for converting to sadd.sat with sign bits. NFC
David Green [Fri, 5 Nov 2021 12:00:03 +0000 (12:00 +0000)]
[InstCombine] Add additional tests for converting to sadd.sat with sign bits. NFC

2 years ago[fir] Add fir.select and fir.select_rank FIR to LLVM IR conversion patterns
Valentin Clement [Fri, 5 Nov 2021 11:54:12 +0000 (12:54 +0100)]
[fir] Add fir.select and fir.select_rank FIR to LLVM IR conversion patterns

The `fir.select` and `fir.select_rank` are lowered to llvm.switch.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: mehdi_amini

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2 years ago[LangRef][VP] Document vp.gather and vp.scatter intrinsics
Fraser Cormack [Mon, 1 Nov 2021 16:41:46 +0000 (16:41 +0000)]
[LangRef][VP] Document vp.gather and vp.scatter intrinsics

This patch fleshes out the missing documentation for the final two VP
intrinsics introduced in D99355: `llvm.vp.gather` and `llvm.vp.scatter`.
It does so mostly by deferring to the `llvm.masked.gather` and
`llvm.masked.scatter` intrinsics, respectively.

Reviewed By: simoll

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

2 years ago[mlir][python] fix constructor generation for optional operands in presence of segmen...
Alex Zinenko [Fri, 5 Nov 2021 11:05:02 +0000 (12:05 +0100)]
[mlir][python] fix constructor generation for optional operands in presence of segment attribute

The ODS-based Python op bindings generator has been generating incorrect
specification of the operand segment in presence if both optional and variadic
operand groups: optional groups were treated as variadic whereas they require
separate treatement. Make sure it is the case. Also harden the tests around
generated op constructors as they could hitherto accept the code for both
optional and variadic arguments.

Reviewed By: nicolasvasilache

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

2 years ago[X86] Enable v32i16 rotate lowering on non-BWI targets
Simon Pilgrim [Fri, 5 Nov 2021 11:00:19 +0000 (11:00 +0000)]
[X86] Enable v32i16 rotate lowering on non-BWI targets

Fixes one of the regressions in D113192

2 years ago[ARM] Extra MVE constant select test. NFC
David Green [Fri, 5 Nov 2021 10:57:38 +0000 (10:57 +0000)]
[ARM] Extra MVE constant select test. NFC

2 years ago[LangRef][VP] Document vp.load and vp.store intrinsics
Fraser Cormack [Mon, 1 Nov 2021 14:40:09 +0000 (14:40 +0000)]
[LangRef][VP] Document vp.load and vp.store intrinsics

This patch fleshes out the missing documentation for two of the VP
intrinsics introduced in D99355: `llvm.vp.load` and `llvm.vp.store`. It
does so mostly by deferring to the `llvm.masked.load` and
`llvm.masked.store` intrinsics, respectively.

Reviewed By: simoll

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

2 years ago[Sema][NFC] Add tests for builtin spaceship operator.
Clement Courbet [Fri, 5 Nov 2021 09:45:28 +0000 (10:45 +0100)]
[Sema][NFC] Add tests for builtin spaceship operator.

In preparation for D112453.

2 years ago[Polly][Isl] Use the function unsignedFromIslSize to manage a isl::size object. NFCI
Riccardo Mori [Fri, 5 Nov 2021 10:14:39 +0000 (11:14 +0100)]
[Polly][Isl] Use the function unsignedFromIslSize to manage a isl::size object. NFCI

This is part of an effort to reduce the differences between the custom C++ bindings used right now by polly in lib/External/isl/include/isl/isl-noxceptions.h and the official isl C++ interface.
In the official interface the type `isl::size` cannot be casted to an unsigned without previously having checked if it contains a valid value with the function `isl::size::is_error()`.
For this reason two helping functions have been added:
 - `IslAssert`: assert that no errors are present in debug builds and just disables the mandatory error check in non-debug builds
 - `unisgnedFromIslSIze`: cast the `isl::size` object to `unsigned`

Changes made:
 - Add the functions `IslAssert` and `unsignedFromIslSize`
 - Add the utility function `rangeIslSize()`
 - Retype `MaxDisjunctsInDomain` from `int` to `unsigned`
 - Retype `RunTimeChecksMaxAccessDisjuncts` from `int` to `unsigned`
 - Retype `MaxDimensionsInAccessRange` from `int` to `unsigned`
 - Replaced some usages of `isl_size` to `unsigned` since we aim not to use `isl_size` anymore
 - `isl-noexceptions.h` has been generated by https://github.com/patacca/isl/commit/e704f73c88f0b4d88e62e447bdb732cf5914094b

No functional change intended.

Reviewed By: Meinersbur

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

2 years ago[PowerPC] use correct selection for v16i8/v8i16 splat load
Chen Zheng [Fri, 5 Nov 2021 03:22:17 +0000 (03:22 +0000)]
[PowerPC] use correct selection for v16i8/v8i16 splat load

Reviewed By: nemanjai

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

2 years agoRevert "[TwoAddressInstructionPass] Update existing physreg live intervals"
Jay Foad [Fri, 5 Nov 2021 09:53:35 +0000 (09:53 +0000)]
Revert "[TwoAddressInstructionPass] Update existing physreg live intervals"

This reverts commit ec0e1e88d24fadb2cb22f431d66b22ee1b01cd43.

It was pushed by mistake.

2 years ago[AMDGPU] NFC formatting fixes in SIMemoryLegalizer
Jay Foad [Fri, 5 Nov 2021 08:22:09 +0000 (08:22 +0000)]
[AMDGPU] NFC formatting fixes in SIMemoryLegalizer

2 years ago[TwoAddressInstructionPass] Update existing physreg live intervals
Jay Foad [Thu, 4 Nov 2021 13:43:09 +0000 (13:43 +0000)]
[TwoAddressInstructionPass] Update existing physreg live intervals

In TwoAddressInstructionPass::processTiedPairs with
-early-live-intervals, update any preexisting physreg live intervals,
as well as virtreg live intervals. By default (without
-precompute-phys-liveness) physreg live intervals only exist for
registers that are live-in to some basic block.

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

2 years ago[mlir][linalg][bufferize] Move bufferizesToAliasOnly to extraClassDecls
Matthias Springer [Fri, 5 Nov 2021 08:47:44 +0000 (17:47 +0900)]
[mlir][linalg][bufferize] Move bufferizesToAliasOnly to extraClassDecls

By doing so, the method can no longer be reimplemented.

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

2 years agoFix `insertFunctionArguments()` block argument order.
Christian Sigg [Thu, 4 Nov 2021 08:05:53 +0000 (09:05 +0100)]
Fix `insertFunctionArguments()` block argument order.

Reviewed By: rriddle

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

2 years agoAdd Bazel support for LLVM_WINDOWS_PREFER_FORWARD_SLASH
Tres Popp [Fri, 5 Nov 2021 09:04:14 +0000 (10:04 +0100)]
Add Bazel support for LLVM_WINDOWS_PREFER_FORWARD_SLASH

This was added in df0ba47c36f6bd0865e3286853b76d37e037c2d7

2 years ago[PowerPC] Add intrinsic to convert between ppc_fp128 and fp128
Qiu Chaofan [Fri, 5 Nov 2021 08:58:38 +0000 (16:58 +0800)]
[PowerPC] Add intrinsic to convert between ppc_fp128 and fp128

ppc_fp128 and fp128 are both 128-bit floating point types. However, we
can't do conversion between them now, since trunc/ext are not allowed
for same-size fp types.

This patch adds two new intrinsics: llvm.ppc.convert.f128.to.ppcf128 and
llvm.convert.ppcf128.to.f128, to support such conversion.

Reviewed By: shchenz

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

2 years ago[Support] Allow configuring the preferred type of slashes on Windows
Martin Storsjö [Wed, 13 Oct 2021 12:18:32 +0000 (12:18 +0000)]
[Support] Allow configuring the preferred type of slashes on Windows

Default to preferring forward slashes when built for MinGW, as
many usecases, when e.g. Clang is used as a drop-in replacement
for GCC, requires the compiler to output paths with forward slashes.

Not all tests pass yet, if configuring to prefer forward slashes though.

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

2 years ago[Support] [Windows] Convert paths to the preferred form
Martin Storsjö [Tue, 5 Oct 2021 10:17:36 +0000 (10:17 +0000)]
[Support] [Windows] Convert paths to the preferred form

This normalizes most paths (except ones input from the user as command
line arguments) into the preferred form, if `real_style()` evaluates to
`windows_forward`.

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

2 years ago[Support] Add a new path style for Windows with forward slashes
Martin Storsjö [Mon, 4 Oct 2021 14:17:00 +0000 (17:17 +0300)]
[Support] Add a new path style for Windows with forward slashes

This behaves just like the regular Windows style, with both separator
forms accepted, but with get_separator() returning forward slashes.

Add a more descriptive name for the existing style, keeping the old
name around as an alias initially.

Add a new function `make_preferred()` (like the C++17
`std::filesystem::path` function with the same name), which converts
windows paths to the preferred separator form (while this one works on
any platform and takes a `path::Style` argument).

Contrary to `native()` (just like `make_preferred()` in `std::filesystem`),
this doesn't do anything at all on Posix, it doesn't try to reinterpret
backslashes into forward slashes there.

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

2 years agoRevert "[Attr] support btf_type_tag attribute"
Martin Storsjö [Fri, 5 Nov 2021 08:12:20 +0000 (10:12 +0200)]
Revert "[Attr] support btf_type_tag attribute"

This reverts commits 737e4216c537c33aab8ec51880f06b8a54325b94 and
ce7ac9e66aba2b937b3d3b5505ce6cc75dcc56ac.

After those commits, the compiler can crash with a reduced
testcase like this:

$ cat reduced.c
void a(*);
void a() {}
$ clang -c reduced.c -O2 -g

2 years ago[libunwind] Try to add --unwindlib=none while configuring and building libunwind
Martin Storsjö [Fri, 10 Sep 2021 19:14:48 +0000 (22:14 +0300)]
[libunwind] Try to add --unwindlib=none while configuring and building libunwind

If Clang is set up to link directly against libunwind (via the
--unwindlib option, or the corresponding builtin default option),
configuring libunwind will fail while bootstrapping (before the
initial libunwind is built), because every cmake test will
fail due to -lunwind not being found, and linking the shared library
will fail similarly.

Check if --unwindlib=none is supported, and add it in that case.
Using check_c_compiler_flag on its own doesn't work, because that only
adds the tested flag to the compilation command, and if -lunwind is
missing, the linking step would still fail - instead try adding it
to CMAKE_REQUIRED_FLAGS and restore the variable if it doesn't work.

This avoids having to pass --unwindlib=none while building libunwind.

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

2 years ago[NPM] Fix bug in llvm/utils/reduce_pipeline.py
Markus Lavin [Fri, 5 Nov 2021 07:38:57 +0000 (08:38 +0100)]
[NPM] Fix bug in llvm/utils/reduce_pipeline.py

Last minute changes in https://reviews.llvm.org/D110908 unfortunately
introduced a bug wrt automatic pipeline expansion. This patch fixes that
as well as gets rid of a few redundant variables.

Reviewed By: aeubanks

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

2 years ago[asan] compiler-rt version of D113143
Vitaly Buka [Fri, 5 Nov 2021 06:50:57 +0000 (23:50 -0700)]
[asan] compiler-rt version of D113143

2 years agoFix some issues with the gdb pretty printers for llvm::Twine
David Blaikie [Fri, 5 Nov 2021 03:45:29 +0000 (20:45 -0700)]
Fix some issues with the gdb pretty printers for llvm::Twine

Still some pending bugs, but at least ironed some things out.

2 years ago[Preprocessor] Fix newline before/after _Pragma.
Michael Kruse [Fri, 5 Nov 2021 05:03:26 +0000 (00:03 -0500)]
[Preprocessor] Fix newline before/after _Pragma.

The PragmaAssumeNonNullHandler (and maybe others) passes an invalid
SourceLocation to its callback, hence PrintPreprocessedOutput does not
know how many lines to insert between the previous token and the
pragma and does nothing.

With this patch we instead assume that the unknown token is on the same
line as the previous such that we can call the procedure that also emits
semantically significant whitespace.

Fixes bug reported here: https://reviews.llvm.org/D104601#3105044

2 years ago[Preprocessor] Fix warning: left and right subexpressions are identical. NFCI.
Michael Kruse [Fri, 5 Nov 2021 05:13:49 +0000 (00:13 -0500)]
[Preprocessor] Fix warning: left and right subexpressions are identical. NFCI.

This is reported by msvc as
warning C6287: redundant code: the left and right subexpressions are identical

EmittedDirectiveOnThisLine implies EmittedTokensOnThisLine
making this an NFC change. To be on the safe side and because both of
them are checked at other places as well, we continue to check both.

Compiler warning reported here:
https://reviews.llvm.org/D104601#2957333

2 years ago[PowerPC] address post-commit comments for D106555; NFC
Chen Zheng [Fri, 5 Nov 2021 05:02:23 +0000 (05:02 +0000)]
[PowerPC] address post-commit comments for D106555; NFC

Address namanjai post commit comments.

2 years ago[lld-macho] Replace LC_LINKER_OPTION parsing
Keith Smiley [Fri, 5 Nov 2021 02:53:18 +0000 (19:53 -0700)]
[lld-macho] Replace LC_LINKER_OPTION parsing

This removes the tablegen based parsing of LC_LINKER_OPTION since it can
only actually contain a very small number of potential arguments. In our
project with tablegen this took 5 seconds before.

This replaces https://reviews.llvm.org/D113075

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

2 years ago[mlir][linalg][bufferize] Separate pass from ComprehensiveBufferize
Matthias Springer [Fri, 5 Nov 2021 04:55:47 +0000 (13:55 +0900)]
[mlir][linalg][bufferize] Separate pass from ComprehensiveBufferize

This commit separates the bufferization from the bufferization pass in Linalg. This allows other dialects to use ComprehensiveBufferize more easily.

This commit mainly moves files to a new directory and adds a new build target.

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

2 years ago[lld-macho] Fix an assertion failure when -u specifies an undefined section$start...
Fangrui Song [Fri, 5 Nov 2021 04:28:33 +0000 (21:28 -0700)]
[lld-macho] Fix an assertion failure when -u specifies an undefined section$start symbol

This matches ld64. Also improve the test for `-dead_strip`.

Reviewed By: #lld-macho, Jez Ng

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

2 years ago[X86][MS-InlineAsm][test] Add triple in ms-inline-asm-array.ll
Shengchen Kan [Fri, 5 Nov 2021 03:02:10 +0000 (11:02 +0800)]
[X86][MS-InlineAsm][test] Add triple in ms-inline-asm-array.ll

Fix the LIT test fail on Mac, which is reported in D113096.

2 years ago[mlir][linalg][bufferize][NFC] Simplify AllocationCallbacks
Matthias Springer [Fri, 5 Nov 2021 02:55:15 +0000 (11:55 +0900)]
[mlir][linalg][bufferize][NFC] Simplify AllocationCallbacks

AllocationCallbacks functions allocate/deallocate only. They no longer set the insertion point.

This is in preparation of decoupling ComprehensiveBufferize from the Linalg dialect.

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

2 years ago[mlir][linalg][bufferize] Decouple BufferizationAliasInfo
Matthias Springer [Fri, 5 Nov 2021 02:40:12 +0000 (11:40 +0900)]
[mlir][linalg][bufferize] Decouple BufferizationAliasInfo

Move dialect-specific and analysis-specific function out of BufferizationAliasInfo. BufferizationAliasInfo's only job now is to keep track of aliases.

This is in preparation of futher decoupling ComprehensiveBufferize from various dialects.

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

2 years ago[mlir][linalg][bufferize] Add isWritable to op interface
Matthias Springer [Fri, 5 Nov 2021 02:29:46 +0000 (11:29 +0900)]
[mlir][linalg][bufferize] Add isWritable to op interface

By default, OpResult buffers are writable. But there are ops (e.g., ConstantOp) for which this is not the case.

The purpose of this commit is to further decouple Comprehensive Bufferize from the Standard dialect.

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

2 years ago[OpaquePtr] Fix initialization-order-fiasco
Vitaly Buka [Fri, 5 Nov 2021 02:26:25 +0000 (19:26 -0700)]
[OpaquePtr] Fix initialization-order-fiasco

Asan detects it after D112732.

2 years ago[mlir][linalg][bufferize] Add MemCpyFn to AllocationCallbacks struct
Matthias Springer [Fri, 5 Nov 2021 01:42:59 +0000 (10:42 +0900)]
[mlir][linalg][bufferize] Add MemCpyFn to AllocationCallbacks struct

This in preparation of decoupling BufferizableOpInterface, Comprehensive Bufferize and dialects.

The goal of this CL is to make `getResultBuffer` (and other `bufferize` functions) independent of `LinalgOps`.

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

2 years ago[NFC] Don't set rlimit in test with MSAN
Vitaly Buka [Fri, 5 Nov 2021 01:08:11 +0000 (18:08 -0700)]
[NFC] Don't set rlimit in test with MSAN

2 years ago[NFC] Disabled few tests with MemoryWithOrigins
Vitaly Buka [Fri, 5 Nov 2021 01:07:15 +0000 (18:07 -0700)]
[NFC] Disabled few tests with MemoryWithOrigins

They pass regular MemorySanitizer, but hang with origin
tracking.

2 years ago[X86][MS-InlineAsm] Add constraint *m for memory access w/ global var
Shengchen Kan [Wed, 3 Nov 2021 08:52:55 +0000 (16:52 +0800)]
[X86][MS-InlineAsm] Add constraint *m for memory access w/ global var

Constraint `*m` should be used when the address of a variable is passed
as a value. And the constraint is missing for MS inline assembly when sth
is written to the address of the variable.

The missing would cause FE delete the definition of the static varible,
and then result in "undefined reference to xxx" issue.

Reviewed By: xiangzhangllvm

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

2 years ago[lld-macho] Clear resolvedReads cache
Keith Smiley [Thu, 4 Nov 2021 16:42:57 +0000 (09:42 -0700)]
[lld-macho] Clear resolvedReads cache

https://reviews.llvm.org/D113153#3108083

smeenai, int3

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

2 years ago[mlir][linalg][bufferize] Remove redundant methods from op interface
Matthias Springer [Fri, 5 Nov 2021 00:35:14 +0000 (09:35 +0900)]
[mlir][linalg][bufferize] Remove redundant methods from op interface

These two methods are redundant and removed:
* `bufferizesToAliasOnly`: If not `bufferizesToMemoryRead` and not `bufferizesToMemoryWrite` but `getAliasingOpResult` returns a non-null value, we know that this OpOperand is alias-only. This method now has a default implementation and does not have to be implemented.
* `getInplaceableOpResult`: The analysis does not differentiate between "inplaceable" and "aliasing". The only thing that matters is whether or not OpOperand and OpResult are aliasing. That is the key property that makes buffer copies necessary.

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

2 years ago[mlir][sparse] implement full reduction "scalarization" across loop nests
Aart Bik [Wed, 3 Nov 2021 02:58:33 +0000 (19:58 -0700)]
[mlir][sparse] implement full reduction "scalarization" across loop nests

The earlier reduction "scalarization" was only applied to a chain of
*innermost* and *for* loops. This revision generalizes this to any
nesting of for- and while-loops. This implies that reductions can be
implemented with a lot less load and store operations. The chaining
is implemented with a forest of yield statements (but not as bad as
when we would also include the while-induction).

Fixes https://bugs.llvm.org/show_bug.cgi?id=52311

Reviewed By: bixia

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

2 years ago[ASan] Added stack safety support in address sanitizer.
Kirill Stoimenov [Thu, 4 Nov 2021 22:05:04 +0000 (15:05 -0700)]
[ASan] Added stack safety support in address sanitizer.

 Added and implemented -asan-use-stack-safety flag, which control if ASan would use the Stack Safety results to emit less code for operations which are marked as 'safe' by the static analysis.

Reviewed By: vitalybuka

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

2 years ago[NewPM] Make eager analysis invalidation per-adaptor
Arthur Eubanks [Wed, 3 Nov 2021 22:45:30 +0000 (15:45 -0700)]
[NewPM] Make eager analysis invalidation per-adaptor

Follow-up change to D111575.
We don't need eager invalidation on every adaptor. Most notably,
adaptors running passes that use very few analyses, or passes that
purely invalidate specific analyses.

Also allow testing of this via a pipeline string
"function<eager-inv>()".

The compile time/memory impact of this is very comparable to D111575.
https://llvm-compile-time-tracker.com/compare.php?from=9a2eec512a29df45c90c2fcb741e9d5c693b1383&to=b9f20bcdea138060967d95a98eab87ce725b22bb&stat=instructions

Reviewed By: nikic

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

2 years agoBPF: Support btf_type_tag attribute
Yonghong Song [Mon, 18 Oct 2021 04:26:15 +0000 (21:26 -0700)]
BPF: Support btf_type_tag attribute

A new kind BTF_KIND_TYPE_TAG is defined. The tags associated
with a pointer type are emitted in their IR order as modifiers.
For example, for the following declaration:
  int __tag1 * __tag1 __tag2 *g;
The BTF type chain will look like
  VAR(g) -> __tag1 --> __tag2 -> pointer -> __tag1 -> pointer -> int
In the above "->" means BTF CommonType.Type which indicates
the point-to type.

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

2 years agoCanonicalization for add to no-op if one of the inputs is zero
not-jenni [Thu, 4 Nov 2021 23:52:24 +0000 (16:52 -0700)]
Canonicalization for add to no-op if one of the inputs is zero

Reviewed By: rsuderman

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

2 years ago[libcxxabi] Fix NO_THREADS version of test_exception_storage.pass.cpp
Daniel McIntosh [Wed, 11 Aug 2021 18:54:16 +0000 (14:54 -0400)]
[libcxxabi] Fix NO_THREADS version of test_exception_storage.pass.cpp

`thread_code` returns param, which for NO_THREADS is going to be
`&thread_globals`. Thus, the return value will never be null. The test
was probably meant to check if `*thread_code(&thread_globals) == 0`.
However, to avoid the extra cast, and to bring the NO_THREADS version
more in line with the regular version of the test, this changes it to
check if thread_globals == 0 directly.

Reviewed By: ldionne, #libc_abi

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

2 years agoBPF: fix a buildbot test failure
Yonghong Song [Thu, 4 Nov 2021 23:06:12 +0000 (16:06 -0700)]
BPF: fix a buildbot test failure

Commit 737e4216c537 ("[Attr] support btf_type_tag attribute")
added btf_type_tag support in llvm. Buildbot reported a
failure with attr-btf_type_tag.ll.

  ; CHECK-NEXT: DW_AT_type (0x[[T1:[0-9]+]] "int ***")

  <stdin>:15:2: note: possible intended match here
   DW_AT_type (0x0000002f "int ***")

The pattern [0-9]+ is not enough to match 0000002f, we
need [0-9a-f]+. This patch fixed the issue.