platform/upstream/llvm.git
2 years ago[InstCombine] Canonicalize range test idiom
Nikita Popov [Sat, 6 Nov 2021 23:05:00 +0000 (00:05 +0100)]
[InstCombine] Canonicalize range test idiom

InstCombine converts range tests of the form (X > C1 && X < C2) or
(X < C1 || X > C2) into checks of the form (X + C3 < C4) or
(X + C3 > C4). It is possible to express all range tests in either
of these forms (with different choices of constants), but currently
neither of them is considered canonical. We may have equivalent
range tests using either ult or ugt.

This proposes to canonicalize all range tests to use ult. An
alternative would be to canonicalize to either ult or ugt depending
on the specific constants involved -- e.g. in practice we currently
generate ult for && style ranges and ugt for || style ranges when
going through the insertRangeTest() helper. In fact, the "clamp like"
fold was relying on this, which is why I had to tweak it to not
assume whether inversion is needed based on just the predicate.

Proof: https://alive2.llvm.org/ce/z/_SP_rQ

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

2 years ago[flang] Make subscript list argument a nullable pointer
peter klausler [Wed, 20 Oct 2021 23:01:52 +0000 (16:01 -0700)]
[flang] Make subscript list argument a nullable pointer

Component::CreatePointerDescriptor unconditionally expects a
vector of subscripts to be passed as an argument, but is called
from NAMELIST input with a null pointer.  Make that argument
a nullable pointer, move it to the end of the argument list,
and give it a default value of nullptr.

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

2 years ago[flang] Distinguish error/warning cases for bad jumps into constructs
Peter Klausler [Fri, 29 Oct 2021 23:23:22 +0000 (16:23 -0700)]
[flang] Distinguish error/warning cases for bad jumps into constructs

Previously, jumps to labels in constructs from exterior statements
would elicit only a warning.  Upgrade these to errors unless the
branch into the construct would enter into only DO, IF, and SELECT CASE
constructs, whose interiors don't scope variables or have other
set-up/tear-down semantics.  Branches into these "safe" constructs
are still errors if they're nested in an unsafe construct that doesn't
also enclose the exterior branch statement.

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

2 years ago[libc++] Trigger a rebuild of the CI Docker images
Louis Dionne [Mon, 8 Nov 2021 19:34:24 +0000 (14:34 -0500)]
[libc++] Trigger a rebuild of the CI Docker images

2 years agoExtend obj2yaml to optionally preserve raw __LINKEDIT/__DATA segments.
Adrian Prantl [Mon, 8 Nov 2021 19:29:04 +0000 (11:29 -0800)]
Extend obj2yaml to optionally preserve raw __LINKEDIT/__DATA segments.

I am planning to upstream MachOObjectFile code to support Darwin
chained fixups. In order to test the new parser features we need a way
to produce correct (and incorrect) chained fixups. Right now the only
tool that can produce them is the Darwin linker. To avoid having to
check in binary files, this patch allows obj2yaml to print a hexdump
of the raw LINKEDIT and DATA segment, which both allows to
bootstrap the parser and enables us to easily create malformed inputs
to test error handling in the parser.

This patch adds two new options to obj2yaml:

  -raw-data-segment
  -raw-linkedit-segment

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

2 years ago[ASTMatcher] Provide a definition for the lambdaCapture matcher
Benjamin Kramer [Mon, 8 Nov 2021 19:26:37 +0000 (20:26 +0100)]
[ASTMatcher] Provide a definition for the lambdaCapture matcher

This is an empty object, but depending on your optimizer settings the
compiler may emit a reference to the symbol.

2 years ago[flang] Fix crash in semantic error recovery situation
Peter Klausler [Tue, 2 Nov 2021 23:41:15 +0000 (16:41 -0700)]
[flang] Fix crash in semantic error recovery situation

A CHECK() in semantics is triggering when analyzing a program
with an undefined derived type pointer because the CHECK is
expecting a new error message to have been issued in a function
but not allowing for the case that a diagnostic could have been
produced earlier.  Adjust the predicate.

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

2 years agoAdd `LambdaCapture`-related matchers.
James King [Mon, 8 Nov 2021 18:39:00 +0000 (18:39 +0000)]
Add `LambdaCapture`-related matchers.

This provides better support for `LambdaCapture`s by making them first-
class and allowing them to be bindable. In addition, this implements several
`LambdaCapture`-related matchers. This does not update how lambdas are
traversed. As a result, something like trying to match `lambdaCapture()` by
itself will not work - it must be used as an inner matcher.

Reviewed By: aaron.ballman, sammccall

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

2 years ago[flang] Fix folding of EPSILON()
Peter Klausler [Fri, 29 Oct 2021 20:00:43 +0000 (13:00 -0700)]
[flang] Fix folding of EPSILON()

The value of EPSILON() was off by one power of two due to my
misreading of the standard; this patch corrects it.
Confirmed by checking other Fortran compilers, which all agree.

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

2 years ago[openmp] Fix build, test passes on CI unexpectedly
Jon Chesterfield [Mon, 8 Nov 2021 18:45:10 +0000 (18:45 +0000)]
[openmp] Fix build, test passes on CI unexpectedly

2 years ago[llvm] Inclusive language: replace master with main in file paths in LIT tests
Quinn Pham [Wed, 27 Oct 2021 18:12:33 +0000 (13:12 -0500)]
[llvm] Inclusive language: replace master with main in file paths in LIT tests

[NFC] As part of using inclusive language within the llvm project, this patch
replaces master with main in file/directory paths in llvm LIT tests.

Reviewed By: bjope

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

2 years ago[OpenMP] Lower printf to __llvm_omp_vprintf
Jon Chesterfield [Mon, 8 Nov 2021 18:37:57 +0000 (18:37 +0000)]
[OpenMP] Lower printf to __llvm_omp_vprintf

Extension of D112504. Lower amdgpu printf to `__llvm_omp_vprintf`
which takes the same const char*, void* arguments as cuda vprintf and also
passes the size of the void* alloca which will be needed by a non-stub
implementation of `__llvm_omp_vprintf` for amdgpu.

This removes the amdgpu link error on any printf in a target region in favour
of silently compiling code that doesn't print anything to stdout.

The exact set of changes to check-openmp probably needs revision before commit

Reviewed By: jdoerfert

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

2 years ago[NFC][llvm-libtool-darwin] Clean up names
Roger Kim [Mon, 8 Nov 2021 18:26:50 +0000 (10:26 -0800)]
[NFC][llvm-libtool-darwin] Clean up names

Removing unclear abbreviations.

Reviewed By: jhenderson

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

2 years ago[NFC][llvm-libtool-darwin] Remove unnecessary conditionals around errors
Roger Kim [Mon, 8 Nov 2021 18:26:43 +0000 (10:26 -0800)]
[NFC][llvm-libtool-darwin] Remove unnecessary conditionals around errors

The existing code has unnecessary logic to indirectly pass
errors through function calls. This diff gets rid of the fluff.

Test Plan: Existing unit tests

Reviewed By: jhenderson, drodriguez, alexander-shaposhnikov

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

2 years ago[mlir][tosa] Spec v0.23 updates
Suraj Sudhir [Mon, 8 Nov 2021 18:13:42 +0000 (10:13 -0800)]
[mlir][tosa] Spec v0.23 updates

Add pad_const field to tosa.pad.
Add builders to enable optional construction of pad_const in pad op.
Update documentation of tosa.clamp to match spec wording.

Signed-off-by: Suraj Sudhir <suraj.sudhir@arm.com>
Reviewed By: rsuderman

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

2 years ago[flang] Complete the fix for NAMELIST look-ahead case
Peter Klausler [Wed, 3 Nov 2021 22:33:29 +0000 (15:33 -0700)]
[flang] Complete the fix for NAMELIST look-ahead case

When processing the devious NAMELIST input

  &group logarray = t t t
    = 666 /

for LOGICAL::logarray(3) and INTEGER::t, the runtime library
needs to do some look-ahead on the input stream to make sure
that the last "t" on the first line is a truth value rather than
an item name -- which in this case it is.  This look-ahead
was implemented in a previous patch but only worked for internal
input cases; this patch implements look-ahead capabilities for
input from an external file, too (and also adjusts repeated
list-directed input items to use this infrastructure, too).

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

2 years ago[Flang][driver] Update the docs
Andrzej Warzynski [Mon, 11 Oct 2021 20:03:54 +0000 (20:03 +0000)]
[Flang][driver] Update the docs

Please note that the updated documentation reflects the design that we are
working towards, but haven't implemented competely yet. We took this approach
in order to provide a more holisitic and complete overview of the design.

In particular, this document assumes that Flang's frontend and compiler
driver can already generate code. This is still work-in-progress and is
being developed on the `fir-dev` branch in the F18 repository [1].

[1] https://github.com/flang-compiler/f18-llvm-project/tree/fir-dev

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

2 years ago[NFC] Fix lit test failures for clang/CodegenCoroutines
hyeongyu kim [Mon, 8 Nov 2021 17:42:55 +0000 (02:42 +0900)]
[NFC] Fix lit test failures for clang/CodegenCoroutines

2 years ago[clang] Fortify warning for scanf calls with field width too big.
Michael Benfield [Thu, 14 Oct 2021 20:02:28 +0000 (20:02 +0000)]
[clang] Fortify warning for scanf calls with field width too big.

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

2 years ago[VPlan] Make sure recurrence splice is not inserted between phis.
Florian Hahn [Mon, 8 Nov 2021 17:42:32 +0000 (17:42 +0000)]
[VPlan] Make sure recurrence splice is not inserted between phis.

All phi-like recipes should be at the beginning of a VPBasicBlock with
no other recipes in between. Ensure that the recurrence-splicing recipe
is not added between phi-like recipes, but after them.

Reviewed By: Ayal

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

2 years ago[RISCV] SMUL_LOHI/UMUL_LOHI should expand for RVV.
Craig Topper [Mon, 8 Nov 2021 17:25:10 +0000 (09:25 -0800)]
[RISCV] SMUL_LOHI/UMUL_LOHI should expand for RVV.

These and MULHS/MULHU both default to Legal. Targets need to set
the ones they don't support to Expand.

I think MULHS/MULHU likely has priority in most places so this
change probably isn't directly testable. I found it while looking
at disabling MULHS/MULHU for nxvXi64 as required for Zve64x.

Reviewed By: frasercrmck

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

2 years ago[MLIR] Attribute and type formats in ODS
Jeff Niu [Fri, 15 Oct 2021 21:39:07 +0000 (21:39 +0000)]
[MLIR] Attribute and type formats in ODS

Declarative attribute and type formats with assembly formats. Define an
`assemblyFormat` field in attribute and type defs with a `mnemonic` to
generate a parser and printer.

```tablegen
def MyAttr : AttrDef<MyDialect, "MyAttr"> {
  let parameters = (ins "int64_t":$count, "AffineMap":$map);
  let mnemonic = "my_attr";
  let assemblyFormat = "`<` $count `,` $map `>`";
}
```

Use `struct` to define a comma-separated list of key-value pairs:

```tablegen
def MyType : TypeDef<MyDialect, "MyType"> {
  let parameters = (ins "int":$one, "int":$two, "int":$three);
  let mnemonic = "my_attr";
  let assemblyFormat = "`<` $three `:` struct($one, $two) `>`";
}
```

Use `struct(*)` to capture all parameters.

Reviewed By: rriddle

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

2 years ago[mlir][vector] Use dyn_cast instead of cast in patterns
Lei Zhang [Mon, 8 Nov 2021 17:33:55 +0000 (12:33 -0500)]
[mlir][vector] Use dyn_cast instead of cast in patterns

This avoids crashes when the pattern is applied to ops with
tensor semantics.

Reviewed By: ThomasRaoux

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

2 years agoRevert "[Clang/Test]: Rename enable_noundef_analysis to disable-noundef-analysis...
hyeongyu kim [Mon, 8 Nov 2021 17:09:49 +0000 (02:09 +0900)]
Revert "[Clang/Test]: Rename enable_noundef_analysis to disable-noundef-analysis and turn it off by default"

This reverts commit aacfbb953eb705af2ecfeb95a6262818fa85dd92.

Revert "Fix lit test failures in CodeGenCoroutines"

This reverts commit 63fff0f5bffe20fa2c84a45a41161afa0043cb34.

2 years ago[llvm] Use make_early_inc_range (NFC)
Kazu Hirata [Mon, 8 Nov 2021 17:09:39 +0000 (09:09 -0800)]
[llvm] Use make_early_inc_range (NFC)

2 years ago[LV] Use VScaleForTuning to fine-tune the cost per lane.
Sander de Smalen [Mon, 8 Nov 2021 15:24:31 +0000 (15:24 +0000)]
[LV] Use VScaleForTuning to fine-tune the cost per lane.

When targeting a specific CPU with scalable vectorization, the knowledge
of that particular CPU's vscale value can be used to tune the cost-model
and make the cost per lane less pessimistic.

If the target implements 'TTI.getVScaleForTuning()', the cost-per-lane
is calculated as:

  Cost / (VScaleForTuning * VF.KnownMinLanes)

Otherwise, it assumes a value of 1 meaning that the behavior
is unchanged and calculated as:

  Cost / VF.KnownMinLanes

Reviewed By: kmclaughlin, david-arm

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

2 years ago[fir] Add !fir.logical type conversion
Valentin Clement [Mon, 8 Nov 2021 16:52:22 +0000 (17:52 +0100)]
[fir] Add !fir.logical type conversion

Add conversion from !fir.logical types to LLVM IR Dialect types.

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

Reviewed By: kiranchandramohan

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2 years agoRevert "Making the code compliant to the documentation about Floating Point"
Aaron Ballman [Mon, 8 Nov 2021 16:43:49 +0000 (11:43 -0500)]
Revert "Making the code compliant to the documentation about Floating Point"

This reverts commit 438437cbb61a39ce27b3d6218ac426b8f8a0132e.

There are still broken bots from this:

https://lab.llvm.org/buildbot/#/builders/188/builds/5495
https://lab.llvm.org/buildbot/#/builders/171/builds/5710

2 years ago[ARM] Precommit i128 test from D111530
Simon Pilgrim [Mon, 8 Nov 2021 16:08:08 +0000 (16:08 +0000)]
[ARM] Precommit i128 test from D111530

2 years ago[gn build] Port 16b07c866ae7
LLVM GN Syncbot [Mon, 8 Nov 2021 15:59:52 +0000 (15:59 +0000)]
[gn build] Port 16b07c866ae7

2 years ago[clang-tidy] Add check for initialization of `absl::Cleanup`.
CJ Johnson [Mon, 8 Nov 2021 15:40:18 +0000 (15:40 +0000)]
[clang-tidy] Add check for initialization of `absl::Cleanup`.

Suggests switching the initialization pattern of `absl::Cleanup` instances from the factory function to class template argument deduction (CTAD) in C++17 and higher.

Reviewed By: ymandel

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

2 years ago[AMDGPU] Make getInstSizeInBytes more generic
Joe Nash [Fri, 5 Nov 2021 20:19:22 +0000 (16:19 -0400)]
[AMDGPU] Make getInstSizeInBytes more generic

NFC. This check mainly handles size affecting literals. Make it check all
explicit operands instead of a few by name. Also make the isLiteral
check handle the KIMM operands, see https://reviews.llvm.org/D111067

Change-Id: I1a362d55b2a10f5c74d445272e8b7829a8b77597

Reviewed By: arsenm

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

Change-Id: Ie6c688f30a71e0335d1c6dd1ff65019bd7ce684e

2 years ago[SCCP] Tune cast instruction handling for overdefined operand
Anton Afanasyev [Sun, 24 Oct 2021 19:43:12 +0000 (22:43 +0300)]
[SCCP] Tune cast instruction handling for overdefined operand

Extended value is known to be inside range smaller than full one.
Prevent SCCP to mark such value as overdefined.

Fixes PR52253

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

2 years ago[libc++][CI] Add AIX pipeline config
David Tenty [Tue, 19 Oct 2021 18:09:46 +0000 (14:09 -0400)]
[libc++][CI] Add AIX pipeline config

This changes adds the pipeline config for both 32-bit and 64-bit AIX targets. As well, we add a lit feature `LIBCXX-AIX-FIXME` which is used to mark the failing tests which remain to be investigated on AIX, so that the CI produces a clean build.

Reviewed By: #libc, ldionne

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

2 years ago[X86] combineMulToPMADDWD - use ComputeMinSignedBits(). NFCI.
Simon Pilgrim [Mon, 8 Nov 2021 15:02:27 +0000 (15:02 +0000)]
[X86] combineMulToPMADDWD - use ComputeMinSignedBits(). NFCI.

Use ComputeMinSignedBits() to ensure the mul source operands at least sign-extend down from the bottom 16 bits.

This will make it easier if/when we try to support handling of source types larger than 32-bits.

2 years ago[NFC][LoopVectorize] Make the createStepForVF interface more caller-friendly
David Sherwood [Wed, 3 Nov 2021 14:21:50 +0000 (14:21 +0000)]
[NFC][LoopVectorize] Make the createStepForVF interface more caller-friendly

The common use case for calling createStepForVF is currently something
like:

  Value *Step = createStepForVF(Builder, ConstantInt::get(Ty, UF), VF);

and it makes more sense to reduce overall lines of code and change the
function to let it create the constant instead. With my patch this
becomes:

  Value *Step = createStepForVF(Builder, Ty, VF, UF);

and the ConstantInt is created instead createStepForVF. A side-effect of
this is that the code in createStepForVF is also becomes simpler.

As part of this patch I've also replaced some calls to getRuntimeVF
with calls to createStepForVF, i.e.

  getRuntimeVF(Builder, Count->getType(), VFactor * UFactor) ->
  createStepForVF(Builder, Count->getType(), VFactor, UFactor)

because this feels semantically better.

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

2 years ago[LLVM][llvm-cfi] Inclusive language: replace uses of blacklist with ignorelist
Zarko Todorovski [Mon, 8 Nov 2021 14:44:26 +0000 (09:44 -0500)]
[LLVM][llvm-cfi] Inclusive language: replace uses of blacklist with ignorelist

Replace the description and file names for this argument. As far as I understand
this is a positional argument and I don't believe this changes breaks any existing
interfaces.

Reviewed By: hctim, MaskRay

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

2 years ago[nfc] Refactor CGGPUBuiltin to help review D112680
Jon Chesterfield [Mon, 8 Nov 2021 14:09:08 +0000 (14:09 +0000)]
[nfc] Refactor CGGPUBuiltin to help review D112680

2 years ago[AArch64][SVE] Add FP types to the supported SVE structure load/stores vector type...
Mindong Chen [Mon, 8 Nov 2021 14:27:35 +0000 (22:27 +0800)]
[AArch64][SVE] Add FP types to the supported SVE structure load/stores vector type list

This adds FP type support to the SVE Container type list as a supplement to D112303.

Reviewed By: peterwaller-arm, paulwalker-arm

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

2 years ago[NFC] Inclusive Language: change master to main for .chm files
Quinn Pham [Fri, 5 Nov 2021 17:33:13 +0000 (12:33 -0500)]
[NFC] Inclusive Language: change master to main for .chm files

[NFC] As part of using inclusive language within the llvm project,
this patch replaces master with main when referring to `.chm` files.

Reviewed By: teemperor

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

2 years ago[analyzer] Retrieve a value from list initialization of multi-dimensional array decla...
Denys Petrov [Fri, 22 Oct 2021 00:24:19 +0000 (03:24 +0300)]
[analyzer] Retrieve a value from list initialization of multi-dimensional array declaration.

Summary: Add support of multi-dimensional arrays in `RegionStoreManager::getBindingForElement`. Handle nested ElementRegion's getting offsets and checking for being in bounds. Get values from the nested initialization lists using obtained offsets.

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

2 years ago[DAG] Add SelectionDAG::ComputeMinSignedBits helper
Simon Pilgrim [Mon, 8 Nov 2021 14:12:35 +0000 (14:12 +0000)]
[DAG] Add SelectionDAG::ComputeMinSignedBits helper

As suggested on D113371, this adds a wrapper to SelectionDAG::ComputeNumSignBits, similar to the llvm::ComputeMinSignedBits wrapper.

I've included some usage, its not exhaustive, just the more obvious cases where the intention is obvious.

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

2 years ago[Test][SCCP] Precommit tests for PR52253
Anton Afanasyev [Sun, 24 Oct 2021 19:35:50 +0000 (22:35 +0300)]
[Test][SCCP] Precommit tests for PR52253

2 years ago[Test][SCCP] Update autogenerated test before precommit
Anton Afanasyev [Thu, 28 Oct 2021 14:21:51 +0000 (17:21 +0300)]
[Test][SCCP] Update autogenerated test before precommit

2 years ago[SVE][CodeGen] Improve codegen for some FP insert_subvector cases
David Sherwood [Fri, 5 Nov 2021 11:42:51 +0000 (11:42 +0000)]
[SVE][CodeGen] Improve codegen for some FP insert_subvector cases

When inserting an unpacked FP subvector into a packed vector we
can simply cast the unpacked value into a packed value, since
both types are legal for SVE. We can then use this as the input
for the UZP instruction. This avoids us expanding the operation
by going through the stack.

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

2 years agoMaking the code compliant to the documentation about Floating Point
Zahira Ammarguellat [Thu, 12 Aug 2021 20:13:16 +0000 (16:13 -0400)]
Making the code compliant to the documentation about Floating Point
support default values for C/C++. FPP-MODEL=PRECISE enables FFP-CONTRACT
FMA is enabled.

Fix for https://bugs.llvm.org/show_bug.cgi?id=50222

2 years ago[SPIR-V] Add SPIR-V triple and clang target info.
Anastasia Stulova [Mon, 8 Nov 2021 11:13:09 +0000 (11:13 +0000)]
[SPIR-V] Add SPIR-V triple and clang target info.

Add new triple and target info for â€˜spirv32’ and â€˜spirv64’ and,
thus, enabling clang (LLVM IR) code emission to SPIR-V target.

The target for SPIR-V is mostly reused from SPIR by derivation
from a common base class since IR output for SPIR-V is mostly
the same as SPIR. Some refactoring are made accordingly.

Added and updated tests for parts that are different between
SPIR and SPIR-V.

Patch by linjamaki (Henry Linjamäki)!

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

2 years agoRevert "Making the code compliant to the documentation about Floating Point"
Nico Weber [Mon, 8 Nov 2021 13:32:42 +0000 (08:32 -0500)]
Revert "Making the code compliant to the documentation about Floating Point"

This reverts commit 17d9560294eee1eae5e2d3ac1ab84f514318409e.
Breaks check-clang everywhere, see e.g.:
https://lab.llvm.org/buildbot/#/builders/105/builds/17229
https://lab.llvm.org/buildbot/#/builders/109/builds/25831
https://lab.llvm.org/buildbot/#/builders/188/builds/5493
https://lab.llvm.org/buildbot/#/builders/123/builds/7073

2 years ago[fir] Add fir.box type conversion
Valentin Clement [Mon, 8 Nov 2021 13:17:26 +0000 (14:17 +0100)]
[fir] Add fir.box type conversion

This patch add the `!fir.box` type conversion to llvm.
`fir.box` is converted to the descriptor as defined in the ISO_Fortran_binding.h
and the addendum defined in descriptor.h.

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

Reviewed By: awarzynski

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: V Donaldson <vdonaldson@nvidia.com>
2 years agoMaking the code compliant to the documentation about Floating Point
Zahira Ammarguellat [Thu, 12 Aug 2021 20:13:16 +0000 (16:13 -0400)]
Making the code compliant to the documentation about Floating Point
support default values for C/C++. FPP-MODEL=PRECISE enables FFP-CONTRACT
FMA is enabled.

Fix for https://bugs.llvm.org/show_bug.cgi?id=50222

2 years agoRevert "[IndVars] Pass TTI to replaceCongruentIVs"
Dmitry Makogon [Mon, 8 Nov 2021 12:35:14 +0000 (19:35 +0700)]
Revert "[IndVars] Pass TTI to replaceCongruentIVs"

This reverts commit db289340c841990055a164e8eb2a3b5ff25677bf.

The patch caused 2 crashes with expensive checks enabled.

2 years ago[AArch64][SVE] Combine FADD and FMUL aarch64 intrinsics to FMLA
Matt [Wed, 3 Nov 2021 11:31:41 +0000 (11:31 +0000)]
[AArch64][SVE] Combine FADD and FMUL aarch64 intrinsics to FMLA

This is a refinement to the work in
https://reviews.llvm.org/D111638

Fold (fadd p a (fmul p b c)) into (fma p a b c)

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

2 years ago[IndVars] Pass TTI to replaceCongruentIVs
Dmitry Makogon [Tue, 2 Nov 2021 15:19:51 +0000 (22:19 +0700)]
[IndVars] Pass TTI to replaceCongruentIVs

In IndVarSimplify after simplifying and extending loop IVs we call 'replaceCongruentIVs'.
This function optionally takes a TTI argument to be able to replace narrow IVs uses
with truncates of the widest one.
For some reason the TTI wasn't passed to the function, so it couldn't perform such
transform.
This patch fixes it.

Reviewed By: mkazantsev

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

2 years ago[DAG] Add BuildVectorSDNode::getConstantRawBits helper
Simon Pilgrim [Mon, 8 Nov 2021 12:07:26 +0000 (12:07 +0000)]
[DAG] Add BuildVectorSDNode::getConstantRawBits helper

We have several places where we need to extract the raw bits data from a BUILD_VECTOR node, so consolidate this to a single helper function that handles Undefs and Integer/FP constants, including implicit truncation.

This should make it easier to extend D113202 to handle more constant folding of bitcasted constant data.

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

2 years ago[mlir][linalg] Improve hoist padding buffer size computation.
Tobias Gysi [Mon, 8 Nov 2021 10:22:46 +0000 (10:22 +0000)]
[mlir][linalg] Improve hoist padding buffer size computation.

Adapt the Fourier Motzkin elimination to take into account affine computations happening outside of the cloned loop nest.

Depends On D112713

Reviewed By: nicolasvasilache

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

2 years ago[OpenMP] libomp: Fix handling of barrier pattern environment variables
@t-msn [Mon, 8 Nov 2021 12:01:19 +0000 (15:01 +0300)]
[OpenMP] libomp: Fix handling of barrier pattern environment variables

It is better to set all barrier patterns to use "dist" when at least
one environment variable specifies "dist". Otherwise if only one
environment is set to "dist" and others left blank inadvertently,
it would result in mixing dist barrier with default hyper barrier
pattern.

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

2 years ago[flang][CodeGen] Transform `fir.call` to `llvm.call`
Andrzej Warzynski [Fri, 5 Nov 2021 13:41:39 +0000 (13:41 +0000)]
[flang][CodeGen] Transform `fir.call` to `llvm.call`

This patch extends the `FIRToLLVMLowering` pass in Flang by adding a
hook to transform `fir.call` to `llvm.call`.

This is part of the upstreaming effort from the `fir-dev` branch in [1].

[1] https://github.com/flang-compiler/f18-llvm-project

Patch originally written by:
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: V Donaldson <vdonaldson@nvidia.com>
Differential Revision: https://reviews.llvm.org/D113278

2 years ago[VE] default to integrated asm in AsmInfo
Simon Moll [Mon, 8 Nov 2021 10:58:07 +0000 (11:58 +0100)]
[VE] default to integrated asm in AsmInfo

VE integrated asm has been the default in Clang. Also use the default setting for integrated asm in the backend.

Reviewed By: kaz7

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

2 years ago[AArch64] Precommit i256 test from D111530
Simon Pilgrim [Mon, 8 Nov 2021 10:47:45 +0000 (10:47 +0000)]
[AArch64] Precommit i256 test from D111530

2 years ago[mlir][linalg] Improve the padding packing loop computation.
Tobias Gysi [Mon, 8 Nov 2021 09:52:13 +0000 (09:52 +0000)]
[mlir][linalg] Improve the padding packing loop computation.

The revision updates the packing loop search in hoist padding. Instead of considering all loops in the backward slice, we now compute a separate backward slice containing the index computations only. This modification ensures we do not add packing loops that are not used to index the packed buffer due to spurious dependencies. One instance where such spurious dependencies can appear is the extract slice operation introduced between the tile loops of a double tiling.

Depends On D112412

Reviewed By: nicolasvasilache

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

2 years ago[AArch64] Combine fptoi.sat(fmul) to fixed point cvtf
David Green [Mon, 8 Nov 2021 10:07:34 +0000 (10:07 +0000)]
[AArch64] Combine fptoi.sat(fmul) to fixed point cvtf

We already have patterns for fptosi and fptoui plus fmul to fixed point
convert, this adds equivalent patterns for fptosi.sat and fptoui.sat,
which should apply equally well for the legal saturating variants.

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

2 years ago[flang] Set the addendum when establishing pointer section in descriptor
Jean Perier [Mon, 8 Nov 2021 10:04:20 +0000 (11:04 +0100)]
[flang] Set the addendum when establishing pointer section in descriptor

If the source has an addendum, the descriptor that is being established
to describe a section over the source needs to copy the addendum so that
derived type information is correctly set in the descriptor being
established.

This allows namelist IO with derived type to work correctly.

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

2 years ago[LoopVectorize] Permit fixed-width epilogue loops for scalable vector bodies
David Sherwood [Tue, 7 Sep 2021 10:20:41 +0000 (11:20 +0100)]
[LoopVectorize] Permit fixed-width epilogue loops for scalable vector bodies

At the moment in LoopVectorizationCostModel::selectEpilogueVectorizationFactor
we bail out if the main vector loop uses a scalable VF. This patch adds
support for generating epilogue vector loops using a fixed-width VF when the
main vector loop uses a scalable VF.

I've changed LoopVectorizationCostModel::selectEpilogueVectorizationFactor
so that we convert the scalable VF into a fixed-width VF and do profitability
checks on that instead. In addition, since the scalable and fixed-width VFs
live in different VPlans that means I had to change the calls to
LVP.hasPlanWithVFs so that we only pass in the fixed-width VF.

New tests added here:

  Transforms/LoopVectorize/AArch64/sve-epilog-vect.ll

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

2 years ago[PowerPC] Implement basic macro fusion in Power10
Qiu Chaofan [Mon, 8 Nov 2021 09:22:50 +0000 (17:22 +0800)]
[PowerPC] Implement basic macro fusion in Power10

Including basic fusion types around arithmetic and logical instructions.

Reviewed By: jsji

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

2 years ago[AArch64] Canonicalize X*(Y+1) or X*(1-Y) to madd/msub
Andrew Wei [Mon, 8 Nov 2021 08:28:31 +0000 (16:28 +0800)]
[AArch64] Canonicalize X*(Y+1) or X*(1-Y) to madd/msub

Performing the rearrangement for add/sub and mul instructions to match the madd/msub pattern

Reviewed By: dmgreen, sdesmalen, david-arm

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

2 years ago[libc++][NFC] Inline most of `__vector_base` into `vector`.
Konstantin Varlamov [Mon, 8 Nov 2021 08:10:13 +0000 (00:10 -0800)]
[libc++][NFC] Inline most of `__vector_base` into `vector`.

`__vector_base` exists for historical reasons and cannot be eliminated
entirely without breaking the ABI. Member variables are left
untouched -- this patch only does changes that clearly cannot affect the
ABI.

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

2 years agoRevert "[libc++] Always define a key function for std::bad_function_call in the dylib"
Konstantin Varlamov [Mon, 8 Nov 2021 08:44:17 +0000 (00:44 -0800)]
Revert "[libc++] Always define a key function for std::bad_function_call in the dylib"

This reverts commit bc74231756d6c317505a9fa4c5a269134687ae56. It was
committed accidentally.

2 years ago[fir] Add test for FIR types conversion
Valentin Clement [Mon, 8 Nov 2021 08:41:19 +0000 (09:41 +0100)]
[fir] Add test for FIR types conversion

Add a separate file to test FIR types conversion to LLVM types.
Conversion comes from `flang/lib/Optimizer/CodeGen/TypeConverter.h`

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

Reviewed By: kiranchandramohan, awarzynski

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

2 years ago[libc++] Always define a key function for std::bad_function_call in the dylib
Louis Dionne [Tue, 2 Nov 2021 19:14:48 +0000 (12:14 -0700)]
[libc++] Always define a key function for std::bad_function_call in the dylib

However, whether applications rely on the std::bad_function_call vtable
being in the dylib is still controlled by the ABI macro, since changing
that would be an ABI break.

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

2 years ago[AMDGPU] Test Commit. NFC
skc7 [Mon, 8 Nov 2021 05:37:19 +0000 (05:37 +0000)]
[AMDGPU] Test Commit. NFC

Reviewed By: hsmhsm

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

2 years ago[XCOFF][llvm-readobj] improve the relocation output.
Esme-Yi [Mon, 8 Nov 2021 03:15:52 +0000 (03:15 +0000)]
[XCOFF][llvm-readobj] improve the relocation output.

Summary:
1. implemented the unexpanded relocations output.
2. modified the expanded output format to align.

Reviewed By: shchenz, jhenderson

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

2 years ago[RISCV] Optimize (add (mul r, c0), c1)
Ben Shi [Tue, 5 Oct 2021 12:28:36 +0000 (12:28 +0000)]
[RISCV] Optimize (add (mul r, c0), c1)

Optimize (add (mul x, c0), c1) ->
         (add (mul (add x, c1/c0+1), c0), c1%c0-c0),
if c1/c0+1 and c1%c0-c0 are simm12, while c1 is not.

Optimize (add (mul x, c0), c1) ->
         (add (mul (add x, c1/c0-1), c0), c1%c0+c0),
if c1/c0-1 and c1%c0+c0 are simm12, while c1 is not.

Reviewed By: craig.topper, asb

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

2 years ago[PowerPC] comment for different input register classes; nfc
Chen Zheng [Mon, 8 Nov 2021 02:15:51 +0000 (02:15 +0000)]
[PowerPC] comment for different input register classes; nfc

Add comments to explain why XXPERMDIs and XXPERMDI have different input register
classes, vsfrc for XXPERMDIs and vsrc for XXPERMDI.

This addresses the comments in abandoned patch D113178, we keep using `f0` instead
of using `vs0` for XXPERMDIs on purpose.

2 years ago[CSKY] Add CSKY 16-bit instruction format and encoding
Zi Xuan Wu [Mon, 8 Nov 2021 02:02:15 +0000 (10:02 +0800)]
[CSKY] Add CSKY 16-bit instruction format and encoding

CSKY is a ARCH which supports mixture of 16-bit and 32-bit instructions natively,
and there is not an indivual predictor or feature to enable/disable 16-bit instruction.
So I think it's better to add 16-bit instruction early, and naturally to use 16-bit and 32-bit instructions.

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

2 years ago[AsmPrinter][ORE] use correct opcode name
Chen Zheng [Thu, 4 Nov 2021 07:47:39 +0000 (07:47 +0000)]
[AsmPrinter][ORE] use correct opcode name

Reviewed By: jsji

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

2 years ago[ORE][AsmPrinter] add testcase for D113173; NFC
Chen Zheng [Thu, 4 Nov 2021 07:39:29 +0000 (07:39 +0000)]
[ORE][AsmPrinter] add testcase for D113173; NFC

2 years ago[Transforms] Use make_early_inc_range (NFC)
Kazu Hirata [Mon, 8 Nov 2021 01:03:15 +0000 (17:03 -0800)]
[Transforms] Use make_early_inc_range (NFC)

2 years ago[X86][AVX2] Recognise 256-bit truncation shuffles and mask 256-bit source
Simon Pilgrim [Sun, 7 Nov 2021 21:24:55 +0000 (21:24 +0000)]
[X86][AVX2] Recognise 256-bit truncation shuffles and mask 256-bit source

For v8i16 shuffle patterns that are lowered with AND+PACKUS, check to see if the sources are from a 256-bit vector and perform the masking using BLENDW at the 256-bit level.

With the test changes we can see more examples of duplicate XMM/YMM zero vectors (PR26018) :(

2 years ago[fir] Add fir.extract_value and fir.insert_value conversion
Valentin Clement [Sun, 7 Nov 2021 13:43:00 +0000 (14:43 +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.

This patch was landed and reverted once.
TypeBuilderFunc getModel<Fortran::ISO::CFI_index_t>() was clashing
with getModel<long long> on windows since they both are 64 bits
signed interger. On linux CFI_index_t is long. Change CFI_index_t
to getModel<long>.

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[ConstantRange] Add exact union/intersect (NFC)
Nikita Popov [Sun, 7 Nov 2021 20:14:21 +0000 (21:14 +0100)]
[ConstantRange] Add exact union/intersect (NFC)

For some optimizations on comparisons it's necessary that the
union/intersect is exact and not a superset. Add methods that
return Optional<ConstantRange> only if the result is exact.

For the sake of simplicity this is implemented by comparing
the subset and superset approximations for now, but it should be
possible to do this more directly, as unionWith() and intersectWith()
already distinguish the cases where the result is imprecise for the
preferred range type functionality.

2 years ago[ConstantRange] Support zero size in isSizeLargerThan()
Nikita Popov [Sun, 7 Nov 2021 20:21:41 +0000 (21:21 +0100)]
[ConstantRange] Support zero size in isSizeLargerThan()

From an API perspective, it does not make a lot of sense that 0
is not a valid argument to this function. Add the exact check needed
to support it.

2 years ago[lldb] Remove failures case from TestTaggedPointerCmd
Jonas Devlieghere [Sun, 7 Nov 2021 18:39:11 +0000 (10:39 -0800)]
[lldb] Remove failures case from TestTaggedPointerCmd

Somehow every pointer looks like it's tagged on GreenDragon. Removing
the check to unblock the bot until we can get to the bottom of this.

2 years ago[AArch64] Rewrite and update fcvt-fixed.ll. NFC
David Green [Sun, 7 Nov 2021 18:11:49 +0000 (18:11 +0000)]
[AArch64] Rewrite and update fcvt-fixed.ll. NFC

This rewrites the fcvt-fixed.ll test case to be separate functions, not
one large function with volatile global stores. It also adds fp16 and
fptoi.sat testing at the same time.

2 years ago[BasicAA] Use index size instead of pointer size
Nikita Popov [Sat, 23 Oct 2021 20:50:24 +0000 (22:50 +0200)]
[BasicAA] Use index size instead of pointer size

When accumulating the GEP offset in BasicAA, we should use the
pointer index size rather than the pointer size.

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

2 years ago[AMDGPU] Remove unused declaration selectSMRD (NFC)
Kazu Hirata [Sun, 7 Nov 2021 17:53:18 +0000 (09:53 -0800)]
[AMDGPU] Remove unused declaration selectSMRD (NFC)

The function body proper was removed on Feb 20, 2019 in commit
79b5c3842b684f873d1ffad502336e973616ea51.

2 years ago[ARM, X86] Use MachineBasicBlock::{predecessors,successors} (NFC)
Kazu Hirata [Sun, 7 Nov 2021 17:53:16 +0000 (09:53 -0800)]
[ARM, X86] Use MachineBasicBlock::{predecessors,successors} (NFC)

2 years ago[AST, Analysis] Use llvm::reverse (NFC)
Kazu Hirata [Sun, 7 Nov 2021 17:53:14 +0000 (09:53 -0800)]
[AST, Analysis] Use llvm::reverse (NFC)

2 years ago[compiler-rt] Produce the right arch suffix for arm baremetal
Manoj Gupta [Sun, 7 Nov 2021 02:14:42 +0000 (19:14 -0700)]
[compiler-rt] Produce the right arch suffix for arm baremetal

D98452 introduced a mismatch between clang expectations for
builtin name for baremetal targets on arm. Fix it by
adding a case for baremetal. This now matches the output of
"clang -target armv7m-none-eabi -print-libgcc-file-name \
-rtlib=compiler-rt"

Reviewed By: mstorsjo

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

2 years ago[AVR] Remove a global initializer. NFCI.
Benjamin Kramer [Sun, 7 Nov 2021 15:30:03 +0000 (16:30 +0100)]
[AVR] Remove a global initializer. NFCI.

2 years ago[libc++][doc] Don't mention Prague twice.
Mark de Wever [Sun, 7 Nov 2021 15:21:05 +0000 (16:21 +0100)]
[libc++][doc] Don't mention Prague twice.

2 years ago[libc++] Make test_allocator constexpr-friendly for constexpr string/vector
Nikolas Klauser [Sun, 7 Nov 2021 15:11:24 +0000 (16:11 +0100)]
[libc++] Make test_allocator constexpr-friendly for constexpr string/vector

Make test_allocator etc. constexpr-friendly so they can be used to test constexpr string and possibly constexpr vector

Reviewed By: Quuxplusone, #libc, ldionne

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

2 years ago[SLP] Fix Wdocumentation warning - remove \returns from void function. NFC.
Simon Pilgrim [Sun, 7 Nov 2021 15:08:39 +0000 (15:08 +0000)]
[SLP] Fix Wdocumentation warning - remove \returns from void function. NFC.

2 years ago[X86] Update RET/LRET instruction to use the same naming convention as IRET (PR36876...
Simon Pilgrim [Sun, 7 Nov 2021 15:06:54 +0000 (15:06 +0000)]
[X86] Update RET/LRET instruction to use the same naming convention as IRET (PR36876). NFC

Be more consistent in the naming convention for the various RET instructions to specify in terms of bitwidth.

Helps prevent future scheduler model mismatches like those that were only addressed in D44687.

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

2 years agoPut implementation details into anonymous namespaces. NFCI.
Benjamin Kramer [Sun, 7 Nov 2021 14:18:30 +0000 (15:18 +0100)]
Put implementation details into anonymous namespaces. NFCI.

2 years ago[clang] Use llvm::reverse. NFCI.
Benjamin Kramer [Sun, 7 Nov 2021 13:24:33 +0000 (14:24 +0100)]
[clang] Use llvm::reverse. NFCI.

2 years ago[X86][AVX] Add missing X86ISD::VBROADCAST(v4f32 -> v8f32) isel pattern for AVX1 targets
Simon Pilgrim [Sun, 7 Nov 2021 12:59:35 +0000 (12:59 +0000)]
[X86][AVX] Add missing X86ISD::VBROADCAST(v4f32 -> v8f32) isel pattern for AVX1 targets

D109434 addressed the v2f64 -> v4f64 case, an internal test has found an equivalent crash for the v4f32 -> v8f32 case.

2 years ago[X86] Add AVX512 test coverage to vselect-zero.ll
Simon Pilgrim [Sun, 7 Nov 2021 12:44:01 +0000 (12:44 +0000)]
[X86] Add AVX512 test coverage to vselect-zero.ll

Noticed on D113212

2 years ago[DAG] SimplifyVBinOp - replace FoldConstantVectorArithmetic with FoldConstantArithmetic
Simon Pilgrim [Fri, 5 Nov 2021 14:59:14 +0000 (14:59 +0000)]
[DAG] SimplifyVBinOp - replace FoldConstantVectorArithmetic with FoldConstantArithmetic

Currently FoldConstantArithmetic only handles binops, so replacing other uses of FoldConstantVectorArithmetic (in particular for SETCC nodes), still require more work.

2 years ago[NFC][Docs] Add missing Doxygen group comments for LLVM-C
Mats Larsen [Sun, 7 Nov 2021 11:23:17 +0000 (12:23 +0100)]
[NFC][Docs] Add missing Doxygen group comments for LLVM-C

The LLVM-C API is relatively small so we've previously added doxygen tags
so it's easier to navigate the LLVM-C web docs. Over the years, more
headers were added without proper doxygen tags, effectively hiding them
from the main LLVM-C doxygen page. This patch adds comments to headers
which did not have them.

Reviewed By: lhames

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

2 years ago[sanitizer][aarch64] Add cast to drop reliance on the type of uc_mcontext.__reserved
Fangrui Song [Sun, 7 Nov 2021 06:26:05 +0000 (22:26 -0800)]
[sanitizer][aarch64] Add cast to drop reliance on the type of uc_mcontext.__reserved

https://sourceware.org/bugzilla/show_bug.cgi?id=22742
uc_mcontext.__reserved probably should not be considered user visible API but
unfortunate it is: it is the only way to access cpu states of some Linux
asm/sigcontext.h extensions. That said, the declaration may be
long double __reserved[256]; (used by musl)
instead of
unsigned char __reserved[4096] __attribute__((__aligned__(16))); (glibc)
to avoid dependency on a GNU variable attribute.