platform/upstream/llvm.git
16 months ago[Flang] Add user option -funderscoring/-fnounderscoring to control trailing underscor...
Mark Danial [Tue, 21 Feb 2023 21:33:06 +0000 (16:33 -0500)]
[Flang] Add user option -funderscoring/-fnounderscoring to control trailing underscore added to external names

This patch adds user option -funderscoring/-fnounderscoring  to control the trailing underscore being appended to external names (e.g. procedure names, common block names). The option in gfortran is documented in https://gcc.gnu.org/onlinedocs/gfortran/Code-Gen-Options.html.

Reviewed By: clementval

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

16 months ago[mlir][sparse] revert optimization for dense->csc conversion.
Peiming Liu [Tue, 21 Feb 2023 21:26:46 +0000 (21:26 +0000)]
[mlir][sparse] revert optimization for dense->csc conversion.

Eliminates the sort seems make the whole conversion slower (probably because loop rotation leads to bad locality).

Reviewed By: aartbik

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

16 months ago[SLP]Do not swap not counted extractelements.
Alexey Bataev [Tue, 21 Feb 2023 18:20:41 +0000 (10:20 -0800)]
[SLP]Do not swap not counted extractelements.

No need to swap extractelements, which were not excluded from the list
during cost analysis. It leads to incorrect cost calculation and make
vector code more profitable than it is actually is.

16 months ago[libc] Introduce a libc internal assertion macro named LIBC_ASSERT.
Siva Chandra Reddy [Thu, 16 Feb 2023 01:01:33 +0000 (01:01 +0000)]
[libc] Introduce a libc internal assertion macro named LIBC_ASSERT.

Few existing call-sites have been modified to use LIBC_ASSERT.

Reviewed By: lntue, michaelrj

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

16 months ago[Hexagon] Improve selection algorithm in HvxSelector::select
Krzysztof Parzyszek [Fri, 17 Feb 2023 17:39:04 +0000 (09:39 -0800)]
[Hexagon] Improve selection algorithm in HvxSelector::select

The previous algorithm could order nodes incorrectly, this one strictly
follows the topological order.

16 months ago[SPIR-V] Emit spv_undef intrinsic for aggregate undef operands
Michal Paszkowski [Thu, 16 Feb 2023 20:23:48 +0000 (21:23 +0100)]
[SPIR-V] Emit spv_undef intrinsic for aggregate undef operands

This change adds a new spv_undef intrinsic which is emitted in place of
aggregate undef operands and later selected to single OpUndef SPIR-V
instruction. The behavior matches that of Khronos SPIR-V Translator and
should support nested aggregates.

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

16 months ago[RISCV] Minor style cleanup in lowerVECTOR_SHUFFLEAsVNSRL [nfc]
Philip Reames [Tue, 21 Feb 2023 19:57:37 +0000 (11:57 -0800)]
[RISCV] Minor style cleanup in lowerVECTOR_SHUFFLEAsVNSRL [nfc]

16 months ago[MemProf] Make hasSingleAllocType helper non-static
Teresa Johnson [Sat, 18 Feb 2023 02:44:29 +0000 (18:44 -0800)]
[MemProf] Make hasSingleAllocType helper non-static

As suggested in D140908, make the hasSingleAllocType helper non-static
so that it can be used in other files. Add unit testing.

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

16 months ago[libc][CMake] Missing TableGen include
Petr Hosek [Mon, 20 Feb 2023 23:07:09 +0000 (23:07 +0000)]
[libc][CMake] Missing TableGen include

HdrGen CMake build uses TableGen so it should include TableGen module.

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

16 months ago[Driver][FreeBSD] Fix DWARF test after 2a2c0fd96757871f4e8052624000c208cc574fdf
Brad Smith [Tue, 21 Feb 2023 19:51:18 +0000 (14:51 -0500)]
[Driver][FreeBSD] Fix DWARF test after 2a2c0fd96757871f4e8052624000c208cc574fdf

The default DWARF version without a FreeBSD version specified is 4.

16 months ago[mlir][GPUToLLVM] Add support for emitting opaque pointers
Markus Böck [Tue, 21 Feb 2023 06:51:44 +0000 (07:51 +0100)]
[mlir][GPUToLLVM] Add support for emitting opaque pointers

Part of https://discourse.llvm.org/t/rfc-switching-the-llvm-dialect-and-dialect-lowerings-to-opaque-pointers/68179

This patch adds the new pass option `use-opaque-pointers` to the GPU to LLVM lowerings (including ROCD and NVVM) and adapts the code to support using opaque pointers in addition to typed pointers.
The required changes mostly boil down to avoiding `getElementType` and specifying base types in GEP and Alloca.

In the future opaque pointers will be the only supported model, hence tests have been ported to using opaque pointers by default. Additional regression tests for typed-pointers have been added to avoid breaking existing clients.

Note: This does not yet port the `GpuToVulkan` passes.

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

16 months ago[mlir][LLVM] Don't make `LLVM_IntPtrBase` a `BuildableType` to allow the use of opaqu...
Markus Böck [Tue, 21 Feb 2023 14:29:32 +0000 (15:29 +0100)]
[mlir][LLVM] Don't make `LLVM_IntPtrBase` a `BuildableType` to allow the use of opaque pointers

Making the constraint a buildable type makes them incompatible with opaque pointers, at least while we still support typed pointers, since Ops making use of the constraint will then automatically create a typed pointer on parse.

This patch therefore fixes that issue by removing the `BuildableType` mixin. This has a bit of a cascading effect however, as all users of the constraint now need operands of that type to be added to the assembly format, hence a lot of adjustments to the syntax of a lot of (mostly intrinsic) ops.

Few things of note: The syntax as is, is only required while we're supporting both typed and opaque pointers. Once we drop support for typed pointers, we can make it a `BuildableType` again. As a drive by I also fixed the address space not being verified in the constraint. Finally, I added some roundtripping tests, most importantly for ops with `type($specific_operand)` occurences. These are printed incorrectly with typed pointers if not wrapped within a `qualified`.

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

16 months ago[PowerPC] clang-format isPPC64ELFv2ABI() function. NFC
Brad Smith [Tue, 21 Feb 2023 19:41:22 +0000 (14:41 -0500)]
[PowerPC] clang-format isPPC64ELFv2ABI() function. NFC

16 months agoReland "[ADT] Relax type requirements for `is_contained`"
Jakub Kuderski [Tue, 21 Feb 2023 19:32:01 +0000 (14:32 -0500)]
Reland "[ADT] Relax type requirements for `is_contained`"

16 months ago[flang] Make sure the length is propagated when emboxing a char to unlimited polymopr...
Valentin Clement [Tue, 21 Feb 2023 19:31:56 +0000 (20:31 +0100)]
[flang] Make sure the length is propagated when emboxing a char to unlimited polymoprhic box

When passing a character with unknown length to a subroutine expecting
an unlimited polymorphic pointer, a new descriptor is created. The
fir.embox operation needs to carry over the length from the character
to be passed correctly.

Reviewed By: PeteSteinfeld

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

16 months ago[flang] Make assignment of derived-type with allocatable polymorphic components with...
Valentin Clement [Tue, 21 Feb 2023 19:30:47 +0000 (20:30 +0100)]
[flang] Make assignment of derived-type with allocatable polymorphic components with the runtime

Derived-type assignment was already handling the case of derived-type with
allocatable components with the runtime. Extend the code so the polymorphic
allocatable component are also taken into account.

Reviewed By: PeteSteinfeld

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

16 months agoRevert "[ADT] Relax type requirements for `is_contained`"
Jakub Kuderski [Tue, 21 Feb 2023 19:30:35 +0000 (14:30 -0500)]
Revert "[ADT] Relax type requirements for `is_contained`"

This reverts commit 75272d5c1299db93aa619fc9e616832f578726c2.

This fails to compile on the clang-debian-cpp20 buildbot:
https://lab.llvm.org/buildbot#builders/249/builds/945.

16 months ago[Driver][FreeBSD] Correct driver behavior if a triple is provided without a version
Brad Smith [Tue, 21 Feb 2023 19:05:34 +0000 (14:05 -0500)]
[Driver][FreeBSD] Correct driver behavior if a triple is provided without a version

While looking at other usage of getOSMajorVersion() I noticed if a version number is not
included in the FreeBSD triple it won't include the --hash-style=both linker option or
not disable the use of .init_array. Without a version should be the latest.

FreeBSD 8 and 9 are no longer supported. So simplify things with the version handling
as well.

Reviewed By: dim

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

16 months ago[PowerPC] Use member function to determine PowerPC Secure PLT
Brad Smith [Tue, 21 Feb 2023 19:00:43 +0000 (14:00 -0500)]
[PowerPC] Use member function to determine PowerPC Secure PLT

Add a member function isPPC32SecurePlt() to determine whether Secure
PLT is used by the target 32-bit PowerPC operating environment.

Reviewed By: dim, maskray

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

16 months ago[NFC][SLP]Add a test for optimistic vectorization, NFC.
Alexey Bataev [Tue, 21 Feb 2023 18:43:52 +0000 (10:43 -0800)]
[NFC][SLP]Add a test for optimistic vectorization, NFC.

16 months ago[SelectionDAG] Migrate away from soft-deprecated functions. NFC
Fangrui Song [Tue, 21 Feb 2023 19:01:34 +0000 (11:01 -0800)]
[SelectionDAG] Migrate away from soft-deprecated functions. NFC

16 months ago[libc] Fix LIBC_GPU_ARCHITECTURES not being used
Joseph Huber [Tue, 21 Feb 2023 18:59:02 +0000 (12:59 -0600)]
[libc] Fix LIBC_GPU_ARCHITECTURES not being used

Summary:
This variable is supposed to control the architectures to build for. At
some point this was changes out for testing and never fixed.

16 months ago[mlir][linalg] Match element type of result when doing propagation of unpack through...
Quinn Dawkins [Mon, 20 Feb 2023 21:27:51 +0000 (16:27 -0500)]
[mlir][linalg] Match element type of result when doing propagation of unpack through elementwise

When propagating tensor.unpack ops through elementwise generics, a new
output tensor is needed if the element type of the input differs from
that of the output in the elementwise op.

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

16 months ago[flang] Remove parameter for libm mlir::populateMathToLibmConversionPatterns.
Alexander Belyaev [Tue, 21 Feb 2023 18:41:17 +0000 (19:41 +0100)]
[flang] Remove parameter for libm mlir::populateMathToLibmConversionPatterns.

https://reviews.llvm.org/rG8a9d4895df780231a14a1afc44e18b1f6b7eab93

16 months ago[libc++][NFC] Simplify __sort{4,5}
Nikolas Klauser [Tue, 21 Feb 2023 14:09:12 +0000 (15:09 +0100)]
[libc++][NFC] Simplify __sort{4,5}

Don't return the number of swaps; it's not used anywhere.

Reviewed By: Mordante, #libc, avogelsgesang

Spies: libcxx-commits

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

16 months ago[docs] Improve guidance on installing the correct buildbot-worker version
Alex Bradbury [Tue, 21 Feb 2023 18:38:33 +0000 (18:38 +0000)]
[docs] Improve guidance on installing the correct buildbot-worker version

The docs currently state that buildbot-worker 2.8.5 is used. However,
looking at the buildbot release notes
<http://docs.buildbot.net/current/relnotes/index.html>, this release
doesn't seem to exist (it's not on PyPI either). The document also links
to http://trac.buildbot.net/ as a source to retrieve an old version and
install it manually, but this is dead.

Instead, drop that advice and suggest pip3 install
buildbot-worker==2.8.4, as done by the Dockerfiles in
llvm-zorg/buildbot/google/docker/*.

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

16 months ago[STLExtras] Allow for non-member `begin`/`end` in `append_range`
Jakub Kuderski [Tue, 21 Feb 2023 18:23:17 +0000 (13:23 -0500)]
[STLExtras] Allow for non-member `begin`/`end` in `append_range`

This makes `append_range` useable with, C arrays and types with custom
`begin`/`end` functions.

Reviewed By: kazu

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

16 months ago[mlir] Use foldDynamicIndexList instead of canonicalizeSubViewPart.
Alexander Belyaev [Tue, 21 Feb 2023 08:16:14 +0000 (09:16 +0100)]
[mlir] Use foldDynamicIndexList instead of canonicalizeSubViewPart.

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

16 months ago[mlir] Clean-up math -> libm/llvm conversion.
Alexander Belyaev [Tue, 21 Feb 2023 07:18:45 +0000 (08:18 +0100)]
[mlir] Clean-up math -> libm/llvm conversion.

At the moment, there is an optional log1pBenefit
populateMathToLibmConversionPatterns which is used to increase the priority of
the log1p->libm pattern compared to log1p->llvm pattern that approximates
log1p with precision issues. Instead, we can have a flag for the MathToLLVM
pass to enable or disable the imprecise approximation.

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

16 months ago[ADT] Relax type requirements for `is_contained`
Jakub Kuderski [Tue, 21 Feb 2023 18:05:01 +0000 (13:05 -0500)]
[ADT] Relax type requirements for `is_contained`

- Do not require both the `Set` and `Element` to be exactly the same type and, instead, only require them to be comparable.
- Do not require `Element` to be copyable.
- Add missing documentation comment.

Reviewed By: beanz

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

16 months ago[RISCV] Extract a helper routine for computing (runtime) VLMax [nfc]
Philip Reames [Tue, 21 Feb 2023 17:55:23 +0000 (09:55 -0800)]
[RISCV] Extract a helper routine for computing (runtime) VLMax [nfc]

16 months ago[InstSimplify] add tests for simplifyWithOpReplaced(); NFC
Sanjay Patel [Tue, 21 Feb 2023 13:23:27 +0000 (08:23 -0500)]
[InstSimplify] add tests for simplifyWithOpReplaced(); NFC

issue #60799
issue #60801

16 months ago[clang]Fix warning for signed conversion on LP64
Yaxun (Sam) Liu [Tue, 14 Feb 2023 14:52:42 +0000 (09:52 -0500)]
[clang]Fix warning for signed conversion on LP64

Currently clang emits warning with -Wconversion for the following code
on LP64 system e.g. x86_64-unknown-linux-gnu:

long foo(long x) {
  return 1LL<<x;
}
warning: implicit conversion changes signedness: 'long long' to 'long' [-Wsign-conversion]

return 1ll << x;
~~~~~~ ~~~~^~~~
This does not make sense since all operands are signed.

This patch fixes that to match -m32 and GCC behaviour.

Reviewed by: Fangrui Song

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

16 months ago[IRMover] Remove UB implying parameter attributes when necessary
Tim Neumann [Tue, 21 Feb 2023 17:35:30 +0000 (18:35 +0100)]
[IRMover] Remove UB implying parameter attributes when necessary

When importing functions from some module X into some module Y, they may reference other functions already present in Y. The signature (especially attributes) of those other functions may have diverged between X and Y (e.g. due to the Dead Argument Elimination optimization). If necessary, modify the attributes to avoid UB.

See the added test and implementation comments for more details.

This was exposed by https://reviews.llvm.org/D133036 before it was reverted. Fixes https://github.com/llvm/llvm-project/issues/58976.

Reviewed By: tejohnson

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

16 months ago[libc] Add Month enum, refactor mktime_test
Jeff Bailey [Tue, 21 Feb 2023 17:20:23 +0000 (17:20 +0000)]
[libc] Add Month enum, refactor mktime_test

Introduce Month enum.

Use designated initializers instead of comments to ensure that tm_data
is initialized correctly.  Use Month enum for initializing .tm_mon to
avoid off-by-one errors.

Co-authored-by: Raman Tenneti <rtenneti@google.com>
Reviewed By: rtenneti

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

16 months ago[GlobalOpt] Add tests with non-GEP ConstExpr.
Florian Hahn [Tue, 21 Feb 2023 17:16:09 +0000 (17:16 +0000)]
[GlobalOpt] Add tests with non-GEP ConstExpr.

Extra tests for CleanupPointerRootUsers with non-GEP constant
expressions for D144468.

16 months ago[clang][docs] Document ThinLTO options for ld64.lld
Jez Ng [Tue, 21 Feb 2023 15:32:07 +0000 (10:32 -0500)]
[clang][docs] Document ThinLTO options for ld64.lld

The LTO-cache-related flags were added here: {D105922}

Reviewed By: tejohnson

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

16 months ago[NFC] Use find_last_of when seraching for code in getRawCommentForDeclNoCacheImpl
Kugan Vivekanandarajah [Tue, 21 Feb 2023 16:24:26 +0000 (16:24 +0000)]
[NFC] Use find_last_of when seraching for code in getRawCommentForDeclNoCacheImpl

ASTContext::getRawCommentForDeclNoCacheImpl in this case, extracts the text between
the comment and declaration to make sure if there are  no other declarations or preprocessor
directives between  comment or declarations.

While using Text.find_first_of or Text.find_last_of  is functionally the same,
 using Text.find_last_of terminates fast in the presence of such.

Especially in generated code with sparse comments, it takes longer
to bailout when there is code in-between. Searching from last
(with find_last_of) bails out faster.

This shows up in perf profiles with clangd in some auto-generated code.
ASTContext::getRawCommentForDeclNoCacheImpl showing as much as 18.2% in this
case. With find_last_of, this drops to 2.8%.

Reviewed By: aaron.ballman

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

16 months ago[gn build] Port b4ecfd3c4675
LLVM GN Syncbot [Tue, 21 Feb 2023 16:11:42 +0000 (16:11 +0000)]
[gn build] Port b4ecfd3c4675

16 months ago[libc++] Forward to std::memcmp for trivially comparable types in equal
Nikolas Klauser [Wed, 7 Dec 2022 17:51:28 +0000 (18:51 +0100)]
[libc++] Forward to std::memcmp for trivially comparable types in equal

Reviewed By: #libc, ldionne

Spies: ldionne, Mordante, libcxx-commits

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

16 months ago[gn build] Port e8cb3559eec0
LLVM GN Syncbot [Tue, 21 Feb 2023 16:02:37 +0000 (16:02 +0000)]
[gn build] Port e8cb3559eec0

16 months ago[Flang][OpenMP] Fix when the toplevel unit is present in declare target
Kiran Chandramohan [Tue, 21 Feb 2023 15:39:19 +0000 (15:39 +0000)]
[Flang][OpenMP] Fix when the toplevel unit is present in declare target

If the toplevel unit is present in a declare target construct, do not
try to again find the enclosing construct.
Patch also re-arranges the checks.

Reviewed By: peixin

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

16 months ago[SLP]Properly define incoming block for user PHI nodes.
Alexey Bataev [Tue, 21 Feb 2023 15:07:43 +0000 (07:07 -0800)]
[SLP]Properly define incoming block for user PHI nodes.

MainOp of the PHI vectorizable entries contains the proper order of
incoming blocks, not the last instruction in the block.

16 months ago[libc++] Move constexpr <cstring> functions into their own headers and remove unused...
Nikolas Klauser [Sat, 4 Feb 2023 23:21:11 +0000 (00:21 +0100)]
[libc++] Move constexpr <cstring> functions into their own headers and remove unused <cstring> includes

Reviewed By: ldionne, Mordante, #libc, #libc_abi

Spies: libcxx-commits

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

16 months ago[OpenMP] Update the bug report link for `libomp` assertion failures
Joseph Huber [Mon, 20 Feb 2023 20:30:17 +0000 (14:30 -0600)]
[OpenMP] Update the bug report link for `libomp` assertion failures

Currently we still print the old https://bugs.llvm.org/ bugzilla link.
We should update this to the issues pane for the LLVM github.

Reviewed By: tlwilmar

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

16 months ago[InstCombine] Add additional alloca comparison tests (NFC)
Nikita Popov [Tue, 21 Feb 2023 15:38:42 +0000 (16:38 +0100)]
[InstCombine] Add additional alloca comparison tests (NFC)

16 months ago[Flang][OpenMP] Use the ultimate symbol for allocatable check
Kiran Chandramohan [Tue, 21 Feb 2023 15:16:16 +0000 (15:16 +0000)]
[Flang][OpenMP] Use the ultimate symbol for allocatable check

Reviewed By: peixin

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

16 months ago[NFC][clang][Modules] Refine test checks by adding `:`
Mariya Podchishchaeva [Tue, 21 Feb 2023 15:07:47 +0000 (10:07 -0500)]
[NFC][clang][Modules] Refine test checks by adding `:`

The test can fail if wokring directory where the test was launched
has a `error` substring in its path.

Reviewed By: ChuanqiXu

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

16 months ago[AArch64] Add a test for loading into a zerovector. NFC
David Green [Tue, 21 Feb 2023 14:42:53 +0000 (14:42 +0000)]
[AArch64] Add a test for loading into a zerovector. NFC

16 months ago[mlir][Linalg][Transform] NFC - Replace assert by more graceful error
Nicolas Vasilache [Tue, 21 Feb 2023 14:09:21 +0000 (06:09 -0800)]
[mlir][Linalg][Transform] NFC - Replace assert by more graceful error

16 months ago[flang][OpenMP] Add parser support for order clause
Kavitha Natarajan [Tue, 24 Jan 2023 09:06:22 +0000 (14:36 +0530)]
[flang][OpenMP] Add parser support for order clause

Added parser support for OpenMP 5.0 & 5.1 feature
ORDER([order-modifier :]concurrent) clause for all
applicable and supported OpenMP directives.

Reviewed By: kiranchandramohan, abidmalikwaterloo

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

16 months ago[AMDGPU] MIR-Tests for Multiplication using KBA
Jessica Del [Mon, 20 Feb 2023 15:51:15 +0000 (16:51 +0100)]
[AMDGPU] MIR-Tests for Multiplication using KBA

These tests show inefficient behavior that will be optimized by a
later change.

By using Known Bits Analysis, we can avoid unnecessary multiplications
or additions with 0.

16 months ago[SimplifyCFG] Check if the return instruction causes undefined behavior
DianQK [Tue, 21 Feb 2023 12:25:59 +0000 (20:25 +0800)]
[SimplifyCFG] Check if the return instruction causes undefined behavior

This should fix https://github.com/rust-lang/rust/issues/107681.

Return undefined to a noundef return value is undefined.

Example:

```
define noundef i32 @test_ret_noundef(i1 %cond) {
entry:
  br i1 %cond, label %bb1, label %bb2
bb1:
  br label %bb2
bb2:
  %r = phi i32 [ undef, %entry ], [ 1, %bb1 ]
  ret i32 %r
}
```

Reviewed By: nikic

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

16 months ago[IPSCCP] Remove noundef when zapping return values
Nikita Popov [Tue, 21 Feb 2023 10:01:18 +0000 (11:01 +0100)]
[IPSCCP] Remove noundef when zapping return values

When replacing return values with undef, we should also drop the
noundef attribute (and other UB implying attributes).

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

16 months ago[NFC] Added a lit test for the arithmetic fence builtin.
Ammarguellat [Fri, 17 Feb 2023 21:52:19 +0000 (16:52 -0500)]
[NFC] Added a lit test for the arithmetic fence builtin.

16 months ago[libomptarget] Remove unused image from global data movement function
Joseph Huber [Mon, 20 Feb 2023 23:03:28 +0000 (17:03 -0600)]
[libomptarget] Remove unused image from global data movement function

This interface function does not actually need the device image type.
It's unused in the function, so it should be able to be safely removed.
The motivation for this is to facilitate downsteam porting of the
amd-stg-open RPC module into the nextgen plugin so we can delete the old
plugin entirely. For that to work we need to be able to call this
function at kernel-launch time, which doesn't have the image. Also it's
cleaner.

Reviewed By: jplehr

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

16 months ago[mlir][OpenACCToLLVM] Add pass option to emit opaque pointers
Markus Böck [Tue, 21 Feb 2023 10:05:27 +0000 (11:05 +0100)]
[mlir][OpenACCToLLVM] Add pass option to emit opaque pointers

Part of https://discourse.llvm.org/t/rfc-switching-the-llvm-dialect-and-dialect-lowerings-to-opaque-pointers/68179

This patch simply adds the pass option use-opaque-pointers to instruct the pass to use opaque-pointers instead of typed pointers during conversion.
The pass itself does not actually make use of any pointers or anything, so did not require any changes except simply setting the option in the type converter. The tests have also been converted to using opaque-pointers

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

16 months ago[GlobalOpt] Add test with large number of stores with non-null loads.
Florian Hahn [Tue, 21 Feb 2023 13:01:10 +0000 (13:01 +0000)]
[GlobalOpt] Add test with large number of stores with non-null loads.

16 months ago[Flang][OpenMP] Add convert to match the argument and result of update Op
Kiran Chandramohan [Tue, 21 Feb 2023 12:34:03 +0000 (12:34 +0000)]
[Flang][OpenMP] Add convert to match the argument and result of update Op

Fixes #60873

Reviewed By: peixin

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

16 months ago[Flang][WWW] Add link to doxygen page
Kiran Chandramohan [Tue, 21 Feb 2023 12:26:38 +0000 (12:26 +0000)]
[Flang][WWW] Add link to doxygen page

Reviewed By: PeteSteinfeld

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

16 months ago[flang] Add TODO when trying to do a polymorphic temp in getTempExtAddr
Valentin Clement [Tue, 21 Feb 2023 12:23:44 +0000 (13:23 +0100)]
[flang] Add TODO when trying to do a polymorphic temp in getTempExtAddr

Reviewed By: jeanPerier

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

16 months ago[runtimes] Remove add_target_flags* functions and use add_flags* instead
Nikolas Klauser [Mon, 20 Feb 2023 15:47:34 +0000 (16:47 +0100)]
[runtimes] Remove add_target_flags* functions and use add_flags* instead

Reviewed By: phosek, #libunwind, #libc, #libc_abi

Spies: libcxx-commits

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

16 months ago[runtimes] Move common functions from Handle{Libcxx,Libcxxabi,Libunwind}Flags.cmake...
Nikolas Klauser [Mon, 20 Feb 2023 15:26:19 +0000 (16:26 +0100)]
[runtimes] Move common functions from Handle{Libcxx,Libcxxabi,Libunwind}Flags.cmake to runtimes/cmake/Modules/HandleFlags.cmake

Reviewed By: phosek, #libunwind, #libc, #libc_abi

Spies: arichardson, libcxx-commits

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

16 months ago[RISCV] Add vendor-defined XTheadMemPair (two-GPR Memory Operations) extension
Manolis Tsamis [Tue, 21 Feb 2023 11:21:35 +0000 (12:21 +0100)]
[RISCV] Add vendor-defined XTheadMemPair (two-GPR Memory Operations) extension

The vendor-defined XTHeadMemPair (no comparable standard extension exists
at the time of writing) extension adds two-GPR load/store pair instructions.

It is supported by the C9xx cores (e.g., found in the wild in the
Allwinner D1) by Alibaba T-Head.

The current (as of this commit) public documentation for this
extension is available at:
  https://github.com/T-head-Semi/thead-extension-spec/releases/download/2.2.2/xthead-2023-01-30-2.2.2.pdf

Support for these instructions has already landed in GNU Binutils:
  https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=6e17ae625570ff8f3c12c8765b8d45d4db8694bd

Depends on D143847

Reviewed By: craig.topper

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

16 months ago[PowerPC][NFC] refactor eligible check for tail call optimization
Ting Wang [Tue, 21 Feb 2023 11:14:47 +0000 (06:14 -0500)]
[PowerPC][NFC] refactor eligible check for tail call optimization

The check logic for TCO is scattered in two functions:
IsEligibleForTailCallOptimization_64SVR4() IsEligibleForTailCallOptimization(),
and serves instruction selection phase only at this moment.

This patch aims to refactor existing logic to export an API for TCO
eligible query before instruction selection phase.

Reviewed By: shchenz, nemanjai

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

16 months ago[GlobalOpt] Add tests for missed CleanupPointerRootUsers opportunity.
Florian Hahn [Tue, 21 Feb 2023 11:04:09 +0000 (11:04 +0000)]
[GlobalOpt] Add tests for missed CleanupPointerRootUsers opportunity.

16 months ago[clang-format][NFC] Clean up nullptr comparison style
Owen Pan [Mon, 20 Feb 2023 00:05:55 +0000 (16:05 -0800)]
[clang-format][NFC] Clean up nullptr comparison style

For example, use 'Next' instead of 'Next != nullptr',
and '!Next' instead of 'Next == nullptr'.

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

16 months ago[clalng-format] Fix handling of TypeScript tuples with optional last member
Taymon A. Beal [Tue, 21 Feb 2023 10:47:36 +0000 (02:47 -0800)]
[clalng-format] Fix handling of TypeScript tuples with optional last member

These were previously incorrectly treated as syntax errors.

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

16 months ago[GlobalOpt] Add test with many stores of the initializer only.
Florian Hahn [Tue, 21 Feb 2023 10:24:50 +0000 (10:24 +0000)]
[GlobalOpt] Add test with many stores of the initializer only.

16 months ago[gn build] Port 8e68c1204580
LLVM GN Syncbot [Tue, 21 Feb 2023 10:00:16 +0000 (10:00 +0000)]
[gn build] Port 8e68c1204580

16 months ago[IPSCCP] Add tests for noundef attribute on zapped returns (NFC)
Nikita Popov [Tue, 21 Feb 2023 09:53:23 +0000 (10:53 +0100)]
[IPSCCP] Add tests for noundef attribute on zapped returns (NFC)

We replace the return value with undef without dropping the
noundef attribute.

16 months ago[RISCV] Use a smaller VL when interleaving fixed vectors
Luke Lau [Mon, 20 Feb 2023 13:26:17 +0000 (13:26 +0000)]
[RISCV] Use a smaller VL when interleaving fixed vectors

Interleaves generated with vwaddu.vv and vwmaccu.vx were using VLs that
were twice the number of elements actually needed in the vector.
This also pulls the interleaving logic out into its own function so it
can be reused by later patches, and adapts it for scalable vectors.

Reviewed By: craig.topper

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

16 months ago[RISCV][NFC] Make a note of the operands for RISCVISD::VNSRL_VL
Luke Lau [Mon, 20 Feb 2023 13:32:50 +0000 (13:32 +0000)]
[RISCV][NFC] Make a note of the operands for RISCVISD::VNSRL_VL

Split out from https://reviews.llvm.org/D144092

Reviewed By: craig.topper

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

16 months ago[AMDGPU] Remove function with incompatible features
pvanhout [Fri, 10 Feb 2023 08:32:51 +0000 (09:32 +0100)]
[AMDGPU] Remove function with incompatible features

Adds a new pass that removes functions
if they use features that are not supported on the current GPU.

This change is aimed at preventing crashes when building code at O0 that
uses idioms such as `if (ISA_VERSION >= N) intrinsic_a(); else intrinsic_b();`
where ISA_VERSION is not constexpr, and intrinsic_a is not selectable
on older targets.
This is a pattern that's used all over the ROCm device libs. The main
motive behind this change is to allow code using ROCm device libs
to be built at O0.

Note: the feature checking logic is done ad-hoc in the pass. There is no other
pass that needs (or will need in the foreseeable future) to do similar
feature-checking logic so I did not see a need to generalize the feature
checking logic yet. It can (and should probably) be generalized later and
moved to a TargetInfo-like class or helper file.

Reviewed By: arsenm, Joe_Nash

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

16 months ago[flang] Use runtime Assign when rhs is polymorphic
Valentin Clement [Tue, 21 Feb 2023 09:14:00 +0000 (10:14 +0100)]
[flang] Use runtime Assign when rhs is polymorphic

Use the runtime when there lhs or rhs is polymorphic. The runtime
allows to deal better with polymorphic entities and aliasing.

Reviewed By: PeteSteinfeld

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

16 months ago[flang] Accept polymorphic scalar in elemental intrinsic lowering
Valentin Clement [Tue, 21 Feb 2023 09:12:07 +0000 (10:12 +0100)]
[flang] Accept polymorphic scalar in elemental intrinsic lowering

When lowering an elemental intrinsic like MERGE, a scalar
polymorphic entity was not recognized as a scalar. Update the check
so polyrmorphic entity can be used.

Reviewed By: PeteSteinfeld

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

16 months ago[mlir][llvm] Add isVarArg flag to lookupOrCreateFn.
Ingo Müller [Fri, 17 Feb 2023 11:51:13 +0000 (11:51 +0000)]
[mlir][llvm] Add isVarArg flag to lookupOrCreateFn.

The function is a helper for looking up a function by name or creating
it if it doesn't exist. The arguments allow to specify the signature of
the function, if it needs to be created, but do not expose the varArg
parameter of LLVMFunctionType. This patch exposes adds an optional
parameter with a default value of false such that existing usage
continue to work as before.

Reviewed By: springerm

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

16 months ago[mlir][transform] Add transform.get_defining_op op
Matthias Springer [Tue, 21 Feb 2023 07:57:16 +0000 (08:57 +0100)]
[mlir][transform] Add transform.get_defining_op op

This op is the inverse of `transform.get_result`.

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

16 months ago[InstSimplify][CaptureTracking] Reduce scope of special case
Nikita Popov [Tue, 21 Feb 2023 07:53:22 +0000 (08:53 +0100)]
[InstSimplify][CaptureTracking] Reduce scope of special case

As described in PR54002, the "icmp of load from global" special
case in CaptureTracking is incorrect, as is the InstSimplify code
that makes use of it.

This moves the special case from CaptureTracking into InstSimplify
to limit its scope to the buggy transform only, and not affect
other code using CaptureTracking as well.

16 months ago[X86] Precommit a test
Kazu Hirata [Tue, 21 Feb 2023 08:01:43 +0000 (00:01 -0800)]
[X86] Precommit a test

This patch precommits a test for:

https://github.com/llvm/llvm-project/issues/60374

16 months ago[AMDGPU] MIR-Tests for Multiplication using KBA
Jessica Del [Mon, 20 Feb 2023 15:51:15 +0000 (16:51 +0100)]
[AMDGPU] MIR-Tests for Multiplication using KBA

These tests show inefficient behavior that will be optimized by a
later change.

By using Known Bits Analysis, we can avoid unnecessary multiplications
or additions with 0.

16 months ago[clang-tidy] update docs for new hungarian identifier-naming types (unsigned char...
Alexis Murzeau [Tue, 21 Feb 2023 07:37:00 +0000 (07:37 +0000)]
[clang-tidy] update docs for new hungarian identifier-naming types (unsigned char and void)

Since 37e6a4f9496c8e35efc654d7619a79d6dbb72f99, `void` and
`unsigned char` were added to primitive types for hungarian notation.

This commit adds them to the documentation.

Reviewed By: carlosgalvezp

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

16 months ago[ADT] Alternative way to declare enum type as bitmask
Serge Pavlov [Tue, 21 Feb 2023 06:44:24 +0000 (13:44 +0700)]
[ADT] Alternative way to declare enum type as bitmask

If an enumeration represents a set of bit flags, using the macro
LLVM_MARK_AS_BITMASK_ENUM can make operations with such enumeration more
convenient. It however brings problems if the enumeration is non-scoped.
As the macro adds an item LLVM_BITMASK_LARGEST_ENUMERATOR to the
enumeration type, only one such type may be declared as bitmask. This
problem could be solved by convertion of the enumeration to scoped, but
it requires static_casts in new places and the convenience can be
eliminated.

This change introduces a new macro LLVM_DECLARE_ENUM_AS_BITMASK, which
allows non-invasive convertion of an enumeration into bitmask. It
provides specialization to trait classes, which previously were built
based on presence of LLVM_BITMASK_LARGEST_ENUMERATOR in the enumeration.
The macro must be specified in global or llvm namespace because the
trait classes are declared in llvm namespace.

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

16 months ago[AMDGPU] Add tests for future commit
Konstantina Mitropoulou [Sat, 18 Feb 2023 00:42:35 +0000 (16:42 -0800)]
[AMDGPU] Add tests for future commit

Reviewed By: foad

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

16 months ago[MLIR][Affine] Fix affine.parallel op domain add
Uday Bondhugula [Tue, 21 Feb 2023 04:45:57 +0000 (10:15 +0530)]
[MLIR][Affine] Fix affine.parallel op domain add

Fix obvious bug in `addAffineParallelOpDomain` that would lead to
incorrect domain constraints for any affine.parallel op with
dimensionality greater than one.

Reviewed By: springerm

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

16 months ago[MLIR] Add replaceUsesWithIf on Operation
Uday Bondhugula [Tue, 21 Feb 2023 04:40:15 +0000 (10:10 +0530)]
[MLIR] Add replaceUsesWithIf on Operation

Add replaceUsesWithIf on Operation along the lines of
Value::replaceUsesWithIf. This had been missing on Operation and is
convenient to replace multi-result operations' results conditionally.

Reviewed By: lattner

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

16 months ago[TypeSize][NFC] Fix type-o
eopXD [Tue, 21 Feb 2023 04:15:56 +0000 (20:15 -0800)]
[TypeSize][NFC] Fix type-o

Signed-off-by: eop Chen <eop.chen@sifive.com>
16 months ago[AIX] Lower some memory intrinsics to millicode functions on AIX
esmeyi [Tue, 21 Feb 2023 03:25:49 +0000 (22:25 -0500)]
[AIX] Lower some memory intrinsics to millicode functions on AIX

Summary: Currently we lower MEMCPY/MEMMOVE/MEMSET/BZERO to the corresponding libc functions. And the libc functions call the millicode functions on AIX. We can lower these intrinsics directly to save one call layer.

Reviewed By: shchenz

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

16 months ago[X86][NFC] Reorganize X86InstrInfo.td
Wang, Xin10 [Tue, 21 Feb 2023 02:16:47 +0000 (10:16 +0800)]
[X86][NFC] Reorganize X86InstrInfo.td

For now X86InstrInfo.td has many definitions for some instrs
and patterns which I think should not exist here, extract them
and move to other files.

It will be more clear to me that X86InstrInfo just define some
X86 specific properties and would not include detailed instrs
definition.

Reviewed By: skan

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

16 months ago[X86] Precommit a test
Kazu Hirata [Tue, 21 Feb 2023 01:00:03 +0000 (17:00 -0800)]
[X86] Precommit a test

This is for:

https://github.com/llvm/llvm-project/issues/60854

16 months ago[X86] Improve (select carry C1+1 C1)
Kazu Hirata [Tue, 21 Feb 2023 00:38:21 +0000 (16:38 -0800)]
[X86] Improve (select carry C1+1 C1)

Without this patch:

  return X < 4 ? 3 : 2;

  return X < 9 ? 7 : 6;

are compiled as:

  31 c0                   xor    %eax,%eax
  83 ff 04                cmp    $0x4,%edi
  0f 93 c0                setae  %al
  83 f0 03                xor    $0x3,%eax

  31 c0                   xor    %eax,%eax
  83 ff 09                cmp    $0x9,%edi
  0f 92 c0                setb   %al
  83 c8 06                or     $0x6,%eax

respectively.  With this patch, we generate:

  31 c0                   xor    %eax,%eax
  83 ff 04                cmp    $0x4,%edi
  83 d0 02                adc    $0x2,%eax

  31 c0                   xor    %eax,%eax
  83 ff 04                cmp    $0x4,%edi
  83 d0 02                adc    $0x2,%eax

respectively, saving 3 bytes while reducing the tree height.

This patch recognizes the equivalence of OR and ADD
(if bits do not overlap) and delegates to combineAddOrSubToADCOrSBB
for further processing.  The same applies to the equivalence of XOR
and SUB.

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

16 months ago[X86] Add test case that clobber base pointer register.
Luo, Yuanke [Mon, 20 Feb 2023 12:00:37 +0000 (20:00 +0800)]
[X86] Add test case that clobber base pointer register.

16 months ago[SLP][X86] minimum-sizes.ll - add AVX512 test coverage
Simon Pilgrim [Mon, 20 Feb 2023 23:31:49 +0000 (23:31 +0000)]
[SLP][X86] minimum-sizes.ll - add AVX512 test coverage

As noticed on D144128, we need better AVX512 coverage for GEP vectorization

16 months ago[Support] Silence warning with Clang ToT.
Alexandre Ganea [Mon, 20 Feb 2023 22:16:21 +0000 (17:16 -0500)]
[Support] Silence warning with Clang ToT.

This fixes the following warning on Windows with latest Clang:
```
[160/3057] Building CXX object lib/Support/CMakeFiles/LLVMSupport.dir/Signals.cpp.obj
In file included from C:/git/llvm-project/llvm/lib/Support/Signals.cpp:260:
C:/git/llvm-project/llvm/lib/Support/Windows/Signals.inc(834,15): warning: comparison of integers of different signs: 'int' and 'unsigned int' [-Wsign-compare]
  if (RetCode == (0xE0000000 | EX_IOERR))
      ~~~~~~~ ^   ~~~~~~~~~~~~~~~~~~~~~
1 warning generated.```

16 months ago[SLP][X86] load-merge.ll - add AVX512 test coverage
Simon Pilgrim [Mon, 20 Feb 2023 23:21:27 +0000 (23:21 +0000)]
[SLP][X86] load-merge.ll - add AVX512 test coverage

As noticed on D144128, we need better AVX512 coverage for GEP vectorization

16 months ago[PowerPC] Correctly use ELFv2 ABI on all OS's that use the ELFv2 ABI
Brad Smith [Mon, 20 Feb 2023 22:57:15 +0000 (17:57 -0500)]
[PowerPC] Correctly use ELFv2 ABI on all OS's that use the ELFv2 ABI

Add a member function isPPC64ELFv2ABI() to determine what ABI is used on the
64-bit PowerPC big endian operating environment.

Reviewed By: nemanjai, dim, pkubaj

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

16 months agoUse modern @got syntax in tsan assembly, instead of old style non_lazy_pointers....
Peter Cooper [Mon, 13 Feb 2023 23:38:01 +0000 (15:38 -0800)]
Use modern @got syntax in tsan assembly, instead of old style non_lazy_pointers.  NFC

Reviewed By: kubamracek, yln, wrotki, dvyukov

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

16 months ago[RISCV][NFC] Add test for different LMULs in vectorizer
Luke Lau [Fri, 10 Feb 2023 01:17:14 +0000 (01:17 +0000)]
[RISCV][NFC] Add test for different LMULs in vectorizer

This is a test for an upcoming patch that proposes to change the default LMUL used by the loop vectorizer from 1 to 2

Reviewed By: reames

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

16 months ago[libc] Fix GPU include directories not being set properly
Joseph Huber [Mon, 20 Feb 2023 21:42:28 +0000 (15:42 -0600)]
[libc] Fix GPU include directories not being set properly

Summary:
For some reason, this variable was set after where it was used. Causing
weird behaviour with including the standard headers. Fix it.

16 months ago[InstCombine] relax constraint on udiv fold
Sanjay Patel [Mon, 20 Feb 2023 19:39:51 +0000 (14:39 -0500)]
[InstCombine] relax constraint on udiv fold

The pair of div folds was just added with:
4966d8ebe1bbe5bd6a4d28

But as noted in the post-commit review, we don't actually need
the no-remainder requirement for an unsigned division (still
need the no-unsigned-wrap though):
https://alive2.llvm.org/ce/z/qHjK3Q