platform/upstream/llvm.git
12 months ago[RISCV] Teach doPeepholeMaskedRVV to handle vslide{up,down}
Luke Lau [Fri, 23 Jun 2023 13:56:56 +0000 (14:56 +0100)]
[RISCV] Teach doPeepholeMaskedRVV to handle vslide{up,down}

We already handle vslide1{up,down}, so this extends it to vslide{up,down}.

This was unintentionally added in https://reviews.llvm.org/D150463 and
then removed in 37cfcfcef76bb615b941d7077ca81168bd7ad080, but unless I'm
missing something this should still be ok as the mask only controls what
destination elements are written to.

Reviewed By: craig.topper

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

12 months ago[RISCV] Add test cases for vmerge peephole with vslides
Luke Lau [Fri, 23 Jun 2023 13:31:45 +0000 (14:31 +0100)]
[RISCV] Add test cases for vmerge peephole with vslides

Currently vslide1{up,down}s can have vmerges folded into them, but not
vslide{up,down}s.

Reviewed By: craig.topper

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

12 months ago[mlir][affine][doc] Fix example snippet for AffineParallelOp. (NFC)
Ingo Müller [Sun, 25 Jun 2023 09:04:49 +0000 (09:04 +0000)]
[mlir][affine][doc] Fix example snippet for AffineParallelOp. (NFC)

There were various syntax errors; all have pretty trivial fixes but
might distract novice users (like me).

Reviewed By: ingomueller-net

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

12 months agoReland [COFF] Support -gsplit-dwarf for COFF on Windows
Haohai Wen [Mon, 26 Jun 2023 07:27:06 +0000 (15:27 +0800)]
Reland [COFF] Support -gsplit-dwarf for COFF on Windows

This relands 3eee5aa528abd67bb6d057e25ce1980d0d38c445 with fixes.

12 months ago[JITLink][RISCV] Adjust offsets of non-relaxable edges
Job Noorman [Mon, 26 Jun 2023 07:09:36 +0000 (09:09 +0200)]
[JITLink][RISCV] Adjust offsets of non-relaxable edges

The relaxation algorithm used to only update offsets of relaxable edges.
This caused non-relaxable edges that appear after a relaxed instruction
to have an incorrect offset and be applied at the wrong location. This
patch fixes this by updating the offsets of all edges.

Note that this bug was caused by an incorrect translation of LLD's
relaxation algorithm. LLD always uses all edges during relaxation while
I decided to filter-out relaxable edges to prevent having to iterate
non-relaxable edges at each step. However, this had the side-effect of
only updating offsets of relaxable edges. This patch leaves the
filtering of relaxable edges as-is but iterates all edges when updating
offsets.

Reviewed By: StephenFan

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

12 months ago[JITLink][RISCV] Expose relaxation pass publicly
Job Noorman [Mon, 26 Jun 2023 07:09:29 +0000 (09:09 +0200)]
[JITLink][RISCV] Expose relaxation pass publicly

This is useful for contexts where shouldAddDefaultTargetPasses returns
false but that still want to perform relaxation.

Reviewed By: StephenFan

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

12 months ago[JITLink][RISCV] Support relaxable edges without relaxation pass
Job Noorman [Mon, 26 Jun 2023 07:09:19 +0000 (09:09 +0200)]
[JITLink][RISCV] Support relaxable edges without relaxation pass

Relaxable edges are created unconditionally, even when the relaxation
pass will not run. However, they were not recognized by applyFixup
causing them to not be applied.

To support configurations without the relaxation pass, this patch adds
these relaxable edges to applyFixup:
- CallRelaxable: Can be treated as R_RISCV_CALL
- AlignRelaxable: Can simply be ignored

An alternative could be to unconditionally run the relaxation pass, even
in contexts where shouldAddDefaultTargetPasses returns false. However, I
could imagine there being use cases for disabling relaxation which
wouldn't be possible anymore then.

Reviewed By: StephenFan

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

12 months ago[NFC][GlobalISel] Don't return `bool` from apply functions
pvanhout [Fri, 23 Jun 2023 10:26:57 +0000 (12:26 +0200)]
[NFC][GlobalISel] Don't return `bool` from apply functions

There is no case where those functions return false. It's always return true.
Even if they were to return false, it's not really something we should rely on I think.
With the current combiner implementation, it would just make `tryCombineAll` return false without retrying anymore rules.

I also believe that if an applyer were to return false, it would mean that the match function is not good enough. Asserting on failure in an apply function is a better idea, IMO.

Reviewed By: arsenm

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

12 months ago[Clang][LoongArch] Consume and check -mabi and -mfpu even if -m*-float is present
WANG Xuerui [Mon, 26 Jun 2023 07:07:21 +0000 (15:07 +0800)]
[Clang][LoongArch] Consume and check -mabi and -mfpu even if -m*-float is present

This kind of CLI flags duplication can sometimes be convenient for build
systems that may have to tinker with these.

For example, in the Linux kernel we almost always want to ensure no FP
instruction is emitted, so `-msoft-float` is present by default; but
sometimes we do want to allow FPU usage (e.g. certain parts of amdgpu DC
code), in which case we want the `-msoft-float` stripped and `-mfpu=64`
added. Here we face a dilemma without this change:

* Either `-mabi` is not supplied by `arch/loongarch` Makefile, in which
  case the correct ABI has to be supplied by the driver Makefile
  (otherwise the ABI will become double-float due to `-mfpu`), which is
  arguably not appropriate for a driver;
* Or `-mabi` is still supplied by `arch/loongarch` Makefile, and the
  build immediately errors out because
  `-Werror=unused-command-line-argument` is unconditionally set for
  Clang builds.

To solve this, simply make sure to check `-mabi` and `-mfpu` (and gain
some useful diagnostics in case of conflicting settings) when
`-m*-float` is successfully parsed.

Reviewed By: SixWeining, MaskRay

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

12 months agosanitizer: enable getentropy interception on Linux/GLIBC 2.25 and onwards
David CARLIER [Sun, 25 Jun 2023 15:21:15 +0000 (16:21 +0100)]
sanitizer: enable getentropy interception on Linux/GLIBC 2.25 and onwards

https://man7.org/linux/man-pages/man3/getentropy.3.html

Reviewers: melver

Reviewed-By: melver
Differential Revision: https://reviews.llvm.org/D153723

12 months ago[mlir] Avoid expensive LLVM IR import warnings
Tobias Gysi [Mon, 26 Jun 2023 06:40:02 +0000 (06:40 +0000)]
[mlir] Avoid expensive LLVM IR import warnings

The revision adds a flag to the LLVM IR import
that avoids emitting expensive warnings about
unsupported debug intrinsics and unhandled
metadata.

Reviewed By: Dinistro

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

12 months ago[C++] [Coroutines] Assume the allocation doesn't return nullptr
Chuanqi Xu [Mon, 26 Jun 2023 06:27:05 +0000 (14:27 +0800)]
[C++] [Coroutines] Assume the allocation doesn't return nullptr

In case of 'get_return_object_on_allocation_failure' get declared, the
compiler is required to call 'operator new(size_t, nothrow_t)' and the
handle the failure case by calling
'get_return_object_on_allocation_failure()'. But the failure case should
be rare and we can assume the allocation is successful and pass the
information to the optimizer.

12 months ago[RISCV] Properly handle partial writes in isConvertibleToVMV_V_V.
Craig Topper [Mon, 26 Jun 2023 05:58:33 +0000 (22:58 -0700)]
[RISCV] Properly handle partial writes in isConvertibleToVMV_V_V.

We were only checking for the previous insructions to write exactly
the register or a super register. We ignored writes to a subregister
and continued searching for the producing instruction. We need to
abort instead.

There's another check inside the if body to abort if the registers
don't match exactly. So we just need to check for overlap so we
enter the if body.

Reviewed By: fakepaper56

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

12 months ago[RISCV] Add test case for D153490. NFC
Craig Topper [Mon, 26 Jun 2023 05:58:18 +0000 (22:58 -0700)]
[RISCV] Add test case for D153490. NFC

12 months ago[RISCV] Use unsigned types for orc_b builtins.
Craig Topper [Mon, 26 Jun 2023 05:53:58 +0000 (22:53 -0700)]
[RISCV] Use unsigned types for orc_b builtins.

Inspired by D153235, I think bit manipulation makes more
sense on unsigned types.

Reviewed By: Jim

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

12 months ago[RISCV] Change the type of argument to clz and ctz from ZiZi/WiWi to iUZi/iUWi
Jim Lin [Mon, 26 Jun 2023 02:27:55 +0000 (10:27 +0800)]
[RISCV] Change the type of argument to clz and ctz from ZiZi/WiWi to iUZi/iUWi

Input argument of clz and ctz should be unsigned type and return value
should be integer like `builtin_clz` and `builtin_ctz` defined in clang/include/clang/Basic/Builtins.def.

Reviewed By: craig.topper

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

12 months ago[RISCV] Remove WriteJmpReg. Use WriteJalr in its place.
Craig Topper [Mon, 26 Jun 2023 04:59:27 +0000 (21:59 -0700)]
[RISCV] Remove WriteJmpReg. Use WriteJalr in its place.

It was only used for the compressed instruction c.jr which expands
to jalr with rd=x0. Use WriteJalr instead to match jalr.

12 months agoRevert "[llvm-exegesis] Introduce SubprocessMemory Utility Class"
Aiden Grossman [Mon, 26 Jun 2023 03:15:43 +0000 (03:15 +0000)]
Revert "[llvm-exegesis] Introduce SubprocessMemory Utility Class"

This reverts commit 0b6b400b98b921279fc08c63a2a68ebfcb12a3e2.

The sporadic test failures were fixed during this land, but I forgot to
fix the build failures on certain platforms (seems to mostly be
AArch64/PPC) that result from them not being able to find the symbols
for shm_open and shm_unlink.

12 months ago[llvm-objcopy] Add LoongArch support
WANG Xuerui [Mon, 26 Jun 2023 01:55:13 +0000 (09:55 +0800)]
[llvm-objcopy] Add LoongArch support

Apart from general feature parity, this is also necessary for enabling
ClangBuiltLinux that defaults to using LLVM tools.

While at it, add a missing comment for the Hexagon definition directly
above, so it doesn't get confused with the SPARC definitions.

Reviewed By: SixWeining, MaskRay, jhenderson

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

12 months ago[LoongArch] Remove AssemblerPredicate for features: f/d/lsx/lasx/lvz/lbt
Weining Lu [Mon, 26 Jun 2023 01:26:15 +0000 (09:26 +0800)]
[LoongArch] Remove AssemblerPredicate for features: f/d/lsx/lasx/lvz/lbt

Linux LoongArch port [1] uses `-msoft-float` (implies no FPU) in its
`cflags` while it also uses floating-point insns in asm sources [2].
GAS allows this usage while IAS currently does not.

This patch removes `AssemblerPredicate`s for floating-point insns so
that to make IAS compitable with GAS. Similarly, also remove
`AssemblerPredicate`s for other ISA extensions, i.e. lsx/las/lvz/lbt.

[1]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/loongarch/Makefile?h=v6.4-rc1#n49
[2]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/loongarch/kernel/fpu.S?h=v6.4-rc1#n29

Reviewed By: xen0n, hev

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

12 months ago[doc][LoongArch] Add missed release note about `ual` feature addition
Weining Lu [Mon, 26 Jun 2023 01:50:36 +0000 (09:50 +0800)]
[doc][LoongArch] Add missed release note about `ual` feature addition

I meant to fold this into 47601815ec3a4f31c797c75748af08acfabc46dc
but failed to do so.

Reviewed By: MaskRay

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

12 months ago[llvm-exegesis] Introduce SubprocessMemory Utility Class
Aiden Grossman [Sat, 20 May 2023 09:50:43 +0000 (09:50 +0000)]
[llvm-exegesis] Introduce SubprocessMemory Utility Class

This patch introduces the SubprocessMemory class to llvm-exegesis. This
class contains several utilities that are needed for managing memory to
set up an execution environment for memory annotations.

Reviewed By: courbet

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

12 months ago[LoongArch] Optimize conditional selection of integer
Wang Rui [Mon, 26 Jun 2023 02:32:24 +0000 (10:32 +0800)]
[LoongArch] Optimize conditional selection of integer

This patch optimizes code generation by leveraging the zeroing behavior of the `maskeqz`/`masknez` instructions.

```
int sel(int a, int b)
{
    return (a < b) ? a : 0;
}
```

```
slt $a1,$a0,$a1
masknez $a2,$r0,$a1
maskeqz $a0,$a0,$a1
or $a0,$a0,$a2
```

=>

```
slt $a1,$a0,$a1
maskeqz $a0,$a0,$a1
```

Reviewed By: SixWeining

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

12 months agoRevert "[LoongArch] Optimize conditional selection of integer"
Weining Lu [Mon, 26 Jun 2023 02:30:42 +0000 (10:30 +0800)]
Revert "[LoongArch] Optimize conditional selection of integer"

This reverts commit 3dd319ecf3be64598ea84d1730033854cade7123.

Sorry, I forgot to amend the author name and email when merging this
patch.

12 months ago[llvm-exegesis] Introduce Subprocess Executor Mode
Aiden Grossman [Sat, 20 May 2023 09:23:27 +0000 (09:23 +0000)]
[llvm-exegesis] Introduce Subprocess Executor Mode

This patch introduces the subprocess executor mode. Currently, this new
mode doesn't do anything fancy, just executing the same code that the
inprocess executor would do, but within a subprocess. This sets up the
ability to add in many more memory-related features in the future.

Reviewed By: courbet

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

12 months ago[clang] Fix a crash on invalid destructor
Younan Zhang [Sun, 25 Jun 2023 16:33:16 +0000 (00:33 +0800)]
[clang] Fix a crash on invalid destructor

This is a follow-up patch to D126194 in order to
fix https://github.com/llvm/llvm-project/issues/63503.

Reviewed By: shafik

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

12 months ago[SimplifyCFG] Remove unused variable 'Inc' (NFC)
Jie Fu [Mon, 26 Jun 2023 00:59:37 +0000 (08:59 +0800)]
[SimplifyCFG] Remove unused variable 'Inc' (NFC)

/data/llvm-project/llvm/lib/Transforms/Utils/SimplifyCFG.cpp:6051:10: error: unused variable 'Inc' [-Werror,-Wunused-variable]
    bool Inc, Wrapped = false;
         ^
1 error generated.

12 months ago[llvm-exegesis] Add ability to assign perf counters to specific PID
Aiden Grossman [Sun, 25 Jun 2023 23:46:22 +0000 (23:46 +0000)]
[llvm-exegesis] Add ability to assign perf counters to specific PID

This patch gives the ability to assign performance counters within
llvm-exegesis to a specific process by passing its PID. This is needed
later on for implementing a subprocess executor. Defaults to zero, the
current process, for the InProcessFunctionExecutorImpl.

Reviewed By: courbet

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

12 months ago[SimplifyCFG] add nsw on BuildLookuptable LinearMap calculation
khei4 [Mon, 19 Jun 2023 03:57:29 +0000 (12:57 +0900)]
[SimplifyCFG] add nsw on BuildLookuptable LinearMap calculation
Differential Revision: https://reviews.llvm.org/D150943

12 months ago[SimplifyCFG] precommit test for LinearMap nsw (NFC)
khei4 [Mon, 19 Jun 2023 03:57:07 +0000 (12:57 +0900)]
[SimplifyCFG] precommit test for  LinearMap nsw (NFC)
Differential Revision: https://reviews.llvm.org/D153238

12 months agoRegAllocGreedy: Fix assert with remarks on unassigned subregisters
Matt Arsenault [Sun, 25 Jun 2023 15:23:15 +0000 (11:23 -0400)]
RegAllocGreedy: Fix assert with remarks on unassigned subregisters

This tried to query the physical subregister on virtual registers
if they were left unassigned.

12 months agoAMDGPU: Handle the easy parts of strict fptrunc
Matt Arsenault [Sun, 25 Jun 2023 21:16:10 +0000 (17:16 -0400)]
AMDGPU: Handle the easy parts of strict fptrunc

f64->f16 is hard. The expansion is all integer but we need
to raise exceptions. Also doesn't handle the illegal f16 targets.

12 months agoAMDGPU: Handle constrained fpext
Matt Arsenault [Sun, 25 Jun 2023 20:39:15 +0000 (16:39 -0400)]
AMDGPU: Handle constrained fpext

12 months ago[NFC] Autogenerate CodeGen/AMDGPU/combine-reg-or-const.ll
Amaury Séchet [Sun, 25 Jun 2023 22:56:42 +0000 (22:56 +0000)]
[NFC] Autogenerate CodeGen/AMDGPU/combine-reg-or-const.ll

12 months ago[NFC] Autogenerate CodeGen/PowerPC/tail-dup-break-cfg.ll
Amaury Séchet [Sun, 25 Jun 2023 21:19:27 +0000 (21:19 +0000)]
[NFC] Autogenerate CodeGen/PowerPC/tail-dup-break-cfg.ll

12 months ago[AArch64][GlobalISel] IR translate support for a return instruction of type <1 x...
Niwin Anto [Sun, 25 Jun 2023 21:39:56 +0000 (14:39 -0700)]
[AArch64][GlobalISel] IR translate support for a return instruction of type <1 x i8> or <1 x i16> when using GlobalISel.

Code generation for return instruction of type <1 x i8> or <1 x i16> when using GlobalISel causes internal compiler crash Could not handle ret ty.

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

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

12 months ago[AArch64][GlobalISel] Select G_UADDE/G_SADDE/G_USUBE/G_SSUBE
Tobias Stadler [Sun, 25 Jun 2023 05:08:50 +0000 (22:08 -0700)]
[AArch64][GlobalISel] Select G_UADDE/G_SADDE/G_USUBE/G_SSUBE

This implements the remaining overflow generating instructions in the AArch64
GlobalISel selector. Now wide add/sub operations do not fallback to SelectionDAG
anymore. We make use of PostSelectOptimize to cleanup the hereby generated
flag-setting operations when the carry-out is unused. Since we do not fallback
anymore when selecting add/sub atomics on O0 some test changes were required
there.

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

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

12 months ago[NFC] Autogenerate CodeGen/PowerPC/pr40922.ll
Amaury Séchet [Sun, 25 Jun 2023 21:05:06 +0000 (21:05 +0000)]
[NFC] Autogenerate CodeGen/PowerPC/pr40922.ll

12 months agoRevert "[clang-tidy] Add modernize-printf-to-std-print check"
Piotr Zegar [Sun, 25 Jun 2023 19:40:52 +0000 (19:40 +0000)]
Revert "[clang-tidy] Add modernize-printf-to-std-print check"

This reverts commit 81418ada06abbeba9fd0ea17282cce542cd07706.

12 months ago[clang-tidy] Add modernize-printf-to-std-print check
Mike Crowe [Sun, 25 Jun 2023 17:38:09 +0000 (17:38 +0000)]
[clang-tidy] Add modernize-printf-to-std-print check

Add FormatStringConverter utility class that is capable of converting
printf-style format strings into std::print-style format strings along
with recording a set of casts to wrap the arguments as required and
removing now-unnecessary calls to std::string::c_str() and
std::string::data()

Use FormatStringConverter to implement a new clang-tidy check that is
capable of converting calls to printf, fprintf, absl::PrintF,
absl::FPrintF, or any functions configured by an option to calls to
std::print and std::println, or other functions configured by options.

In other words, the check turns:

 fprintf(stderr, "The %s is %3d\n", description.c_str(), value);

into:

 std::println(stderr, "The {} is {:3}", description, value);

if it can.

std::print and std::println can do almost anything that standard printf
can, but the conversion has some some limitations that are described in
the documentation. If conversion is not possible then the call remains
unchanged.

Depends on D153716

Reviewed By: PiotrZSL

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

12 months ago[ASTMatchers] Add argumentCountAtLeast narrowing matcher
Mike Crowe [Sun, 25 Jun 2023 16:41:48 +0000 (16:41 +0000)]
[ASTMatchers] Add argumentCountAtLeast narrowing matcher

This will be used by the modernize-use-std-print clang-tidy check and
related checks later.

Reviewed By: PiotrZSL

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

12 months agoRevert "[COFF] Support -gsplit-dwarf for COFF on Windows"
Nico Weber [Sun, 25 Jun 2023 18:32:36 +0000 (14:32 -0400)]
Revert "[COFF] Support -gsplit-dwarf for COFF on Windows"

This reverts commit 3eee5aa528abd67bb6d057e25ce1980d0d38c445.

Breaks tests on mac, see https://reviews.llvm.org/D152785#4447118

12 months ago[ConstraintElim] Add tests with condition used in phi.
Florian Hahn [Sun, 25 Jun 2023 16:07:21 +0000 (17:07 +0100)]
[ConstraintElim] Add tests with condition used in phi.

Add extra tests where conditions are used in phis for D153660.

12 months ago[ConstraintElim] Add uses to remark tests to make it more robust.
Florian Hahn [Sun, 25 Jun 2023 15:58:44 +0000 (16:58 +0100)]
[ConstraintElim] Add uses to remark tests to make it more robust.

Add uses of conditions, so the test keeps testing what it is meant to
test after D153660.

12 months ago[clang][Diagnostics] Provide parameter source range to arity-mismatch notes
Takuya Shimizu [Sun, 25 Jun 2023 15:27:15 +0000 (00:27 +0900)]
[clang][Diagnostics] Provide parameter source range to arity-mismatch notes

Consider the following piece of code:
```
void func( int aa,
           int bb,
           int cc) {}

void arity_mismatch() {
  func(2, 4);
}
```
BEFORE:
```
source.cpp:6:3: error: no matching function for call to 'func'
    6 |   func(2, 4);
      |   ^~~~
source.cpp:1:6: note: candidate function not viable: requires 3 arguments, but 2 were provided
    1 | void func( int aa,
      |      ^
```
AFTER:
```
source.cpp:6:3: error: no matching function for call to 'func'
    6 |   func(2, 4);
      |   ^~~~
source.cpp:1:6: note: candidate function not viable: requires 3 arguments, but 2 were provided
    1 | void func( int aa,
      |      ^     ~~~~~~~
    2 |            int bb,
      |            ~~~~~~~
    3 |            int cc) {}
      |            ~~~~~~
```

Reviewed By: cjdb, aaron.ballman

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

12 months agoRevert "[llvm] Move StringExtras.h include from Error.h to Error.cpp"
Elliot Goodrich [Sun, 25 Jun 2023 15:09:36 +0000 (16:09 +0100)]
Revert "[llvm] Move StringExtras.h include from Error.h to Error.cpp"

This reverts commit 2fa0dbd7bf353db98b27b56137cced0a67de2748.

12 months ago[llvm] Move StringExtras.h include from Error.h to Error.cpp
Elliot Goodrich [Sat, 17 Jun 2023 12:18:23 +0000 (13:18 +0100)]
[llvm] Move StringExtras.h include from Error.h to Error.cpp

Move the implementation of the `toString` function from
`llvm/Support/Error.h` to the source file, which allows us to move
`#include "llvm/ADT/StringExtras.h"` to the source file as well.

As `Error.h` is present in a large number of translation units this
means we are unnecessarily bringing in the contents of
`StringExtras.h` - itself a large file with lots of includes - and
slowing down compilation.

Also move the `#include "llvm/ADT/SmallVector.h"` directive to the
source file as it's no longer needed, but this does not give as much of
a benefit.

This reduces the total number of preprocessing tokens across the LLVM
source files in lib from (roughly) 1,920,413,050 to 1,903,629,230 - a
reduction of ~0.87%. This should result in a small improvement in
compilation time.

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

12 months ago[llvm] Add missing StringExtras.h includes
Elliot Goodrich [Sat, 17 Jun 2023 12:18:23 +0000 (13:18 +0100)]
[llvm] Add missing StringExtras.h includes

In preparation for removing the `#include "llvm/ADT/StringExtras.h"`
from the header to source file of `llvm/Support/Error.h`, first add in
all the missing includes that were previously included transitively
through this header.

12 months ago[Clang][NFC] Add feature test macro checks for C++2c
Corentin Jabot [Sun, 25 Jun 2023 08:26:30 +0000 (10:26 +0200)]
[Clang][NFC] Add feature test macro checks for C++2c

12 months ago[RISCV] Add missing Read classes to some compressed instructions.
Craig Topper [Sun, 25 Jun 2023 07:48:26 +0000 (00:48 -0700)]
[RISCV] Add missing Read classes to some compressed instructions.

Reviewed By: wangpc

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

12 months ago[RISCV] Add GPR bypasses for most scalar integer instructions to the SiFive7 schedule...
Craig Topper [Sun, 25 Jun 2023 07:47:56 +0000 (00:47 -0700)]
[RISCV] Add GPR bypasses for most scalar integer instructions to the SiFive7 scheduler model.

SiFive7's scalar execution consists of 4 stages AG, M1, M2, WB.
Most simple arithmetic and branch instructions can execute in
either AG or M2.

If the operands are ready, the instruction will execute in the AG
stage. Otherwise, it executes in the M2 stage. Everything is fully
bypassed, so dependent instructions should only see 1 cycle latency.

This patch adds ReadAdvances to pretend that these instructions
execute in the M2 ALU and reads their operands then. This allows
the scheduler to schedule dependent instructions back to back.

I've increased branch latency to 3 since they are also executed in both
stages. Still need to fix JALR, but I want to cleanup some scheduler
classes first.

Multiply, cpop and division instructions can only start in the AG stage.

Still need to do some work for FP instructions that produce integer results.

I've added an llvm-mca test that creates a long dependency chain.
The timeline view can show that things are bypassed. I
didn't check all permutations, but we have some variety.

Reviewed By: wangpc

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

12 months ago[AArch64] Add SVE tests for double reducts of vector.reduce.fmaximum/fminimum. NFC
David Green [Sun, 25 Jun 2023 07:44:43 +0000 (08:44 +0100)]
[AArch64] Add SVE tests for double reducts of vector.reduce.fmaximum/fminimum. NFC

Now that the SVE parts are in, we can fill in the double reduction tests
without them causing problems.

12 months ago[C++20][Modules] Complete implementation of module.import p7.
Iain Sandoe [Mon, 12 Jun 2023 19:38:02 +0000 (20:38 +0100)]
[C++20][Modules] Complete implementation of module.import p7.

The following test fails to compile TU b.cpp because we are not making the transitively imported modules visible (per [module.import]/p7)

```
a.cppm:
export module a;

export int foo() {
   return 42;
}

b.cppm:
export module b;
import a;

export int bar();

b.cpp:
module b;

int bar() {
   return foo();
}

clang++ -c -std=c++2b -fmodule-output a.cppm
clang++ -c -std=c++2b -fmodule-output -fprebuilt-module-path=. b.cppm
clang++ -c -std=c++2b -fprebuilt-module-path=. b.cpp
b.cpp:4:12: error: declaration of 'foo' must be imported from module 'a' before it is required
   return foo();
```

This is fixed by the following patch (which also addresses a FIXME in basic.def.odr/p6.cppm).

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

12 months ago[BPF] Remove unused legacy passes after TargetMachine::adjustPassManager removal
Fangrui Song [Sun, 25 Jun 2023 05:44:06 +0000 (22:44 -0700)]
[BPF] Remove unused legacy passes after TargetMachine::adjustPassManager removal

D137796 made these passes unused.

`opt --bpf-ir-peephole` is specified in one test. Add a `registerPipelineParsingCallback`
so that we can use change the test to use `opt --passes=bpf-ir-peephole` instead.

12 months ago[COFF] Support -gsplit-dwarf for COFF on Windows
Haohai Wen [Sun, 25 Jun 2023 03:54:23 +0000 (11:54 +0800)]
[COFF] Support -gsplit-dwarf for COFF on Windows

D152340 has split WinCOFFObjectWriter to WinCOFFWriter. This patch adds
another WinCOFFWriter as DwoWriter to write Dwo sections to dwo file.
Driver options are also updated accordingly to support -gsplit-dwarf in
CL mode.

e.g. $ clang-cl  -c -gdwarf -gsplit-dwarf foo.c

Like what -gsplit-dwarf did in ELF, using this option will create DWARF object
(.dwo) file. DWARF debug info is split between COFF object and DWARF object
file. It can reduce the executable file size especially for large project.

Reviewed By: skan, MaskRay

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

12 months ago[clang] Fix pretty-printing for variables declared in a for-loop condition
Vaibhav Thakkar [Sun, 25 Jun 2023 02:27:10 +0000 (19:27 -0700)]
[clang] Fix pretty-printing for variables declared in a for-loop condition

Reviewed By: MaskRay

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

12 months ago[flang] Rename remaining `__Fortran_PPC_intrinsics` to `__ppc_intrinsics`
Shao-Ce SUN [Sat, 24 Jun 2023 15:04:49 +0000 (23:04 +0800)]
[flang] Rename remaining `__Fortran_PPC_intrinsics` to `__ppc_intrinsics`

Reviewed By: kkwli0

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

12 months ago[NFC] Autogenerate CodeGen/PowerPC/select-i1-vs-i1.ll
Amaury Séchet [Sun, 25 Jun 2023 01:27:29 +0000 (01:27 +0000)]
[NFC] Autogenerate CodeGen/PowerPC/select-i1-vs-i1.ll

12 months ago[NFC] Autogenerate CodeGen/ARM/2013-07-29-vector-or-combine.ll
Amaury Séchet [Sun, 25 Jun 2023 01:05:21 +0000 (01:05 +0000)]
[NFC] Autogenerate CodeGen/ARM/2013-07-29-vector-or-combine.ll

12 months ago[NFC] Autogenerate CodeGen/ARM/2011-03-15-LdStMultipleBug.ll
Amaury Séchet [Sun, 25 Jun 2023 01:02:49 +0000 (01:02 +0000)]
[NFC] Autogenerate CodeGen/ARM/2011-03-15-LdStMultipleBug.ll

12 months ago[NFC] Autogenerate CodeGen/ARM/and-sext-combine.ll
Amaury Séchet [Sun, 25 Jun 2023 00:55:03 +0000 (00:55 +0000)]
[NFC] Autogenerate CodeGen/ARM/and-sext-combine.ll

12 months ago[NFC] Autogenerate CodeGen/ARM/machine-cse-cmp.ll
Amaury Séchet [Sun, 25 Jun 2023 00:44:30 +0000 (00:44 +0000)]
[NFC] Autogenerate CodeGen/ARM/machine-cse-cmp.ll

12 months ago[NFC] Autogenerate CodeGen/ARM/pr35103.ll
Amaury Séchet [Sun, 25 Jun 2023 00:14:07 +0000 (00:14 +0000)]
[NFC] Autogenerate CodeGen/ARM/pr35103.ll

12 months ago[libc++][ranges] Implement P2494R2 (Relaxing range adaptors to allow for move only...
yronglin [Sun, 25 Jun 2023 00:14:55 +0000 (08:14 +0800)]
[libc++][ranges] Implement P2494R2 (Relaxing range adaptors to allow for move only types)

Implement P2494R2 `Relaxing range adaptors to allow for move only types`

https://open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2494r2.html#wording-ftm

According to the words in P2494R2, I haven't add new test for `drop_while_view`, `take_while_view` and `filter_view`, because these views has the requirement that the predicate is an `indirect_unary_predicate`, which requires that the predicate is `copy_constructible`, so they still can't accept move only types as predicate.

```
[P2483R0] also suggests future work to relax the requirements on the predicate types stored by standard views. This paper does not perform this relaxation, as the copy constructibility requirement is enshrined in the indirect callable concepts ([indirectcallable.indirectinvocable]). Thus, while this paper modifies the views that currently use copyable-box for user provided predicates, it only does so to apply the rename of the exposition-only type to movable-box; it does not change any of the constraints on those views. It does, however, relax the requirements on invocables accepted by the transform family of views, because those are not constrained using the indirect callable concepts.
```

Reviewed By: #libc, var-const

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

12 months ago[mlir][polyapprox] Use llvm::numbers for constants.
Jacques Pienaar [Sun, 25 Jun 2023 00:03:37 +0000 (17:03 -0700)]
[mlir][polyapprox] Use llvm::numbers for constants.

 Fixes windows build.

12 months ago[lldb] Use LLDB_LOGF for printf format strings in AppleObjCDeclVendor.cpp
Dave Lee [Sat, 24 Jun 2023 22:00:38 +0000 (15:00 -0700)]
[lldb] Use LLDB_LOGF for printf format strings in AppleObjCDeclVendor.cpp

12 months ago[DWARF] Remove remnant .zdebug section recognition
Fangrui Song [Sat, 24 Jun 2023 18:07:12 +0000 (11:07 -0700)]
[DWARF] Remove remnant .zdebug section recognition

There is a minor behavior difference that is not worth testing for the obsoleted
format. Previously, llvm-dwarfdump considers .zdebug_info as a debug section but
does not decompress it, leading to a warning when the content cannot be parsed.
Now llvm-dwarfdump just ignores the section without a warning.

12 months ago[libc++] Remove the type_traits includes from limits and new
Ian Anderson [Mon, 5 Jun 2023 22:08:54 +0000 (15:08 -0700)]
[libc++] Remove the type_traits includes from limits and new

type_traits is currently unable to include __type_traits/noexcept_move_assign_container.h, because it would cause several include cycles.

type_traits -> __type_traits/noexcept_move_assign_container.h -> __memory/allocator_traits.h -> __memory/construct_at.h -> new -> exception -> type_traits

type_traits -> __type_traits/noexcept_move_assign_container.h -> __memory/allocator_traits.h -> __memory/construct_at.h -> new -> type_traits

type_traits -> __type_traits/noexcept_move_assign_container.h -> __memory/allocator_traits.h -> limits -> type_traits

This is a problem for clang modules after the std mega module is broken up (D144322), because it becomes a module cycle which is a hard error.

Unconditionally remove the type_traits includes from limits and new in all versions, and also remove the exception include from new. (These are already removed in C++23.)

Reviewed By: ldionne, Mordante, #libc

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

12 months ago[DWARF] Adjust warning condition for .dwo sections with relocations
Fangrui Song [Sat, 24 Jun 2023 17:06:17 +0000 (10:06 -0700)]
[DWARF] Adjust warning condition for .dwo sections with relocations

D106624 added a .dwo warning (when there are relocations) that may fire for
non-debug sections, e.g. `.rodata.dwo` when there is a data symbol foo in
-fdata-sections mode. Adjust it to only warn for .debug sections.

While here, change the diagnostic to be more conventional
https://llvm.org/docs/CodingStandards.html#error-and-warning-messages and use
the relocated section name instead of the relocation section name.

This change does not handle `.zdebug` (support was mostly removed from LLVM) or
`__debug` (Mach-O, no DWO support).

Reviewed By: ayermolo, HaohaiWen

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

12 months ago[openmp] remove initializeRewriteSymbolsLegacyPassPass
Shao-Ce SUN [Sat, 24 Jun 2023 16:32:42 +0000 (00:32 +0800)]
[openmp] remove initializeRewriteSymbolsLegacyPassPass

Fix build error caused by D153679

Reviewed By: nikic

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

12 months ago[libc++] Add noexcept clauses to swap per P0408R7 (Efficient Access to basic_stringbu...
Piotr Fusik [Sat, 24 Jun 2023 16:27:06 +0000 (18:27 +0200)]
[libc++] Add noexcept clauses to swap per P0408R7 (Efficient Access to basic_stringbuf's Buffer)

Reviewed By: #libc, Mordante

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

12 months ago[GlobalIsel][X86]] Legalize G_CONSTANT_FOLD_BARRIER
Thorsten Schütt [Sat, 24 Jun 2023 05:36:23 +0000 (07:36 +0200)]
[GlobalIsel][X86]] Legalize G_CONSTANT_FOLD_BARRIER

Reviewed By: RKSimon

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

12 months ago[libc++][ranges] Addresses: LWG3719 - Directory iterators should be usable with...
Hristo Hristov [Mon, 19 Jun 2023 17:45:03 +0000 (20:45 +0300)]
[libc++][ranges] Addresses:  LWG3719 - Directory iterators should be usable with default sentinel

Addresses:  LWG3719 - Directory iterators should be usable with default sentinel
https://wg21.link/LWG3719

Reviewed By: #libc, Mordante

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

12 months ago[clang-tidy] Fix false negative in readability-convert-member-functions-to-static
Nathan James [Sat, 24 Jun 2023 14:18:20 +0000 (14:18 +0000)]
[clang-tidy] Fix false negative in readability-convert-member-functions-to-static

A nested class in a member function can erroneously confuse the check into
thinking that any CXXThisExpr found relate to the outer class, preventing any warnings.
Fix this by not traversing any nested classes.

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

Reviewed By: PiotrZSL

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

12 months ago[CodeGen] Remove unused forward declaration Value
Kazu Hirata [Sat, 24 Jun 2023 14:33:54 +0000 (07:33 -0700)]
[CodeGen] Remove unused forward declaration Value

The last use was removed by:

  commit 7d894374551f6d5787db0aef2da8dd6aefa616fb
  Author: OCHyams <orlando.hyams@sony.com>
  Date:   Thu Mar 16 08:48:36 2023 +0000

12 months ago[CodeGen] Remove unused forward declarations Instruction and Type
Kazu Hirata [Sat, 24 Jun 2023 14:33:52 +0000 (07:33 -0700)]
[CodeGen] Remove unused forward declarations Instruction and Type

The last uses were removed by:

  commit 79b3f0823e562fc652c3272b2ccfb99174445fa6
  Author: Tim Northover <tnorthover@apple.com>
  Date:   Tue Feb 7 11:28:00 2023 +0000

12 months ago[LegacyPM] Remove RewriteSymbolsLegacyPass
Kazu Hirata [Sat, 24 Jun 2023 14:33:50 +0000 (07:33 -0700)]
[LegacyPM] Remove RewriteSymbolsLegacyPass

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

12 months ago[LegacyPM] Remove PlaceSafepointsLegacyPass
Kazu Hirata [Sat, 24 Jun 2023 14:33:49 +0000 (07:33 -0700)]
[LegacyPM] Remove PlaceSafepointsLegacyPass

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

12 months ago[CodeGen] Remove unused forward declaration DominatorTree
Kazu Hirata [Sat, 24 Jun 2023 13:59:52 +0000 (06:59 -0700)]
[CodeGen] Remove unused forward declaration DominatorTree

The last use was removed by:

  commit 73523021d0a97c150a76a5cf4a91e99cd03b9efb
  Author: Chandler Carruth <chandlerc@gmail.com>
  Date:   Mon Jan 13 13:07:17 2014 +0000

12 months ago[Analysis] Remove unused forward declaration PhiValues
Kazu Hirata [Sat, 24 Jun 2023 13:59:50 +0000 (06:59 -0700)]
[Analysis] Remove unused forward declaration PhiValues

The last use was removed by:

  commit 243acd5dcbc637e477062877185ad76d8ff63d9d
  Author: Nikita Popov <npopov@redhat.com>
  Date:   Fri Dec 9 15:29:35 2022 +0100

12 months ago[Analysis] Remove unused forward declaration GetElementPtrInst
Kazu Hirata [Sat, 24 Jun 2023 13:59:49 +0000 (06:59 -0700)]
[Analysis] Remove unused forward declaration GetElementPtrInst

The last use was removed by:

  commit 2d79b713663169b3732fcbdf56cac243b5c41e28
  Author: Philip Reames <preames@rivosinc.com>
  Date:   Thu Apr 6 08:23:08 2023 -0700

12 months ago[Analysis] Remove unused forward declaration BasicAAResult
Kazu Hirata [Sat, 24 Jun 2023 13:59:47 +0000 (06:59 -0700)]
[Analysis] Remove unused forward declaration BasicAAResult

The last use was removed by:

  commit f9b523ebc367f1535bf61797383471e567b24b75
  Author: Kazu Hirata <kazu@google.com>
  Date:   Wed May 31 07:30:14 2023 -0700

12 months ago[gn build] Port 7f6e0052a97f
LLVM GN Syncbot [Sat, 24 Jun 2023 11:01:56 +0000 (11:01 +0000)]
[gn build] Port 7f6e0052a97f

12 months ago[clang-tidy] Add misc-header-include-cycle check
Piotr Zegar [Sat, 24 Jun 2023 10:59:30 +0000 (10:59 +0000)]
[clang-tidy] Add misc-header-include-cycle check

Check detects cyclic #include dependencies between user-defined headers.

Reviewed By: njames93

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

12 months ago[AArch64] Add SVE lowering for vector.reduce.fminimum and fmaximum
David Green [Sat, 24 Jun 2023 10:12:58 +0000 (11:12 +0100)]
[AArch64] Add SVE lowering for vector.reduce.fminimum and fmaximum

Following what is already performed for vector.reduce.fmin/fmax, this adds
lowering for the new vector.reduce.fminimum/fmaximum nodes to the SVE fminv
and fmaxv instructions via the existing FMINV_PRED/FMAXV_PRED nodes.

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

12 months agoRevert "[clang-tidy] Add misc-header-include-cycle check"
Piotr Zegar [Sat, 24 Jun 2023 08:41:52 +0000 (08:41 +0000)]
Revert "[clang-tidy] Add misc-header-include-cycle check"

This reverts commit f3aa6cc0f5d56752242203c2a9231c1bc230c15e.

12 months ago[clang-tidy] Add misc-header-include-cycle check
Piotr Zegar [Sat, 24 Jun 2023 07:01:32 +0000 (07:01 +0000)]
[clang-tidy] Add misc-header-include-cycle check

Check detects cyclic #include dependencies between user-defined headers.

Reviewed By: njames93

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

12 months ago[C++20][Modules] Implement P2615R1 revised export diagnostics.
Iain Sandoe [Wed, 14 Jun 2023 18:48:04 +0000 (19:48 +0100)]
[C++20][Modules] Implement P2615R1 revised export diagnostics.

It has been reported to that the current clang  errors for, specifically,
static_assert in export contexts are a serious blocker to adoption of
modules in some cases.

There is also implementation divergence with GCC and MSVC allowing the
constructs mentioned below where clang currently rejects them with an
error.

The category of errors [for declarations in an exported context] is:
(unnamed, static_assert, empty and asm decls). These are now permitted
after P2615R1 which was approved by WG21 as a DR (and thus should be
applied to C++20 as well).

This patch removes these diagnostics and amends the testsuite accordingly.

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

12 months ago[Attributor] Avoid more AAs through IR implication
Johannes Doerfert [Sat, 24 Jun 2023 07:24:02 +0000 (00:24 -0700)]
[Attributor] Avoid more AAs through IR implication

12 months ago[Attributor] Avoid uninitialized memory read.
Johannes Doerfert [Sat, 24 Jun 2023 07:25:22 +0000 (00:25 -0700)]
[Attributor] Avoid uninitialized memory read.

12 months ago[Support] Remove countLeadingZeros, countPopulation, etc
Kazu Hirata [Sat, 24 Jun 2023 07:00:06 +0000 (00:00 -0700)]
[Support] Remove countLeadingZeros, countPopulation, etc

These functions have been deprecated since:

  commit ec116ea684b43aadfdda03cea2c2a86423e3fc27
  Author: Kazu Hirata <kazu@google.com>
  Date:   Sun Feb 12 12:11:51 2023 -0800

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

12 months ago[clang] Add -fcheck-new support
Pedro Falcato [Sat, 24 Jun 2023 05:45:17 +0000 (22:45 -0700)]
[clang] Add -fcheck-new support

Add -fcheck-new and -fno-check-new, from GCC, which make the compiler
not assume pointers returned from operator new are non-null.
Fixes #16931.

Reviewed By: MaskRay

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

12 months ago[test][MSAN] Fix test by printing action before execution it
Vitaly Buka [Sat, 24 Jun 2023 04:10:26 +0000 (21:10 -0700)]
[test][MSAN] Fix test by printing action before execution it

We expect log messages from enother thread triggered by actions.

12 months ago[GlobalIsel][X86] G_STORE extension
Thorsten Schütt [Fri, 23 Jun 2023 16:36:59 +0000 (18:36 +0200)]
[GlobalIsel][X86] G_STORE extension

Reviewed By: arsenm

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

12 months ago[Attributor][FIX] Do not ignore refinement for IPO
Johannes Doerfert [Fri, 23 Jun 2023 22:00:48 +0000 (15:00 -0700)]
[Attributor][FIX] Do not ignore refinement for IPO

This is just a cleanup commit, a follow up will make this way more
structured.

12 months ago[Attributor] Avoid the type check in getCalledFunction
Johannes Doerfert [Fri, 23 Jun 2023 20:08:57 +0000 (13:08 -0700)]
[Attributor] Avoid the type check in getCalledFunction

We now consistently use `CallBase::getCalledOperand` rather than
`getCalledFunction`, as we do not want the type checked performed by the
latter. This exposed various missing checks to handle mismatches
properly, but it is good to have them explicit now.

In a follow up we might want to flag certain calls as UB, but for now,
we allow everything to cut down on unexpected differences.

12 months ago[mlir] Replace HTML escaped character
Kai Sasaki [Sat, 24 Jun 2023 02:43:40 +0000 (02:43 +0000)]
[mlir] Replace HTML escaped character

12 months ago[llvm] Replace use of Type::getPointerTo() (NFC)
Youngsuk Kim [Sat, 24 Jun 2023 01:52:43 +0000 (21:52 -0400)]
[llvm] Replace use of Type::getPointerTo() (NFC)

Partial progress towards replacing in-tree uses of
`Type::getPointerTo()`.

If `getPointerTo()` is used solely to support an unnecessary bitcast,
remove the bitcast.

Reviewed By: barannikov88, nikic

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

12 months agoImprove fatal error message when handling promised interfaces
Mehdi Amini [Sat, 24 Jun 2023 01:15:47 +0000 (03:15 +0200)]
Improve fatal error message when handling promised interfaces

When initializing DialectInterfaceCollection, we wouldn't have the missing
interface name in the error.

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

12 months agoAdd missing dependent dialects to AsyncToAsyncRuntimePass and GpuKernelOutliningPass
Mehdi Amini [Sat, 24 Jun 2023 01:46:10 +0000 (03:46 +0200)]
Add missing dependent dialects to AsyncToAsyncRuntimePass and GpuKernelOutliningPass

These aren't detected during testing most of the time because the way we
are setting up mlir-opt and the fact that we always use func.func: it'll
trigger the load of the InlinerInterface extension for the FuncDialect which
itself loads these dialects unconditionally.