platform/upstream/llvm.git
2 years ago[AArch64] NFC: Change description of Streaming SVE mode.
Sander de Smalen [Mon, 28 Feb 2022 15:42:34 +0000 (15:42 +0000)]
[AArch64] NFC: Change description of Streaming SVE mode.

Streaming SVE mode includes more than just the streaming compatible
SVE/SVE2/NEON instructions.

2 years ago[AMDGPU] Precommit tests for D120709
Jay Foad [Tue, 1 Mar 2022 11:09:54 +0000 (11:09 +0000)]
[AMDGPU] Precommit tests for D120709

2 years ago[NFC][clang-tidy][docs] Remove mention of backported fix of `readability-suspicious...
Whisperity [Tue, 1 Mar 2022 11:06:59 +0000 (12:06 +0100)]
[NFC][clang-tidy][docs] Remove mention of backported fix of `readability-suspicious-call-argument` from `ReleaseNotes`

Commit 416e689ecda66616da855c82f7ec652657730c6a introduced a fix to
`readability-suspicious-call-argument` which added an entry to the
Release Notes, but the same change was backported to **14.0** in commit
e89602b7b2ec12f20f2618cefb864c2b22d0048a.

Hence, this change is not a new thing of the to-be 15.0 release.

2 years ago[SCEV] Only verify BECounts for reachable loops (PR50523)
Nikita Popov [Mon, 28 Feb 2022 10:12:42 +0000 (11:12 +0100)]
[SCEV] Only verify BECounts for reachable loops (PR50523)

For unreachable loops, any BECount is legal, and since D98706 SCEV
can make use of this for loops that are unreachable due to constant
branches. To avoid false positives, adjust SCEV verification to only
check BECounts in reachable loops.

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

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

2 years ago[AArch64] Add tests with unnecessary dependency with faddp lowering.
Florian Hahn [Tue, 1 Mar 2022 10:30:33 +0000 (10:30 +0000)]
[AArch64] Add tests with unnecessary dependency with faddp lowering.

The added tests highlight an unnecessary cross-iteration dependency when
lowering reductions to faddp. This dependency can negatively impact
performance.

2 years ago[AArch64] Use common CHECK prefix for test, reducing duplicated checks.
Florian Hahn [Tue, 1 Mar 2022 10:30:29 +0000 (10:30 +0000)]
[AArch64] Use common CHECK prefix for test, reducing duplicated checks.

Use the common CHECK prefix with runlines with and without fullfp16.
This means no duplicated checks are generated for tests not using fp16.

2 years ago[NVPTX] Fix nvvm.match.sync*.i64 intrinsics return type (i64 -> i32)
Kristina Bessonova [Tue, 1 Mar 2022 10:21:15 +0000 (12:21 +0200)]
[NVPTX] Fix nvvm.match.sync*.i64 intrinsics return type (i64 -> i32)

NVVM IR specification defines them with i32 return type:

  declare i32 @llvm.nvvm.match.any.sync.i64(i32 %membermask, i64 %value)
  declare {i32, i1} @llvm.nvvm.match.all.sync.i64(i32 %membermask, i64 %value)
  ...
  The i32 return value is a 32-bit mask where bit position in mask corresponds
  to thread’s laneid.

as well as PTX ISA:

  9.7.12.8. Parallel Synchronization and Communication Instructions: match.sync

  match.any.sync.type  d, a, membermask;
  match.all.sync.type  d[|p], a, membermask;
  ...
  Destination d is a 32-bit mask where bit position in mask corresponds
  to thread’s laneid.

Additionally, ptxas doesn't accept intructions, produced by NVPTX backend.
After this patch, it compiles with no issues.

Reviewed By: tra

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

2 years ago[UpdateLLCTestChecks] Add support for isel debug output in update_llc_test_checks.py
Yatao Wang [Tue, 1 Mar 2022 09:54:24 +0000 (10:54 +0100)]
[UpdateLLCTestChecks] Add support for isel debug output in update_llc_test_checks.py

Add a check on run lines to pick up isel options in llc commands and allow
generating check lines of isel final output other than assembly. If llc command
line contains -debug-only=isel, update_llc_test_checks.py will try to scrub isel
output, otherwise, the script will fall back on default behaviour, which is try to
scrub assembly output instead.

The motivation of this change is to allow usage of update_llc_test_checks.py to
autogenerate checks of instruction selection results. In this way, we can detect
errors at an earlier stage before the compilation goes all the way to assembly.
It is an example of having some transparency for the stages between IR and
assembly. These generated tests are almost like "unit tests" of isel stage.

This patch only implements the initial change to differentiate isel output from
assembly output for Lanai. Other targets will not be supported for isel check
generation at the moment. Although adding support for it will only require
implementing the function regex and scrubber for corresponding targets.

The Lanai implementation was chosen mainly for the simplicity of demonstrating
the difference between isel checks and asm checks.

This patch also do not include the implementation of function prefix, which is
required for the generated isel checks to pass. I will put up a follow up revision
for the function prefix change to complete isel support.

Reviewed By: Flakebi

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

2 years ago[LLD] [COFF] Use the new encodeSectionName() helper for long section names
Martin Storsjö [Mon, 28 Feb 2022 21:07:16 +0000 (23:07 +0200)]
[LLD] [COFF] Use the new encodeSectionName() helper for long section names

The previous code used an unbounded sprintf, which in theory can
overflow, writing either the null terminator or the last digits
into the next struct member.

In practice, in LLD, all long section names are written sequentially
first at the start of the string table, followed by all the long
symbol names. Due to this, even if the total string table would
end up large, the long section names have fairly short offsets,
which is why this hasn't been an issue in practice.

I don't think it's worth trying to write a test that produces an
executable with enough long section names to make the section names
themselves exceed 10^6 bytes, which is currently necessary to trigger
faults with the previous form.

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

2 years ago[llvm][AArch64] Restore lit cfg for TypePromotion tests
David Spickett [Tue, 1 Mar 2022 09:28:15 +0000 (09:28 +0000)]
[llvm][AArch64] Restore lit cfg for TypePromotion tests

Accidentally deleted in 20d75059a2ea49117a3dc9a78fb5b815a84ae33e.

As seen in failures on https://lab.llvm.org/buildbot/#/builders/171/builds/10952.

2 years agoRevert "[TypePromotion] Avoid some unnecessary truncs"
Sam Parker [Tue, 1 Mar 2022 08:59:28 +0000 (08:59 +0000)]
Revert "[TypePromotion] Avoid some unnecessary truncs"

This reverts commit 281d29b8fed369c6ebe33ed85c518fc1ed81f44a.

Report of a miscompilation and awaiting a reproducer.

2 years ago[NFC][hwasan] Check __GLIBCXX__ before checking _GLIBCXX_RELEASE in test
Hans Wennborg [Tue, 1 Mar 2022 08:36:14 +0000 (09:36 +0100)]
[NFC][hwasan] Check __GLIBCXX__ before checking _GLIBCXX_RELEASE in test

_GLIBCXX_RELEASE wasn't defined before GCC 7.1.

This is another follow-up to https://reviews.llvm.org/D119161

2 years ago[C++20][Modules][8/8] Amend module visibility rules for partitions.
Iain Sandoe [Sun, 4 Apr 2021 11:31:31 +0000 (12:31 +0100)]
[C++20][Modules][8/8] Amend module visibility rules for partitions.

Implementation partitions bring two extra cases where we have
visibility of module-private data.

1) When we import a module implementation partition.
2) When a partition implementation imports the primary module intertace.

We maintain a record of direct imports into the current module since
partition decls from direct imports (but not trasitive ones) are visible.

The rules on decl-reachability are much more relaxed (with the standard
giving permission for an implementation to load dependent modules and for
the decls there to be reachable, but not visible).

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

2 years ago[mlir][OpDSL] Rename function to make signedness explicit (NFC).
gysit [Tue, 1 Mar 2022 08:10:51 +0000 (08:10 +0000)]
[mlir][OpDSL] Rename function to make signedness explicit (NFC).

The revision renames the following OpDSL functions:
```
TypeFn.cast -> TypeFn.cast_signed
BinaryFn.min -> BinaryFn.min_signed
BinaryFn.max -> BinaryFn.max_signed
```
The corresponding enum values on the C++ side are renamed accordingly:
```
#linalg.type_fn<cast> -> #linalg.type_fn<cast_signed>
#linalg.binary_fn<min> -> #linalg.binary_fn<min_signed>
#linalg.binary_fn<max> -> #linalg.binary_fn<max_signed>
```

Depends On D120110

Reviewed By: aartbik

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

2 years ago[RISCV] Add FMV_W_X and FMV_H_X instrutions to hasAllNBitUsers
Lian Wang [Tue, 1 Mar 2022 07:35:19 +0000 (07:35 +0000)]
[RISCV] Add FMV_W_X and FMV_H_X instrutions to hasAllNBitUsers

Reviewed By: craig.topper

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

2 years ago[MLIR][Standalone] Don't look for Python if bindings are OFF
Lorenzo Chelini [Wed, 23 Feb 2022 14:13:15 +0000 (15:13 +0100)]
[MLIR][Standalone] Don't look for Python if bindings are OFF

Reviewed By: stellaraccident

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

2 years ago[mlir][OpDSL] Add arithmetic function attributes.
gysit [Tue, 1 Mar 2022 07:40:06 +0000 (07:40 +0000)]
[mlir][OpDSL] Add arithmetic function attributes.

The revision extends OpDSL with unary and binary function attributes. A function attribute, makes the operations used in the body of a structured operation configurable. For example, a pooling operation may take an aggregation function attribute that specifies if the op shall implement a min or a max pooling. The goal of this revision is to define less and more flexible operations.

We may thus for example define an element wise op:
```
linalg.elem(lhs, rhs, outs=[out], op=BinaryFn.mul)
```
If the op argument is not set the default operation is used.

Depends On D120109

Reviewed By: nicolasvasilache, aartbik

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

2 years ago[RISCV] Add schedule class for Zbp extension and Zbr extension
lian wang [Thu, 17 Feb 2022 06:05:53 +0000 (06:05 +0000)]
[RISCV] Add schedule class for Zbp extension and Zbr extension

Reviewed By: craig.topper

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

2 years ago[gn build] Port d8a2afb244da
LLVM GN Syncbot [Tue, 1 Mar 2022 07:28:51 +0000 (07:28 +0000)]
[gn build] Port d8a2afb244da

2 years ago[ELF] isKnownZFlag: move known literal flags to an array. NFC
Fangrui Song [Tue, 1 Mar 2022 07:23:33 +0000 (23:23 -0800)]
[ELF] isKnownZFlag: move known literal flags to an array. NFC

The chain of == comparisons is a bit unwieldy to update.

While here, sort the entries alphabetically.

2 years ago[clang][analyzer] Add modeling of 'errno'.
Balázs Kéri [Fri, 25 Feb 2022 09:15:06 +0000 (10:15 +0100)]
[clang][analyzer] Add modeling of 'errno'.

Add a checker to maintain the system-defined value 'errno'.
The value is supposed to be set in the future by existing or
new checkers that evaluate errno-modifying function calls.

Reviewed By: NoQ, steakhal

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

2 years ago[Support] Allow the ability to change WithColor's auto detection function
Jonas Devlieghere [Mon, 28 Feb 2022 21:59:19 +0000 (13:59 -0800)]
[Support] Allow the ability to change WithColor's auto detection function

WithColor has an "auto detection mode" which looks whether the
corresponding whether the corresponding cl::opt is enabled or not. While
this is great when opting into cl::opt, it's not so great for downstream
users of this utility, which might have their own competing options to
enable or disable colors. The WithColor constructor takes a color mode,
but the big benefit of the class are its static error and warning
helpers and default error handlers.

In order to allow users of this utility to enable or disable colors
globally, this patch adds the ability to specify a global auto detection
function. By default, the auto detection function behaves the way that
it does today. The benefit of this patch lies in that it can be
overwritten. In addition to a ability to change the auto detection
function, I've also made it possible to get your hands on the default
auto detection function, so you swap it back if if you so desire.

This patch allow downstream users (like LLDB) to globally disable colors
with its own command line flag.

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

2 years ago[asan][test] Remove Linux/asan_prelink_test.cpp
Fangrui Song [Tue, 1 Mar 2022 04:26:33 +0000 (20:26 -0800)]
[asan][test] Remove Linux/asan_prelink_test.cpp

glibc 2.37 will remove prelink support. See
https://sourceware.org/pipermail/libc-alpha/2022-January/135565.html for its
broken current state.

Reviewed By: kstoimenov

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

2 years ago[LoongArch][NFC] Delete unnecessary return behind of llvm_unreachable
Weining Lu [Tue, 1 Mar 2022 02:57:14 +0000 (10:57 +0800)]
[LoongArch][NFC] Delete unnecessary return behind of llvm_unreachable

2 years ago[BOLT] Fix X86MCPlusBuilder::replaceRegWithImm
Amir Ayupov [Thu, 24 Feb 2022 06:30:03 +0000 (22:30 -0800)]
[BOLT] Fix X86MCPlusBuilder::replaceRegWithImm

Reassigning the operand didn't update the operand type which resulted in an
assertion (`Assertion `isReg() && "This is not a register operand!"' failed.`)
Reset the instruction instead.

Test Plan:
```
ninja check-bolt
...
PASS: BOLT-Unit :: Core/./CoreTests/X86/MCPlusBuilderTester.ReplaceRegWithImm/0 (90 of 136)
```

Reviewed By: rafauler

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

2 years ago[lld-macho] Have relocation address included in range-check error message
Jez Ng [Tue, 1 Mar 2022 02:56:38 +0000 (21:56 -0500)]
[lld-macho] Have relocation address included in range-check error message

This makes it easier to debug those errors. See e.g. https://github.com/llvm/llvm-project/issues/52767#issuecomment-1028713943

We take the approach of 'reverse-engineering' the InputSection from the
output buffer offset. This provides for a cleaner Target API, and is
similar to LLD-ELF's implementation of getErrorPlace().

Reviewed By: #lld-macho, Roger

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

2 years ago[X86] Use bit test instructions to optimize some logic atomic operations
Phoebe Wang [Tue, 1 Mar 2022 01:56:49 +0000 (09:56 +0800)]
[X86] Use bit test instructions to optimize some logic atomic operations

This is to match GCC's optimizations: https://gcc.godbolt.org/z/3odh9e7WE

Reviewed By: craig.topper

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

2 years ago[RISCV][NFC] Move defined non_imm12 to proper place in RISCVInstrInfoZb.td
Lian Wang [Tue, 1 Mar 2022 01:44:38 +0000 (01:44 +0000)]
[RISCV][NFC] Move defined non_imm12 to proper place in RISCVInstrInfoZb.td

Reviewed By: craig.topper

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

2 years ago[Clang] Remove redundant init-parens in AST print
Zhihao Yuan [Tue, 1 Mar 2022 01:29:54 +0000 (19:29 -0600)]
[Clang] Remove redundant init-parens in AST print

Given a dependent `T` (maybe an undeduced `auto`),

Before:

    new T(z)  -->  new T((z))  # changes meaning with more args
    new T{z}  -->  new T{z}
        T(z)  -->      T(z)
        T{z}  -->      T({z})  # forbidden if T is auto

After:

    new T(z)  -->  new T(z)
    new T{z}  -->  new T{z}
        T(z)   -->     T(z)
        T{z}   -->     T{z}

Depends on D113393

Reviewed By: aaron.ballman

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

2 years ago[c++2b] Implement P0849R8 auto(x)
Zhihao Yuan [Tue, 1 Mar 2022 01:17:49 +0000 (19:17 -0600)]
[c++2b] Implement P0849R8 auto(x)

https://wg21.link/p0849

Reviewed By: aaron.ballman, erichkeane

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

2 years ago[Windows] Don't try to use x64 linker on ARM64 Windows.
Eli Friedman [Mon, 28 Feb 2022 21:32:25 +0000 (13:32 -0800)]
[Windows] Don't try to use x64 linker on ARM64 Windows.

Trying to invoke an x64 binary on ARM64 Windows 10 won't work, and will
print an obscure error message.  Choose the 32-bit linker instead, which
will run under emulation.

The x64 linker should in theory run under ARM64 Windows 11.  We could
detect this using IsWow64GuestMachineSupported(), but I don't have a
setup to test that with at the moment.

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

2 years ago[test] Silence compiler warning.
Michael Kruse [Tue, 1 Mar 2022 00:44:36 +0000 (18:44 -0600)]
[test] Silence compiler warning.

signed/unsigned comparison in gtest macro.

Also fix buidlbots:
https://lab.llvm.org/buildbot#builders/36/builds/18337
https://lab.llvm.org/buildbot#builders/57/builds/15594

2 years ago[ASan] Removed unused AddressSanitizerPass functional pass.
Kirill Stoimenov [Mon, 28 Feb 2022 20:38:31 +0000 (20:38 +0000)]
[ASan] Removed unused AddressSanitizerPass functional pass.

This is a clean-up patch. The functional pass was rolled into the module pass in D112732.

Reviewed By: vitalybuka, aeubanks

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

2 years ago[OpenMPIRBuilder] Implement static-chunked workshare-loop schedules.
Michael Kruse [Fri, 25 Feb 2022 23:44:14 +0000 (17:44 -0600)]
[OpenMPIRBuilder] Implement static-chunked workshare-loop schedules.

Add applyStaticChunkedWorkshareLoop method implementing static schedule when chunk-size is specified. Unlike a static schedule without chunk-size (where chunk-size is chosen by the runtime such that each thread receives one chunk), we need two nested loops: one for looping over the iterations of a chunk, and a second for looping over all chunks assigned to the threads.

This patch includes the following related changes:
 * Adapt applyWorkshareLoop to triage between the schedule types, now possible since all schedules have been implemented. The default schedule is assumed to be non-chunked static, as without OpenMPIRBuilder.
 * Remove the chunk parameter from applyStaticWorkshareLoop, it is ignored by the runtime. Change the value for the value passed to the init function to 0, as without OpenMPIRBuilder.
 * Refactor CanonicalLoopInfo::setTripCount and CanonicalLoopInfo::mapIndVar as used by both, applyStaticWorkshareLoop and applyStaticChunkedWorkshareLoop.
 * Enable Clang to use the OpenMPIRBuilder in the presence of the schedule clause.

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

2 years ago[flang] Allow more concurrently open NEWUNIT= values, with recycling
Peter Klausler [Wed, 16 Feb 2022 21:26:44 +0000 (13:26 -0800)]
[flang] Allow more concurrently open NEWUNIT= values, with recycling

Add a header-only implementation of Briggs & Torczon's fast small
integer set data structure to flang/include/flang/Common, and use
it in the runtime to manage a pool of Fortran unit numbers with
recycling.  This replaces the bit set previously used for that
purpose.  The set is initialized on demand with the negations of
all the NEWUNIT= unit numbers that can be returned to any kind
of integer variable.

For programs that require more concurrently open NEWUNIT= unit
numbers than the pool can hold, they are now allocated with a
non-recycling counter.  This allows as many open units as the
operating system provides.

Many of the top-line comments in flang/unittests/Runtime had the
wrong path name.  I noticed this while adding a unit test for the
fast integer set data structure, and cleaned them up.

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

2 years ago[libc++] [ranges] Use "inline constexpr bool" not "constexpr bool" for helpers.
Arthur O'Dwyer [Mon, 28 Feb 2022 23:48:58 +0000 (18:48 -0500)]
[libc++] [ranges] Use "inline constexpr bool" not "constexpr bool" for helpers.

Reviewed as part of D118616.

2 years ago[libc] Add a class "Atomic" as a simple equivalent of std::atomic.
Siva Chandra Reddy [Sun, 27 Feb 2022 22:15:21 +0000 (22:15 +0000)]
[libc] Add a class "Atomic" as a simple equivalent of std::atomic.

Only the methods currently required by the libc have been added.
Most of the existing uses of atomic operations have been switched over
to this new class. A future change will clean up the rest of uses.

This change now allows building mutex and condition variable code with a
C++ compiler which does not have stdatomic.h, for example g++.

Reviewed By: lntue

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

2 years ago[Flang] NFC: Changes to adhere to coding guidelines
Kiran Chandramohan [Mon, 28 Feb 2022 23:39:22 +0000 (23:39 +0000)]
[Flang] NFC: Changes to adhere to coding guidelines

This patch includes some changes which brings the code in line with
llvm coding guidelines.
-> Remove curlies for one line if statements.
-> Remove else after return.
-> Removes a few usage of auto.
-> Add Doxygen comments

Addresses post review comments in D120403 by @schweitz.

Reviewed By: schweitz

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

2 years agoAdds a flag to optionally disable tosa decompositions
not-jenni [Mon, 28 Feb 2022 23:30:13 +0000 (15:30 -0800)]
Adds a flag to optionally disable tosa decompositions

Reviewed By: rsuderman

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

2 years ago[flang] Catch I/O of bad derived type at compile time
Peter Klausler [Fri, 11 Feb 2022 17:44:47 +0000 (09:44 -0800)]
[flang] Catch I/O of bad derived type at compile time

Derived types with allocatable and pointer components cannot
be used in I/O data transfer statements unless they have defined
I/O procedures available (as type-bound or regular generics).
These cases are caught as errors by the I/O runtime library,
but it would be better if they were flagged during compilation.

(Address comment in review: don't use explicit name string lengths.)

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

2 years agoRevert "[Support] Allow the ability to change WithColor's auto detection function"
Jonas Devlieghere [Mon, 28 Feb 2022 23:31:54 +0000 (15:31 -0800)]
Revert "[Support] Allow the ability to change WithColor's auto detection function"

This reverts commit a83cf7a84628a9e3a24cfd33c69f786cf74df4ec because it
breaks a bunch of build bots.

2 years ago[AArch64][SME] Add rdsvl instruction
Hsiangkai Wang [Sat, 26 Feb 2022 02:39:48 +0000 (02:39 +0000)]
[AArch64][SME] Add rdsvl instruction

This patch adds support for the following SME instruction:

  * RDSVL

The reference can be found here:
https://developer.arm.com/documentation/ddi0602/2021-12

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

2 years ago[AArch64][SME] Add addsvl and addspl instructions
Hsiangkai Wang [Fri, 25 Feb 2022 08:57:45 +0000 (08:57 +0000)]
[AArch64][SME] Add addsvl and addspl instructions

This patch adds support for the following SME instructions:

  * ADDSPL, ADDSVL

The reference can be found here:
https://developer.arm.com/documentation/ddi0602/2021-12

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

2 years ago[mlir] Match Arithmetic::ConstantOp and Tensor::ExtractSliceOp.
Okwan Kwon [Tue, 22 Feb 2022 21:50:14 +0000 (21:50 +0000)]
[mlir] Match Arithmetic::ConstantOp and Tensor::ExtractSliceOp.

Add a pattern matcher for ExtractSliceOp when its source is a constant.

The matching heuristics can be governed by the control function since
generating a new constant is not always beneficial.

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

2 years ago[Support] Allow the ability to change WithColor's auto detection function
Jonas Devlieghere [Mon, 28 Feb 2022 21:59:19 +0000 (13:59 -0800)]
[Support] Allow the ability to change WithColor's auto detection function

WithColor has an "auto detection mode" which looks whether the
corresponding whether the corresponding cl::opt is enabled or not. While
this is great when opting into cl::opt, it's not so great for downstream
users of this utility, which might have their own competing options to
enable or disable colors. The WithColor constructor takes a color mode,
but the big benefit of the class are its static error and warning
helpers and default error handlers.

In order to allow users of this utility to enable or disable colors
globally, this patch adds the ability to specify a global auto detection
function. By default, the auto detection function behaves the way that
it does today. The benefit of this patch lies in that it can be
overwritten. In addition to a ability to change the auto detection
function, I've also made it possible to get your hands on the default
auto detection function, so you swap it back if if you so desire.

This patch allow downstream users (like LLDB) to globally disable colors
with its own command line flag.

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

2 years agoUse __builtin_clz to find leading 1 in generic sqrt (where possible)
Clint Caywood [Mon, 28 Feb 2022 22:28:11 +0000 (17:28 -0500)]
Use __builtin_clz to find leading 1 in generic sqrt (where possible)

__builtin_clz requires just a single instruction on x86 and arm, so this is a performance improvement.

Reviewed By: lntue

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

2 years ago[gn build] Port
LLVM GN Syncbot [Mon, 28 Feb 2022 22:24:55 +0000 (22:24 +0000)]
[gn build] Port

2 years ago[libc++abi] Install the libc++abi headers from libc++abi
Louis Dionne [Thu, 17 Feb 2022 16:19:45 +0000 (11:19 -0500)]
[libc++abi] Install the libc++abi headers from libc++abi

libc++abi should be responsible for installing its own headers, it
doesn't make sense for libc++ to be responsible for it.

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

2 years ago[libc++][NFC] Fix typo in comment
Louis Dionne [Mon, 28 Feb 2022 22:05:35 +0000 (17:05 -0500)]
[libc++][NFC] Fix typo in comment

2 years ago[libc++][NFC] Remove unused Lit feature in the test suite
Louis Dionne [Mon, 28 Feb 2022 22:03:55 +0000 (17:03 -0500)]
[libc++][NFC] Remove unused Lit feature in the test suite

2 years ago[mlir][linalg] Enhance FoldInsertPadIntoFill to support op chain
Lei Zhang [Mon, 28 Feb 2022 21:43:03 +0000 (16:43 -0500)]
[mlir][linalg] Enhance FoldInsertPadIntoFill to support op chain

If we have a chain of `tensor.insert_slice` ops inserting some
`tensor.pad` op into a `linalg.fill` and ranges do not overlap,
we can also elide the `tensor.pad` later.

Reviewed By: ThomasRaoux

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

2 years ago[mlir][linalg] Fold tensor.pad when inserting into linalg.fill
Lei Zhang [Mon, 28 Feb 2022 21:34:46 +0000 (16:34 -0500)]
[mlir][linalg] Fold tensor.pad when inserting into linalg.fill

Fold tensor.insert_slice(tensor.pad(<input>), linalg.fill) into
tensor.insert_slice(<input>, linalg.fill) if the padding value and
the filling value are the same.

Reviewed By: ThomasRaoux

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

2 years ago[libcxx] [test] Fix the monetary locale curr_symbol test on Windows, Apple and FreeBSD
Martin Storsjö [Tue, 18 Jan 2022 09:48:27 +0000 (09:48 +0000)]
[libcxx] [test] Fix the monetary locale curr_symbol test on Windows, Apple and FreeBSD

International currency symbols (like USD, EUR) are returned with a
trailing space, like "USD ", on previously supported Unix platforms.
On Windows, the locales return them without a trailing space.

Also adjust the test for expecting a different unicode sequence for
the national currency symbol for ru_RU.UTF-8 and zh_CN.UTF-8.

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

2 years ago[HIP] File device library ABI version file name
Yaxun (Sam) Liu [Fri, 25 Feb 2022 05:03:36 +0000 (00:03 -0500)]
[HIP] File device library ABI version file name

It should be oclc_abi_version* instead of abi_version*.

Reviewed by: Artem Belevich

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

2 years ago[SLP] Check invariant that all instructions in bundle are in same block [NFC]
Philip Reames [Mon, 28 Feb 2022 21:17:35 +0000 (13:17 -0800)]
[SLP] Check invariant that all instructions in bundle are in same block [NFC]

2 years ago[YAMLParser] Add multi-line literal folding support
Scott Linder [Mon, 28 Feb 2022 20:20:25 +0000 (20:20 +0000)]
[YAMLParser] Add multi-line literal folding support

Last year I was working at Swift to add support for [Localization of Compiler Diagnostic Messages](https://forums.swift.org/t/localization-of-compiler-diagnostic-messages/36412/41). We are currently using YAML as the new diagnostic format. The LLVM::YAMLParser didn't have a support for multiline string literal folding and it's crucial to have that for the diagnostic message to help us keep up with the 80 columns rule. Therefore, I decided to add a multiline string literal folding support to the YAML parser.

Patch By: @HassanElDesouky (Hassan ElDesouky)

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

2 years ago[NFC] Don't pass temporary LangOptions to Lexer
Jorge Gorbe Moya [Mon, 28 Feb 2022 20:52:43 +0000 (12:52 -0800)]
[NFC] Don't pass temporary LangOptions to Lexer

Since https://reviews.llvm.org/D120334, passing a temporary LangOptions
object to Lexer results in stack-use-after-scope.

2 years ago[docs] Add note about interaction between clang plugins and -clear-ast-before-backend
Arthur Eubanks [Mon, 28 Feb 2022 17:30:42 +0000 (09:30 -0800)]
[docs] Add note about interaction between clang plugins and -clear-ast-before-backend

Reviewed By: rnk

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

2 years ago[RISCV] Only enable combineROTR_ROTL_RORW_ROLW with Zbp.
Craig Topper [Mon, 28 Feb 2022 20:46:31 +0000 (12:46 -0800)]
[RISCV] Only enable combineROTR_ROTL_RORW_ROLW with Zbp.

I think the immediate values we check for on the GREV nodes already
protect this, but better to be explicit.

2 years ago[flang][NFC] Add complex operations lowering tests
Valentin Clement [Mon, 28 Feb 2022 20:37:18 +0000 (21:37 +0100)]
[flang][NFC] Add complex operations lowering tests

Just adds some lowering test for complex operations. These were not
added when the lowering landed.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: schweitz

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

2 years ago[Clang] noinline call site attribute
Dávid Bolvanský [Mon, 28 Feb 2022 20:20:59 +0000 (21:20 +0100)]
[Clang] noinline call site attribute

Motivation:

```
int foo(int x, int y) { // any compiler will happily inline this function
    return x / y;
}

int test(int x, int y) {
    int r = 0;
    [[clang::noinline]] r += foo(x, y); // for some reason we don't want any inlining here
    return r;
}

```

In 2018, @kuhar proposed "Introduce per-callsite inline intrinsics"  in https://reviews.llvm.org/D51200 to solve this motivation case (and many others).

This patch solves this problem with call site attribute. The implementation is "smaller" wrt approach which uses new intrinsics and thanks to https://reviews.llvm.org/D79121 (Add nomerge statement attribute to clang), we have got some basic infrastructure to deal with attrs on statements with call expressions.

GCC devs are more inclined to call attribute solution as well, as builtins are problematic for them - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104187. But they have no patch proposal yet so..  We have free hands here.

If this approach makes sense, next future steps would be support for call site attributes for always_inline / flatten.

Reviewed By: aaron.ballman, kuhar

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

2 years ago[NFC] Make 1st param to getTemplateInstantiationArgs const correct
Erich Keane [Mon, 28 Feb 2022 20:13:16 +0000 (12:13 -0800)]
[NFC] Make 1st param to getTemplateInstantiationArgs const correct

The function doesn't modify anything, and took minimal effort to get
const-correct, AND is necessary for a patch I've been working on for
concepts.

2 years ago[gn build] Port a3255f219a86
LLVM GN Syncbot [Mon, 28 Feb 2022 20:01:32 +0000 (20:01 +0000)]
[gn build] Port a3255f219a86

2 years ago[libc++] Explicitly reject `uniform_int_distribution<bool>` and `<char>`.
Arthur O'Dwyer [Thu, 2 Dec 2021 00:55:26 +0000 (19:55 -0500)]
[libc++] Explicitly reject `uniform_int_distribution<bool>` and `<char>`.

`uniform_int_distribution<T>` is UB unless `T` is one of the non-character,
non-boolean integer types (`short` or larger). However, libc++ has never
enforced this. D114129 accidentally made `uniform_int_distribution<bool>`
into an error. Make it now *intentionally* an error; and likewise for the
character types and all user-defined class and enum types; but permit
`__[u]int128_t` to continue working.

Apply the same static_assert to all the integer distributions.

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

2 years ago[libc++] [ranges] Permit std::mergeable and std::sortable with HAS_NO_INCOMPLETE_RANGES.
Arthur O'Dwyer [Fri, 18 Feb 2022 16:36:59 +0000 (11:36 -0500)]
[libc++] [ranges] Permit std::mergeable and std::sortable with HAS_NO_INCOMPLETE_RANGES.

This follows the general direction of D118736 that
`_LIBCPP_HAS_NO_INCOMPLETE_RANGES` does *not* guard anything outside
of the `std::ranges::` namespace itself. This means we must permit
`ranges::less` etc. in no-ranges mode; that seems fine to me.

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

2 years ago[NFC] Don't pass temporary LangOptions to Lexer
Dawid Jurczak [Mon, 28 Feb 2022 19:14:44 +0000 (20:14 +0100)]
[NFC] Don't pass temporary LangOptions to Lexer

Since https://reviews.llvm.org/D120334 we shouldn't pass temporary LangOptions to Lexer.
This change fixes stack-use-after-scope UB in LocalizationChecker found by sanitizer-x86_64-linux-fast buildbot
and resolve similar issue in HeaderIncludes.

2 years ago[AMDGPU] Extend SILoadStoreOptimizer to handle flat load/stores
Stanislav Mekhanoshin [Thu, 24 Feb 2022 19:13:46 +0000 (11:13 -0800)]
[AMDGPU] Extend SILoadStoreOptimizer to handle flat load/stores

TODO: merge flat with global promoting to flat.

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

2 years ago[ELF] Change some non-null pointer parameters to references. NFC
Fangrui Song [Mon, 28 Feb 2022 19:19:00 +0000 (11:19 -0800)]
[ELF] Change some non-null pointer parameters to references. NFC

To decrease difference for D120650. Also, rename some `OutputSection *sec` (and
`cmd`) to the more common `osec`.

2 years ago[doc] Add llvm-ifs commandline guide
Haowei Wu [Fri, 28 Jan 2022 23:30:43 +0000 (15:30 -0800)]
[doc] Add llvm-ifs commandline guide

This patch adds llvm-ifs commandline guide

Differential Review: https://reviews.llvm.org/D118514

2 years agoRevert "[mlir] Fold Arithmetic::ConstantOp and Tensor::ExtractSliceOp."
Okwan Kwon [Mon, 28 Feb 2022 19:11:29 +0000 (19:11 +0000)]
Revert "[mlir] Fold Arithmetic::ConstantOp and Tensor::ExtractSliceOp."

This reverts commit 3104994104f0c2f274acf5e01eb6cc82e9cca06b.

2 years ago[InstCombine] fold mul-with-overflow intrinsic with -1 operand
Sanjay Patel [Mon, 28 Feb 2022 17:13:55 +0000 (12:13 -0500)]
[InstCombine] fold mul-with-overflow intrinsic with -1 operand

extractvalue (any_mul_with_overflow X, -1), 0 --> -X

There are similar other potential transforms that we could do as
noted by the last TODO in the test diffs.

Fixes #54053

2 years ago[NFC][LoopVectorizer] Simplify LoopVectorize/X86/gather_scatter.ll
Andrei Elovikov [Mon, 28 Feb 2022 17:46:51 +0000 (09:46 -0800)]
[NFC][LoopVectorizer] Simplify LoopVectorize/X86/gather_scatter.ll

The test used to run whole O3 pipeline. Modify it to contain LLVM IR right
before LV and limit passes to "-loop-vectorizer -simplifycfg".

For the RUN line with forced VF force interleave factor as well to simplify
CHECKs as interleaving isn't related to the purpose of the test.

I also tried to add "noalias" to pointer arguments in
@test_gather_not_profitable_pr48429 but LAI seems unable to use them.

Reviewed By: fhahn

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

2 years ago[RISCV] Don't call combineROTR_ROTL_RORW_ROLW for SLLW/SRLW/SRAW nodes. NFC
Craig Topper [Mon, 28 Feb 2022 18:53:35 +0000 (10:53 -0800)]
[RISCV] Don't call combineROTR_ROTL_RORW_ROLW for SLLW/SRLW/SRAW nodes. NFC

I think the function does the correct thing internally, but it's
confusing to read.

2 years ago[mlir-tblgen] Fix non-deterministic generating static verifier in DRR.
Chia-hung Duan [Mon, 28 Feb 2022 18:21:28 +0000 (18:21 +0000)]
[mlir-tblgen] Fix non-deterministic generating static verifier in DRR.

Use SetVector instead of DenseSet to ensure we always generate the same
name for the same function. This issue is found in
https://github.com/llvm/llvm-project/issues/53768.

Reviewed By: quinnp, rdzhabarov

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

2 years ago[OpenMP] Add verbose output for linker wrapper
Joseph Huber [Mon, 28 Feb 2022 18:14:54 +0000 (13:14 -0500)]
[OpenMP] Add verbose output for linker wrapper

Summary;
This path adds printing support for the linker wrapper. When the user
passes `-v` it will not print the commands used by the linker wrapper to
indicate to the user what is happening during the linking.

2 years ago[ELF] Rename Symbol::compare to shouldReplace. NFC
Fangrui Song [Mon, 28 Feb 2022 18:25:21 +0000 (18:25 +0000)]
[ELF] Rename Symbol::compare to shouldReplace. NFC

The return value is not a boolean instead of a tri-state.
Suggested by Peter Smith in D120640.

2 years ago[libc++] Fix double file closing in `std::filesystem::remove_all()`.
Konstantin Varlamov [Mon, 28 Feb 2022 17:55:27 +0000 (12:55 -0500)]
[libc++] Fix double file closing in `std::filesystem::remove_all()`.

According to Linux documentation (see e.g. https://linux.die.net/man/3/closedir):

> A successful call to `closedir()` also closes the underlying file
> descriptor associated with `dirp`.

Thus, calling `close()` after a successful call to `closedir()` is at
best redundant. Worse, should a different thread open a file in-between
the calls to `closedir()` and `close()` and get the same file descriptor,
the call to `close()` might actually close a different file than was
intended.

rdar://89251874

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

2 years ago[mlir] Fold Arithmetic::ConstantOp and Tensor::ExtractSliceOp.
Okwan Kwon [Tue, 22 Feb 2022 21:50:14 +0000 (21:50 +0000)]
[mlir] Fold Arithmetic::ConstantOp and Tensor::ExtractSliceOp.

Fold ExtractSliceOp when the source is a constant.

2 years ago[JITLink] Add R_RISCV_SUB6 relocation
luxufan [Tue, 22 Feb 2022 10:56:32 +0000 (18:56 +0800)]
[JITLink] Add R_RISCV_SUB6 relocation

Add R_RISCV_SUB6 relocation

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

2 years ago[RISCV] Custom type legalize i32 ISD::ABS on RV64 without Zbb.
Craig Topper [Mon, 28 Feb 2022 17:30:27 +0000 (09:30 -0800)]
[RISCV] Custom type legalize i32 ISD::ABS on RV64 without Zbb.

Default type legalization will create sext_inreg+abs, but we may
not be able to remove the sext_inreg.

Instead this patch expands abs during type legalization to
Y = sraiw X, 31; subw(xor X, Y), Y) which doesn't require the input
to be sign extended.

This gives a big improvement for some neg-abs tests where the
abs is used more than the the neg. Previously the abs was expanded
a different way before and after type legalization. Now they are
expanded in a similar way enabling more CSE.

Reviewed By: asb

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

2 years ago[clang] Remove unused variable AllElementsInt.
Arthur O'Dwyer [Sun, 27 Feb 2022 15:36:25 +0000 (10:36 -0500)]
[clang] Remove unused variable AllElementsInt.

This has been unused ever since it was committed in b8a501ccf1.

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

2 years ago[InstCombine] fold select-of-zero-or-ones with negated op
Sanjay Patel [Mon, 28 Feb 2022 17:03:11 +0000 (12:03 -0500)]
[InstCombine] fold select-of-zero-or-ones with negated op

(X u< 2) ? -X : -1 --> sext (X != 0)
(X u> 1) ? -1 : -X --> sext (X != 0)

https://alive2.llvm.org/ce/z/U3y5Bb
https://alive2.llvm.org/ce/z/hgi-4p

This is part of solving:

2 years ago[InstCombine] add tests for select of zero or all ones; NFC
Sanjay Patel [Mon, 28 Feb 2022 16:20:02 +0000 (11:20 -0500)]
[InstCombine] add tests for select of zero or all ones; NFC

See #54053

2 years ago[InstCombine] add tests for mul-with-overflow by -1; NFC
Sanjay Patel [Mon, 28 Feb 2022 14:21:23 +0000 (09:21 -0500)]
[InstCombine] add tests for mul-with-overflow by -1; NFC

2 years agoClarify documentation of cpu_dispatch/cpu_specific
Erich Keane [Mon, 28 Feb 2022 15:03:55 +0000 (07:03 -0800)]
Clarify documentation of cpu_dispatch/cpu_specific

There has been some internal confusion lately as to how cpu_dispatch and
cpu_specific dispatch to processors, so this patch clarifies the
documentation to make it more clear that:

1- Unlike ICC, we do not consider the vendor string (that is, an AMD
processor might result in something other than generic)

2- there are some processors that aren't really distinguishable thanks
to the library limitation, so the variant being selected is unspecified.

In reality, I believe the 'stable_sort' makes it so the 1st one that
meets the requirements is the one that is selected (and that matches my
experimented result), but I don't want to limit our implementation.

2 years ago[SLP]Improve bottom-to-top reordering.
Alexey Bataev [Tue, 22 Feb 2022 21:50:17 +0000 (13:50 -0800)]
[SLP]Improve bottom-to-top reordering.

Currently bottom-to-top reordering analysis counts orders of the
operands and then adds natural order counts for the operand users. It is
very conservative, this the user nodes themselves may require
reordering. Patch improves bottom-to-top analysis by checking for the
user nodes if they require/allows the reordring. If the user node must
be reordered, has reused scalars, is an alternate op vectorization node,
is a non-ordered gather node or may allow reordering because of the
reordered operands, such node is considered as the node that allows
reodring and is not counted as a node with the natural order.

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

2 years ago[NFC][Lexer] Make Lexer::LangOpts const reference
Dawid Jurczak [Fri, 25 Feb 2022 11:07:33 +0000 (12:07 +0100)]
[NFC][Lexer] Make Lexer::LangOpts const reference

This change can be seen as code cleanup but motivation is more performance related.
While browsing perf reports captured during Linux build we can notice unusual portion of instructions executed in std::vector<std::string> copy constructor like:

0.59%     0.58%  clang-14    clang-14      [.] std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >,
                                                                std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >::vector

or even:

1.42%     0.26%  clang    clang-14             [.] clang::LangOptions::LangOptions
       |
        --1.16%--clang::LangOptions::LangOptions
                  |
                   --0.74%--std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >,
                            std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >::vector

After more digging we can see that relevant LangOptions std::vector members (*Files, ModuleFeatures and NoBuiltinFuncs)
are constructed when Lexer::LangOpts field is initialized on list:

Lexer::Lexer(..., const LangOptions &langOpts, ...)
            : ..., LangOpts(langOpts),

Since LangOptions copy constructor is called by Lexer(..., const LangOptions &LangOpts,...) and local Lexer objects are created thousands times
(in Lexer::getRawToken, Preprocessor::EnterSourceFile and more) during single module processing in frontend it makes std::vector copy constructors surprisingly hot.

Unfortunately even though in current Lexer implementation mentioned std::vector members are unused and most of time empty,
no compiler is smart enough to optimize their std::vector copy constructors out (take a look at test assembly): https://godbolt.org/z/hdoxPfMYY even with LTO enabled.
However there is simple way to fix this. Since Lexer doesn't access *Files, ModuleFeatures, NoBuiltinFuncs and any other LangOptions fields (but only LangOptionsBase)
we can simply get rid of redundant copy constructor assembly by changing LangOpts type to more appropriate const LangOptions reference: https://godbolt.org/z/fP7de9176

Additionally we need to store LineComment outside LangOpts because it's written in SkipLineComment function.
Also FormatTokenLexer need to be adjusted a bit to avoid lifetime issues related to passing local LangOpts reference to Lexer.

After this change I can see more than 1% speedup in some of my microbenchmarks when using Clang release binary built with LTO.
For Linux build gains are not so significant but still nice at the level of -0.4%/-0.5% instructions drop.

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

2 years ago[InlineCost] Use SmallPtrSet for DeadBlocks (NFC)
Nikita Popov [Mon, 28 Feb 2022 14:25:03 +0000 (15:25 +0100)]
[InlineCost] Use SmallPtrSet for DeadBlocks (NFC)

This set is only used with contains operations, so there is no
need to use a SetVector.

2 years ago[NFC][Clang][AArch64] Clean up AArch64TargetInfo::hasFeature
Archibald Elliott [Fri, 25 Feb 2022 18:39:34 +0000 (18:39 +0000)]
[NFC][Clang][AArch64] Clean up AArch64TargetInfo::hasFeature

2 years ago[AArch64][SVE] Fold away SETCC if original input was predicate vector.
Sander de Smalen [Mon, 28 Feb 2022 12:17:25 +0000 (12:17 +0000)]
[AArch64][SVE] Fold away SETCC if original input was predicate vector.

This adds the following two folds:

Fold 1:
   setcc_merge_zero(
       all_active, extend(nxvNi1 ...), != splat(0))
  -> nxvNi1 ...

Fold 2:
   setcc_merge_zero(
       pred, extend(nxvNi1 ...), != splat(0))
  -> nxvNi1 and(pred, ...)

Reviewed By: david-arm

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

2 years agoRecommit "[VPlan] Introduce recipe to build scalar steps."
Florian Hahn [Mon, 28 Feb 2022 14:12:20 +0000 (14:12 +0000)]
Recommit "[VPlan] Introduce recipe to build scalar steps."

This reverts the revert commit ff93260bf6bddfbad1fa65c4d5184988885b900f.

The underlying issue causing the PPC bot failures has been fixed in
cbaac1473403 and a corresponding test case has been added in
ad2cad1c521c.

Original message:

    This patch adds a new VPScalarIVStepsRecipe to handle building scalar
    steps.

    In the first patch, it only handles the case where there is no vector
    induction variable needed.

    Reviewed By: Ayal

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

2 years ago[clang][tests] Fix ve-toolchain tests with CLANG_DEFAULT_UNWINDLIB
Timm Bäder [Mon, 28 Feb 2022 06:45:35 +0000 (07:45 +0100)]
[clang][tests] Fix ve-toolchain tests with CLANG_DEFAULT_UNWINDLIB

Otherwise, the driver will insert e.g. -lgcc_s when
CLANG_DEFAULT_UNWINDLIB=libgcc is set during the clang build.

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

2 years ago[flang] Lower power operations
Valentin Clement [Mon, 28 Feb 2022 13:48:40 +0000 (14:48 +0100)]
[flang] Lower power operations

Lower the power operation for real, integer
and complex.

The power operation is lowered to library calls.

This patch is part of the upstreaming effort from fir-dev branch.

Depends on D120403

Reviewed By: schweitz

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

2 years ago[AArch64] Async unwind - function prologues
Momchil Velikov [Mon, 28 Feb 2022 11:51:17 +0000 (11:51 +0000)]
[AArch64] Async unwind - function prologues

This patch rearranges emission of CFI instructions, so the resulting
DWARF and `.eh_frame` information is precise at every instruction.

The current state is that the unwind info is emitted only after the
function prologue. This is fine for synchronous (e.g. C++) exceptions,
but the information is generally incorrect when the program counter is
at an instruction in the prologue or the epilogue, for example:

```
stp x29, x30, [sp, #-16]!           // 16-byte Folded Spill
mov x29, sp
.cfi_def_cfa w29, 16
...
```

after the `stp` is executed the (initial) rule for the CFA still says
the CFA is in the `sp`, even though it's already offset by 16 bytes

A correct unwind info could look like:
```
stp x29, x30, [sp, #-16]!           // 16-byte Folded Spill
.cfi_def_cfa_offset 16
mov x29, sp
.cfi_def_cfa w29, 16
...
```

Having this information precise up to an instruction is useful for
sampling profilers that would like to get a stack backtrace. The end
goal (towards this patch is just a step) is to have fully working
`-fasynchronous-unwind-tables`.

Reviewed By: danielkiss, MaskRay

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

2 years ago[mlir] Apply ClangTidy performance fixes (NFC)
Adrian Kuegel [Mon, 28 Feb 2022 12:17:34 +0000 (13:17 +0100)]
[mlir] Apply ClangTidy performance fixes (NFC)

2 years ago[AArch64][SVE] Handle more cases in findMoreOptimalIndexType.
Sander de Smalen [Mon, 28 Feb 2022 11:32:05 +0000 (11:32 +0000)]
[AArch64][SVE] Handle more cases in findMoreOptimalIndexType.

This patch addresses @paulwalker-arm's comment on D117900 to
only update/write the by-ref operands iff the function returns
true. It also handles a few more cases where a series of added
offsets can be folded into the base pointer, rather than just looking
at a single offset.

Reviewed By: paulwalker-arm

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

2 years ago[compiler-rt] Disable coverage trace pc guard tests on Thumb
David Spickett [Mon, 28 Feb 2022 11:56:07 +0000 (11:56 +0000)]
[compiler-rt] Disable coverage trace pc guard tests on Thumb

These are failing on our silent bot:
https://lab.llvm.org/staging/#/builders/162/builds/358

$ <run cmd>
main
foo
bar
baz
SanitizerCoverage: ./sanitizer_coverage_trace_pc_guard-dso.cpp.tmp.2122517.sancov: 2 PCs written
SanitizerCoverage: ./sanitizer_coverage_trace_pc_guard-dso.cpp.tmp_2.so.2122517.sancov: 1 PCs written
SanitizerCoverage: ./sanitizer_coverage_trace_pc_guard-dso.cpp.tmp_1.so.2122517.sancov: 1 PCs written
$ <sancov cmd>
ERROR: Coverage points in binary and .sancov file do not match.

Also reproduces if you build for Thumb on v8 hardware.

Doesn't fail when built with Arm only code so I guess the Thumb mode bit
in the PCs might be the issue.

2 years ago[mlir][linalg] Check the iterator types are valid.
gysit [Mon, 28 Feb 2022 11:25:12 +0000 (11:25 +0000)]
[mlir][linalg] Check the iterator types are valid.

Improve the LinalgOp verification to ensure the iterator types is known. Previously, unknown iterator types have been ignored without warning, which can lead to confusing bugs.

Reviewed By: nicolasvasilache

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

2 years ago[LV] Remove induction recipes only used outside vector loop.
Florian Hahn [Mon, 28 Feb 2022 11:14:21 +0000 (11:14 +0000)]
[LV] Remove induction recipes only used outside vector loop.

Exit values of vector inductions are generated completely independent of
the induction recipes. Consider them for removal, if they are not used
in loop.

This fixes a crash exposed by 49b23f451cf7130.

2 years agoPartially revert "[SchedModels][CortexA55] Add ASIMD integer instructions"
David Green [Mon, 28 Feb 2022 10:58:52 +0000 (10:58 +0000)]
Partially revert "[SchedModels][CortexA55] Add ASIMD integer instructions"

The Cortex-A55 scheduling model is used for -mcpu=generic, meaning it
can have a wider effect than just the A55. The changes to the A55
scheduling model seems to have caused performance regressions on
Cortex-A510 device which have latencies closer to the original and
different forwarding paths.

This partially reverts the changes from D117003, at least until we can
do something to improve Cortex-A510. According to my results, this
improves the A510 results without altering the A55 very much.