platform/upstream/llvm.git
20 months ago[clang-tidy] Fix minor bug in bugprone-too-small-loop-variable
Piotr Zegar [Sat, 18 Mar 2023 10:44:11 +0000 (10:44 +0000)]
[clang-tidy] Fix minor bug in bugprone-too-small-loop-variable

Correct issue when incorrectly matched bitfield loop
variable would still be considered valid and equal to
base type, because check didnt compare size of bitfield.

Fixes issue introduced in: D142587

Reviewed By: carlosgalvezp

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

20 months ago[gn] port d60d3455eb2b
Nico Weber [Sat, 18 Mar 2023 09:13:31 +0000 (10:13 +0100)]
[gn] port d60d3455eb2b

20 months ago[RISCV] Use 'unsigned' for XLen in RISCVTargetDefEmitter.cpp. NFC
Craig Topper [Sat, 18 Mar 2023 07:41:03 +0000 (00:41 -0700)]
[RISCV] Use 'unsigned' for XLen in RISCVTargetDefEmitter.cpp. NFC

The values are small so the difference doesn't matter, but the
consuming function is defined to take 'unsigned'.

20 months ago[AMDGPU] Reserve extra SGPR blocks wth XNACK "any" TID Setting
Austin Kerbow [Mon, 6 Mar 2023 18:10:14 +0000 (10:10 -0800)]
[AMDGPU] Reserve extra SGPR blocks wth XNACK "any" TID Setting

ASMPrinter was relying on feature bits to setup extra SGRPs in the knerel
descriptor for the xnack_mask. This was broken for the dynamic XNACK "any" TID
setting which could cause user SGPRs to be clobbered if the number of SGPRs
reserved was near a granulated block boundary.

When XNACK was enabled this worked correctly in the ASMParser which meant some
kernels were only failing without "-save-temps".

Fixes: SWDEV-382764

Reviewed By: kzhuravl

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

20 months ago[JITLink] Store Sections in a DenseMap with the section name as key.
Lang Hames [Sat, 18 Mar 2023 03:14:11 +0000 (20:14 -0700)]
[JITLink] Store Sections in a DenseMap with the section name as key.

This speeds up section lookup by name.

This change was motivated by poor performance of a testcase while trying to fix
the NoAlloc lifetime patch that was originally landed as 2cc64df0bd6. The
NoAlloc lifetime patch causes ELF non-SHF_ALLOC sections to be given a JITLink
Section (previously they were skipped), and the
llvm/test/ExecutionEngine/JITLink/X86/ELF_shndex.s testcase creates > 64k
non-SHF_ALLOC sections, each of which now needs to be checked to ensure that its
name does not clash. Moving to a DenseMap allows us to implement this check
efficiently.

20 months ago[WebAssembly] Support debug info for TLS + global in PIC mode
Heejin Ahn [Thu, 2 Mar 2023 06:53:51 +0000 (22:53 -0800)]
[WebAssembly] Support debug info for TLS + global in PIC mode

This adds debug info support for
- `thread_local` global variables, both in non-PIC and PIC modes
- (non-thread_local) Global variables in PIC mode

The former needs to read the value from an offset relative to
`__tls_base` and the latter an offset from `__memory_base`. The code for
doing this overlaps with some of the existing code to add
`__stack_pointer` global, so this adds a new member function to add a
a global in `TI_GLOBAL_RELOC` mode and use it in all three places.

Split DWARF support is currently patchy at best, because the index for
`__tls_base` is not fixed after dynamic linking. The preexisting split
DWARF support for `__stack_pointer` relies on that in practice it is
always index 0. This does similar hardcoding for `__tls_base` and
`__memory_base`, but `__tls_base`'s index in dynamic linking is not
fixed now (See
https://github.com/llvm/llvm-project/blob/19afbfe33156d211fa959dadeea46cd17b9c723c/lld/wasm/Driver.cpp#L786-L823
for details), TLS + dynamic linking will not work at the moment.

Fixes https://bugs.chromium.org/p/chromium/issues/detail?id=1416702.

Reviewed By: dschuff

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

20 months ago[WebAssembly] Add comments on local.tee transformation
Heejin Ahn [Tue, 14 Mar 2023 07:32:43 +0000 (00:32 -0700)]
[WebAssembly] Add comments on local.tee transformation

We have a good comment on `TEE` transformation in `RegStackify`:
https://github.com/llvm/llvm-project/blob/547e3456660000a16fc5c2a2f819f1a2b5d35b5d/llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp#L613-L632

And I think it can be helpful to have some more comments on how the
`TEE`s created in `RegStackify` are converted into `LOCAL_TEE`s.

Variable `OldReg` is changed to `DefReg` to be consistent with
`RegStackify`'s comment.

Reviewed By: tlively

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

20 months ago[WebAssembly] Use MachineInstr::setDebugValueUndef
Heejin Ahn [Mon, 13 Mar 2023 09:44:47 +0000 (02:44 -0700)]
[WebAssembly] Use MachineInstr::setDebugValueUndef

When making `DBG_VALUE`/`DBG_VALUE_LIST` instructions undefined, there
is a method that takes care of it so we don't need to do it manually.
This changes the test because previously we are converting
`DBG_VALUE_LIST`s into `DBG_VALUE $noreg` but now we leave
`DBG_VALUE_LIST` but set it to undef by turning all its register
operands `$noreg`. The effect is the same.

Reviewed By: dschuff

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

20 months ago[llvm-readobj] Output valid JSON for GroupSections
Paul Kirth [Sat, 18 Mar 2023 01:36:40 +0000 (01:36 +0000)]
[llvm-readobj] Output valid JSON for GroupSections

The current implementation output the LLVM formatted heading for group
sections, which was not valid JSON. This patch provides two small
customization points that allow the heading to vary between the two
implementations, and another that allows the section members to be
output as valid JSON objects.

Reviewed By: jhenderson

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

20 months ago[WebAssembly] Replace Bugzilla links with Github issues
Heejin Ahn [Mon, 13 Mar 2023 09:48:03 +0000 (02:48 -0700)]
[WebAssembly] Replace Bugzilla links with Github issues

Reviewed By: dschuff, asb

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

20 months ago[llvm-readobj] Fix "Section" output when emitting relocations in JSON
Paul Kirth [Sat, 18 Mar 2023 00:05:41 +0000 (00:05 +0000)]
[llvm-readobj] Fix "Section" output when emitting relocations in JSON

Prior to this patch, the JSON output would emit an invalid key from the
shared LLVM implementation. This caused llvm-readobj to output invalid
JSON. This patch introduces a small helper function to print the
relocation information differently between the LLVM and JSON formats.

Before this patch:

```
    "Relocations": [Section (2) .rel.text {

      {
        "Relocation": {
          "Offset": 0,
          "Type": {
            "Value": "R_X86_64_NONE",
            "RawValue": 0
          },
          "Symbol": {
            "Value": "rel_0",
            "RawValue": 1
          }
        }
      },
      ...

```

After this patch:

```
   "Relocations": [
      {
        "SectionIdx": 2,
        "Relocs": [
          {
            "Relocation": {
              "Offset": 0,
              "Type": {
                "Name": "R_X86_64_NONE",
                "Value": 0
              },
              "Symbol": {
                "Name": "rel_0",
                "Value": 1
              }
            }
          },
          ...
```

Reviewed By: jhenderson

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

20 months ago[TSan] Make sure we only collect non-TSan frames for memory operations r=dvyukov...
Julian Lettner [Thu, 16 Mar 2023 22:57:56 +0000 (15:57 -0700)]
[TSan] Make sure we only collect non-TSan frames for memory operations r=dvyukov,rsundahl,thetruestblue,wrotki,kubamracek!

A previous change [1] moved retrieval of the caller PC
(`__builtin_return_address(0)` via `CALLERPC`) from an
interface-boundary function into a shared helper function
`ExternalAccess`.  If this function does not get inlined, we fail to
collect the appropriate caller PC for the "TSan interface boundary".

[1] https://reviews.llvm.org/D32360

rdar://78489600

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

20 months agogn build: Pass -fno-emulated-tls when targeting Android.
Peter Collingbourne [Sat, 18 Mar 2023 00:05:46 +0000 (17:05 -0700)]
gn build: Pass -fno-emulated-tls when targeting Android.

Matches the CMake build:
https://github.com/llvm/llvm-project/blob/93c1a5f3ddd41e0ec09f38ab0045bd5e92199fd5/compiler-rt/CMakeLists.txt#L343
(we always use API level 29).

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

20 months ago[NVPTX] Report fatal error on empty argument type.
Pavel Kopyl [Thu, 16 Mar 2023 02:01:50 +0000 (03:01 +0100)]
[NVPTX] Report fatal error on empty argument type.

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

20 months ago[llvm-readobj] Rename JSON Flag fields to be more consistent
Paul Kirth [Sat, 18 Mar 2023 00:00:57 +0000 (00:00 +0000)]
[llvm-readobj] Rename JSON Flag fields to be more consistent

Today the JSON uses `Value` and `RawValue` when printing `Flags`, when really
the `Value` field is always the name of an Enum variant, and `RawValue` is its
underlying numeric value. Similarly, we rename the `RawFlags` key to `Value`,
to match the new scheme. This also allows JSON parsing to use consistent logic
for `Flag` types.

Reviewed By: jhenderson

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

20 months ago[llvm-readobj] Fix JSON output for Relocations
Paul Kirth [Fri, 17 Mar 2023 23:40:23 +0000 (23:40 +0000)]
[llvm-readobj] Fix JSON output for Relocations

The existing JSON incorrectly outputs line breaks and other invalid JSON.

Example Before this patch:

```
...
"Relocations":[Section (9) .rela.dyn {
  0xA3B0 R_X86_64_RELATIVE - 0x43D0
  0xA3B8 R_X86_64_RELATIVE - 0x4A30
...
```

Example After this patch:

```
...
"Relocations":[Section (9) .rela.dyn {
{"Relocation":{"Offset":41904,"Type":{"Value":"R_X86_64_RELATIVE","RawValue":8},
"Symbol":{"Value":"","RawValue":0},"Addend":17360}},
{"Relocation":{"Offset":41912,"Type":{"Value":"R_X86_64_RELATIVE","RawValue":8},
"Symbol":{"Value":"","RawValue":0},"Addend":18992}},
{"Relocation":{"Offset":41920,"Type":{"Value":"R_X86_64_RELATIVE","RawValue":8},
"Symbol":{"Value":"","RawValue":0},"Addend":17440}},
...
```

Note there are still issues with the Section, but each Relocation is
now a valid JSON object that can be parsed. Future patches will address
the issues regarding JSON output for the Section.

Reviewed By: jhenderson

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

20 months ago[llvm-readobj] Standardize JSON output for `Other` field
Paul Kirth [Fri, 17 Mar 2023 23:32:00 +0000 (23:32 +0000)]
[llvm-readobj] Standardize JSON output for `Other` field

Today, the LLVM output uses special handling when the Other field is 0.
This output makes sense for a command line utility that a human will
read, but JSON is a machine readable format, so being consistent is more
important. Prior to this change, any consumer of the JSON output would
need to handle the Other field specially, since the structure of the
JSON would no longer be consistent.

Changes to JSON output when Other flag == 0:
```
"Other": 0,   ->   "Other": {
                      "RawFlags": 0,
                       "Flags": []
                    },
```

There are no changes to when Other flag != 0:
```
"Other": {        ->   "Other": {
  "RawFlags": 1,          "RawFlags": 1,
  "Flags": [              "Flags": [
      ...                     ...
  ]                       ]
},                     },
```

This patch adds a overload for the JSONELFDumper's printSymbol() method,
that uses consistent output formatting, regardless of the value of the
Other field.

Depends on D137092

Reviewed By: jhenderson

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

20 months ago[libc++] Use the _LIBCPP_VERBOSE_ABORT macro instead of calling the function directly
Nikolas Klauser [Thu, 16 Mar 2023 14:05:49 +0000 (15:05 +0100)]
[libc++] Use the _LIBCPP_VERBOSE_ABORT macro instead of calling the function directly

These calls were added in D141222.

Reviewed By: #libc, ldionne

Spies: ldionne, libcxx-commits, smeenai, mikhail.ramalho

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

20 months ago[llvm-readobj] Use a helper to extract the Other Flags from symbols
Paul Kirth [Fri, 17 Mar 2023 23:29:31 +0000 (23:29 +0000)]
[llvm-readobj] Use a helper to extract the Other Flags from symbols

Since all ELFDumper implementations will require the same logic when
dealing with Other Flags, we move the logic into a helper so that it can
be easily reused across implementations.

Reviewed By: jhenderson

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

20 months ago[LSR] Rework term-fold tests
Philip Reames [Fri, 17 Mar 2023 19:09:27 +0000 (12:09 -0700)]
[LSR] Rework term-fold tests

There were two major problems with the tests.

First, with the pointer size being 32 bit and the original IVs also being 32 bit, almost all of the positive tests were actually unsound.  An upcoming change will add the appropriate safety check, but the test diffs are really hard to understand without switching the tests to 64 bit pointers first.

Second, checking debug messages for failures is a major bad practice.  This should not have been accepted in review at all.  The reason is that it makes the *order* of legality checks visibile and modifying any of them becomes annoying and tedious.

20 months agoRevert "[fuzzer] Use puts() rather than printf() in CopyFileToErr()"
Matthew Voss [Fri, 17 Mar 2023 22:57:07 +0000 (15:57 -0700)]
Revert "[fuzzer] Use puts() rather than printf() in CopyFileToErr()"

This reverts commit 03aa02adb03c928ae4ec9d139b303348f81861c9.

Reverting due to bot failures:
https://lab.llvm.org/buildbot/#/builders/247/builds/2653

20 months ago[mlir][gpu][nvvm] refined sparsity selector test and verification of mma.sp
Aart Bik [Fri, 17 Mar 2023 18:40:10 +0000 (11:40 -0700)]
[mlir][gpu][nvvm] refined sparsity selector test and verification of mma.sp

Reviewed By: ThomasRaoux

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

20 months ago[Docs] Fix llvm-cov debuginfod option formatting.
Daniel Thornburgh [Fri, 17 Mar 2023 22:48:50 +0000 (15:48 -0700)]
[Docs] Fix llvm-cov debuginfod option formatting.

20 months ago[MLIR] Do not hardcode attribute indexes in intrinsic decls
Artem Belevich [Fri, 17 Mar 2023 21:48:47 +0000 (14:48 -0700)]
[MLIR] Do not hardcode attribute indexes in intrinsic decls

We're not checking the attributes themselves, so hardcoded attribute numbers
only make the tests more fragile, without improving the testing.

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

20 months ago[bazel] add missing dependency to //mlir:SPIRVCommonConversion
Jorge Gorbe Moya [Fri, 17 Mar 2023 22:00:50 +0000 (15:00 -0700)]
[bazel] add missing dependency to //mlir:SPIRVCommonConversion

20 months ago[libc++] Remove unnecessary main() function in .compile.pass.cpp and .verify.cpp...
Louis Dionne [Thu, 16 Mar 2023 16:45:41 +0000 (12:45 -0400)]
[libc++] Remove unnecessary main() function in .compile.pass.cpp and .verify.cpp tests

We pretty consistently don't define those cause they are not needed,
and it removes the potential pitfall to think that these tests are
being run. This doesn't touch .compile.fail.cpp tests since those
should be replaced by .verify.cpp tests anyway, and there would be
a lot to fix up.

As a fly-by, I also fixed a bit of formatting, removed a few unused
includes and made some very minor, clearly NFC refactorings such as
in allocator.traits/allocator.traits.members/allocate.verify.cpp where
the old test basically made no sense the way it was written.

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

20 months agoscudo: Don't define mallinfo2 on Android.
Peter Collingbourne [Fri, 17 Mar 2023 18:59:39 +0000 (11:59 -0700)]
scudo: Don't define mallinfo2 on Android.

On Android, mallinfo2 is an alias of mallinfo, which results
in errors if we try to define both.

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

20 months agoLiveRangeEdit: Use Register
Matt Arsenault [Fri, 10 Mar 2023 20:15:06 +0000 (16:15 -0400)]
LiveRangeEdit: Use Register

20 months agoRevert unintentionally committed "Use nvptxcompile library."
Artem Belevich [Fri, 17 Mar 2023 21:23:42 +0000 (14:23 -0700)]
Revert unintentionally committed "Use nvptxcompile library."

This reverts commit 5f66348e59aa7ce5e5780a972b3875268c45d57c.

20 months agoSeparate SerializeToCubin from GPUTransforms.
Artem Belevich [Fri, 17 Mar 2023 20:47:46 +0000 (13:47 -0700)]
Separate SerializeToCubin from GPUTransforms.

SerializeToCubin depends on CUDA at *runtime* which is undesirable for MLIR's
general use case, as compilation should be doable on any host, regardless of
whether it has a GPU.

SerializeToCubin is needed to run some GPU tests, so when we build mlir-opt,
SerializeToCubin pass is linked in directly into mlir-opt.

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

20 months agoUse nvptxcompile library.
Artem Belevich [Tue, 7 Mar 2023 23:21:37 +0000 (15:21 -0800)]
Use nvptxcompile library.

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

20 months ago[Clang][OpenMP] Insert alloca for kernel args at function entry block instead of...
Dhruva Chakrabarti [Fri, 17 Mar 2023 16:16:17 +0000 (12:16 -0400)]
[Clang][OpenMP] Insert alloca for kernel args at function entry block instead of the launch point.

If an inlined kernel is called in a loop, the launch point alloca would
lead to increasing stack usage every time the kernel is invoked. This
could make the application run out of stack space and crash. This problem
is fixed by using the alloca insertion point while creating the alloca instruction.

Fixes https://github.com/llvm/llvm-project/issues/60602

Reviewed By: jdoerfert

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

20 months ago[clang] Properly parse variable template requires clause in lambda
Emilia Dreamer [Fri, 17 Mar 2023 08:13:02 +0000 (10:13 +0200)]
[clang] Properly parse variable template requires clause in lambda

Since P0857, part of C++20, a *lambda-expression* can contain a
*requires-clause* after its *template-parameter-list*.

While support for this was added as part of
eccc734a69c0c012ae3160887b65a535b35ead3e, one specific case isn't
handled properly, where the *requires-clause* consists of an
instantiation of a boolean variable template. This is due to a
diagnostic check which was written with the assumption that a
*requires-clause* can never be followed by a left parenthesis. This
assumption no longer holds for lambdas.

This diagnostic check would then attempt to perform a "recovery", but it
does so in a valid parse state, resulting in an invalid parse state
instead!

This patch adds a special case when parsing requires clauses of lambda
templates, to skip this diagnostic check.

Fixes https://github.com/llvm/llvm-project/issues/61278
Fixes https://github.com/llvm/llvm-project/issues/61387

Reviewed By: erichkeane

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

20 months ago[flang] Replace !fir.ref<T> -> T conversion with a load
Renaud-K [Thu, 16 Mar 2023 01:11:50 +0000 (18:11 -0700)]
[flang] Replace !fir.ref<T> -> T conversion with a load
Differential revision: https://reviews.llvm.org/D146186

20 months agoRevert "[JITLink][ORC] Rename MemDeallocPolicy to MemLifetimePolicy, add ..."
Lang Hames [Fri, 17 Mar 2023 19:57:38 +0000 (12:57 -0700)]
Revert "[JITLink][ORC] Rename MemDeallocPolicy to MemLifetimePolicy, add ..."

This reverts commit 2cc64df0bd6a802eab592dbc282463c3e4a4281c while I investigate
bot failures (e.g. https://lab.llvm.org/buildbot/#/builders/3/builds/23081).

20 months ago[lldb] Enable TestPublicAPIHeaders.py on Apple Silicon
Alex Langford [Fri, 17 Mar 2023 18:34:58 +0000 (11:34 -0700)]
[lldb] Enable TestPublicAPIHeaders.py on Apple Silicon

This cleans up the test a bit and enables it to run on apple silicon
machines.

20 months ago[JITLink][ORC] Rename MemDeallocPolicy to MemLifetimePolicy, add NoAlloc option.
Lang Hames [Thu, 16 Mar 2023 00:09:04 +0000 (17:09 -0700)]
[JITLink][ORC] Rename MemDeallocPolicy to MemLifetimePolicy, add NoAlloc option.

The original MemDeallocPolicy had two options:
* Standard: allocated memory lives until deallocated or abandoned.
* Finalize: allocated memory lives until all finalize actions have been run,
            then is destroyed.

This patch introduces a new 'NoAlloc' option. NoAlloc indicates that the
section should be ignored by the JITLinkMemoryManager -- the memory manager
should allocate neither working memory nor executor address space to blocks in
NoAlloc sections. The NoAlloc option is intended to support metadata sections
(e.g. debug info) that we want to keep in the graph and have fixed up if
necessary, but don't want allocated or transmitted to the executor (or we want
that allocation and transmission to be managed manually by plugins).

Since NoAlloc blocks are ignored by the JITLinkMemoryManager they will not have
working memory allocated to them by default post-allocation. Clients wishing to
modify the content of a block in a NoAlloc section should call
`Block::getMutableMemory(LinkGraph&)` to get writable memory allocated on the
LinkGraph's allocator (this memory will exist for the lifetime of the graph).
If no client requests mutable memory prior to the fixup phase then the generic
link algorithm will do so when it encounters the first edge in any given block.

Addresses of blocks in NoAlloc sections are initialized by the LinkGraph
creator (a LinkGraphBuilder, if the graph is generated from an object file),
and should not be modified by the JITLinkMemoryManager. Plugins are responsible
for updating addresses if they add/remove content from these sections. The
meaning of addresses in NoAlloc-sections is backend/plugin defined, but for
fixup purposes they will be treated the same as addresses in Standard/Finalize
sections. References from Standard/Finalize sections to NoAlloc sections are
expected to be common (these represent metadata tracking executor addresses).
References from NoAlloc sections to Standard/Finalize sections are expected to
be rare/non-existent (they would represent JIT'd code / data tracking metadata
in the controller, which would be surprising). LinkGraphBuilders and specific
backends may impose additional constraints on edges between Standard/Finalize
and NoAlloc sections where required for correctness.

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

20 months agoRegAllocGreedy: Don't use Register reference
Matt Arsenault [Fri, 10 Mar 2023 12:56:51 +0000 (08:56 -0400)]
RegAllocGreedy: Don't use Register reference

20 months agoIntrinsics: Make vector reduce intrinsics speculatable
Matt Arsenault [Fri, 17 Mar 2023 16:00:05 +0000 (12:00 -0400)]
Intrinsics: Make vector reduce intrinsics speculatable

20 months ago[RISCV] Add isReMaterializable to FLI instructions.
Craig Topper [Fri, 17 Mar 2023 19:16:36 +0000 (12:16 -0700)]
[RISCV] Add isReMaterializable to FLI instructions.

Reviewed By: reames

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

20 months ago[RISCV] Add isAsCheapAsAMove to FLI instructions.
Craig Topper [Fri, 17 Mar 2023 19:05:51 +0000 (12:05 -0700)]
[RISCV] Add isAsCheapAsAMove to FLI instructions.

This can prevent unnecessarily hoisting out of loops.

Test case cribbed from AArch64.

I also intend to make them rematerializable.

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

20 months ago[RISCV] Add test case showing fli being hoisted out of a loop and creating extra...
Craig Topper [Fri, 17 Mar 2023 19:05:44 +0000 (12:05 -0700)]
[RISCV] Add test case showing fli being hoisted out of a loop and creating extra copies/spills.

Test case for D146314.

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

20 months ago[libc++][NFC] Move the stdlib= test suite configuration for Apple into the cfg.in...
Louis Dionne [Fri, 17 Mar 2023 16:40:50 +0000 (12:40 -0400)]
[libc++][NFC] Move the stdlib= test suite configuration for Apple into the cfg.in files

This centralizes where configuration lives.

20 months ago[MLIR] Add label to print-ir pass
Frederik Gossen [Fri, 17 Mar 2023 18:47:18 +0000 (14:47 -0400)]
[MLIR] Add label to print-ir pass

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

20 months ago[libc++][NFC] Precise comments in test suite setup
Louis Dionne [Fri, 17 Mar 2023 16:41:49 +0000 (12:41 -0400)]
[libc++][NFC] Precise comments in test suite setup

20 months ago[SLP]Introduce shuffle of the nodes + gather/vectorbuild of the remaining scalars.
Alexey Bataev [Wed, 15 Mar 2023 19:33:00 +0000 (12:33 -0700)]
[SLP]Introduce shuffle of the nodes + gather/vectorbuild  of the remaining scalars.

Currently compiler does not support mixing of shuffled nodes
+ gather/buildvector of the remaining scalar values. It may reduce total
  number of instructions and improve performance of the
  gather/buildvector sequences.

Part of D110978

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

20 months ago[AMDGPU] Remove some unneeded curly braces
Jay Foad [Fri, 17 Mar 2023 18:08:01 +0000 (18:08 +0000)]
[AMDGPU] Remove some unneeded curly braces

20 months ago[libc] Fix dependency to unit tests, and quitting in non-GPU mode
Joseph Huber [Fri, 17 Mar 2023 18:06:58 +0000 (13:06 -0500)]
[libc] Fix dependency to unit tests, and quitting in non-GPU mode

Summary:
Fixes the lack of a dependency after changing the order of some
includes. Also we weren't running any tests as the GPU was always
disabling them. Fix the logic.

20 months ago[AMDGPU] Simplify SMEM Real instruction definitions. NFC.
Jay Foad [Fri, 17 Mar 2023 17:57:34 +0000 (17:57 +0000)]
[AMDGPU] Simplify SMEM Real instruction definitions. NFC.

Only override InOperandList when the Real instruction needs a different
type for $offset than the Pseudo.

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

20 months ago[libc] Enable integration tests targeting the GPU
Joseph Huber [Thu, 16 Mar 2023 16:42:57 +0000 (11:42 -0500)]
[libc] Enable integration tests targeting the GPU

This patch enables integration tests running on the GPU. This uses the
RPC interface implemented in D145913 to compile the necessary
dependencies for the integration test object. We can then use this to
compile the objects for the GPU directly and execute them using the AMD
HSA loader combined with its RPC server. For example, the compiler is
performing the following actions to execute the integration tests.

```
$ clang++ --target=amdgcn-amd-amdhsa -mcpu=gfx1030 -nostdlib -flto -ffreestanding \
    crt1.o io.o quick_exit.o test.o rpc_client.o args_test.o -o image
$ ./amdhsa_loader image 1 2 5
args_test.cpp:24: Expected 'my_streq(argv[3], "3")' to be true, but is false
```

This currently only works with a single threaded client implementation
running on AMDGPU. Further work will implement multiple clients for AMD
and the ability to run on NVPTX as well.

Depends on D145913

Reviewed By: sivachandra, JonChesterfield

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

20 months ago[libc] Add initial support for an RPC mechanism for the GPU
Joseph Huber [Fri, 10 Mar 2023 22:48:53 +0000 (16:48 -0600)]
[libc] Add initial support for an RPC mechanism for the GPU

This patch adds initial support for an RPC client / server architecture.
The GPU is unable to perform several system utilities on its own, so in
order to implement features like printing or memory allocation we need
to be able to communicate with the executing process. This is done via a
buffer of "sharable" memory. That is, a buffer with a unified pointer
that both the client and server can use to communicate.

The implementation here is based off of Jon Chesterfields minimal RPC
example in his work. We use an `inbox` and `outbox` to communicate
between if there is an RPC request and to signify when work is done.
We use a fixed-size buffer for the communication channel. This is fixed
size so that we can ensure that there is enough space for all
compute-units on the GPU to issue work to any of the ports. Right now
the implementation is single threaded so there is only a single buffer
that is not shared.

This implementation still has several features missing to be complete.
Such as multi-threaded support and asynchrnonous calls.

Depends on D145912

Reviewed By: sivachandra

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

20 months ago[lldb] Fix d875838e8b45cb0da5070298d0c1a2d1ee78ce7e
Dave Lee [Fri, 17 Mar 2023 17:42:45 +0000 (10:42 -0700)]
[lldb] Fix d875838e8b45cb0da5070298d0c1a2d1ee78ce7e

20 months ago[mlir][spirv] Allow vectors of index types in elementwise conversions
Quinn Dawkins [Thu, 16 Mar 2023 19:03:36 +0000 (15:03 -0400)]
[mlir][spirv] Allow vectors of index types in elementwise conversions

Currently the conversion of elementwise ops only checks for scalar index
types when checking for bitwidth emulation.

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

20 months ago[clang][WebAssembly] Initial support for reference type funcref in clang
Paulo Matos [Wed, 26 Oct 2022 06:48:39 +0000 (08:48 +0200)]
[clang][WebAssembly] Initial support for reference type funcref in clang

This is the funcref counterpart to 890146b. We introduce a new attribute
that marks a function pointer as a funcref. It also implements builtin
__builtin_wasm_ref_null_func(), that returns a null funcref value.

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

20 months ago[lldb][test] Replace use of p with expression in Shell tests (NFC)
Dave Lee [Thu, 16 Mar 2023 15:20:06 +0000 (08:20 -0700)]
[lldb][test] Replace use of p with expression in Shell tests (NFC)

In Shell tests, replace use of the `p` alias with the `expression` command.

To avoid conflating tests of the alias with tests of the expression command,
this patch canonicalizes to the use `expression`.

See also D141539 which made the same change to API tests.

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

20 months ago[lldb] Unify WatchpointSP variable names (NFC)
Jonas Devlieghere [Fri, 17 Mar 2023 17:06:25 +0000 (10:06 -0700)]
[lldb] Unify WatchpointSP variable names (NFC)

LLDB uses `_up`, `_sp` and `_wp` suffixes for unique, shared and weak
pointers respectively. This can become confusing in combination with
watchpoints which are commonly abbreviated to `wp`. Update
CommandObjectWatchpoint to use `watch_sp` for all `WatchpointSP`
variables.

20 months agoRevert "[flang] Feature list plugin"
Valentin Clement [Fri, 17 Mar 2023 16:59:22 +0000 (17:59 +0100)]
Revert "[flang] Feature list plugin"

This reverts commit bde91fd03f72a25151caa9f8ee2d4572ff14619b.

Failing buildbot: https://lab.llvm.org/buildbot/#/builders/181/builds/15552

20 months ago[flang] Pass box address for bind(c) assumed type dummy argument
Valentin Clement [Fri, 17 Mar 2023 16:58:15 +0000 (17:58 +0100)]
[flang] Pass box address for bind(c) assumed type dummy argument

When interfacing with C code, assumed type should be passed as
basic pointer.

Reviewed By: PeteSteinfeld

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

20 months ago[lldb] Set the watchpoint spec for expression watchpoints
Jonas Devlieghere [Fri, 17 Mar 2023 02:19:32 +0000 (19:19 -0700)]
[lldb] Set the watchpoint spec for expression watchpoints

When setting a variable watchpoint, the watchpoint stores the variable
name in the watchpoint spec. For expression variables we should store
the expression in the watchpoint spec. This patch adds that
functionality.

rdar://106096860

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

20 months ago[flang][NFC] Fix subroutine name
Valentin Clement [Fri, 17 Mar 2023 16:35:58 +0000 (09:35 -0700)]
[flang][NFC] Fix subroutine name

20 months ago[Libomptarget] Emit a special warning when no images are found
Joseph Huber [Fri, 17 Mar 2023 15:37:29 +0000 (10:37 -0500)]
[Libomptarget] Emit a special warning when no images are found

When offloading is mandatory we can emit a more helpful message if we
did not find any compatible images with the user's system.

Fixes #60221

Reviewed By: ye-luo

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

20 months ago[LV] Don't consider pointer as uniform if it is also stored.
Florian Hahn [Fri, 17 Mar 2023 16:26:07 +0000 (16:26 +0000)]
[LV] Don't consider pointer as uniform if it is also stored.

Update isVectorizedMemAccessUse to also check if the pointer is stored.
This prevents LV to incorrectly consider a pointer as uniform if it is
used as both pointer and stored by the same StoreInst.

Fixes #61396.

20 months agoRevert "[AST] Use ModRefInfo to represent access kind (NFC)"
Nikita Popov [Fri, 17 Mar 2023 16:22:37 +0000 (17:22 +0100)]
Revert "[AST] Use ModRefInfo to represent access kind (NFC)"

This reverts commit 2c78a9e65ccfe36d213a409592bebdd3ed8ba771.

Fails to compile on mlir-s390x-linux buildbot using GCC 9.4 with:

    llvm/lib/Analysis/AliasSetTracker.cpp: In member function 'void llvm::AliasSet::mergeSetIn(llvm::AliasSet&, llvm::AliasSetTracker&, llvm::BatchAAResults&)':
    llvm/lib/Analysis/AliasSetTracker.cpp:50:19: error: invalid operands of types 'unsigned char:2' and 'unsigned char:2' to binary 'operator|'

20 months ago[mlir][gpu][nvvm] fixed bug with literal for inline asm for mma instruction
Aart Bik [Wed, 15 Mar 2023 04:43:20 +0000 (21:43 -0700)]
[mlir][gpu][nvvm] fixed bug with literal for inline asm for mma instruction

The 'mma.sp.sync.aligned' family of instructions expects
the sparsity selector as a direct literal (0x0 or 0x1).
The current MLIR inline asm passed this as a value in
register, which broke the downstream assemblers

This is a small step towards supporting 2:4 sparsity on
NVidia GPUs in the sparse compiler of MLIR.

Reviewed By: ThomasRaoux, guraypp

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

20 months ago[LV] Remove scalable constraints on creating bitcasts
Graham Hunter [Thu, 16 Mar 2023 13:48:45 +0000 (13:48 +0000)]
[LV] Remove scalable constraints on creating bitcasts

InnerLoopVectorizer::createBitOrPointerCast only supported fixed
length vectors since it hadn't been updated. Supporting scalable
vectors is just a matter of changing types and using elementcount
instead of numelements, since there's nothing which actually relies
on knowing the exact length of the vector.

Original written by mgabka.

Split out from D145163.

20 months ago[clang] Fix two unused variable warnings from if statements. NFC
Craig Topper [Fri, 17 Mar 2023 16:17:57 +0000 (09:17 -0700)]
[clang] Fix two unused variable warnings from if statements. NFC

20 months ago[LICM] Regenerate test checks (NFC)
Nikita Popov [Fri, 17 Mar 2023 16:16:54 +0000 (17:16 +0100)]
[LICM] Regenerate test checks (NFC)

20 months ago[Flang][Driver] Add support for fopenmp-is-device and fembed-offload-object to Flang...
Andrew Gozillon [Fri, 17 Mar 2023 16:06:55 +0000 (11:06 -0500)]
[Flang][Driver] Add support for fopenmp-is-device and fembed-offload-object to Flang ToolChain

This allows-fembed-offload-object's and -fopenmp-is-device
compiler invocation arguments to be passed to the Flang frontend
during split compilation when offloading in OpenMP.

An example use case is when passing an offload-arch alongside
-fopenmp to embed device objects compiled for the offload-arch
within the host architecture.

This borrows from existing clangDriver+Clang.h/.cpp work and the intent
is currently to reuse as much of the existing infrastructure and design as
we can to achieve offloading for Flang+OpenMP. An overview of
Clang's offloading design can be found
here: https://clang.llvm.org/docs/OffloadingDesign.html

Reviewers:
awarzynski
jhuber6

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

20 months ago[StandardInstrumentations] Check that module analyses are properly invalidated
Arthur Eubanks [Thu, 16 Mar 2023 16:57:35 +0000 (09:57 -0700)]
[StandardInstrumentations] Check that module analyses are properly invalidated

Followup to D146003/D146160

Reviewed By: nikic

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

20 months ago[CodeView] Add source languages ObjC and ObjC++
Stefan Gränitz [Fri, 17 Mar 2023 16:08:20 +0000 (17:08 +0100)]
[CodeView] Add source languages ObjC and ObjC++

This patch adds llvm::codeview::SourceLanguage entries, DWARF translations, and PDB source file extensions in LLVM and allow LLDB's PDB parsers to recognize them correctly.

The CV_CFL_LANG enum in the Visual Studio 2022 documentation https://learn.microsoft.com/en-us/visualstudio/debugger/debug-interface-access/cv-cfl-lang defines:
```
    CV_CFL_OBJC     = 0x11,
    CV_CFL_OBJCXX   = 0x12,
```

Since the initial commit in D24317, ObjC was emitted as C language and ObjC++ as Masm.

Reviewed By: DavidSpickett

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

20 months ago[fuzzer] Use puts() rather than printf() in CopyFileToErr()
Roy Sundahl [Thu, 16 Mar 2023 01:56:11 +0000 (18:56 -0700)]
[fuzzer] Use puts() rather than printf() in CopyFileToErr()

CopyFileToErr() uses Printf("%s", ...) which fails with a negative size on
files >2Gb (Its path is through var-args wrappers to an unnecessary "%s"
expansion and subject to int overflows) Using puts() in place of printf()
bypasses this path and writes the string directly to stderr. This avoids the
present loss of data when a crashed worker has generated >2Gb of output.

rdar://99384640

Reviewed By: yln

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

20 months ago[AST] Use ModRefInfo to represent access kind (NFC)
Nikita Popov [Fri, 17 Mar 2023 16:05:11 +0000 (17:05 +0100)]
[AST] Use ModRefInfo to represent access kind (NFC)

AST was using a custom enum with exactly the same semantics. Use
the standard one instead.

20 months ago[Docs] Add release notes for D146089.
Craig Topper [Fri, 17 Mar 2023 15:59:03 +0000 (08:59 -0700)]
[Docs] Add release notes for D146089.

20 months agoRevert "[Coroutines] Fix premature conversion of return object"
Ilya Biryukov [Fri, 17 Mar 2023 15:52:17 +0000 (16:52 +0100)]
Revert "[Coroutines] Fix premature conversion of return object"

This reverts commit 54225c457a336b1609c6d064b2b606a9238a28b9.
The lack of RVO causes compile errors in our code.
Reverting to unblock our integrate.

See D145639 for full discussion.

20 months ago[libc++][NFC] Fix typo in comment
Louis Dionne [Fri, 17 Mar 2023 15:57:34 +0000 (11:57 -0400)]
[libc++][NFC] Fix typo in comment

20 months agoInstCombine: Fold is.fpclass for single infinity to fcmp
Matt Arsenault [Sun, 11 Dec 2022 00:59:39 +0000 (19:59 -0500)]
InstCombine: Fold is.fpclass for single infinity to fcmp

llvm.is.fpclass(x, fcPosInf) -> fcmp oeq x, +inf
llvm.is.fpclass(x, fcNegInf) -> fcmp oeq x, -inf
llvm.is.fpclass(x, ~fcPosInf) -> fcmp one x, +inf
llvm.is.fpclass(x, ~fcNegInf) -> fcmp one x, -inf

llvm.is.fpclass(x, fcPosInf|fcNan) -> fcmp ueq x, +inf
llvm.is.fpclass(x, fcNegInf|fcNan) -> fcmp ueq, -inf
llvm.is.fpclass(x, ~fcPosInf & ~fcNan) -> fcmp one, x, +inf
llvm.is.fpclass(x, ~fcNegInf & ~fcNan) -> fcmp one, x, -inf

This regresses some of the logic of fcmp tests. These should be restored
in a future patch to better handle combining logic of fcmp and class.

20 months ago[flang] Use llvm-readobj instead of llvm-readelf in rv64 test
David Spickett [Fri, 17 Mar 2023 15:45:42 +0000 (15:45 +0000)]
[flang] Use llvm-readobj instead of llvm-readelf in rv64 test

In some circumstances llvm-readelf symlink to llvm-readobj appears
to not be available. For want of a proper fix in CMake, use llvm-readobj
in the test instead.

20 months agoInstCombine: Fold is.fpclass nan|zero to fcmp ueq 0
Matt Arsenault [Fri, 3 Feb 2023 21:29:31 +0000 (17:29 -0400)]
InstCombine: Fold is.fpclass nan|zero to fcmp ueq 0

20 months agoRevert "InstCombine: Fold is.fpclass nan|zero to fcmp ueq 0"
Matt Arsenault [Fri, 17 Mar 2023 15:36:53 +0000 (11:36 -0400)]
Revert "InstCombine: Fold is.fpclass nan|zero to fcmp ueq 0"

This reverts commit b5ff7640cd1391ebe67e47a043fed6faf8bdcbb7.

Merge resolution gone wrong merged two unrelated patches

20 months ago[LSR] Cleanup term-fold tests
Philip Reames [Fri, 17 Mar 2023 15:32:00 +0000 (08:32 -0700)]
[LSR] Cleanup term-fold tests

Autogen for naming change, and remove comments about C code inspiration.  Multiple of these are out of sync with the actual IR, and these are IR tests anyways.

20 months agoInstCombine: Fold is.fpclass nan|zero to fcmp ueq 0
Matt Arsenault [Fri, 3 Feb 2023 21:29:31 +0000 (17:29 -0400)]
InstCombine: Fold is.fpclass nan|zero to fcmp ueq 0

20 months agoCodeGen: Reorder case handling for is.fpclass legalization
Matt Arsenault [Thu, 2 Feb 2023 14:14:36 +0000 (10:14 -0400)]
CodeGen: Reorder case handling for is.fpclass legalization

Subnormal and zero checks can be combined into one, so move
the code closer to reduce the diff in a future change.

20 months ago[Hexagon] Ensure proper ordering of instructions in HVC::AlignVectors
Krzysztof Parzyszek [Fri, 17 Mar 2023 14:01:16 +0000 (07:01 -0700)]
[Hexagon] Ensure proper ordering of instructions in HVC::AlignVectors

The shuffle reduction creates a dependency chain. Make sure that the
inputs to the next instruction are placed ahead of the instruction itself.

20 months ago[Hexagon] Add names to all instructions created in HVC
Krzysztof Parzyszek [Fri, 17 Mar 2023 13:47:46 +0000 (06:47 -0700)]
[Hexagon] Add names to all instructions created in HVC

20 months ago[Hexagon] Add debug code to HVC::AlignVectors
Krzysztof Parzyszek [Fri, 17 Mar 2023 13:44:42 +0000 (06:44 -0700)]
[Hexagon] Add debug code to HVC::AlignVectors

That and clarify/expand some comments.

20 months ago[LSR] Another minor code style improvement [nfc]
Philip Reames [Fri, 17 Mar 2023 15:08:46 +0000 (08:08 -0700)]
[LSR] Another minor code style improvement [nfc]

20 months ago[Polly] Remove some bitcasts (NFC)
Nikita Popov [Fri, 17 Mar 2023 14:58:52 +0000 (15:58 +0100)]
[Polly] Remove some bitcasts (NFC)

No longer relevant with opaque pointers.

20 months ago[LSR] Minor code style improvement [nfc]
Philip Reames [Fri, 17 Mar 2023 14:50:26 +0000 (07:50 -0700)]
[LSR] Minor code style improvement [nfc]

20 months ago[clang][test] Fix -DBUILD_SHARED_LIBS build by adding depency on MC from clangTesting
Alex Bradbury [Fri, 17 Mar 2023 14:42:41 +0000 (14:42 +0000)]
[clang][test] Fix -DBUILD_SHARED_LIBS build by adding depency on MC from clangTesting

Commit 34de7da6246cdfa6ff6f3d3c514583cddc0a10ec (D143436) introduced a
dependency on the TargetRegistry in `getAnyTargetForTesting`. This is
part of MC, which wasn't listed in clang/lib/Testing/CMakeLists.txt.
This broke the -DBUILD_SHARED_LIBS=True builds.

20 months ago[Polly] Convert remaining tests to opaque pointers (NFC)
Nikita Popov [Fri, 17 Mar 2023 14:28:24 +0000 (15:28 +0100)]
[Polly] Convert remaining tests to opaque pointers (NFC)

20 months agoInstCombine: Add a few more tests for is.fpclass folding
Matt Arsenault [Wed, 15 Mar 2023 11:24:38 +0000 (07:24 -0400)]
InstCombine: Add a few more tests for is.fpclass folding

20 months ago[LLDB] Remove some typed pointer code (NFCI)
Nikita Popov [Fri, 17 Mar 2023 14:21:41 +0000 (15:21 +0100)]
[LLDB] Remove some typed pointer code (NFCI)

Various bitcast handling should no longer be necessary with
opaque pointers.

20 months ago[LV] Add test where pointer is incorrectly marked as uniform.
Florian Hahn [Fri, 17 Mar 2023 14:23:56 +0000 (14:23 +0000)]
[LV] Add test where pointer is incorrectly marked as uniform.

Test for #61396.

20 months agoGlobalISel: Use FPClassTest in is.fpclass lowering
Matt Arsenault [Fri, 17 Mar 2023 13:21:57 +0000 (09:21 -0400)]
GlobalISel: Use FPClassTest in is.fpclass lowering

20 months ago[Polly] Convert some tests to opaque pointers (NFC)
Nikita Popov [Fri, 17 Mar 2023 13:45:41 +0000 (14:45 +0100)]
[Polly] Convert some tests to opaque pointers (NFC)

20 months ago[LV] Convert consecutive-ptr-uniforms.ll to use opaque pointers (NFC).
Florian Hahn [Fri, 17 Mar 2023 14:07:10 +0000 (14:07 +0000)]
[LV] Convert consecutive-ptr-uniforms.ll to use opaque pointers (NFC).

20 months agoAdd __builtin_FILE_NAME()
Ilya Karapsin [Fri, 17 Mar 2023 13:50:34 +0000 (09:50 -0400)]
Add __builtin_FILE_NAME()

Add '__builtin_FILE_NAME()', which expands to the filename because the
full path is not always needed. It corresponds to the '__FILE_NAME__'
predefined macro and is consistent with the other '__builin' functions
added for predefined macros.

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

20 months ago[Polly] Convert some tests to opaque pointers (NFC)
Nikita Popov [Fri, 17 Mar 2023 13:30:41 +0000 (14:30 +0100)]
[Polly] Convert some tests to opaque pointers (NFC)

20 months ago[Docs] Fix typo in LoopTerminology.
Carlos Alberto Enciso [Fri, 17 Mar 2023 13:38:44 +0000 (13:38 +0000)]
[Docs] Fix typo in LoopTerminology.

20 months ago[lldb][PDB] Rename GetDeclarationForSymbol() -> AddSourceInfoToDecl()
Stefan Gränitz [Fri, 17 Mar 2023 13:37:26 +0000 (14:37 +0100)]
[lldb][PDB] Rename GetDeclarationForSymbol() -> AddSourceInfoToDecl()

The old name of this function was confusing for me, when I started working on the PDB parser. The new name clearifies that the function adds file, line and column (typically referred as source info) and indicates that the information is stored in the provided decl parameter.

Reviewed By: DavidSpickett

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