platform/upstream/llvm.git
23 months ago[Libomptarget] Build the DeviceRTL BC using clang directly
Joseph Huber [Thu, 21 Jul 2022 18:12:01 +0000 (14:12 -0400)]
[Libomptarget] Build the DeviceRTL BC using clang directly

Currently the bitcode library is build using the clang front-end
manually. This was originally done because we did not support device
only compilation. Now we support device only compilation, at least for a
single offloading toolchain, so we can instead use clang directly rather
than using the front-end. This saves us needing to define things like
`aux_triple`.

Reviewed By: tianshilei1992

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

23 months ago[Docs] Add release notes for opaque pointers (NFC)
Nikita Popov [Fri, 22 Jul 2022 12:13:12 +0000 (14:13 +0200)]
[Docs] Add release notes for opaque pointers (NFC)

23 months agoRevert "[Libomptarget] Stop testing CPU offloading with LTO"
Ron Lieberman [Fri, 22 Jul 2022 12:04:33 +0000 (12:04 +0000)]
Revert "[Libomptarget] Stop testing CPU offloading with LTO"

This reverts commit 3e8d46921fbc51831f9ba775d6405812bfdd32c7.

23 months ago[mlir][linalg] Add tile-and-fuse with transform dialect example
Matthias Springer [Fri, 22 Jul 2022 11:27:02 +0000 (13:27 +0200)]
[mlir][linalg] Add tile-and-fuse with transform dialect example

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

23 months ago[mlir][linalg] Add attribute matcher to structured.match transform op
Matthias Springer [Fri, 22 Jul 2022 11:26:48 +0000 (13:26 +0200)]
[mlir][linalg] Add attribute matcher to structured.match transform op

This is useful for building small test cases and will be utilized in a subsequent commit that adds a fusion example.

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

23 months ago[mlir][linalg][transform] Add fuse_into_containing op
Matthias Springer [Fri, 22 Jul 2022 11:26:34 +0000 (13:26 +0200)]
[mlir][linalg][transform] Add fuse_into_containing op

This op fuses a given payload op into a given container op. Inside the container, all uses of the producer are replaced (fused) with the newly inserted op. If the producer is tileable and accessed via a tensor.extract_slice, the new op computes only the requested slice ("tile and fuse"). Otherwise, the entire tensor value is computed inside the container ("clone and fuse").

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

23 months ago[clang-tidy][NFC] Add preposition "of" to code annotation of ElseAfterReturnCheck
Zhouyi Zhou [Fri, 22 Jul 2022 11:37:50 +0000 (12:37 +0100)]
[clang-tidy][NFC] Add preposition "of" to code annotation of ElseAfterReturnCheck

Reviewed By: njames93

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

23 months ago[AMDGPU] Add a test where regClassPriorityTrumpsGlobalness uses more vgprs
Jay Foad [Fri, 22 Jul 2022 11:08:14 +0000 (12:08 +0100)]
[AMDGPU] Add a test where regClassPriorityTrumpsGlobalness uses more vgprs

23 months ago[mlir][arith] cmpi: move constant to the right side
Ivan Butygin [Sat, 16 Jul 2022 10:05:03 +0000 (12:05 +0200)]
[mlir][arith] cmpi: move constant to the right side

Convert arith.cmpi to the canonical form with constants on the right side
to simplify further optimizations and open more opportunities for CSE.

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

23 months ago[AMDGPU] gfx11 Fix VOP3 dot instructions
Petar Avramovic [Fri, 22 Jul 2022 09:43:09 +0000 (11:43 +0200)]
[AMDGPU] gfx11 Fix VOP3 dot instructions

Fix src modifiers for operands with bf16 type.
op_sel[0:1] are ignored.

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

23 months ago[mlir][linalg] Fix FoldTensorCastConsumerOp invalid folding
Ivan Butygin [Thu, 21 Jul 2022 23:09:22 +0000 (01:09 +0200)]
[mlir][linalg] Fix FoldTensorCastConsumerOp invalid folding

CastOp can be in conditionally reachable region, in which case this folding will be invalid.
Only conservatively fold ops in same block for now.

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

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

23 months ago[lldb][ARM] Invert emulation test assert message
David Spickett [Fri, 22 Jul 2022 09:33:43 +0000 (09:33 +0000)]
[lldb][ARM] Invert emulation test assert message

Previously you got:
AssertionError: False is not True : Emulation test succeeded.

Which is a bit of a head scratcher. The message is used when
the test fails, not when it succeeds.

23 months ago[ASTMatchers] Fix standalone build
Nathan James [Fri, 22 Jul 2022 09:32:27 +0000 (10:32 +0100)]
[ASTMatchers] Fix standalone build

Disable the tests and remove private include introduced in d89f9e963e4979466193dc6a15fe091bf7ca5c47.

23 months ago[libc++][ranges] implement `std::ranges::includes`
Hui Xie [Tue, 19 Jul 2022 19:54:35 +0000 (20:54 +0100)]
[libc++][ranges] implement `std::ranges::includes`

implement `std::ranges::includes` and delegate to `std::includes`

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

23 months ago[libc++][ranges] implement `std::ranges::equal_range`
Hui Xie [Thu, 14 Jul 2022 19:35:15 +0000 (20:35 +0100)]
[libc++][ranges] implement `std::ranges::equal_range`

implement `std::ranges::equal_range` which delegates to
`std::equal_range`

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

23 months ago[lldb] Handle jumping to the end in DW_OP_skip/DW_OP_bra
Andy Yankovsky [Thu, 21 Jul 2022 16:41:32 +0000 (16:41 +0000)]
[lldb] Handle jumping to the end in DW_OP_skip/DW_OP_bra

DW_OP_skip/DW_OP_bra can move offset to the end of the data, which means that this was the last instruction to execute and the interpreter should terminate.

Reviewed By: labath

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

23 months agoDon't write to source directory in test
Benjamin Kramer [Fri, 22 Jul 2022 09:14:26 +0000 (11:14 +0200)]
Don't write to source directory in test

23 months ago[C++20] [Modules] Handle reachability for partial specialization
Chuanqi Xu [Fri, 22 Jul 2022 09:03:38 +0000 (17:03 +0800)]
[C++20] [Modules] Handle reachability for partial specialization

Previously we don't catch the reachability for partial specialization.
Handle them in this patch.

23 months ago[CMake][Clang] Copy folder without permissions
Sebastian Neubauer [Thu, 21 Jul 2022 12:06:42 +0000 (14:06 +0200)]
[CMake][Clang] Copy folder without permissions

Copying the folder keeps the original permissions by default. This
creates problems when the source folder is read-only, e.g. in a
packaging environment.
Then, the copied folder in the build directory is read-only as well.
Later on, with configure_file, ClangConfig.cmake is copied into that
directory (in the build tree), failing when the directory is read-only.

Fix that problem by copying the folder without keeping the original
permissions.

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

23 months ago[pseudo] Add ambiguity & unparseability metrics to -print-statistics
Sam McCall [Fri, 22 Jul 2022 08:25:16 +0000 (10:25 +0200)]
[pseudo] Add ambiguity & unparseability metrics to -print-statistics

These can be used to quantify parsing improvements from a change.

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

23 months ago[Symbolizer] Fix use-after-free
Benjamin Kramer [Fri, 22 Jul 2022 08:28:25 +0000 (10:28 +0200)]
[Symbolizer] Fix use-after-free

MarkupFilter keeps a reference to the last filtered StringRef. Just keep
it alive a bit longer. Found by asan.

23 months ago[ELF] Simplify createObjectFile/createLazyFile. NFC
Fangrui Song [Fri, 22 Jul 2022 08:26:11 +0000 (01:26 -0700)]
[ELF] Simplify createObjectFile/createLazyFile. NFC

And avoid redundant identify_magic test.

23 months agoUse any_of (NFC)
Kazu Hirata [Fri, 22 Jul 2022 08:05:17 +0000 (01:05 -0700)]
Use any_of (NFC)

23 months ago[AArch64] Emit vector FP cmp when LE is used with fast-math
Cullen Rhodes [Fri, 22 Jul 2022 07:27:12 +0000 (07:27 +0000)]
[AArch64] Emit vector FP cmp when LE is used with fast-math

Reviewed By: paulwalker-arm

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

23 months ago[AArch64] Add fcmp fast math tests
Cullen Rhodes [Fri, 22 Jul 2022 07:26:54 +0000 (07:26 +0000)]
[AArch64] Add fcmp fast math tests

Reviewed By: paulwalker-arm

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

23 months ago[InstCombine] Slightly extend alloc optimization test (NFC)
Nikita Popov [Fri, 22 Jul 2022 07:42:26 +0000 (09:42 +0200)]
[InstCombine] Slightly extend alloc optimization test (NFC)

Also test realloc, and dead writes to the allocation.

23 months agore-land [C++20][Modules] Build module static initializers per P1874R1.
Iain Sandoe [Sun, 15 May 2022 13:47:54 +0000 (14:47 +0100)]
re-land [C++20][Modules] Build module static initializers per P1874R1.

The re-land fixes module map module dependencies seen on Greendragon, but
not in the clang test suite.

---

Currently we only implement this for the Itanium ABI since the correct
mangling for the initializers in other ABIs is not yet known.

Intended result:

For a module interface [which includes partition interface and implementation
units] (instead of the generic CXX initializer) we emit a module init that:

 - wraps the contained initializations in a control variable to ensure that
   the inits only happen once, even if a module is imported many times by
   imports of the main unit.

 - calls module initializers for imported modules first.  Note that the
   order of module import is not significant, and therefore neither is the
   order of imported module initializers.

 - We then call initializers for the Global Module Fragment (if present)
 - We then call initializers for the current module.
 - We then call initializers for the Private Module Fragment (if present)

For a module implementation unit, or a non-module TU that imports at least one
module we emit a regular CXX init that:

 - Calls the initializers for any imported modules first.
 - Then proceeds as normal with remaining inits.

For all module unit kinds we include a global constructor entry, this allows
for the (in most cases unusual) possibility that a module object could be
included in a final binary without a specific call to its initializer.

Implementation:

 - We provide the module pointer in the AST Context so that CodeGen can act
   on it and its sub-modules.

 - We need to account for module build lines like this:
  ` clang -cc1 -std=c++20 Foo.pcm -emit-obj -o Foo.o` or
  ` clang -cc1 -std=c++20 -xc++-module Foo.cpp -emit-obj -o Foo.o`

 - in order to do this, we add to ParseAST to set the module pointer in
   the ASTContext, once we establish that this is a module build and we
   know the module pointer. To be able to do this, we make the query for
   current module public in Sema.

 - In CodeGen, we determine if the current build requires a CXX20-style module
   init and, if so, we defer any module initializers during the "Eagerly
   Emitted" phase.

 - We then walk the module initializers at the end of the TU but before
   emitting deferred inits (which adds any hidden and static ones, fixing
   https://github.com/llvm/llvm-project/issues/51873 ).

 - We then proceed to emit the deferred inits and continue to emit the CXX
   init function.

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

23 months ago[pseudo] Eliminate the dangling-else syntax ambiguity.
Haojian Wu [Thu, 21 Jul 2022 08:18:33 +0000 (10:18 +0200)]
[pseudo] Eliminate the dangling-else syntax ambiguity.

- the grammar ambiguity is eliminated by a guard;
- modify the guard function signatures, now all parameters are folded in
  to a single object, avoid a long parameter list (as we will add more
  parameters in the near future);

Reviewed By: sammccall

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

23 months ago[gn build] Port 8184b252cdab
LLVM GN Syncbot [Fri, 22 Jul 2022 07:02:59 +0000 (07:02 +0000)]
[gn build] Port 8184b252cdab

23 months ago[LLDB][ClangExpression] Allow expression evaluation from within C++ Lambdas
Michael Buch [Tue, 12 Jul 2022 08:40:12 +0000 (09:40 +0100)]
[LLDB][ClangExpression] Allow expression evaluation from within C++ Lambdas

This patch adds support for evaluating expressions which reference
a captured `this` from within the context of a C++ lambda expression.
Currently LLDB doesn't provide Clang with enough information to
determine that we're inside a lambda expression and are allowed to
access variables on a captured `this`; instead Clang simply fails
to parse the expression.

There are two problems to solve here:
1. Make sure `clang::Sema` doesn't reject the expression due to an
illegal member access.
2. Materialize all the captured variables/member variables required
to evaluate the expression.

To address (1), we currently import the outer structure's AST context
onto `$__lldb_class`, making the `contextClass` and the `NamingClass`
match, a requirement by `clang::Sema::BuildPossibleImplicitMemberExpr`.

To address (2), we inject all captured variables as locals into the
expression source code.

**Testing**

* Added API test

23 months ago[LLDB][Expression] Allow instantiation of IR Entity from ValueObject
Michael Buch [Thu, 7 Jul 2022 14:58:42 +0000 (15:58 +0100)]
[LLDB][Expression] Allow instantiation of IR Entity from ValueObject

This is required in preparation for the follow-up patch which adds
support for evaluating expressions from within C++ lambdas. In such
cases we need to materialize variables which are not part of the
current frame but instead are ivars on a 'this' pointer of the current
frame.

23 months ago[LLDB][NFC] Create variable for hardcoded alignment/size constants in materializer
Michael Buch [Thu, 7 Jul 2022 14:53:30 +0000 (15:53 +0100)]
[LLDB][NFC] Create variable for hardcoded alignment/size constants in materializer

23 months ago[pseudo] Tweak the cli option messages, NFC.
Haojian Wu [Thu, 21 Jul 2022 12:04:44 +0000 (14:04 +0200)]
[pseudo] Tweak the cli option messages, NFC.

23 months ago[pseudo] Fix link error after 3132e9cd7c9fda63
Sam McCall [Fri, 22 Jul 2022 06:43:17 +0000 (08:43 +0200)]
[pseudo] Fix link error after 3132e9cd7c9fda63

23 months ago[Attributor][FIX] Also update the unit test to match expectations
Johannes Doerfert [Fri, 22 Jul 2022 06:23:55 +0000 (01:23 -0500)]
[Attributor][FIX] Also update the unit test to match expectations

23 months ago[Attributor][FIX] Update unit test after API change
Johannes Doerfert [Fri, 22 Jul 2022 06:04:53 +0000 (01:04 -0500)]
[Attributor][FIX] Update unit test after API change

23 months ago[flang] Lower F08 mask intrinsics
Tarun Prabhu [Fri, 22 Jul 2022 06:03:09 +0000 (00:03 -0600)]
[flang] Lower F08 mask intrinsics

Lower F08 maskl and maskr intrinsics.

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

23 months ago[flang] Lower F08 shift intrinsics
Tarun Prabhu [Fri, 22 Jul 2022 05:36:08 +0000 (23:36 -0600)]
[flang] Lower F08 shift intrinsics

Lower F08 shift (shiftl, shiftr, shifta) and combined shift (dshiftl, dshiftr)
intrinsics. The combined shift intrinsics are implemented using the
definitions of shiftl and shiftr as described by the standard.

For non-conformant arguments to the shift intrinsics, the implementation tries
to replicate the behavior of other compilers if most of the other behave
consistently.

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

23 months ago[flang][NFC] Test folding F08 mask intrinsics
Tarun Prabhu [Fri, 22 Jul 2022 05:30:38 +0000 (23:30 -0600)]
[flang][NFC] Test folding F08 mask intrinsics

Test compile-time folding of F08 maskl and maskr intrinsics.

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

23 months ago[flang][NFC] Test folding of F08 shift intrinsics
Tarun Prabhu [Fri, 22 Jul 2022 05:25:45 +0000 (23:25 -0600)]
[flang][NFC] Test folding of F08 shift intrinsics

Test compile-time folding of F08 shift (shiftl, shiftr, shifta) and combined shift (dshiftl, dshiftr) intrinsics.

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

23 months ago[flang] Lower F08 bit population count intrinsics
Tarun Prabhu [Fri, 22 Jul 2022 05:05:33 +0000 (23:05 -0600)]
[flang] Lower F08 bit population count intrinsics

Lower F08 bit population count intrinsics popcnt, poppar, leadz and trailz. popcnt, leadz and trailz are implemented using the corresponding MLIR math intrinsics. poppar is implemented in terms of popcnt.

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

23 months ago[Attributor][FIX] Handle non-recursive but re-entrant functions properly
Johannes Doerfert [Tue, 12 Jul 2022 05:38:32 +0000 (00:38 -0500)]
[Attributor][FIX] Handle non-recursive but re-entrant functions properly

If a function is non-recursive we only performed intra-procedural
reasoning for reachability (via AA::isPotentiallyReachable). However,
if it is re-entrant that doesn't mean we can't reach. Instead of this
problematic logic in the reachability reasoning we utilize logic in
AAPointerInfo. If a location is for sure written by a function it can
be re-entrant or recursive we know only intra-procedural reasoning is
sufficient.

23 months ago[RS4GC] Handle special cases in unreachable code for memcpy/memmov
Max Kazantsev [Fri, 22 Jul 2022 04:29:29 +0000 (11:29 +0700)]
[RS4GC] Handle special cases in unreachable code for memcpy/memmov

The existing code doesn't expect dummy values (undef, poison, null-derived
constants etc) as arguments of these intrinsics. However, they can be there
in unreached code. Currently we fail trying to find base for them.

Handle these cases separately. Return null as base for them to be consistent
with the handling in the main algorithm in findBaseDefiningValue.

Differential Revision: https://reviews.llvm.org/D129561
Reviewed By: apilipenko

23 months ago[MLIR] Add affine.if canonicalization to compose in affine.apply ops
Uday Bondhugula [Tue, 19 Jul 2022 05:49:55 +0000 (11:19 +0530)]
[MLIR] Add affine.if canonicalization to compose in affine.apply ops

Add affine.if canonicalization to compose affine.apply ops into its set
and operands. This eliminates affine.apply ops feeding into affine.if
ops.

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

23 months ago[Attributor] Dominating must-write accesses allow unknown initial values
Johannes Doerfert [Thu, 19 May 2022 22:20:48 +0000 (17:20 -0500)]
[Attributor] Dominating must-write accesses allow unknown initial values

If we have a dominating must-write access we do not need to know the
initial value of some object to perform reasoning about the potential
values. The dominating must-write has overwritten the initial value.

23 months ago[Intrinsics] Add `nocallback` to the memset/cpy/move intrinsics
Johannes Doerfert [Sun, 10 Jul 2022 20:01:38 +0000 (15:01 -0500)]
[Intrinsics] Add `nocallback` to the memset/cpy/move intrinsics

These were forgotten when D118680 was applied. Similar to D125937.

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

23 months agoRevert "[OpenMP][OMPD] GDB plugin code to leverage libompd to provide debugging"
Ye Luo [Fri, 22 Jul 2022 02:58:15 +0000 (21:58 -0500)]
Revert "[OpenMP][OMPD] GDB plugin code to leverage libompd to provide debugging"

This reverts commit 51d3f421f48f7c888c37a13be049a4ca8b61436e.

23 months agoRevert "Fixing build bot failure due to python-pip unavailability."
Ye Luo [Fri, 22 Jul 2022 02:57:57 +0000 (21:57 -0500)]
Revert "Fixing build bot failure due to python-pip unavailability."

This reverts commit 9dc0d6aaa1e27b97e5d163f2590cf24b769a0c36.

23 months ago[OpenMP][FIX] Ensure thread and team state are defined properly
Johannes Doerfert [Fri, 22 Jul 2022 00:29:18 +0000 (19:29 -0500)]
[OpenMP][FIX] Ensure thread and team state are defined properly

The namespaces were missing causing the symbols to have "C" mangling.
To avoid this in the future we qualify the names now fully.

23 months ago[Attributor][NFC] Remove unnecessary overwritten methods
Johannes Doerfert [Sun, 10 Jul 2022 19:59:01 +0000 (14:59 -0500)]
[Attributor][NFC] Remove unnecessary overwritten methods

23 months ago[Driver][test] Remove unused "-o %t.s" from frame-pointer*.c
Fangrui Song [Fri, 22 Jul 2022 02:41:24 +0000 (19:41 -0700)]
[Driver][test] Remove unused "-o %t.s" from frame-pointer*.c

23 months ago[LoongArch] Support load/store of dso_local PIC global values
Fangrui Song [Fri, 22 Jul 2022 02:37:56 +0000 (19:37 -0700)]
[LoongArch] Support load/store of dso_local PIC global values

lowerGlobalAddress added by D128427 can be used for PIC. The actual condition is
that the global value needs to be dso_local (a dso_preemptable one needs GOT
indirection).

load-store.ll has UB due to out-of-bounds load/store. Fix the UB in the variable
test and add an array test. Note: NOPIC array index is currently wrong.

Reviewed By: wangleiat

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

23 months ago[verify-uselistorder] Hide unrelated options
Fangrui Song [Fri, 22 Jul 2022 01:41:28 +0000 (18:41 -0700)]
[verify-uselistorder] Hide unrelated options

23 months ago[InstCombine] remove useless ‘InstCombiner::’. nfc
Chenbing Zheng [Fri, 22 Jul 2022 01:24:24 +0000 (09:24 +0800)]
[InstCombine] remove useless ‘InstCombiner::’. nfc

Reviewed By: RKSimon

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

23 months ago[sanstats] Hide unrelated options
Fangrui Song [Fri, 22 Jul 2022 01:08:33 +0000 (18:08 -0700)]
[sanstats] Hide unrelated options

23 months ago[sancov] --help: hide unrelated options
Fangrui Song [Fri, 22 Jul 2022 01:00:30 +0000 (18:00 -0700)]
[sancov] --help: hide unrelated options

23 months ago[modules] Replace `-Wauto-import` with `-Rmodule-include-translation`.
Volodymyr Sapsai [Tue, 19 Jul 2022 21:27:02 +0000 (14:27 -0700)]
[modules] Replace `-Wauto-import` with `-Rmodule-include-translation`.

Diagnostic for `-Wauto-import` shouldn't be a warning because it doesn't
represent a potential problem in code that should be fixed. And the
emitted fix-it is likely to trigger `-Watimport-in-framework-header`
which makes it challenging to have a warning-free codebase. But it is
still useful to see how include directives are translated into modular
imports and which module a header belongs to, that's why keep it as a remark.

Keep `-Wauto-import` for now to allow a gradual migration for codebases
using `-Wno-auto-import`, e.g., `-Weverything -Wno-auto-import`.

rdar://79594287

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

23 months ago[LLDB][Reliability] Fix accessing invalid iterator
Slava Gurevich [Thu, 21 Jul 2022 22:04:04 +0000 (15:04 -0700)]
[LLDB][Reliability] Fix accessing invalid iterator

Using invalidated vector iterator is at best a UB and could crash depending on STL implementation.
Fixing via minimal changes to preserve the existing code style.

Coverity warning 1454828  (scan.coverity.com)

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

23 months ago[X86][FP16] Do not split FP64->FP16 to FP64->FP32->FP16
Phoebe Wang [Thu, 21 Jul 2022 23:56:29 +0000 (07:56 +0800)]
[X86][FP16] Do not split FP64->FP16 to FP64->FP32->FP16

Truncation from double to half is not always identical to truncating to float first and then to half. https://godbolt.org/z/56s9517hd

On the other hand, expanding to float and then to double is always identical to expanding to double directly. https://godbolt.org/z/Ye8vbYPnY

Reviewed By: RKSimon, skan

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

23 months ago[Frontend] Correct values of ATOMIC_*_LOCK_FREE to match builtin
Ryan Prichard [Thu, 21 Jul 2022 20:09:48 +0000 (13:09 -0700)]
[Frontend] Correct values of ATOMIC_*_LOCK_FREE to match builtin

Correct the logic used to set `ATOMIC_*_LOCK_FREE` preprocessor macros not
to rely on the ABI alignment of types. Instead, just assume all those
types are aligned correctly by default since clang uses safe alignment
for `_Atomic` types even if the underlying types are aligned to a lower
boundary by default.

For example, the `long long` and `double` types on x86 are aligned to
32-bit boundary by default. However, `_Atomic long long` and `_Atomic
double` are aligned to 64-bit boundary, therefore satisfying
the requirements of lock-free atomic operations.

This fixes PR #19355 by correcting the value of
`__GCC_ATOMIC_LLONG_LOCK_FREE` on x86, and therefore also fixing
the assumption made in libc++ tests. This also fixes PR #30581 by
applying a consistent logic between the functions used to implement
both interfaces.

Reviewed By: hfinkel, efriedma

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

23 months ago[CUDA] Ignore __CLANG_ATOMIC_LLONG_LOCK_FREE on i386
Ryan Prichard [Thu, 21 Jul 2022 20:09:39 +0000 (13:09 -0700)]
[CUDA] Ignore __CLANG_ATOMIC_LLONG_LOCK_FREE on i386

The default host CPU for an i386 triple is typically at least an i586,
which has cmpxchg8b (Clang feature, "cx8"). Therefore,
`__CLANG_ATOMIC_LLONG_LOCK_FREE` is 2 on the host, but the value should
be 1 for the device.

Also, grep for `__CLANG_ATOMIC_*` instead of `__GCC_ATOMIC_*`. The CLANG
macros are always emitted, but the GCC macros are omitted for the
*-windows-msvc targets. The `__GCC_HAVE_SYNC_COMPARE_AND_SWAP` macro
always has GCC in its name, not CLANG, however.

Reviewed By: tra

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

23 months ago[SPIRV] add SPIRVPrepareFunctions pass and update other passes
Ilia Diachkov [Wed, 20 Jul 2022 15:48:16 +0000 (18:48 +0300)]
[SPIRV] add SPIRVPrepareFunctions pass and update other passes

The patch adds SPIRVPrepareFunctions pass, which modifies function
signatures containing aggregate arguments and/or return values before
IR translation. Information about the original signatures is stored in
metadata. It is used during call lowering to restore correct SPIR-V types
of function arguments and return values. This pass also substitutes some
llvm intrinsic calls to function calls, generating the necessary functions
in the module, as the SPIRV translator does.

The patch also includes changes in other modules, fixing errors and
enabling many SPIR-V features that were omitted earlier. And 15 LIT tests
are also added to demonstrate the new functionality.

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

Co-authored-by: Aleksandr Bezzubikov <zuban32s@gmail.com>
Co-authored-by: Michal Paszkowski <michal.paszkowski@outlook.com>
Co-authored-by: Andrey Tretyakov <andrey1.tretyakov@intel.com>
Co-authored-by: Konrad Trifunovic <konrad.trifunovic@intel.com>
23 months agoprecommit update_mir_test_checks run for D130316 NFC
Nick Desaulniers [Fri, 22 Jul 2022 00:10:53 +0000 (17:10 -0700)]
precommit update_mir_test_checks run for D130316 NFC

23 months ago[LV] Fix a conceptual mistake around meaning of uniform in isPredicatedInst
Philip Reames [Thu, 21 Jul 2022 21:40:20 +0000 (14:40 -0700)]
[LV] Fix a conceptual mistake around meaning of uniform in isPredicatedInst

This code confuses LV's "Uniform" and LVL/LAI's "Uniform".  Despite the
common name, these are different.
* LVs notion means that only the first lane *of each unrolled part* is
  required.  That is, lanes within a single unroll factor are considered
  uniform.  This allows e.g. widenable memory ops to be considered
  uses of uniform computations.
* LVL and LAI's notion refers to all lanes across all unrollings.

IsUniformMem is in turn defined in terms of LAI's notion.  Thus a
UniformMemOpmeans is a memory operation with a loop invariant address.
This means the same address is accessed in every iteration.

The tweaked piece of code was trying to match a uniform mem op (i.e.
fully loop invariant address), but instead checked for LV's notion of
uniformity.  In theory, this meant with UF > 1, we could speculate
a load which wasn't safe to execute.

This ends up being mostly silent in current code as it is nearly
impossible to create the case where this difference is visible.  The
closest I've come in the test case from 54cb87, but even then, the
incorrect result is only visible in the vplan debug output; before this
change we sink the unsafely speculated load back into the user's predicate
blocks before emitting IR.  Both before and after IR are correct so the
differences aren't "interesting".

The other test changes are uninteresting.  They're cases where LV's uniform
analysis is slightly weaker than SCEV isLoopInvariant.

23 months ago[LV] Add a load focused version of the r45679 test
Philip Reames [Thu, 21 Jul 2022 22:27:33 +0000 (15:27 -0700)]
[LV] Add a load focused version of the r45679 test

This a reproducer for bug in predicated instruction handling.  The final result code is correct, but the reasoning by which we get there isn't.

23 months ago[RISCV] Add sext.b/h and zext.b/h/w to RISCVInstrInfo::foldMemoryOperandImpl.
Craig Topper [Thu, 21 Jul 2022 21:23:30 +0000 (14:23 -0700)]
[RISCV] Add sext.b/h and zext.b/h/w to RISCVInstrInfo::foldMemoryOperandImpl.

We can always fold zext.b since it is just andi. The others require
Zba/Zbb.

Reviewed By: reames

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

23 months ago[GlobalOpt] Enable evaluation of atomic loads
Alexander Shaposhnikov [Thu, 21 Jul 2022 21:29:39 +0000 (21:29 +0000)]
[GlobalOpt] Enable evaluation of atomic loads

Relax the check to allow evaluation of atomic loads
(but still skip volatile loads).

Test plan:
1/ ninja check-llvm check-clang
2/ Bootstrapped LLVM/Clang pass tests

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

23 months ago[gn build] Port 1d057a6d4306
LLVM GN Syncbot [Thu, 21 Jul 2022 21:26:59 +0000 (21:26 +0000)]
[gn build] Port 1d057a6d4306

23 months agoRevert "[libc++] Use uninitialized algorithms for vector"
Augusto Noronha [Thu, 21 Jul 2022 21:19:20 +0000 (14:19 -0700)]
Revert "[libc++] Use uninitialized algorithms for vector"

This reverts commit 23cf42e706fbc2a939ce1470da16599b42258aea.

23 months ago[gn build] Port 1dad6247d275
LLVM GN Syncbot [Thu, 21 Jul 2022 20:54:39 +0000 (20:54 +0000)]
[gn build] Port 1dad6247d275

23 months agoFix use after free in MarkupFilter.cpp
Daniel Thornburgh [Thu, 21 Jul 2022 20:52:15 +0000 (13:52 -0700)]
Fix use after free in MarkupFilter.cpp

23 months ago[OpenMP][NFC] Claim iterators in 'map' clause and motion clauses
Chi Chun Chen [Thu, 21 Jul 2022 20:50:22 +0000 (15:50 -0500)]
[OpenMP][NFC] Claim iterators in 'map' clause and motion clauses

23 months ago[Libomptarget] Stop testing CPU offloading with LTO
Joseph Huber [Thu, 21 Jul 2022 19:29:58 +0000 (15:29 -0400)]
[Libomptarget] Stop testing CPU offloading with LTO

Summary:
Some of the buildbots don't find the libraries because they don't build
for the GPU. Although it should always be there it's unclear why these
buildbots are having problemsd. LTO is only interesting on the GPU and
these tests take extra time anyway so I'm just going to disable them for
now.

23 months ago[MemProf] Add memprof metadata related analysis utilities
Teresa Johnson [Wed, 29 Jun 2022 20:25:58 +0000 (13:25 -0700)]
[MemProf] Add memprof metadata related analysis utilities

Adds a number of utilities that are used to help create and update
memprof related metadata. These will be used during profile matching
and annotation, as well as by the inliner when updating the metadata.
Also adds unit tests for the utilities.

See also related RFCs:
RFC: Sanitizer-based Heap Profiler [1]
RFC: A binary serialization format for MemProf [2]
RFC: IR metadata format for MemProf [3]
(Note that the IR metadata format has changed from the RFC during
implementation, as described in the preceeding patch adding the basic
metadata and verification support.)

Depends on D128141.

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

23 months ago[pseudo] Key guards by RuleID, add guards to literals (and 0).
Sam McCall [Tue, 19 Jul 2022 08:54:52 +0000 (10:54 +0200)]
[pseudo] Key guards by RuleID, add guards to literals (and 0).

After this, NUMERIC_CONSTANT and strings should parse only one way.

There are 8 types of literals, and 24 valid (literal, TokenKind) pairs.
This means adding 8 new named guards (or 24, if we want to assert the token).

It seems fairly clear to me at this point that the guard names are unneccesary
indirection: the guards are in fact coupled to the rule signature.

(Also add the zero guard I forgot in the previous patch.)

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

23 months ago[ASTMatchers] Adding a new matcher for callee declarations of Obj-C
Ziqing Luo [Thu, 21 Jul 2022 20:20:19 +0000 (13:20 -0700)]
[ASTMatchers] Adding a new matcher for callee declarations of Obj-C
message expressions

For an Obj-C message expression `[o m]`, the adding matcher will match
the declaration of the method `m`.  This commit overloads the existing
`callee` ASTMatcher, which originally was only for C/C++ nodes but
also applies to Obj-C messages now.

Reviewed By: aaron.ballman

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

23 months ago[libc] Add a convenience class and function for integer to string conversion.
Siva Chandra Reddy [Wed, 20 Jul 2022 21:02:53 +0000 (21:02 +0000)]
[libc] Add a convenience class and function for integer to string conversion.

Printf's integer converter has been modified to use the new converter. In
future, it will be used to implement other parts of the libc.

Reviewed By: michaelrj

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

23 months ago[MinGW] Don't currently set visibility=hidden when building for MinGW
Martin Storsjö [Wed, 20 Jul 2022 10:39:33 +0000 (13:39 +0300)]
[MinGW] Don't currently set visibility=hidden when building for MinGW

If we build the Target libraries with -fvisibility=hidden, then
LLVM_EXTERNAL_VISIBILITY must also be able to override it back
to default visibility.

Currently, the LLVM_EXTERNAL_VISIBILITY define is a no-op for
mingw targets, thus set CMAKE_CXX_VISIBILITY_PRESET correspondingly.

This unbreaks the mingw dylib build, if the compiler actually
takes hidden visiblity into account (e.g. after D130121).

(Later, once hidden visiblity can be used for MinGW targets, we
can make LLVM_EXTERNAL_VISIBILITY and LLVM_LIBRARY_VISIBILITY expand
to actual attributes, and reverse this commit.)

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

23 months ago[LV][SVE] Autogen a test for ease of update
Philip Reames [Thu, 21 Jul 2022 19:52:48 +0000 (12:52 -0700)]
[LV][SVE] Autogen a test for ease of update

23 months ago[mlir] Explicitly mark dialect prefixing
Jacques Pienaar [Thu, 21 Jul 2022 19:58:19 +0000 (12:58 -0700)]
[mlir] Explicitly mark dialect prefixing

Missed previously and needed to flip the default. Most of these just
flipped to _Raw to retain existing state/keep this small except for TOSA
dialect which got flipped to _Both as no further change was needed..

23 months ago[bazel] add headers now required after 17e4c217b663
Augie Fackler [Thu, 21 Jul 2022 19:07:05 +0000 (15:07 -0400)]
[bazel] add headers now required after 17e4c217b663

23 months agoBuildLibCalls: move inference of freeing memory later
Augie Fackler [Wed, 20 Jul 2022 16:24:36 +0000 (12:24 -0400)]
BuildLibCalls: move inference of freeing memory later

This probably should have been part of D123089, but the effects of it
don't show up until we start removing functions from the table in
D130107. Oops.

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

23 months agoMemoryBuiltins: accept non-TLI funcs with attribs as allocator funcs
Augie Fackler [Fri, 1 Apr 2022 02:33:13 +0000 (22:33 -0400)]
MemoryBuiltins: accept non-TLI funcs with attribs as allocator funcs

This allows us to accept annotations from out-of-tree languages (the
example test is derived from Rust) so they can enjoy the benefits of
LLVM's optimizations without requiring LLVM to have language-specific
knowledge.

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

23 months agoMemoryBuiltins: start using properties of functions
Augie Fackler [Wed, 30 Mar 2022 18:14:53 +0000 (14:14 -0400)]
MemoryBuiltins: start using properties of functions

Prior to this change, we relied on the hard-coded list for all of the
information performed by MemoryBuiltins. With this change, we're able to
start relying on properites of functions described in attributes, which
opens the door to out-of-tree compilers being able to describe their
allocator functions to LLVM's optimizer logic without having to register
their implementation details with LLVM.

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

23 months ago[PatternMatch][InstCombine] match a vector with constant expression element(s) as...
Sanjay Patel [Thu, 21 Jul 2022 19:07:06 +0000 (15:07 -0400)]
[PatternMatch][InstCombine] match a vector with constant expression element(s) as a constant expression

The InstCombine test is reduced from issue #56601. Without the more
liberal match for ConstantExpr, we try to rearrange constants in
Negator forever.

Alternatively, we could adjust the definition of m_ImmConstant to be
more conservative, but that's probably a larger patch, and I don't
see any downside to changing m_ConstantExpr. We never capture and
modify a ConstantExpr; transforms just want to avoid it.

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

23 months ago[PatternMatch] add tests for constant expression matcher; NFC
Sanjay Patel [Thu, 21 Jul 2022 15:52:23 +0000 (11:52 -0400)]
[PatternMatch] add tests for constant expression matcher; NFC

23 months ago[LoopAccessAnalysis] Simplify D119047
Arthur Eubanks [Wed, 9 Feb 2022 22:18:14 +0000 (14:18 -0800)]
[LoopAccessAnalysis] Simplify D119047

No need to add checks for every type per pointer that we couldn't create
a check for the first time around, just the types that weren't
successful.

Reviewed By: fhahn

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

23 months ago[RISCV][LV] Split coverage of uniform load with outside use
Philip Reames [Thu, 21 Jul 2022 19:02:17 +0000 (12:02 -0700)]
[RISCV][LV] Split coverage of uniform load with outside use

Turns out this has a large effect of tail folding, so split out a single test to cover that case and remove it from the others.

23 months ago[cmake] Don't export `LLVM_TOOLS_INSTALL_DIR` anymore
John Ericson [Sat, 11 Jun 2022 06:11:59 +0000 (06:11 +0000)]
[cmake] Don't export `LLVM_TOOLS_INSTALL_DIR` anymore

First of all, `LLVM_TOOLS_INSTALL_DIR` put there breaks our NixOS
builds, because `LLVM_TOOLS_INSTALL_DIR` defined the same as
`CMAKE_INSTALL_BINDIR` becomes an *absolute* path, and then when
downstream projects try to install there too this breaks because our
builds always install to fresh directories for isolation's sake.

Second of all, note that `LLVM_TOOLS_INSTALL_DIR` stands out against the
other specially crafted `LLVM_CONFIG_*` variables substituted in
`llvm/cmake/modules/LLVMConfig.cmake.in`.

@beanz added it in d0e1c2a550ef348aae036d0fe78cab6f038c420c to fix a
dangling reference in `AddLLVM`, but I am suspicious of how this
variable doesn't follow the pattern.

Those other ones are carefully made to be build-time vs install-time
variables depending on which `LLVMConfig.cmake` is being generated, are
carefully made relative as appropriate, etc. etc. For my NixOS use-case
they are also fine because they are never used as downstream install
variables, only for reading not writing.

To avoid the problems I face, and restore symmetry, I deleted the
exported and arranged to have many `${project}_TOOLS_INSTALL_DIR`s.
`AddLLVM` now instead expects each project to define its own, and they
do so based on `CMAKE_INSTALL_BINDIR`. `LLVMConfig` still exports
`LLVM_TOOLS_BINARY_DIR` which is the location for the tools defined in
the usual way, matching the other remaining exported variables.

For the `AddLLVM` changes, I tried to copy the existing pattern of
internal vs non-internal or for LLVM vs for downstream function/macro
names, but it would good to confirm I did that correctly.

Reviewed By: nikic

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

23 months ago[mlir] Flip dialects to _Prefixed
Jacques Pienaar [Thu, 21 Jul 2022 19:03:07 +0000 (12:03 -0700)]
[mlir] Flip dialects to _Prefixed

At least two weeks passed since flipped to _Both. Made some additional
NFC changes in .td files that were not converted earlier.

23 months ago[NFC] Fix compiler warning in MarkupFilter
Daniel Thornburgh [Thu, 21 Jul 2022 19:00:15 +0000 (12:00 -0700)]
[NFC] Fix compiler warning in MarkupFilter

23 months ago[flang] Run algebraic simplification optimization pass.
Slava Zakharin [Thu, 14 Jul 2022 23:50:41 +0000 (16:50 -0700)]
[flang] Run algebraic simplification optimization pass.

Try 2 to merge 4fbd1d6c872e8228f23a6e13914222af40ca6461.

Flang algebraic simplification pass will run algebraic simplification
rewrite patterns for Math/Complex/etc. dialects. It is enabled
under opt-for-speed optimization levels (i.e. for O1/O2/O3; Os/Oz will not
enable it).

With this change the FIR/MLIR optimization pipeline becomes affected
by the -O* optimization level switches. Until now these switches
only affected the middle-end and back-end.

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

23 months agoAdding a new variant of DepthwiseConv2D
George Petterson [Thu, 21 Jul 2022 18:36:47 +0000 (14:36 -0400)]
Adding a new variant of DepthwiseConv2D

This is the same as the existing multiplier-1 variant of DepthwiseConv2D, but in PyTorch dim order.

Reviewed By: nicolasvasilache

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

23 months ago[Symbolizer] Implement contextual symbolizer markup elements.
Daniel Thornburgh [Fri, 10 Jun 2022 23:11:36 +0000 (16:11 -0700)]
[Symbolizer] Implement contextual symbolizer markup elements.

This change implements the contextual symbolizer markup elements: reset,
module, and mmap. These provide information about the runtime context of
the binary necessary to resolve addresses to symbolic values.

Summary information is printed to the output about this context.
Multiple mmap elements for the same module line are coalesced together.
The standard requires that such elements occur on their own lines to
allow for this; accordingly, anything after a contextual element on a
line is silently discarded.

Implementing this cleanly requires that the filter drive the parser;
this allows skipped sections to avoid being parsed. This also makes the
filter quite a bit easier to use, at the cost of some unused
flexibility.

Reviewed By: peter.smith

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

23 months ago[llvm-cov] Improve error message by printing the object file name that produces error
Zequan Wu [Thu, 21 Jul 2022 17:18:16 +0000 (10:18 -0700)]
[llvm-cov] Improve error message by printing the object file name that produces error

If error occurs on constructing coverage info for one of the object files, it prints the name of the object file, so that users know which one is the cause of error.

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

23 months ago[SemaCXX] Set promotion type for enum if its type is promotable to integer type even...
Zequan Wu [Wed, 20 Jul 2022 23:08:25 +0000 (16:08 -0700)]
[SemaCXX] Set promotion type for enum if its type is promotable to integer type even if it has no definition.

EnumDecl's promotion type is set either to the parsed type or calculated type
after completing its definition. When it's bool type and has no definition,
its promotion type is bool which is not allowed by clang.

Fixes #56560.

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

23 months ago{RISCV][LV] Add tail folding coverage of uniform load store cases
Philip Reames [Thu, 21 Jul 2022 18:07:40 +0000 (11:07 -0700)]
{RISCV][LV] Add tail folding coverage of uniform load store cases

23 months ago{RISCV][LV] Add a test for uniform store of a loop varying value
Philip Reames [Thu, 21 Jul 2022 18:04:23 +0000 (11:04 -0700)]
{RISCV][LV] Add a test for uniform store of a loop varying value

23 months ago[NFC] Empty commit to test commit access
Anubhab Ghosh [Thu, 21 Jul 2022 17:58:10 +0000 (23:28 +0530)]
[NFC] Empty commit to test commit access

23 months ago[lld-macho] Fix LOH parsing segfault
Jez Ng [Thu, 21 Jul 2022 17:58:15 +0000 (13:58 -0400)]
[lld-macho] Fix LOH parsing segfault

`advanceSubsection()` didn't account for the possibility that a section
could have no subsections.

Reviewed By: #lld-macho, thakis, BertalanD

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