platform/upstream/llvm.git
2 years ago[lldb] Deobfuscate python-swigsafecast.swig
Pavel Labath [Thu, 18 Nov 2021 10:12:19 +0000 (11:12 +0100)]
[lldb] Deobfuscate python-swigsafecast.swig

This file was way more complicated than it needed to be.

This patch removes the automagic reference-to-pointer delegation and
replaces the template specializations with regular free functions
(taking reference arguments).

The reason I chose references is twofold:
- there are more arguments being passed by reference than by pointer
- the reference arguments make it more obvious that there is a lot of
  leaking going on in there.

Currently, the code was assuming that the pointer arguments have some
kind of a special meaning and that pointer functions take ownership of
their arguments, which isn't true (it's possible it was true at some
point in the past, I haven't done the archeology).

This makes it easier to implement proper lifetime management in
follow-up patches.

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

2 years ago[SCEV] Move mustprogress based no-self-wrap logic so it applies to all exit conditions
Philip Reames [Thu, 18 Nov 2021 18:05:04 +0000 (10:05 -0800)]
[SCEV] Move mustprogress based no-self-wrap logic so it applies to all exit conditions

This change moves logic which we'd added specifically for less than tests so that it applies to equalities and greater than tests as well. The basic idea is that if we can show an IV cycles infinitely through the same series on self-wrap, and that the exit condition must be taken to prevent UB, we can conclude that it must be taken before self-wrap and thus infer said flag.

The motivation here is simple loops with unsigned induction variables w/non-one steps and inequality tests. A toy example would be:
for (unsigned i = 0; i != N; i += 2) { body; }

If body contains no side effects, and this is a mustprogress function, we can assume that this must be a finite loop and thus that the exit count is N/2.

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

2 years ago[NFC][clang] Inclusive language: replace masterPort with mainPort
Quinn Pham [Tue, 9 Nov 2021 14:38:50 +0000 (08:38 -0600)]
[NFC][clang] Inclusive language: replace masterPort with mainPort

[NFC] This patch replaces `masterPort` with `mainPort` in these
testcases.

Reviewed By: ZarkoCA

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

2 years ago[mlir][Linalg] Do not return failure when all tile sizes are zero.
MaheshRavishankar [Thu, 18 Nov 2021 17:27:27 +0000 (09:27 -0800)]
[mlir][Linalg] Do not return failure when all tile sizes are zero.

Returning failure when tile sizes are all zero prevents the change in
the marker. This makes pattern rewriter run the pattern multiple times
only to exit when it hits a limit. Instead just clone the operation
(since tiling is essentially cloning in this case). Then the
transformation filter kicks in to avoid the pattern rewriter to be
invoked many times.

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

2 years ago[llvm] Use range-based for loops (NFC)
Kazu Hirata [Thu, 18 Nov 2021 17:09:52 +0000 (09:09 -0800)]
[llvm] Use range-based for loops (NFC)

2 years ago[flang] Skip `Fortran STOP:` before message when NO_STOP_MESSAGE is set
Jean Perier [Thu, 18 Nov 2021 17:06:19 +0000 (18:06 +0100)]
[flang] Skip `Fortran STOP:` before message when NO_STOP_MESSAGE is set

In 'STOP bye bye', do not print 'Fortran STOP:` before 'bye bye' when
NO_STOP_MESSAGE environment variable is set at runtime.

Also only exit with code 1 in StopStatementText if this is an ERROR STOP.
This matches other compiler behaviors.

Move STOP related unit tests in their own test file and add new tests to
cover this change.

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

2 years agoAdd a breadcrumb comment to make debugging a user error when using ./utils/update_ana...
Philip Reames [Thu, 18 Nov 2021 17:05:28 +0000 (09:05 -0800)]
Add a breadcrumb comment to make debugging a user error when using ./utils/update_analyze_test_checks.py easier.

We won't talk about how long it took me to figure this out.  The difference in batch vs interactive on the "did you mean to print bitcode" message made this confusing.

2 years ago[flang] Fix off-by-one results from folding MAXEXPONENT and MINEXPONENT
Peter Klausler [Mon, 15 Nov 2021 23:18:32 +0000 (15:18 -0800)]
[flang] Fix off-by-one results from folding MAXEXPONENT and MINEXPONENT

Every one was too low by one.

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

2 years ago[mlir][doc] Avoid name overlap that confuses copy_docs.sh (NFC)
Jacques Pienaar [Thu, 18 Nov 2021 17:03:10 +0000 (09:03 -0800)]
[mlir][doc] Avoid name overlap that confuses copy_docs.sh (NFC)

2 years ago[X86] LowerRotate - pull out repeated is ISD::ROTL check. NFC.
Simon Pilgrim [Thu, 18 Nov 2021 17:02:18 +0000 (17:02 +0000)]
[X86] LowerRotate - pull out repeated is ISD::ROTL check. NFC.

2 years ago[SCEV] Add test coverage for invertible functions of IVs
Philip Reames [Thu, 18 Nov 2021 16:56:35 +0000 (08:56 -0800)]
[SCEV] Add test coverage for invertible functions of IVs

2 years ago[Flang] Add a factory class for creating Complex Ops
Kiran Chandramohan [Thu, 18 Nov 2021 16:43:16 +0000 (16:43 +0000)]
[Flang] Add a factory class for creating Complex Ops

Use the factory class in the FIRBuilder.
Add unit tests for the factory class function and the convert function
of the Complex class.

Reviewed By: clementval, rovka

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2 years ago[Clang][SVE] Fix windows test breakage in 26f56438e3dab44cea4c8f16d4cb16e9424b02c6
Bradley Smith [Thu, 18 Nov 2021 16:50:16 +0000 (16:50 +0000)]
[Clang][SVE] Fix windows test breakage in 26f56438e3dab44cea4c8f16d4cb16e9424b02c6

2 years agoUnbreak test after D111899
Adrian Prantl [Thu, 18 Nov 2021 16:51:40 +0000 (08:51 -0800)]
Unbreak test after D111899

2 years ago[LoopVectorize] Check the number of uses of an FAdd before classifying as ordered
Kerry McLaughlin [Tue, 16 Nov 2021 16:30:54 +0000 (16:30 +0000)]
[LoopVectorize] Check the number of uses of an FAdd before classifying as ordered

checkOrderedReductions looks for Phi nodes which can be classified as in-order,
meaning they can be vectorised without unsafe math. In order to vectorise the
reduction it should also be classified as in-loop by getReductionOpChain, which
checks that the reduction has two uses.

In this patch, a similar check is added to checkOrderedReductions so that we
now return false if there are more than two uses of the FAdd instruction.
This fixes PR52515.

Reviewed By: fhahn, david-arm

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

2 years ago[flang][CodeGen] Transform `fir.field_index` to a sequence of LLVM MLIR
Andrzej Warzynski [Tue, 16 Nov 2021 08:36:05 +0000 (08:36 +0000)]
[flang][CodeGen] Transform `fir.field_index` to a sequence of LLVM MLIR

This patch extends the `FIRToLLVMLowering` pass in Flang by adding a
hook to transform `fir.field_index` to a sequence of LLVM MLIR
instructions.

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

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

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

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: Jean Perier <jperier@nvidia.com>
2 years ago[MLIR][GPU] Add target arguments to SerializeToHsaco
Krzysztof Drewniak [Wed, 17 Nov 2021 23:56:35 +0000 (23:56 +0000)]
[MLIR][GPU] Add target arguments to SerializeToHsaco

Compiling code for AMD GPUs requires knowledge of which chipset is
being targeted, especially if the code uses chipset-specific
intrinsics (which is the case in a downstream convolution generator).
This commit adds `target`, `chipset` and `features` arguments to the
SerializeToHsaco constructor to enable passing in this required
information.

It also amends the ROCm integration tests to pass in the target
chipset, which is set to the chipset of the first GPU on the system
executing the tests.

Reviewed By: mehdi_amini

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

2 years ago[mlir][doc] Rename doc to match previous name
Jacques Pienaar [Thu, 18 Nov 2021 16:23:49 +0000 (08:23 -0800)]
[mlir][doc] Rename doc to match previous name

Previous change inadvertently changed link.

2 years ago[libunwind] Add an interface for dynamic .eh_frame registration
Peter S. Housel [Thu, 14 Oct 2021 20:31:05 +0000 (13:31 -0700)]
[libunwind] Add an interface for dynamic .eh_frame registration

The libgcc runtime library provides __register_frame and
__deregister_frame functions, which can be used by dynamic code
generators to register an .eh_frame section, which contains one or
more Call Frame Information records, each consisting of a Common
Information Entry record followed by one or more Frame Description
Entry records. This libunwind library also provides __register_frame
and __deregister_frame functions, but they are aliases for
__unw_add_dynamic_fde and __unw_remove_dynamic_fde and thus can only
take a single FDE.

This patch adds __unw_add_dynamic_eh_frame_section and
__unw_remove_dynamic_eh_frame_section functions which explicitly use
the .eh_frame format. Clients such as the ORCv2 platform and runtime
can check for these functions and use them if unwinding is being
provided by libunwind, or fall back to __register_frame and
__deregister_frame if unwinding is provided by libgcc.

Reviewed By: lhames

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

2 years ago[AMDGPU] Regenerate test checks in splitkit-getsubrangeformask.ll
Jay Foad [Thu, 18 Nov 2021 15:51:23 +0000 (15:51 +0000)]
[AMDGPU] Regenerate test checks in splitkit-getsubrangeformask.ll

2 years ago[libc++] Minor fixups in the new introsort code.
Arthur O'Dwyer [Thu, 18 Nov 2021 03:26:59 +0000 (22:26 -0500)]
[libc++] Minor fixups in the new introsort code.

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

2 years ago[Clang][SVE] Properly enable/disable dependant SVE target features based upon +(no...
Bradley Smith [Fri, 12 Nov 2021 11:18:54 +0000 (11:18 +0000)]
[Clang][SVE] Properly enable/disable dependant SVE target features based upon +(no)sve.* options

Co-authored-by: Graham Hunter <graham.hunter@arm.com>
Differential Revision: https://reviews.llvm.org/D113776

2 years agoCoro: Remove coro_end and coro_suspend_retcon in private unprocessed functions
Arnold Schwaighofer [Tue, 16 Nov 2021 18:57:06 +0000 (10:57 -0800)]
Coro: Remove coro_end and coro_suspend_retcon in private  unprocessed functions

We might emit functions that are private and never called. The coro
split pass only processes functions that might be called. Remove
intrinsics that we can't generate code for.

rdar://84619859

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

2 years ago[libunwind][AIX] Mark signal_frame.pass.cpp UNSUPPORTED on AIX
Xing Xue [Thu, 18 Nov 2021 15:24:58 +0000 (10:24 -0500)]
[libunwind][AIX] Mark signal_frame.pass.cpp UNSUPPORTED on AIX

Summary:
This patch marks libunwind test case signal_frame.pass.cpp as UNSUPPORTED on AIX because the AIX assembler does not support CFI directives.

Reviewed by: danielkiss, MaskRay, ldionne, libunwind

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

2 years ago[clang][clangd] Improve signature help for variadic functions.
Adam Czachorowski [Wed, 6 Oct 2021 16:50:13 +0000 (18:50 +0200)]
[clang][clangd] Improve signature help for variadic functions.

This covers both C-style variadic functions and template variadic w/
parameter packs.

Previously we would return no signatures when working with template
variadic functions once activeParameter reached the position of the
parameter pack (except when it was the only param, then we'd still
show it when no arguments were given). With this commit, we now show
signathure help correctly.

Additionally, this commit fixes the activeParameter value in LSP output
of clangd in the presence of variadic functions (both kinds). LSP does
not allow the activeParamter to be higher than the number of parameters
in the active signature. With "..." or parameter pack being just one
argument, for all but first argument passed to "..." we'd report
incorrect activeParameter value. Clients such as VSCode would then treat
it as 0, as suggested in the spec) and highlight the wrong parameter.

In the future, we should add support for per-signature activeParamter
value, which exists in LSP since 3.16.0. This is not part of this
commit.

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

2 years ago[flang][nfc] Remove trailing whitespaces from tests
Andrzej Warzynski [Thu, 18 Nov 2021 14:22:18 +0000 (14:22 +0000)]
[flang][nfc] Remove trailing whitespaces from tests

2 years ago[flang][codegen] Add `fir.end` conversion placeholder
Andrzej Warzynski [Fri, 5 Nov 2021 16:04:23 +0000 (16:04 +0000)]
[flang][codegen] Add `fir.end` conversion placeholder

This patch extends the FIRToLLVMLowering pass in Flang by adding a hook
to transform fir.end. This is just a placeholder for now as fir.end is
not required yet.

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>
Differential Revision: https://reviews.llvm.org/D113295

2 years ago[LV] Add basic check lines to test added in 00200dbda31674e59.
Florian Hahn [Thu, 18 Nov 2021 14:08:57 +0000 (14:08 +0000)]
[LV] Add basic check lines to test added in 00200dbda31674e59.

2 years ago[lldb] (Partially) enable formatting of utf strings before the program is started
Pavel Labath [Wed, 3 Nov 2021 12:43:33 +0000 (13:43 +0100)]
[lldb] (Partially) enable formatting of utf strings before the program is started

The StringPrinter class was using a Process instance to read memory.
This automatically prevented it from working before starting the
program.

This patch changes the class to use the Target object for reading
memory, as targets are always available. This required moving
ReadStringFromMemory from Process to Target.

This is sufficient to make frame/target variable work, but further
changes are necessary for the expression evaluator. Preliminary analysis
indicates the failures are due to the expression result ValueObjects
failing to provide an address, presumably because we're operating on
file addresses before starting. I haven't looked into what would it take
to make that work.

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

2 years ago[clang] Remove CLANG_ROUND_TRIP_CC1_ARGS and always roundtrip in +assert builds
Nico Weber [Wed, 17 Nov 2021 21:32:33 +0000 (16:32 -0500)]
[clang] Remove CLANG_ROUND_TRIP_CC1_ARGS and always roundtrip in +assert builds

This removes the ability to disable roundtripping in assert builds.
(Roundtripping happens by default in assert builds both before and after
this patch.)

The CLANG_ROUND_TRIP_CC1_ARGS was added as an escape hatch 9 months ago
in https://reviews.llvm.org/D97462, with a FIXME to remove it eventually.
It's probably time to remove it.

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

2 years ago[fir] Add tests for mlir::ComplexType conversion
Diana Picus [Mon, 15 Nov 2021 11:46:34 +0000 (11:46 +0000)]
[fir] Add tests for mlir::ComplexType conversion

It turns out that mlir::ComplexType is translated the same way with or
without a conversion in TypeConverter.h. Add tests to make sure this
doesn't change in the future.

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

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

2 years ago[lldb] Convert internal platform usages GetSupportedArchitectures
Pavel Labath [Wed, 17 Nov 2021 20:13:56 +0000 (21:13 +0100)]
[lldb] Convert internal platform usages GetSupportedArchitectures

2 years ago[Flang] Notify conversion failure for Proc ops, types
Kiran Chandramohan [Thu, 18 Nov 2021 11:26:53 +0000 (11:26 +0000)]
[Flang] Notify conversion failure for Proc ops, types

Add the FIR to LLVM conversion patterns for the BoxProcHostOp, EmboxProcOp,
and UnboxProcOp ops and the boxproc type. These are currently unimplemented.
Implementation will come at a later time when support for Fortran 2003
procedure pointer feature is added.

Reviewed By: clementval, rovka

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

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2 years ago[LV] Add test case for PR52024.
Florian Hahn [Thu, 18 Nov 2021 12:10:44 +0000 (12:10 +0000)]
[LV] Add test case for PR52024.

This patch adds a reduced version of the test case from PR52024.

Together with 764d9aa97905 the test causes a crash, because LV expands a
SCEV expression during code generation, when the dominator tree is not
up-to-date.

2 years ago[AArch64][RISCV] Fix expected smulo/umulo test output
Fraser Cormack [Thu, 18 Nov 2021 11:53:16 +0000 (11:53 +0000)]
[AArch64][RISCV] Fix expected smulo/umulo test output

These tests were introduced in D109809 which I pushed on behalf of
@tangxingxin1008. I must have not understood the correct arcanist
workflow for this and as such may have locally tested a stale build.

This patch fixes the issue by re-running update_llc_test_checks.py on
all four tests.

2 years ago[clang][lex] Refactor check for the first file include
Jan Svoboda [Thu, 18 Nov 2021 11:34:54 +0000 (12:34 +0100)]
[clang][lex] Refactor check for the first file include

This patch refactors the code that checks whether a file has just been included for the first time.

The `HeaderSearch::FirstTimeLexingFile` function is removed and the information is threaded to the original call site from `HeaderSearch::ShouldEnterIncludeFile`. This will make it possible to avoid tracking the number of includes in a follow up patch.

Depends on D114092.

Reviewed By: dexonsmith

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

2 years ago[clang][lex] NFC: Remove unused HeaderFileInfo member
Jan Svoboda [Thu, 18 Nov 2021 11:32:25 +0000 (12:32 +0100)]
[clang][lex] NFC: Remove unused HeaderFileInfo member

This patch removes `HeaderFileInfo::isNonDefault`, which is not being used anywhere.

Reviewed By: dexonsmith, vsapsai

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

2 years ago[clang][deps] Don't emit `-fmodule-map-file=`
Jan Svoboda [Thu, 18 Nov 2021 11:22:55 +0000 (12:22 +0100)]
[clang][deps] Don't emit `-fmodule-map-file=`

During explicit modules build, when all modules are provided via `-fmodule-file=<path>` and implicit modules and implicit module maps are disabled (`-fno-implicit-modules`, `-fno-implicit-module-maps`), we don't need to load the original module map files at all. This patch stops emitting the `-fmodule-map-file=` arguments we don't need, saving some compilation time due to avoiding parsing such module maps and making the command line shorter.

Reviewed By: bnbarham

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

2 years ago[AArch64][ARM] Enablement of Cortex-A710 Support
Mubashar Ahmad [Thu, 14 Oct 2021 14:21:42 +0000 (15:21 +0100)]
[AArch64][ARM] Enablement of Cortex-A710 Support

Phabricator review: https://reviews.llvm.org/D113256

2 years ago[clang][modules] NFC: Fix typo in test name
Jan Svoboda [Thu, 18 Nov 2021 10:56:42 +0000 (11:56 +0100)]
[clang][modules] NFC: Fix typo in test name

2 years ago[docs] Update outdated mentions of lab.llvm.org:8011.
Florian Hahn [Thu, 18 Nov 2021 10:51:47 +0000 (10:51 +0000)]
[docs] Update outdated mentions of lab.llvm.org:8011.

Some places were still referring to the outdated buildbot URL
http://lab.llvm.org:8011. Update those to use the new URL
http://lab.llvm.org/buildbot/#.

2 years ago[docs] Remove mention of retired smooshlab IRC bot.
Florian Hahn [Thu, 18 Nov 2021 10:45:16 +0000 (10:45 +0000)]
[docs] Remove mention of retired smooshlab IRC bot.

the smooshlab bot has been offline for years. Remove it from the list of
IRC bots.

2 years ago[TargetLowering][RISCV] Fixed a scalable vector issue when lowering [s|u]mul.overflow...
Eric Tang [Thu, 18 Nov 2021 09:30:38 +0000 (09:30 +0000)]
[TargetLowering][RISCV] Fixed a scalable vector issue when lowering [s|u]mul.overflow intrinsics

    Fixed the vector type issue that where we used getVectorNumElements()
    should be replaced by getVectorElementCount() when lowering these
    intrinsics.

    This is similar to D94149

Signed-off-by: Eric Tang <tangxingxin1008@gmail.com>
Reviewed By: craig.topper, frasercrmck

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

2 years agoRemove non-affecting module maps from PCM files.
Ilya Kuteev [Thu, 18 Nov 2021 09:55:57 +0000 (10:55 +0100)]
Remove non-affecting module maps from PCM files.

Problem:
PCM file includes references to all module maps used in compilation which created PCM. This problem leads to PCM-rebuilds in distributed compilations as some module maps could be missing in isolated compilation. (For example in our distributed build system we create a temp folder for every compilation with only modules and headers that are needed for that particular command).

Solution:
Add only affecting module map files to a PCM-file.

Reviewed By: rsmith

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

2 years ago[fir] Add fir.embox conversion
Valentin Clement [Thu, 18 Nov 2021 10:05:45 +0000 (11:05 +0100)]
[fir] Add fir.embox conversion

Convert a `fir.embox` operation to LLVM IR dialect.
A `fir.embox` is converted to a sequence of operation that
create, allocate if needed, and populate a descriptor.

Current limitiation: alignment is set by default but should be retrieved in the specific target.

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

Reviewed By: kiranchandramohan, awarzynski

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

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: Jean Perier <jperier@nvidia.com>
2 years ago[CodeGen][SVE] Add missing isel patterns for vector_reverse
David Sherwood [Wed, 17 Nov 2021 14:41:46 +0000 (14:41 +0000)]
[CodeGen][SVE] Add missing isel patterns for vector_reverse

We were missing patterns for vector_reverse of unpacked FP vector
types, as well as all the supported bfloat vectors.

Tests added here:

  CodeGen/AArch64/named-vector-shuffle-reverse-sve.ll

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

2 years ago[SCEV] Reorder operands checks in collectConditions.
Florian Hahn [Thu, 18 Nov 2021 09:36:16 +0000 (09:36 +0000)]
[SCEV] Reorder operands checks in collectConditions.

The initial two cases require a SCEVConstant as RHS. Pull up the condition
to check and swap SCEVConstants from below. Also remove a redundant
check & swap if RHS is SCEVUnknown.

2 years ago[SCEV] Add additional guard tests with swapped condition ops.
Florian Hahn [Thu, 18 Nov 2021 09:35:18 +0000 (09:35 +0000)]
[SCEV] Add additional guard tests with swapped condition ops.

2 years ago[NFC][clangd] fix clang-tidy finding on isa_and_nonnull
Christian Kühnel [Mon, 15 Nov 2021 15:25:12 +0000 (15:25 +0000)]
[NFC][clangd] fix clang-tidy finding on isa_and_nonnull

This is a cleanup of the only llvm-prefer-isa-or-dyn-cast-in-conditionals finding in the clangd code base. This patch was created by automatically applying the fixes from clang-tidy.

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

2 years ago[PowerPC] fix typos in comments, NFC
Chen Zheng [Thu, 18 Nov 2021 08:55:23 +0000 (08:55 +0000)]
[PowerPC] fix typos in comments, NFC

2 years ago[fir] Add fir.constc conversion
Diana Picus [Tue, 16 Nov 2021 09:07:51 +0000 (09:07 +0000)]
[fir] Add fir.constc conversion

Add the codegen for fir.constc.

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

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

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: Jean Perier <jperier@nvidia.com>
2 years ago[mlir][Python] Fix generation of accessors for Optional
Michal Terepeta [Thu, 18 Nov 2021 08:41:57 +0000 (09:41 +0100)]
[mlir][Python] Fix generation of accessors for Optional

Previously, in case there was only one `Optional` operand/result within
the list, we would always return `None` from the accessor, e.g., for a
single optional result we would generate:

```
return self.operation.results[0] if len(self.operation.results) > 1 else None
```

But what we really want is to return `None` only if the length of
`results` is smaller than the total number of element groups (i.e.,
the optional operand/result is in fact missing).

This commit also renames a few local variables in the generator to make
the distinction between `isVariadic()` and `isVariableLength()` a bit
more clear.

Reviewed By: ftynse

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

2 years agoFix Windows build after commit 49682f1.
Douglas Yung [Thu, 18 Nov 2021 08:23:22 +0000 (00:23 -0800)]
Fix Windows build after commit 49682f1.

2 years ago[mlir][linalg][bufferize] Fix bufferize bug where non-tensor ops are not skipped
Matthias Springer [Thu, 18 Nov 2021 07:18:54 +0000 (16:18 +0900)]
[mlir][linalg][bufferize] Fix bufferize bug where non-tensor ops are not skipped

`BufferizableOpInterface::bufferize` will only be called on ops that
have tensor operands and/or results.

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

2 years ago[mlir][linalg][bufferize][NFC] Decouple ComprehensiveBufferize from tensor dialect
Matthias Springer [Thu, 18 Nov 2021 07:10:10 +0000 (16:10 +0900)]
[mlir][linalg][bufferize][NFC] Decouple ComprehensiveBufferize from tensor dialect

Add a new BufferizableOpInterface method `isNotConflicting` that can be used to implement custom analysis rules.

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

2 years ago[mlir] Convert NamedAttribute to be a class
River Riddle [Thu, 18 Nov 2021 05:23:32 +0000 (05:23 +0000)]
[mlir] Convert NamedAttribute to be a class

NamedAttribute is currently represented as an std::pair, but this
creates an extremely clunky .first/.second API. This commit
converts it to a class, with better accessors (getName/getValue)
and also opens the door for more convenient API in the future.

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

2 years ago[libc++] [test] Add "robust_re_difference_type.compile.pass.cpp" for all the algorithms.
Arthur O'Dwyer [Mon, 15 Nov 2021 15:00:07 +0000 (10:00 -0500)]
[libc++] [test] Add "robust_re_difference_type.compile.pass.cpp" for all the algorithms.

Also, mark these tests as compile-only. They actually are safe to run â€” notice that
the code "runs" at constexpr-time in C++20, without error â€” because both of the
input ranges are entirely filled with nullptr, so no matter how you shuffle the
elements, they remain sorted and partitioned and heapified and everything.
But there's no real reason to run them at runtime, so let's just avoid the distraction.

Test cases that fail in trunk right now are commented out with `TODO FIXME`.

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

2 years ago[X86][Driver] Add X86 target option to avoid fail to other targets. NFC
Phoebe Wang [Thu, 18 Nov 2021 04:37:36 +0000 (12:37 +0800)]
[X86][Driver] Add X86 target option to avoid fail to other targets. NFC

2 years ago[X86][ABI] Do not return float/double from x87 registers when x87 is disabled
Phoebe Wang [Thu, 18 Nov 2021 03:24:31 +0000 (11:24 +0800)]
[X86][ABI] Do not return float/double from x87 registers when x87 is disabled

This is aligned with GCC's behavior.
Also, alias `-mno-fp-ret-in-387` to `-mno-x87`, by which we can fix pr51498.

Reviewed By: nickdesaulniers

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

2 years ago[gn build] Port 92832e4889ae
LLVM GN Syncbot [Thu, 18 Nov 2021 04:03:38 +0000 (04:03 +0000)]
[gn build] Port 92832e4889ae

2 years ago[libc++] Enable <atomic> when threads are disabled
Louis Dionne [Wed, 17 Nov 2021 15:59:31 +0000 (10:59 -0500)]
[libc++] Enable <atomic> when threads are disabled

std::atomic is, for the most part, just a thin veneer on top of compiler
builtins. Hence, it should be available even when threads are not available
on the system, and in fact there has been requests for such support.

This patch:
- Moves __libcpp_thread_poll_with_backoff to its own header so it can
  be used in <atomic> when threads are disabled.
- Adds a dummy backoff policy for atomic polling that doesn't know about
  threads.
- Adjusts the <atomic> feature-test macros so they are provided even when
  threads are disabled.
- Runs the <atomic> tests when threads are disabled.

rdar://77873569

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

2 years ago[gn build] Port 49682f14bf3f
LLVM GN Syncbot [Thu, 18 Nov 2021 03:43:59 +0000 (03:43 +0000)]
[gn build] Port 49682f14bf3f

2 years agotsan: remove quadratic behavior in pthread_join
Dmitry Vyukov [Wed, 17 Nov 2021 02:23:21 +0000 (18:23 -0800)]
tsan: remove quadratic behavior in pthread_join

pthread_join needs to map pthread_t of the joined thread to our Tid.
Currently we do this with linear search over all threads.
This has quadratic complexity and becomes much worse with the new
tsan runtime, which memorizes all threads that ever existed.

To resolve this add a hash map of live threads only (that are still
associated with pthread_t) and use it for the mapping.

With the new tsan runtime some programs spent 1/3 of time in this mapping.
After this change the mapping disappears from profiles.

Depends on D113996.

Reviewed By: vitalybuka, melver

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

2 years ago[SPIR-V] Add translator tool
Henry Linjamäki [Wed, 17 Nov 2021 08:23:49 +0000 (11:23 +0300)]
[SPIR-V] Add translator tool

Add a tool for constructing commands for translating LLVM IR to
SPIR-V.

Used by HIPSPV tool chain (D110618).

Reviewed By: bader

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

2 years ago[clang] Use range-based for loops with llvm::reverse (NFC)
Kazu Hirata [Thu, 18 Nov 2021 03:40:48 +0000 (19:40 -0800)]
[clang] Use range-based for loops with llvm::reverse (NFC)

2 years ago[gn build] Port 24d1673c8b9b
LLVM GN Syncbot [Thu, 18 Nov 2021 03:23:58 +0000 (03:23 +0000)]
[gn build] Port 24d1673c8b9b

2 years ago[X86] Add -mskip-rax-setup support to align with GCC
Phoebe Wang [Thu, 18 Nov 2021 02:39:54 +0000 (10:39 +0800)]
[X86] Add -mskip-rax-setup support to align with GCC

AMD64 ABI mandates caller to specify the number of used SSE registers
when passing variable arguments.
GCC also provides option -mskip-rax-setup to skip the setup of rax when
SSE is disabled. This helps to reduce the code size, see pr23258.

Reviewed By: nickdesaulniers

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

2 years ago[NFC][llvm] Inclusive language: remove uses of sanity in llvm/lib/ExecutionEngine/
Zarko Todorovski [Thu, 18 Nov 2021 03:13:32 +0000 (22:13 -0500)]
[NFC][llvm] Inclusive language: remove uses of sanity in llvm/lib/ExecutionEngine/

Reworded and removed code comments to avoid using `sanity check` and `sanity
test`.

2 years ago[llvm-tblgen][RISCV] Make llvm-tblgen RISCVCompressInstEmitter to be common infra...
Zi Xuan Wu [Thu, 18 Nov 2021 02:22:21 +0000 (10:22 +0800)]
[llvm-tblgen][RISCV] Make llvm-tblgen RISCVCompressInstEmitter to be common infra across different targets

Not only RISCV but also other target such as CSKY, there are compressed instructions mixed with normal instructions.
To reuse the basic infra to compress/uncompress and predict instruction, we need reconstruct the RISCVCompressInstEmitter
and make it more general and suitable for other target.

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

2 years ago[sanitizer] Fix DenseMap for compiler-rt
Vitaly Buka [Thu, 18 Nov 2021 02:18:15 +0000 (18:18 -0800)]
[sanitizer] Fix DenseMap for compiler-rt

Depends on D114047.

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

2 years ago[NFC][sanitizer] Fix headers of DenseMap
Vitaly Buka [Tue, 16 Nov 2021 21:14:25 +0000 (13:14 -0800)]
[NFC][sanitizer] Fix headers of DenseMap

Depends on D114046.

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

2 years ago[NFC][sanitizer] Clang format copied code
Vitaly Buka [Tue, 16 Nov 2021 20:41:06 +0000 (12:41 -0800)]
[NFC][sanitizer] Clang format copied code

Depends on D114045.

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

2 years ago[NFC][sanitizer] Add unchanged DenseMap
Vitaly Buka [Tue, 16 Nov 2021 18:24:32 +0000 (10:24 -0800)]
[NFC][sanitizer] Add unchanged DenseMap

It's just a copy even without reformatting.

Reviewed By: dvyukov, melver

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

2 years ago[NFC][llvm] Inclusive language: reword and remove uses of sanity in llvm/lib/Target
Zarko Todorovski [Thu, 18 Nov 2021 02:59:00 +0000 (21:59 -0500)]
[NFC][llvm] Inclusive language: reword and remove uses of sanity in llvm/lib/Target

Reworded removed code comments that contain `sanity check` and `sanity
test`.

2 years agoPR52537: When performing a no-op TreeTransform of a rewritten binary
Richard Smith [Thu, 18 Nov 2021 02:13:25 +0000 (18:13 -0800)]
PR52537: When performing a no-op TreeTransform of a rewritten binary
operator, mark any functions it calls as referenced.

2 years ago[Driver][Android] Remove unneeded isNoExecStackDefault
Fangrui Song [Thu, 18 Nov 2021 02:15:24 +0000 (18:15 -0800)]
[Driver][Android] Remove unneeded isNoExecStackDefault

ld.lld used by Android ignores .note.GNU-stack and defaults to noexecstack,
so the `-z noexecstack` linker option is unneeded.

The `--noexecstack` assembler option is unneeded because AsmPrinter.cpp
prints `.section .note.GNU-stack,"",@progbits` (when `llvm.init.trampoline` is unused),
so the assembler won't synthesize an executable .note.GNU-stack.

Reviewed By: danalbert

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

2 years ago[NFC][sanitizer] Fix veradic-macro warning in RAW_CHECK
Vitaly Buka [Thu, 18 Nov 2021 02:10:17 +0000 (18:10 -0800)]
[NFC][sanitizer] Fix veradic-macro warning in RAW_CHECK

2 years ago[mlir][sparse] refine lexicographic insertion to any tensor
Aart Bik [Tue, 16 Nov 2021 20:46:55 +0000 (12:46 -0800)]
[mlir][sparse] refine lexicographic insertion to any tensor

First version was vectors only. With some clever "path" insertion,
we now support any d-dimensional tensor. Up next: reductions too

Reviewed By: bixia, wrengr

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

2 years agoRevert "[NFC] Refactor symbol table parsing."
Greg Clayton [Thu, 18 Nov 2021 02:07:28 +0000 (18:07 -0800)]
Revert "[NFC] Refactor symbol table parsing."

This reverts commit 951b107eedab1829f18049443f03339dbb0db165.

Buildbots were failing, there is a deadlock in /Users/gclayton/Documents/src/llvm/clean/llvm-project/lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s when ELF files try to relocate things.

2 years agoRevert "Revert "Make it possible for lldb to launch a remote binary with no local...
Jim Ingham [Wed, 17 Nov 2021 22:49:55 +0000 (14:49 -0800)]
Revert "Revert "Make it possible for lldb to launch a remote binary with no local file.""

This reverts commit dd5505a8f2c75a903ec944b6e46aed2042610673.

I picked the wrong class for the test, should have been GDBRemoteTestBase.

2 years ago[sanitizer] Add a few of type_traits tools
Vitaly Buka [Wed, 17 Nov 2021 23:05:16 +0000 (15:05 -0800)]
[sanitizer] Add a few of type_traits tools

For D114047

2 years ago[Coroutine] Warn deprecated 'std::experimental::coro' uses
Chuanqi Xu [Thu, 18 Nov 2021 01:34:58 +0000 (09:34 +0800)]
[Coroutine] Warn deprecated 'std::experimental::coro' uses

Since we've decided the to not support std::experimental::coroutine*, we
should tell the user they need to update.

Reviewed By: Quuxplusone, ldionne, Mordante

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

2 years ago[mlir][tosa] Revert add-0 canonicalization for floating-point
Robert Suderman [Thu, 18 Nov 2021 01:16:13 +0000 (17:16 -0800)]
[mlir][tosa] Revert add-0 canonicalization for floating-point

Floating point optimization can produce incorrect numerical resutls for
-0.0 + 0.0 optimization as result needs to be -0.0.

Reviewed By: eric-k256

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

2 years ago[X86][AMX] Don't emit tilerelease for old AMX instrisic.
Luo, Yuanke [Wed, 17 Nov 2021 08:22:53 +0000 (16:22 +0800)]
[X86][AMX] Don't emit tilerelease for old AMX instrisic.

We should avoid mixing old AMX instrinsic with new AMX intrinsic. For
old AMX intrinsic, user is responsible for invoking tile release. This
patch is to check if there is any tile config generated by compiler. If
so it emit tilerelease instruction, otherwise it don't emit the
instruction.

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

2 years agoAutogen a test for ease of update
Philip Reames [Thu, 18 Nov 2021 01:20:57 +0000 (17:20 -0800)]
Autogen a test for ease of update

2 years ago[X86] add 3 missing intrinsics: _mm_(mask/maskz)_cvtpbh_ps
Freddy Ye [Thu, 18 Nov 2021 00:47:42 +0000 (08:47 +0800)]
[X86] add 3 missing intrinsics: _mm_(mask/maskz)_cvtpbh_ps

Reviewed By: craig.topper, pengfei

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

2 years ago[flang] Add a semantics test for co_sum
Damian Rouson [Wed, 17 Nov 2021 23:15:10 +0000 (15:15 -0800)]
[flang] Add a semantics test for co_sum

Test a range of acceptable forms of co_sum calls, including
combinations of keyword and non-keyword actual arguments of
numeric types.  Also test that several invalid forms of
co_sum call generate the correct error messages.

Reviewed By: kiranchandramohan, ktras

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

2 years ago[AMDGPU] Update GFX10 memory model to account for MALL
Carl Ritson [Wed, 17 Nov 2021 23:47:14 +0000 (08:47 +0900)]
[AMDGPU] Update GFX10 memory model to account for MALL

Document memory attached last level (MALL) cache added in GFX10.3.

Reviewed By: t-tye

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

2 years ago[flang] Fix INQUIRE(PAD=) and (POSITION=) for predefined units
Peter Klausler [Tue, 16 Nov 2021 00:04:02 +0000 (16:04 -0800)]
[flang] Fix INQUIRE(PAD=) and (POSITION=) for predefined units

The predefined units were not being initialized with FORM='FORMATTED',
so INQUIRE(PAD=) was failing if no I/O had already been done.

INQUIRE(POSITION=) was returning 'REWIND' on stdin/stdout (which
is somewhat defensible from the definition, and is what Intel Fortran
does), but most implementations return 'ASIS'.  Change the runtime
to return 'REWIND' only for positionable external files, but 'ASIS'
for terminals, sockets, &c.

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

2 years ago[lld-macho] Add warn flags to enable/disable warnings on -install_name
Vincent Lee [Wed, 10 Nov 2021 02:10:28 +0000 (18:10 -0800)]
[lld-macho] Add warn flags to enable/disable warnings on -install_name

ld64 doesn't warn on builds using `-install_name` if it's a bundle. But, the
current warning is nice to have because `install_name` only works with dylib.
To prevent an overflow of warnings in build logs and have parity with ld64,
create a `--warn-dylib-install-name` and `--warn-no-dylib-install-name` flag
that enables this LLD specific warning.

Reviewed By: #lld-macho, thakis

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

2 years agoLiteralSupport: Don't assert() on invalid input
Daan De Meyer [Tue, 16 Nov 2021 15:46:34 +0000 (15:46 +0000)]
LiteralSupport: Don't assert() on invalid input

When using clangd, it's possible to trigger assertions in
NumericLiteralParser and CharLiteralParser when switching git branches.
This commit removes the initial asserts on invalid input and replaces
those asserts with the error handling mechanism from those respective
classes instead. This allows clangd to gracefully recover without
crashing.

See https://github.com/clangd/clangd/issues/888 for more information
on the clangd crashes.

2 years ago[compiler-rt][asan] Re-add `self`
Leonard Chan [Wed, 17 Nov 2021 23:47:40 +0000 (15:47 -0800)]
[compiler-rt][asan] Re-add `self`

We ran into errors where this wasn't defined in Fuchsia's asan implementation.

2 years agoRevert "[sanitizer] Add a few of type_traits tools"
Vitaly Buka [Wed, 17 Nov 2021 23:45:45 +0000 (15:45 -0800)]
Revert "[sanitizer] Add a few of type_traits tools"

Does not work with GCC

This reverts commit a82ee2be9c6378cd34deb3ab002d78acd2b04ff3.

2 years ago[MLIR][Docs] Fix link syntax in Rationale.md
J. Ryan Stinnett [Wed, 17 Nov 2021 23:37:29 +0000 (23:37 +0000)]
[MLIR][Docs] Fix link syntax in Rationale.md

2 years ago[LegalizeTypes] Further limit expansion of CTTZ during type promotion.
Craig Topper [Wed, 17 Nov 2021 23:21:00 +0000 (15:21 -0800)]
[LegalizeTypes] Further limit expansion of CTTZ during type promotion.

Don't expand CTTZ if CTPOP or CTLZ is supported on the promoted type.
We have special handling for CTTZ expansion to use those ops with a
small conversion. The setup for that doesn't generate extra code or
large constants so we don't gain anything from expanding early and we
make CTTZ_ZERO_UNDEF codegen worse.

Follow up from post commit feedback on D112268. We don't seem to have
any in tree tests that care about this.

2 years ago[NFC] Refactor symbol table parsing.
Greg Clayton [Tue, 16 Nov 2021 05:02:53 +0000 (21:02 -0800)]
[NFC] Refactor symbol table parsing.

Symbol table parsing has evolved over the years and many plug-ins contained duplicate code in the ObjectFile::GetSymtab() that used to be pure virtual. With this change, the "Symbtab *ObjectFile::GetSymtab()" is no longer virtual and will end up calling a new "void ObjectFile::ParseSymtab(Symtab &symtab)" pure virtual function to actually do the parsing. This helps centralize the code for parsing the symbol table and allows the ObjectFile base class to do all of the common work, like taking the necessary locks and creating the symbol table object itself. Plug-ins now just need to parse when they are asked to parse as the ParseSymtab function will only get called once.

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

2 years ago[sanitizer] Add a few of type_traits tools
Vitaly Buka [Wed, 17 Nov 2021 23:05:16 +0000 (15:05 -0800)]
[sanitizer] Add a few of type_traits tools

For D114047

2 years ago[mlir][tosa] Fixed shape inference for tosa.transpose_conv2d
Rob Suderman [Wed, 17 Nov 2021 22:48:09 +0000 (14:48 -0800)]
[mlir][tosa] Fixed shape inference for tosa.transpose_conv2d

Transpose conv2d shape inference was incorrect, tests did not properly validate
that the shape inference was executing. Corrected shape inference, and extended
tests to actually execute.

Reviewed By: NatashaKnk

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

2 years agoAdd Android test case for -Wpartial-availability. Also update Android availability...
James Farrell [Wed, 17 Nov 2021 22:44:06 +0000 (22:44 +0000)]
Add Android test case for -Wpartial-availability. Also update Android availability tests to match on the whole string, so we can distinguish between "Android 16" and "Android 16.0.0" at the end of warning messages.

Reviewed By: danalbert, srhines

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

2 years ago[OpenMP][libomp] Enable HWLOC topology detection of multiple CPU kinds
Peyton, Jonathan L [Thu, 21 Oct 2021 19:07:15 +0000 (14:07 -0500)]
[OpenMP][libomp] Enable HWLOC topology detection of multiple CPU kinds

Teach the HWLOC topology method how to detect Atom and Core
types so hybrid CPUs are properly detected and represented when using
the HWLOC topology method.

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