platform/upstream/llvm.git
20 months agoRevert rG0b0a38a7a229b70d7261771ba0e702843bd34e97 : "[X86] combineX86ShufflesRecursiv...
Simon Pilgrim [Mon, 13 Feb 2023 13:28:42 +0000 (13:28 +0000)]
Revert rG0b0a38a7a229b70d7261771ba0e702843bd34e97 : "[X86] combineX86ShufflesRecursively - don't widen shuffle subvector inputs"

Reports of miscompiles, that I'm still trying to triage - reverting for now

20 months ago[mlir][MemRef][Transform] Don't apply multibuffer on "useless" allocs
Quentin Colombet [Fri, 10 Feb 2023 16:21:38 +0000 (17:21 +0100)]
[mlir][MemRef][Transform] Don't apply multibuffer on "useless" allocs

`alloc`s that have users outside of loops are guaranteed to fail in
`multibuffer`.

Instead of exposing ourselves to that failure in the transform dialect,
filter out the `alloc`s that fall in this category.

To be able to do this filtering we have to change the `multibuffer`
transform op from `TransformEachOpTrait` to a plain `TransformOp`. This is
because `TransformEachOpTrait` expects that every successful `applyToOne`
returns a non-empty result.

Couple of notes:
- I changed the assembly syntax to make sure we only get `alloc` ops as
  input. (And added a test case to make sure we reject invalid inputs.)
- `multibuffer` can still fail pretty easily when you know its limitations.
  See the updated `op failed to multibuffer` test case for instance.
  Longer term, instead of leaking/coupling the actual implementation (in
  this case the checks normally done in `memref::multiBuffer`) with the
  transform dialect (the added check in `::apply`), we may want to refactor
  how we structure the underlying implementation. E.g., we could imagine a
  `canApply` method for all the implementations that we want to hook up in
  the transform dialect.
  This has some implications on how not to duplicate work between
  `canApply` and the actual implementation but I thought I throw that here
  to have us think about it :).

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

20 months ago[gn] port c4f7cc867299 (CoroTests)
Nico Weber [Mon, 13 Feb 2023 13:03:00 +0000 (08:03 -0500)]
[gn] port c4f7cc867299 (CoroTests)

20 months ago[Libomptarget] Remove dependency on the DeviceRTL from the GPU plugins
Joseph Huber [Thu, 2 Feb 2023 16:58:16 +0000 (10:58 -0600)]
[Libomptarget] Remove dependency on the DeviceRTL from the GPU plugins

The GPU plugins have a dependency on the device libraries. Sometimes we
cannot build the device libraries because the user does not have a valid
`clang` to use or it was explicitly disabled. Currently this leads to a
transitive failure because we cannot meet this dependency. This patch
simply removes that dependency.

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

Reviewed By: tianshilei1992

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

20 months ago[lldb][Test][NFC] TestExternalCtorDtorLookup: add more instantiations to test linkage...
Michael Buch [Mon, 13 Feb 2023 12:50:31 +0000 (12:50 +0000)]
[lldb][Test][NFC] TestExternalCtorDtorLookup: add more instantiations to test linkage name is correct

20 months ago[AArch64] Fix LSE2/LSE128/RCPC3 precedence
Tomas Matheson [Tue, 7 Feb 2023 16:20:46 +0000 (16:20 +0000)]
[AArch64] Fix LSE2/LSE128/RCPC3 precedence

D142712 added tests for when both lse2 and lse128 are available, but
in practice there is no way to enable LSE128 without LSE2 from clang:
LSE128 is a v9 only feature and LSE2 has been mandatory since v8.4,
and +/-lse2 can not be specified on the clang command line.

Therefore it makes more sense that lse2+lse128 should emit lse128
instructions, otherwise they will not be emitted at all.

It also makes sense to remove the lse128-only backend tests if that set
of attributes is never set by the frontend.

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

20 months ago[libc++] Granularize <type_traits> includes in <algorithm>
Nikolas Klauser [Mon, 26 Dec 2022 15:24:01 +0000 (16:24 +0100)]
[libc++] Granularize <type_traits> includes in <algorithm>

Reviewed By: Mordante, #libc

Spies: libcxx-commits, wenlei

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

20 months agoReapply "[AMDGPU] Modify adjustInliningThreshold to also consider the cost of passing...
Janek van Oirschot [Fri, 10 Feb 2023 17:03:30 +0000 (17:03 +0000)]
Reapply "[AMDGPU] Modify adjustInliningThreshold to also consider the cost of passing function arguments through the stack"

Reapplies 142c28ffa1323e9a8d53200a22c80d5d778e0d0f as part of D140242 which got reverted due to amdgpu openmp test failures.

This diff fixes said failures by eliding most of `adjustInliningThresholdUsingCallee` for indirect calls as the callee function is unavailable for indirect calls.

Reviewed By: arsenm, #amdgpu

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

20 months ago[mlir][MemRef][TransformOps] Fix error reporting for multibuffer
Quentin Colombet [Fri, 10 Feb 2023 12:43:33 +0000 (13:43 +0100)]
[mlir][MemRef][TransformOps] Fix error reporting for multibuffer

Multibuffer will fail to apply on allocs that are used outside of loops.
This was properly caught in the current implementation but the way we report
it was broken.
Notes cannot be emitted on their own, they need to be attached to another
main diagnostic.

Long story short, change the severity of the report from Note to Error.

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

20 months ago[DWARFLinker] Refactor cloneAddressAttribute().
Alexey Lapshin [Thu, 2 Feb 2023 16:17:52 +0000 (17:17 +0100)]
[DWARFLinker] Refactor cloneAddressAttribute().

As a preparation for implementing DWARFv5 address ranges generation,
this patch refactors cloneAddressAttribute() method. It has special
handling for addresses which can be relocated in some unrelated value,
for applying relocations twice, for indexed addresses. Instead of
all these special handlings this patch uses general handling:

Read attribute value from InputDIE and apply PCOffset.

Another thing is that current handling of DW_FORM_addrx misses the
fact that relocations might be applied twice in some cases. This
patch fixes this problem also.

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

20 months ago[libc] Fix LIBC_LOOP_NOUNROLL being a noop
Guillaume Chatelet [Mon, 13 Feb 2023 11:14:13 +0000 (11:14 +0000)]
[libc] Fix LIBC_LOOP_NOUNROLL being a noop

20 months ago[Coroutines] Modify CoroFrame materializable into a callback
David Stuttard [Thu, 19 Jan 2023 13:55:49 +0000 (13:55 +0000)]
[Coroutines] Modify CoroFrame materializable into a callback

This change makes it possible to optionally provide a different callback to
determine if an instruction is materializable.

By default the behaviour is unchanged.

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

20 months ago[Coroutines] Improve rematerialization stage
David Stuttard [Mon, 23 Jan 2023 12:52:44 +0000 (12:52 +0000)]
[Coroutines] Improve rematerialization stage

As originally implemented, the rematerialization of valid instructions across
the suspend point would iterate 4 times, meaning that up to 4 instructions could
be rematerialized.

This implementation changes that approach to instead build a graph of
rematerializable instructions, then move all of them. This is faster than the
original approach and is not limited to an arbitrary limit.

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

20 months ago[Coroutines] Presubmit test for more coro remats
David Stuttard [Thu, 12 Jan 2023 11:08:12 +0000 (11:08 +0000)]
[Coroutines] Presubmit test for more coro remats

Added more tests that check for >4 instructions.
Also added a retcon-remat test that checks rematerialization into a suspend
block predecessor (such as when remat for a retcon suspend happens).

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

20 months ago[ARM] O3-pipeline fix
Samuel Parker [Mon, 13 Feb 2023 11:00:54 +0000 (11:00 +0000)]
[ARM] O3-pipeline fix

20 months ago[flang] RFC: -fstack-arrays
Tom Eccles [Wed, 7 Dec 2022 17:52:31 +0000 (17:52 +0000)]
[flang] RFC: -fstack-arrays

An RFC describing how -fstack-arrays will be implemented.

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

20 months ago[flang][hlfir] lower hlfir.sum into fir runtime call
Tom Eccles [Fri, 27 Jan 2023 18:01:44 +0000 (18:01 +0000)]
[flang][hlfir] lower hlfir.sum into fir runtime call

This duplicates some argument lowering and return value processing from
flang/lib/Lower/ConvertCall.cpp. The existing code in CovertCall lowers
directly into the fir.call (without the hlfir transformational intrinsic
operation), and it is too tied to the lowering code to move into
flang/lib/Optimizer to allow for more complete re-use here.

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

20 months ago[flang] lower sum intrinsic to hlfir.sum operation
Tom Eccles [Mon, 23 Jan 2023 09:52:31 +0000 (09:52 +0000)]
[flang] lower sum intrinsic to hlfir.sum operation

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

20 months ago[flang] add hlfir.sum operation
Tom Eccles [Tue, 17 Jan 2023 17:37:15 +0000 (17:37 +0000)]
[flang] add hlfir.sum operation

Add an HLFIR operation for the SUM transformational intrinsic, according
to the design set out in flang/doc/HighLevelFIR.md.

I decided to make hlfir.sum very lenient about the form of its
arguments. This allows the sum intrinsic to be lowered to only this HLFIR
operation, without needing several operations to convert and box
arguments. Having only one operation generated for the intrinsic
invocation should make optimisation passes on HLFIR simpler.

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

20 months ago[mlir][SCFToOpenMP] Add pass option to emit LLVM opaque pointers
Markus Böck [Sun, 12 Feb 2023 20:34:21 +0000 (21:34 +0100)]
[mlir][SCFToOpenMP] Add pass option to emit LLVM opaque pointers

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

There were luckily only very few changes that had to be made. To allow users to also specify the pass option from C++ code I have also migrated the pass to use autogenerated constructors to autogenerate a pass option struct.

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

20 months ago[mlir][Vector] add pass option to `convert-vector-to-llvm` to emit opaque pointers
Markus Böck [Sun, 12 Feb 2023 20:05:53 +0000 (21:05 +0100)]
[mlir][Vector] add pass option to `convert-vector-to-llvm` 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 allows the use of `convert-vector-to-llvm` with LLVM opaque pointer types. The changes required were relatively minor:
* there were a few GEPs and loads that required specifying the result or base type
* a few bitcasts, especially when interacting with memref have to not be emitted when using opaque pointers

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

20 months ago[flang] use mlir::LoopLikeOpInterface::blockIsInLoop
Tom Eccles [Thu, 9 Feb 2023 15:25:40 +0000 (15:25 +0000)]
[flang] use mlir::LoopLikeOpInterface::blockIsInLoop

The inlined version of this function can now go away because
https://reviews.llvm.org/D141401 has been merged.

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

20 months ago[LLDB] Apply FixCodeAddress to all forms of address arguments
David Spickett [Fri, 28 Oct 2022 09:52:06 +0000 (10:52 +0100)]
[LLDB] Apply FixCodeAddress to all forms of address arguments

This is a follow up to https://reviews.llvm.org/D141629
and applies the change it made to all paths through ToAddress
(now DoToAddress).

I have included the test from my previous attempt
https://reviews.llvm.org/D136938.

The initial change only applied fixing to addresses that
would parse as integers, so my test case failed. Since
ToAddress has multiple exit points, I've wrapped it into
a new method DoToAddress.

Now you can call ToAddress, it will call DoToAddress and
no matter what path you take, the address will be fixed.

For the memory tagging commands we actually want the full
address (to work out mismatches). So I added ToRawAddress
for that.

I have tested this on a QEMU AArch64 Linux system with
Memory Tagging, Pointer Authentication and Top Byte Ignore
enabled. By running the new test and all other tests in
API/linux/aarch64.

Some commands have had calls to the ABI plugin removed
as ToAddress now does this for them.

The "memory region" command still needs to use the ABI plugin
to detect the end of memory when there are non-address bits.

Reviewed By: jasonmolenda

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

20 months agoAdjust #pragma warning so GCC is not unhappy
Roger Ferrer Ibanez [Mon, 13 Feb 2023 09:51:48 +0000 (09:51 +0000)]
Adjust #pragma warning so GCC is not unhappy

In d768bf994f508d7eaf9541a568be3d71096febf5 a warning to help
transitioning was added to llvm/Support/Host.h but it includes extra
parentheses which make GCC unhappy (clang seems to accept them fine).

This change removes the parentheses around the string literal.

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

20 months ago[mlir][LinAlgTransformOps][NFC] Use emitSilenceableError
Quentin Colombet [Mon, 13 Feb 2023 09:18:19 +0000 (10:18 +0100)]
[mlir][LinAlgTransformOps][NFC] Use emitSilenceableError

Update the error reporting to the easier to use "emitSilenceableError"

NFC

20 months ago[HardwareLoops] NewPM support.
Samuel Parker [Mon, 13 Feb 2023 09:12:12 +0000 (09:12 +0000)]
[HardwareLoops] NewPM support.

With the NPM, we're now defaulting to preserving LCSSA, so a couple
of tests have changed slightly.

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

20 months agoAdd build for Windows on Arm in packaging script
Pierrick Bouvier [Mon, 13 Feb 2023 09:36:04 +0000 (14:36 +0500)]
Add build for Windows on Arm in packaging script

Reviewed By: hans

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

20 months ago[llvm][TableGen][Jupyter] Show llvm-tblgen not found error in notebook
David Spickett [Wed, 25 Jan 2023 11:25:03 +0000 (11:25 +0000)]
[llvm][TableGen][Jupyter] Show llvm-tblgen not found error in notebook

Previously this message was only shown on the command line,
which is not much help if you can't see that.
(you've full screened the browser or you aren't running Jupyter
on the same machine)

Instead return the error as stderr which will get printed in
the notebook just like stderr from llvm-tblgen would.

I've refactored the message sending along the way. Note that
even when we do not send a stream, we still need to send the
status reply. The send_... methods will do that for you.

Reviewed By: jpienaar

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

20 months ago[NFC] Set C++20 Named Modules for CodeGen in ASTContext in the early place
Chuanqi Xu [Mon, 13 Feb 2023 09:12:20 +0000 (17:12 +0800)]
[NFC] Set C++20 Named Modules for CodeGen in ASTContext in the early place

Previously we'll set the named modules for ASTContext in ParseAST. But
this is not intuitive and we need comments to tell the intuition. This
patch moves the code the right the place, where the corrresponding
module is first created/loaded. Now it is more intuitive and we can use
the value in the earlier places.

20 months ago[clangd] Drop includes from disabled PP regions in preamble patch
Kadir Cetinkaya [Wed, 8 Feb 2023 18:53:55 +0000 (19:53 +0100)]
[clangd] Drop includes from disabled PP regions in preamble patch

In rest of the clangd functionality we treat these includes as
non-existent. Do so under preamble patching.

Depends on D143197

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

20 months ago[clangd] Fix bugs in main-file include patching for stale preambles
Kadir Cetinkaya [Thu, 2 Feb 2023 13:15:56 +0000 (14:15 +0100)]
[clangd] Fix bugs in main-file include patching for stale preambles

- Make sure main file includes are present even when they're not patched
  (because they didn't change or we're explicitly not patching them).
- Populate extra fields for includes, which can be used by include-cleaner.

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

20 months ago[Test][SCEV] Add a test where the trip count can't be calculated
Maksim Kazantsev mkazantsev@azul.com [Mon, 13 Feb 2023 08:27:38 +0000 (08:27 +0000)]
[Test][SCEV] Add a test where the trip count can't be calculated

Add a test in which the trip count could have been calculated
correctly thanks to an assume since it is known to divide by the
step of the IV.

Patch by Alon Kom!

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

20 months ago[milr][llvm] Add remaining loop metadata support
Christian Ulmann [Mon, 13 Feb 2023 08:08:58 +0000 (09:08 +0100)]
[milr][llvm] Add remaining loop metadata support

This commit adds support for the last two loop metadata nodes produced
anywhere in the llvm-project.

Reviewed By: gysit

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

20 months agoRevert "[CMake] Remove custom ccache CMake logic"
Tobias Hieta [Mon, 13 Feb 2023 07:56:56 +0000 (08:56 +0100)]
Revert "[CMake] Remove custom ccache CMake logic"

This reverts commit 0fad18c44a14b909a1aa47165021273d4c10a665.

We need bots to be updated first.

20 months ago[mlir][llvm] Improve LoadOp and StoreOp import.
Tobias Gysi [Mon, 13 Feb 2023 07:12:09 +0000 (08:12 +0100)]
[mlir][llvm] Improve LoadOp and StoreOp import.

The revision supports importing the volatile keyword and nontemporal
metadata for the LoadOp and StoreOp. Additionally, it updates the
builders and uses an assembly format for printing and parsing.

The operation type still requires custom parse and print methods
due to the current handling of typed and opaque pointers.

Reviewed By: Dinistro

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

20 months ago[CMake] Remove custom ccache CMake logic
Tobias Hieta [Mon, 13 Feb 2023 07:42:04 +0000 (08:42 +0100)]
[CMake] Remove custom ccache CMake logic

CMake supports CMAKE_CXX_COMPILER_LAUNCHER since CMake 3.4
so this custom CMake logic we had in LLVM can now be removed.

The only downside with this is that we can't set ccache
options from LLVM CMake, but it's arguable that this doesn't
belong in LLVM but should be done in a script calling the
build.

This was discussed in the forums here:

https://discourse.llvm.org/t/tips-for-incremental-building/67289/4?u=tobiashieta

Reviewed By: phosek

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

20 months ago[gn build] Port b7b28c6cfe04
LLVM GN Syncbot [Mon, 13 Feb 2023 06:06:30 +0000 (06:06 +0000)]
[gn build] Port b7b28c6cfe04

20 months ago[clang-tidy][libc] Add an inline function checker for the libc project.
Siva Chandra Reddy [Thu, 26 Jan 2023 01:21:12 +0000 (01:21 +0000)]
[clang-tidy][libc] Add an inline function checker for the libc project.

The new checker checks if inline functions defined in header files are
tagged with the LIBC_INLINE macro. See https://libc.llvm.org/code_style.html
for more information about this macro.

Reviewed By: carlosgalvezp

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

20 months ago[AMDGPU] Use llvm::bit_cast (NFC)
Kazu Hirata [Mon, 13 Feb 2023 05:59:14 +0000 (21:59 -0800)]
[AMDGPU] Use llvm::bit_cast (NFC)

AFAICT, this is the only place where we pass a 64-bit value into
BitsToFloat.

20 months ago[llvm-debuginfo-analyzer] LLVM 16.0.0-rc1 Failing test on osx-64.
Carlos Alberto Enciso [Mon, 13 Feb 2023 05:25:17 +0000 (05:25 +0000)]
[llvm-debuginfo-analyzer] LLVM 16.0.0-rc1 Failing test on osx-64.

As describe in

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

the following DebugInfo LogicalView Tests unit tests failed:

- ELFReader
- SelectElements

The tests fail only on the OSX-64 platform with the CMake options:

-DLLVM_BUILD_LLVM_DYLIB=ON -DLLVM_LINK_LLVM_DYLIB=ON

Using the same options on a Linux platform all the tests pass:
- https://lab.llvm.org/buildbot/#/builders/196
- llvm-x86_64-debian-dylib

Basically it is a dynamic library initialization affecting a static
instance for the string pool (LVStringPool).

That string pool instance is accessed by all the logical elements
to store/retrieve any associated string during the creation of the
logical view.

For a logical view comparison, both logical readers (Reference and
Target) use retrieved indexes when comparing their strings.

Moved the static instance to LVSupport module (unnamed namespace).

Reviewed By: jmorse

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

20 months ago[llvm] Deprecate PowerOf2Floor and ByteSwap_{16,32,64}
Kazu Hirata [Mon, 13 Feb 2023 05:42:07 +0000 (21:42 -0800)]
[llvm] Deprecate PowerOf2Floor and ByteSwap_{16,32,64}

llvm/include/llvm/ADT/bit.h now has equivalent functions
forward-ported from C++20.

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

20 months ago[x86] Move combineAddOrSubToADCOrSBB within the source file (NFC)
Kazu Hirata [Mon, 13 Feb 2023 03:48:35 +0000 (19:48 -0800)]
[x86] Move combineAddOrSubToADCOrSBB within the source file (NFC)

D143838 needs to use combineAddOrSubToADCOrSBB just above combineOr.
This patch simply moves up combineAddOrSubToADCOrSBB within the source
file to avoid forward-declaring the functions.

20 months ago[X86] Precommit tests for D143838
Kazu Hirata [Mon, 13 Feb 2023 03:33:23 +0000 (19:33 -0800)]
[X86] Precommit tests for D143838

20 months agoRecommit [C++20] [Modules] [ClangScanDeps] Enable to print make-style dependency...
Chuanqi Xu [Mon, 13 Feb 2023 03:12:08 +0000 (11:12 +0800)]
Recommit [C++20] [Modules] [ClangScanDeps] Enable to print make-style dependency file within P1689 format (4/4)

Required in https://reviews.llvm.org/D137534.

The build systems needs the information to know that "header X changed,
scanning may have changed, so please rerun scanning". Although it is
possible to get the information by running clang-scan-deps for the
second time with make format, it is not user friendly clearly.

Reviewed By: jansvoboda11

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

20 months agoRecommit [C++20] [Modules] [ClangScanDeps] Allow clang-scan-deps to without specified...
Chuanqi Xu [Mon, 13 Feb 2023 03:01:24 +0000 (11:01 +0800)]
Recommit [C++20] [Modules] [ClangScanDeps] Allow clang-scan-deps to without specified compilation database in P1689 (3/4)

In a private chat with @ben.boeckel , we get in consensus it would be
great for cmake if the invocation of clang-scan-deps can get rid of
compilation database. Due to the compilation database can't do very well
for the files which are not existed yet. @ben.boeckel may have more
context to add here.

This patch should be innocent for others usages.

Reviewed By: jansvoboda11

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

20 months agoRecommit [C++20] [Modules] [ClangScanDeps] Add ClangScanDeps support for C++20 Named...
Chuanqi Xu [Fri, 10 Feb 2023 02:26:35 +0000 (10:26 +0800)]
Recommit [C++20] [Modules] [ClangScanDeps] Add ClangScanDeps support for C++20 Named Modules in P1689 format (2/4)

Close https://github.com/llvm/llvm-project/issues/51792
Close https://github.com/llvm/llvm-project/issues/56770

This patch adds ClangScanDeps support for C++20 Named Modules in P1689
format. We can find the P1689 format at:
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p1689r5.html.
After we land the patch, we're able to compile C++20 Named
Modules with CMake! And although P1689 is written by kitware people,
other build systems should be able to use the format to compile C++20
Named Modules too.

TODO: Support header units in P1689 Format.
TODO2: Support C++20 Modules in the full dependency format of
ClangScanDeps. We also want to support C++20 Modules and clang modules
together according to
https://discourse.llvm.org/t/how-should-we-support-dependency-scanner-for-c-20-modules/66027.
But P1689 format cares about C++20 Modules only for now. So let's focus
on C++ Modules and P1689 format. And look at the full dependency format
later.

I'll add the ReleaseNotes and Documentations after the patch get landed.

Reviewed By: jansvoboda11

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

20 months ago[flang] Handle forward references to modules
Peter Klausler [Sun, 5 Feb 2023 01:55:45 +0000 (17:55 -0800)]
[flang] Handle forward references to modules

When a USE of a module precedes its definition in the same source
file, ensure that the module is processed by name resolution before
the USE statement.  This prevents the risk of the USE statement using
an obsolete module file that is later overwritten during the same
compilation.

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

20 months ago[X86][FP16] Add tests to show suboptimal codegen, NFC
Phoebe Wang [Sun, 12 Feb 2023 14:55:27 +0000 (22:55 +0800)]
[X86][FP16] Add tests to show suboptimal codegen, NFC

20 months ago[flang] Warn on overflow folding DIM()
Peter Klausler [Sat, 4 Feb 2023 01:19:55 +0000 (17:19 -0800)]
[flang] Warn on overflow folding DIM()

The intrinsic function DIM can overflow when its second argument
is negative.  Detect this case for real and integer arguments and
emit a warning when necessary.

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

20 months ago[flang] Catch misuse of a procedure designator as an output item
Peter Klausler [Fri, 3 Feb 2023 00:50:09 +0000 (16:50 -0800)]
[flang] Catch misuse of a procedure designator as an output item

f18 was diagnosing the misuse of a procedure pointer as an output item,
but not the more general case of a procedure designator other than
a pointer.

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

20 months ago[gn build] Port 2a06757a200c
LLVM GN Syncbot [Sun, 12 Feb 2023 22:51:56 +0000 (22:51 +0000)]
[gn build] Port 2a06757a200c

20 months ago[libc++][spaceship] Implement `lexicographical_compare_three_way`
Adrian Vogelsgesang [Thu, 4 Aug 2022 22:21:27 +0000 (15:21 -0700)]
[libc++][spaceship] Implement `lexicographical_compare_three_way`

The implementation makes use of the freedom added by LWG 3410. We have
two variants of this algorithm:
* a fast path for random access iterators: This fast path computes the
  maximum number of loop iterations up-front and does not compare the
  iterators against their limits on every loop iteration.
* A basic implementation for all other iterators: This implementation
  compares the iterators against their limits in every loop iteration.
  However, it still takes advantage of the freedom added by LWG 3410 to
  avoid unnecessary additional iterator comparisons, as originally
  specified by P1614R2.

https://godbolt.org/z/7xbMEen5e shows the benefit of the fast path:
The hot loop generated of `lexicographical_compare_three_way3` is
more tight than for `lexicographical_compare_three_way1`. The added
benchmark illustrates how this leads to a 30% - 50% performance
improvement on integer vectors.

Implements part of P1614R2 "The Mothership has Landed"

Fixes LWG 3410 and LWG 3350

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

20 months ago[LV] Update recipe builder functions to pass VPlan directly (NFC).
Florian Hahn [Sun, 12 Feb 2023 22:35:14 +0000 (22:35 +0000)]
[LV] Update recipe builder functions to pass VPlan directly (NFC).

Passing VPlanPtr requires a dereference of std::unique_ptr on each
access, which is unnecessary. Just pass the plan by reference.

20 months ago[Flang][OpenMP][NFC] Remove usage of else after return
Kiran Chandramohan [Sun, 12 Feb 2023 21:59:05 +0000 (21:59 +0000)]
[Flang][OpenMP][NFC] Remove usage of else after return

20 months ago[Support] Use llvm::popcount (NFC)
Kazu Hirata [Sun, 12 Feb 2023 21:39:18 +0000 (13:39 -0800)]
[Support] Use llvm::popcount (NFC)

This should fix builds on Windows.

20 months ago[ORC] Add MachOPlatform::Create overload -- Pass ORC runtime as def generator.
Lang Hames [Sun, 12 Feb 2023 20:34:20 +0000 (12:34 -0800)]
[ORC] Add MachOPlatform::Create overload -- Pass ORC runtime as def generator.

The existing Create method took a path to the ORC runtime and created a
StaticLibraryDefinitionGenerator for it. The new overload takes a
std::unique_ptr<DefinitionGenerator> directly instead. This provides more
flexibility when constructing MachOPlatforms. E.g. The runtime archive can be
embedded in a special section in the ORC controller executable or library,
rather than being on-disk.

20 months ago[flang] Fix crash on SELECT RANK
Peter Klausler [Thu, 2 Feb 2023 22:26:01 +0000 (14:26 -0800)]
[flang] Fix crash on SELECT RANK

In some circumstances, such as in compile-time array shape analysis,
clients of the utility function ResolveAssociations() don't really
want it to drill all of the way down to an assumed-rank dummy argument.
Add a variation, ResolveAssociationsExceptSelectRank(), that
will return a specific rank case's AssocEntity symbol instead.
This fixes a crash in subscript validation checking that stemmed from
deducing an incorrect number of lower and upper bound expressions
from a specific rank case association entity.

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

20 months ago[llvm] Deprecate llvm::count{Leading,Trailing}{Zeros,Ones} and llvm::countPopulation
Kazu Hirata [Sun, 12 Feb 2023 20:11:51 +0000 (12:11 -0800)]
[llvm] Deprecate llvm::count{Leading,Trailing}{Zeros,Ones} and llvm::countPopulation

llvm/include/llvm/ADT/bit.h now has equivalent functions
forward-ported from C++20.

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

20 months ago[libc++][NFC] Fix formatting in ranges status page
Adrian Vogelsgesang [Sun, 12 Feb 2023 20:05:38 +0000 (12:05 -0800)]
[libc++][NFC] Fix formatting in ranges status page

20 months ago[flang] Warn about construct names that are not distinct in the inclusive scope
Peter Klausler [Thu, 2 Feb 2023 20:11:01 +0000 (12:11 -0800)]
[flang] Warn about construct names that are not distinct in the inclusive scope

f18 implements BLOCK scoping for construct names, like most but not all Fortran
compilers, but in the 2018 standard such names are defined to be local identifiers
whose scope is the inclusive scope -- i.e., the subprogram or main program.
Detect usage that depends on this extension and emit a portability warning.

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

20 months ago[lldb] Add the ability to provide a message to a progress event update
Jonas Devlieghere [Sun, 12 Feb 2023 18:55:39 +0000 (10:55 -0800)]
[lldb] Add the ability to provide a message to a progress event update

Consider the following example as motivation. Say you have to load
symbols for 3 dynamic libraries: `libFoo`, `libBar` and `libBaz`.
Currently, there are two ways to report process for this operation:

 1. As 3 separate progress instances. In this case you create a progress
    instance with the message "Loading symbols: libFoo", "Loading
    symbols: libBar", and "Loading symbols: libBaz" respectively. Each
    progress event gets a unique ID and therefore cannot be correlated
    by the consumer.

 2. As 1 progress instance with 3 units of work. The title would be
    "Loading symbols" and you call Progress::Increment for each of the
    libraries. The 3 progress events share the same ID and can easily be
    correlated, however, in the current design, there's no way to
    include the name of the libraries.

The second approach is preferred when the amount of work is known in
advance, because determinate progress can be reported (i.e. x out of y
operations completed). An additional benefit is that the progress
consumer can decide to ignore certain progress updates by their ID if
they are deemed to noisy, which isn't trivial for the first approach due
to the use of different progress IDs.

This patch adds the ability to add a message (detail) to a progress
event update. For the example described above, progress can now be
displayed as shown:

  [1/3] Loading symbols: libFoo
  [2/3] Loading symbols: libBar
  [3/3] Loading symbols: libBaz

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

20 months ago[X86] combineConcatVectorOps - concatenate 512-bit VPERMILPS nodes.
Simon Pilgrim [Sun, 12 Feb 2023 18:26:22 +0000 (18:26 +0000)]
[X86] combineConcatVectorOps - concatenate 512-bit VPERMILPS nodes.

20 months ago[X86] Add some basic matrix multiplication test coverage
Simon Pilgrim [Sun, 12 Feb 2023 18:13:52 +0000 (18:13 +0000)]
[X86] Add some basic matrix multiplication test coverage

Based off the IR generated from matrix_type / -fenable-matrix - including 2x2, 3x3, 4x4 and 8x8 matrices

20 months ago[Flang][OpenMP][NFC] Correct a few instances of variable naming
Kiran Chandramohan [Sun, 12 Feb 2023 16:57:36 +0000 (16:57 +0000)]
[Flang][OpenMP][NFC] Correct a few instances of variable naming

In lowering code Flang follows the MLIR coding guideline of using
camelBack for variables names. Correct a few instances that were
not following this guideline.

20 months ago[AArch64] Regenerate and extend zip1 tests. NFC
David Green [Sun, 12 Feb 2023 16:52:38 +0000 (16:52 +0000)]
[AArch64] Regenerate and extend zip1 tests. NFC

This cleans up the existing tests and adds some extra cases that can be lowered
to zip instructions.

20 months agoBlockFrequencyInfoImpl.cpp - add missing closing namespace comment. NFC
Simon Pilgrim [Sun, 12 Feb 2023 16:42:22 +0000 (16:42 +0000)]
BlockFrequencyInfoImpl.cpp - add missing closing namespace comment. NFC

Fixes clang-tidy llvm-namespace-comment warning

20 months agoBlockFrequencyInfoImpl.h - use auto* for pointer types. NFC.
Simon Pilgrim [Sun, 12 Feb 2023 16:40:47 +0000 (16:40 +0000)]
BlockFrequencyInfoImpl.h - use auto* for pointer types. NFC.

Silence clang-tidy llvm-qualified-auto warnings

20 months agoBlockFrequency.h - add missing closing namespace comment. NFC
Simon Pilgrim [Sun, 12 Feb 2023 16:37:29 +0000 (16:37 +0000)]
BlockFrequency.h - add missing closing namespace comment. NFC

Fixes clang-tidy llvm-namespace-comment warning

20 months ago[flang] Support polymorphic inputs for the TRANSPOSE intrinsic
Valentin Clement [Sun, 12 Feb 2023 15:57:24 +0000 (16:57 +0100)]
[flang] Support polymorphic inputs for the TRANSPOSE intrinsic

Force TRANSPOSE with polymorphic inputs through the runtime call
and carry the polymorphic type information from the matrix to
the result.

Reviewed By: jeanPerier

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

20 months ago[X86] combinePredicateReduction - attempt to fold subvector all_of(icmp_eq()) / any_o...
Simon Pilgrim [Sun, 12 Feb 2023 15:23:38 +0000 (15:23 +0000)]
[X86] combinePredicateReduction - attempt to fold subvector all_of(icmp_eq()) / any_of(icmp_ne()) to integers

Noticed while working on Issue #59867 and Issue #53419 - there's still more to do here, but for "all vector" comparisons, we should try to cast to a scalar integer for sub-128bit types

20 months ago[Clang] Add the list of approved (Issaquah) C++ papers to the status page
Corentin Jabot [Sat, 11 Feb 2023 16:54:23 +0000 (08:54 -0800)]
[Clang] Add the list of approved (Issaquah) C++ papers to the status page

20 months agoDemandedBits.cpp - use auto* when initializing from cast<>. NFC.
Simon Pilgrim [Sun, 12 Feb 2023 14:57:11 +0000 (14:57 +0000)]
DemandedBits.cpp - use auto* when initializing from cast<>. NFC.

Silence clang-tidy warnings

20 months agoRegisterPressure.h - consistently initialize all pointer fields. NFC.
Simon Pilgrim [Sun, 12 Feb 2023 14:55:03 +0000 (14:55 +0000)]
RegisterPressure.h - consistently initialize all pointer fields. NFC.

Silence static analyser warning - we're initializing some fields but not others.

20 months agoRevert rG23cb32c6d5bda0919cc1ef129917ceb2dbf1b1b8 "[X86] combineX86ShufflesRecursivel...
Simon Pilgrim [Sun, 12 Feb 2023 14:46:02 +0000 (14:46 +0000)]
Revert rG23cb32c6d5bda0919cc1ef129917ceb2dbf1b1b8 "[X86] combineX86ShufflesRecursively - treat ISD::TRUNCATE as faux shuffle"

This is causing a miscompile - waiting on a regression test from @bkramer

20 months agoRevert "[AArch64] Reassociate sub(x, add(m1, m2)) to sub(sub(x, m1), m2)"
Martin Storsjö [Sun, 12 Feb 2023 13:54:01 +0000 (15:54 +0200)]
Revert "[AArch64] Reassociate sub(x, add(m1, m2)) to sub(sub(x, m1), m2)"

This reverts commit c52255d26a23df6ecf09f60ca3e3615467f16bbe.

That commit caused certain files (in ffmpeg, libvpx and libaom) to hang
while compiling, see https://reviews.llvm.org/D143143 for repro.

20 months ago[InstCombine] canonicalize cmp+select as smin/smax
Sanjay Patel [Sun, 12 Feb 2023 11:56:43 +0000 (06:56 -0500)]
[InstCombine] canonicalize cmp+select as smin/smax

(V == SMIN) ? SMIN+1 : V --> smax(V, SMIN+1)
(V == SMAX) ? SMAX-1 : V --> smin(V, SMAX-1)

https://alive2.llvm.org/ce/z/d5bqjy

Follow-up for the unsigned variants added with:
86b4d8645fc1b866

issue #60374

20 months ago[InstCombine] add tests for disguised smin/smax; NFC
Sanjay Patel [Sat, 11 Feb 2023 14:26:18 +0000 (09:26 -0500)]
[InstCombine] add tests for disguised smin/smax; NFC

Adapted from the existing umin/umax tests.

20 months ago[bazel][libc] Add a few more missing dependency that show up when parsing headers
Benjamin Kramer [Sun, 12 Feb 2023 12:03:54 +0000 (13:03 +0100)]
[bazel][libc] Add a few more missing dependency that show up when parsing headers

20 months agollvm-tblgen: Apply IWYU in some files
NAKAMURA Takumi [Sun, 12 Feb 2023 03:41:55 +0000 (12:41 +0900)]
llvm-tblgen: Apply IWYU in some files

20 months agoCodeGenTarget.cpp: Reformat.
NAKAMURA Takumi [Sun, 12 Feb 2023 03:03:40 +0000 (12:03 +0900)]
CodeGenTarget.cpp: Reformat.

20 months agoLLVMFuzzerCLI: [CMake] Prune the last PARTIAL_SOURCES_INTENDED to cover all sources.
NAKAMURA Takumi [Fri, 20 Jan 2023 22:33:24 +0000 (07:33 +0900)]
LLVMFuzzerCLI: [CMake] Prune the last PARTIAL_SOURCES_INTENDED to cover all sources.

20 months agoLLVMProcessSources.cmake: Improve PARTIAL_SOURCES_INTENDED.
NAKAMURA Takumi [Mon, 17 May 2021 15:01:30 +0000 (00:01 +0900)]
LLVMProcessSources.cmake: Improve PARTIAL_SOURCES_INTENDED.

The last non-partial-specified target can collect and check source files.

Case A:
  llvm_add_library(foo PARTIAL_SOURCES_INTENDED ...)
  llvm_add_library(bar PARTIAL_SOURCES_INTENDED ...)
  llvm_add_library(baz ...)

  baz checks source files in foo, bar, and baz.

Case B:
  llvm_add_library(hoge PARTIAL_SOURCES_INTENDED ...)
  llvm_add_library(fuga PARTIAL_SOURCES_INTENDED ...)
  llvm_add_library(piyo PARTIAL_SOURCES_INTENDED ...)
  llvm_check_source_file_list() # Explicitly checks sources in hoge, fuga, and piyo.

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

20 months agoReland "[lldb][DWARFASTParserClang] Attach linkage name to ctors/dtors if missing"
Michael Buch [Sun, 12 Feb 2023 01:49:07 +0000 (01:49 +0000)]
Reland "[lldb][DWARFASTParserClang] Attach linkage name to ctors/dtors if missing"

This relands the commit previously reverted in
`d2cc2c5610ffa78736aa99512bc85a85417efb0a` due to failures on Linux
when debugging split-debug-info enabled executables.

The problem was we called `SymbolFileDWARF::FindFunctions` directly
instead of `Module::FindFunctions` which resulted in a nullptr
dereference because the backing `SymbolFileDWARFDwo` didn't have
an index attached to it. The relanded version calls `Module::FindFunctions`
instead.

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

20 months ago[test] Remove occurences of br undef in Transform/Util tests [NFC]
Kriti Gupta [Sun, 12 Feb 2023 10:12:25 +0000 (10:12 +0000)]
[test] Remove occurences of br undef in Transform/Util tests [NFC]

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

20 months agoRevert "[C++20] [Modules] [ClangScanDeps] Add ClangScanDeps support for C++20 Named...
NAKAMURA Takumi [Sun, 12 Feb 2023 09:36:11 +0000 (18:36 +0900)]
Revert "[C++20] [Modules] [ClangScanDeps] Add ClangScanDeps support for C++20 Named Modules in P1689 format (2/4)"

This reverts commit de17c665e3f995c7f5a0e453461ce3a1b8aec196.

See also D137527

20 months agoRevert "[C++20] [Modules] [ClangScanDeps] Allow clang-scan-deps to without specified...
NAKAMURA Takumi [Sun, 12 Feb 2023 09:35:40 +0000 (18:35 +0900)]
Revert "[C++20] [Modules] [ClangScanDeps] Allow clang-scan-deps to without specified compilation database in P1689 (3/4)"

This reverts commit 591fdcde921334b2d502779006d7c168307a2106.

See also D137527

20 months agoRevert "[ClangScanDeps] Add UNSUPPORTED: system-windows to test P1689.cppm"
NAKAMURA Takumi [Sun, 12 Feb 2023 09:34:29 +0000 (18:34 +0900)]
Revert "[ClangScanDeps] Add UNSUPPORTED: system-windows to test P1689.cppm"

This reverts commit 79a3803bb2ccdd852436cd1653017a1159a12157.

See also D137527

20 months ago[docs] Make consistent between MLIR tutorial doc and example code
Hsiangkai Wang [Sat, 11 Feb 2023 15:08:00 +0000 (15:08 +0000)]
[docs] Make consistent between MLIR tutorial doc and example code

In MLIR tutorial example code, use `Pure` to remove the side-effects of
operations. Update the document to be consistent with the example code.

Reviewed By: mehdi_amini

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

20 months ago[AArch64] Consider tiny code model in emitLoadFromConstantPool.
Hsiangkai Wang [Sat, 11 Feb 2023 15:17:35 +0000 (15:17 +0000)]
[AArch64] Consider tiny code model in emitLoadFromConstantPool.

We should be able to use load(literal) to access constant pool under
the tiny code model.

Reviewed By: aemerson

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

20 months ago[Clang][perf-training] Remove trailing whitespace in perf-helper
Amir Ayupov [Sun, 12 Feb 2023 05:10:27 +0000 (21:10 -0800)]
[Clang][perf-training] Remove trailing whitespace in perf-helper

20 months ago[AArch64] Use llvm::countr_{zero,one} (NFC)
Kazu Hirata [Sun, 12 Feb 2023 01:53:01 +0000 (17:53 -0800)]
[AArch64] Use llvm::countr_{zero,one} (NFC)

20 months ago[JITLink] Don't initialize local ArrayRefs with initializer lists.
Lang Hames [Sun, 12 Feb 2023 00:52:33 +0000 (16:52 -0800)]
[JITLink] Don't initialize local ArrayRefs with initializer lists.

This can lead to use-after-free errors (see e.g.
https://lab.llvm.org/buildbot/#/builders/168/builds/11848).

20 months ago[RISCV] Remove dead code from RISCVDAGToDAGISel::selectVSETVLI. NFC
Craig Topper [Sun, 12 Feb 2023 00:51:07 +0000 (16:51 -0800)]
[RISCV] Remove dead code from RISCVDAGToDAGISel::selectVSETVLI. NFC

vsetvli no longer has side effects so we don't need code for
handling INSTRINSIC_W_CHAIN.

20 months agoSpecify target triple for bb-prefix-dump.ll
Mircea Trofin [Sat, 11 Feb 2023 16:01:06 +0000 (08:01 -0800)]
Specify target triple for bb-prefix-dump.ll

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

20 months ago[JITLink] Add explicit conversion to silence warnings / errors on bots.
Lang Hames [Sat, 11 Feb 2023 21:11:02 +0000 (13:11 -0800)]
[JITLink] Add explicit conversion to silence warnings / errors on bots.

Commit 10b5fec2563 uses a char -1 value, which triggers narrowing conversion
warnings / errors on some platforms (see e.g.
https://lab.llvm.org/buildbot/#/builders/36/builds/30312). Adding an explicit
conversion should fix this.

20 months ago[libcxx][ranges] mark new join view tests unsupported without experimental flag
Hui [Sat, 11 Feb 2023 20:41:43 +0000 (20:41 +0000)]
[libcxx][ranges] mark new join view tests unsupported without experimental flag

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

20 months ago[RISCV] Fix mistake in comment. NFC
Craig Topper [Sat, 11 Feb 2023 20:30:32 +0000 (12:30 -0800)]
[RISCV] Fix mistake in comment. NFC

20 months ago[JITLink][ORC] Add LinkGraph::allocateCString method.
Lang Hames [Sat, 11 Feb 2023 19:58:25 +0000 (11:58 -0800)]
[JITLink][ORC] Add LinkGraph::allocateCString method.

Renames the existing allocateString method to allocateContent and adds a pair of
allocateCString methods.

The previous allocateString method did not include a null-terminator. It behaved
the same as allocateContent except with a Twine input, rather than an
ArrayRef<char>. Renaming allocateString to allocateBuffer (overloading the
existing method) makes this clearer.

The new allocateCString methods allocate the given content plus a
null-terminator character, and return a buffer covering both the string and
null-terminator. This makes them suitable for creating c-string content for
jitlink::Blocks.

Existing users of the old allocateString method have been updated to use the
new allocateContent overload.

20 months ago[libc++] fix `shared_ptr`'s incorrect constraints
Hui [Sun, 5 Feb 2023 19:31:30 +0000 (19:31 +0000)]
[libc++] fix `shared_ptr`'s incorrect constraints

Fix several bugs:
1. https://llvm.org/PR60258
   The conversion constructors' constraint `__compatible_with` incorrectly allow array types conversion to scalar types
2. https://llvm.org/PR53368
   The constructor that takes `unique_ptr` are not suffiently constrained.
3. The constructors that take raw pointers incorretly use `__compatible_with`. They have different constraints

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

20 months ago[X86] combineX86ShufflesRecursively - treat ISD::TRUNCATE as faux shuffle
Simon Pilgrim [Sat, 11 Feb 2023 19:16:01 +0000 (19:16 +0000)]
[X86] combineX86ShufflesRecursively - treat ISD::TRUNCATE as faux shuffle

getFauxShuffleMask can't handle ISD::TRUNCATE itself as it can't handle inputs that are larger than the output

Another step towards removing combineX86ShuffleChainWithExtract