platform/upstream/llvm.git
2 years ago[clang] Enforce instantiation of constexpr template functions during non-constexpr...
serge-sans-paille [Sat, 18 Jun 2022 11:48:41 +0000 (13:48 +0200)]
[clang] Enforce instantiation of constexpr template functions during non-constexpr evaluation

Otherwise these functions are not instantiated and we end up with an undefined
symbol.

Fix #55560

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

2 years ago[Support] Delete redundant 'static' from namespace scope 'static constexpr'. NFC
Fangrui Song [Sun, 10 Jul 2022 06:36:01 +0000 (23:36 -0700)]
[Support] Delete redundant 'static' from namespace scope 'static constexpr'. NFC

2 years ago[RISCV] Modify the custom isel for (add X, imm) used by load/stores.
Craig Topper [Sun, 10 Jul 2022 02:37:13 +0000 (19:37 -0700)]
[RISCV] Modify the custom isel for (add X, imm) used by load/stores.

We have custom isel that tries to select the Lo12 bits using a
separate ADDI that can later folded into the load/store address
by the post-isel peephole.

This patch disables this if the load/store already had a non-zero
offset. A non-zero offset implies that CodeGenPrepare split several
large offsets used by different loads and stores into a common large
offset and multiple small offsets that could be folded. Folding more
of the lo12 bits changes this common offset by increasing the small
offsets. While this can save an instruction to materialize the common
offset, it can also prevent the small offsets from fitting in a
compressed load/store instruction.

Removing this also simplifies the last piece needed to fold the custom
isel for add into SelectAddrRegImm and remove the post-isel peephole.

2 years ago[libc] Linux threads - store a ptr to the thread attribs in the start args.
Siva Chandra Reddy [Sat, 9 Jul 2022 21:44:37 +0000 (21:44 +0000)]
[libc] Linux threads - store a ptr to the thread attribs in the start args.

Previosly, a pointer to the thread data structure was stored in the
start args. However, the thread data structure need not have the
lifetime of the thread. On the the other hand, thread attributes are
stored on the thread stack so they live as long as the thread lives.

2 years agoRestore Python install behavior from before D128230.
Stella Laurenzo [Sun, 10 Jul 2022 01:35:44 +0000 (18:35 -0700)]
Restore Python install behavior from before D128230.

In D128230, we accidentally moved the install for Python sources outside of the loop, having one install() per group of files. While it would be nice if we could do this, it means that we flatten the relative directory tree and every source ends up in the root. The right way to do this is to use FILE_SETS, which preserve the relative directory tree, but they are not available until CMake 3.23.

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

2 years ago[LV] Move VPWidenRecipe::execute to VPlanRecipes.cpp (NFC).
Florian Hahn [Sun, 10 Jul 2022 01:46:56 +0000 (18:46 -0700)]
[LV] Move VPWidenRecipe::execute to VPlanRecipes.cpp (NFC).

2 years ago[LinkerWrapper] Forward `-mllvm` options to the linker wrapper
Joseph Huber [Wed, 6 Jul 2022 15:28:32 +0000 (11:28 -0400)]
[LinkerWrapper] Forward `-mllvm` options to the linker wrapper

This patch adds the ability to use `-mllvm` options in the linker
wrapper when performing bitcode linking or the module compilation.
This is done by passing in the LLVM argument to the clang-linker-wrapper
tool. Inside the linker-wrapper tool we invoke the `CommandLine` parser
solely for forwarding command line options to the `clang-linker-wrapper`
to the LLVM tools that also use the `CommandLine` parser. The actual
arguments to the linker wrapper are parsed using the `Opt` library
instead.

For example, in the following command the `CommandLine` parser will attempt to
parse `abc`, while the `opt` parser takes `-mllvm <arg>` and ignores it so it is
not passed to the linker arguments.
```
clang-linker-wrapper -mllvm -abc -- <linker-args>
```

As far as I can tell this is the easiest way to forward arguments to
LLVM tool invocations. If there is a better way to pass these arguments
(such as through the LTO config) let me know.

Reviewed By: MaskRay

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

2 years ago[libcxx] Uglify __support/musl
Brad Smith [Sat, 9 Jul 2022 21:59:34 +0000 (17:59 -0400)]
[libcxx] Uglify __support/musl

Uglify __support/musl

Reviewed By: philnik

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

2 years ago[ARM][AArch64] Add additional test for multiuse vldn binop shuffles. NFC
David Green [Sat, 9 Jul 2022 21:48:12 +0000 (22:48 +0100)]
[ARM][AArch64] Add additional test for multiuse vldn binop shuffles. NFC

For D129419, these are the same as the existing test, but run through
-early-cse.

2 years agofix comment typo to cycle bots
Nico Weber [Sat, 9 Jul 2022 20:41:58 +0000 (22:41 +0200)]
fix comment typo to cycle bots

2 years ago[RISCV] Support folding constant addresses in SelectAddrRegImm.
Craig Topper [Sat, 9 Jul 2022 18:54:52 +0000 (11:54 -0700)]
[RISCV] Support folding constant addresses in SelectAddrRegImm.

We already handled this by folding an ADDI in the post-isel peephole.
My goal is to remove that peephole so this adds the functionality
to isel.

2 years ago[DAGCombiner][X86] Fold sra (sub AddC, (shl X, N1C)), N1C --> sext (sub AddC1',(trunc...
Craig Topper [Sat, 9 Jul 2022 18:40:53 +0000 (11:40 -0700)]
[DAGCombiner][X86] Fold sra (sub AddC, (shl X, N1C)), N1C --> sext (sub AddC1',(trunc X to (width - N1C)))

We already handled this case for add with a constant RHS. A
similar pattern can occur for sub with a constant left hand side.

Test cases use add and a mul representing (neg (shl X, C)) because
that's what I saw in the wild. The mul will be decomposed and then
the new transform can kick in.

Tests have not been committed, but this patch shows the changes.

Reviewed By: RKSimon

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

2 years ago[mlir][vector] Relax reduction distribution pattern
Thomas Raoux [Sat, 9 Jul 2022 18:36:39 +0000 (18:36 +0000)]
[mlir][vector] Relax reduction distribution pattern

Support distributing reductions with vector size multiple of the warp
size.

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

2 years ago[libc][NFC] Remove the now used thread_attrib target.
Siva Chandra Reddy [Sat, 9 Jul 2022 18:25:27 +0000 (18:25 +0000)]
[libc][NFC] Remove the now used thread_attrib target.

2 years ago[CMake][Fuchsia] Use libunwind as the default unwinder
Petr Hosek [Sat, 28 May 2022 05:55:38 +0000 (05:55 +0000)]
[CMake][Fuchsia] Use libunwind as the default unwinder

Fuchsia already uses libunwind, but it does so implicitly via libc++.
This change makes the unwinder choice explicit.

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

2 years ago[Fuchsia] Remove the test cflags to explicitly set the unwinder
Petr Hosek [Sat, 9 Jul 2022 17:00:01 +0000 (17:00 +0000)]
[Fuchsia] Remove the test cflags to explicitly set the unwinder

These are no longer needed and cause issue when cross-compiling.

2 years agoFix -Warray-parameter warning
David Blaikie [Sat, 9 Jul 2022 17:04:01 +0000 (17:04 +0000)]
Fix -Warray-parameter warning

Remove the bound in the definition, since it's not guaranteed/could
provide a false sense of security (I'd be inclined to go further and
change this to a pointer parameter, since that's what it really is - but
figured I'd preserve some of the author's intent here)

2 years agoReapply 51c705fbe5d, "[JITLink] Include LinkGraph name in...", with fixes.
Lang Hames [Sat, 9 Jul 2022 16:12:19 +0000 (09:12 -0700)]
Reapply 51c705fbe5d, "[JITLink] Include LinkGraph name in...", with fixes.

Original commit reverted in 976de7130b338aa0d0e63255826a79347635c107 due to test
failures. This commit includes fixes for the tests.

2 years ago[SimplifyLibCalls] refactor pow(x, n) expansion where n is a constant integer value
Paul Osmialowski [Sat, 9 Jul 2022 15:58:18 +0000 (11:58 -0400)]
[SimplifyLibCalls] refactor pow(x, n) expansion where n is a constant integer value

Since the backend's codegen is capable to expand powi into fmul's, it
is not needed anymore to do so in the ::optimizePow() function of
SimplifyLibCalls.cpp. What is sufficient is to always turn pow(x, n)
into powi(x, n) for the cases where n is a constant integer value.

Dropping the current expansion code allowed relaxation of the folding
conditions and now this can also happen at optimization levels below
Ofast.

The added CodeGen/AArch64/powi.ll test case ensures that powi is
actually expanded into fmul's, confirming that this refactor did not
cause any performance degradation.

Following an idea proposed by David Sherwood <david.sherwood@arm.com>.

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

2 years agoRevert "[JITLink] Include LinkGraph name in debugging output."
Lang Hames [Sat, 9 Jul 2022 15:30:04 +0000 (08:30 -0700)]
Revert "[JITLink] Include LinkGraph name in debugging output."

Revert 51c705fbe5d8cc85868fc0f35e9b86d7ec301ee5 while I investigate some
builder failures.

2 years ago[LinkerWrapper] Fix errors not exiting inside of the LTO pipeline
Joseph Huber [Thu, 7 Jul 2022 15:28:32 +0000 (11:28 -0400)]
[LinkerWrapper] Fix errors not exiting inside of the LTO pipeline

The LTO pipeline handles its errors using the diagnostics handler
callback function. We were not checking the results of these errors and
not properly returning an error code in the linker wrapper when errors
occured inside of the LTO pipeline. This patch adds a simple boolean
flag to indicate if the LTO backend failed to any reason and quit.

Reviewed By: ye-luo

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

2 years agoRevert "[Clang] Add a warning on invalid UTF-8 in comments."
Corentin Jabot [Sat, 9 Jul 2022 15:18:35 +0000 (17:18 +0200)]
Revert "[Clang] Add a warning on invalid UTF-8 in comments."

It is probable thart this change crashes on the powerpc bots.

This reverts commit 355532a1499aa9b13a89fb5b5caaba2344d57cd7.

2 years ago[JITLink][AArch64] Rename PointerToGOT and fix typo.
Lang Hames [Sat, 9 Jul 2022 01:55:43 +0000 (18:55 -0700)]
[JITLink][AArch64] Rename PointerToGOT and fix typo.

PointerToGOT lowering was accidentally changed from Delta32 to Delta64 in
db3722580335c. This patch moves it back to Delta32 and renames the generic
aarch64 edge to Delta32ToGOT to avoid the ambiguity.

No test case yet -- I haven't figured out how to write a succinct test case
(this typically appears in CIEs in eh-frames).

2 years ago[JITLink] Include LinkGraph name in debugging output.
Lang Hames [Sat, 9 Jul 2022 01:36:29 +0000 (18:36 -0700)]
[JITLink] Include LinkGraph name in debugging output.

Makes it easier to identify the graph being fixed up at a glance.

2 years ago[C++20][Modules] Update handling of implicit inlines [P1779R3]
Iain Sandoe [Sun, 3 Jul 2022 13:27:10 +0000 (14:27 +0100)]
[C++20][Modules] Update handling of implicit inlines [P1779R3]

This provides updates to
[class.mfct]:
Pre C++20 [class.mfct]p2:
  A member function may be defined (8.4) in its class definition, in
  which case it is an inline member function (7.1.2)
Post C++20 [class.mfct]p1:
  If a member function is attached to the global module and is defined
  in its class definition, it is inline.

and
[class.friend]:
Pre-C++20 [class.friend]p5
  A function can be defined in a friend declaration of a
  class . . . . Such a function is implicitly inline.
Post C++20 [class.friend]p7
  Such a function is implicitly an inline function if it is attached
  to the global module.

We add the output of implicit-inline to the TextNodeDumper, and amend
a couple of existing tests to account for this, plus add tests for the
cases covered above.

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

2 years ago[clang-tidy] Sort release notes entries alphabetically by check name
Danny Mösch [Sat, 9 Jul 2022 13:45:19 +0000 (15:45 +0200)]
[clang-tidy] Sort release notes entries alphabetically by check name

2 years ago[clang-tidy] Initialize boolean variables with `false` in cppcoreguidelines-init...
Danny Mösch [Sat, 9 Jul 2022 12:38:41 +0000 (14:38 +0200)]
[clang-tidy] Initialize boolean variables with `false` in cppcoreguidelines-init-variables' fix-it

In case of a variable with a built-in boolean type, `false` is a better fit to default-initialize it.

Reviewed By: njames93

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

2 years ago[C++20][Modules] Fix two tests for CTORs that return pointers [NFC].
Iain Sandoe [Sat, 9 Jul 2022 10:18:49 +0000 (11:18 +0100)]
[C++20][Modules] Fix two tests for CTORs that return pointers [NFC].

The test are to check that we call the correctly mangled CTORs, so that
the return values from them are irrelevant.  I forgot that some targets
return a pointer, apologies for the breakage.

2 years ago[Clang] Add a warning on invalid UTF-8 in comments.
Corentin Jabot [Fri, 17 Jun 2022 14:23:41 +0000 (16:23 +0200)]
[Clang] Add a warning on invalid UTF-8 in comments.

Introduce an off-by default `-Winvalid-utf8` warning
that detects invalid UTF-8 code units sequences in comments.

Invalid UTF-8 in other places is already diagnosed,
as that cannot appear in identifiers and other grammar constructs.

The warning is off by default as its likely to be somewhat disruptive
otherwise.

This warning allows clang to conform to the yet-to be approved WG21
"P2295R5 Support for UTF-8 as a portable source file encoding"
paper.

Reviewed By: aaron.ballman, #clang-language-wg

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

2 years ago[CMake] Set the common link flags for memprof tests
Petr Hosek [Sat, 9 Jul 2022 08:59:58 +0000 (08:59 +0000)]
[CMake] Set the common link flags for memprof tests

This was missed in ba007f20bb4acf95262f49ab527ce35c4a1f5a19 by mistake.

2 years ago[C++20][Modules] Build module static initializers per P1874R1.
Iain Sandoe [Sun, 15 May 2022 13:47:54 +0000 (14:47 +0100)]
[C++20][Modules] Build module static initializers per P1874R1.

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

Intended result:

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

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

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

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

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

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

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

Implementation:

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

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

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

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

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

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

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

2 years ago[clang] Add a fixit for warn-self-assign if LHS is a field with the same name as...
Nathan James [Sat, 9 Jul 2022 07:28:07 +0000 (08:28 +0100)]
[clang] Add a fixit for warn-self-assign if LHS is a field with the same name as parameter on RHS

Add a fix-it for the common case of setters/constructors using parameters with the same name as fields
```lang=c++
struct A{
  int X;
  A(int X) { /*this->*/X = X; }
  void setX(int X) { /*this->*/X = X;
};
```

Reviewed By: aaron.ballman

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

2 years ago[mlir][bufferization] Do not canonicalize to_tensor(to_memref(x))
Matthias Springer [Sat, 9 Jul 2022 07:15:36 +0000 (09:15 +0200)]
[mlir][bufferization] Do not canonicalize to_tensor(to_memref(x))

This is a partial revert of D128615.

to_memref(to_tensor(x)) always be folded to x. But to_tensor(to_memref(x)) cannot be folded in the general case because writes to the intermediary memref may go unnoticed.

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

2 years ago[AMDGPU][NFC] Harmonize decl&def of R600TargetLowering::OptimizeSwizzle
serge-sans-paille [Sat, 9 Jul 2022 07:05:22 +0000 (09:05 +0200)]
[AMDGPU][NFC] Harmonize decl&def of R600TargetLowering::OptimizeSwizzle

The freshly baked -Warray-parameter warning discovered an inconsistency in
argument declaration, use the stricter one.

This fixes build issues like https://lab.llvm.org/buildbot#builders/18/builds/5305

2 years ago[clang-format] Fix an assertion failure on -lines=0:n
owenca [Fri, 8 Jul 2022 06:34:44 +0000 (23:34 -0700)]
[clang-format] Fix an assertion failure on -lines=0:n

Also fixed the error message for start line > end line and added test cases.

Fixes #56438.

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

2 years ago[CMake] Use explicit header path when using in-tree libc++ for tests
Petr Hosek [Fri, 17 Jun 2022 08:11:32 +0000 (08:11 +0000)]
[CMake] Use explicit header path when using in-tree libc++ for tests

This is a follow up to D118200 which applies a similar cleanup to
headers when using in-tree libc++ to avoid accidentally picking up
the system headers.

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

2 years ago[Inliner] Make recusive inlinee stack size limit tunable
Wenlei He [Sat, 9 Jul 2022 00:17:11 +0000 (17:17 -0700)]
[Inliner] Make recusive inlinee stack size limit tunable

For recursive callers, we want to be conservative when inlining callees with large stack size. We currently have a limit `InlineConstants::TotalAllocaSizeRecursiveCaller`, but that is hard coded.

We found the current limit insufficient to suppress problematic inlining that bloats stack size for deep recursion. This change adds a switch to make the limit tunable as a mitigation.

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

2 years agoRevert "[CMake] Use explicit header path when using in-tree libc++ for tests"
Petr Hosek [Sat, 9 Jul 2022 04:27:16 +0000 (04:27 +0000)]
Revert "[CMake] Use explicit header path when using in-tree libc++ for tests"

This reverts commit 61b410cb8b9af0aa265e730a3070b3154d869803 as this
appears to have broken some sanitizer tests.

2 years ago[CMake] Use explicit header path when using in-tree libc++ for tests
Petr Hosek [Fri, 17 Jun 2022 08:11:32 +0000 (08:11 +0000)]
[CMake] Use explicit header path when using in-tree libc++ for tests

This is a follow up to D118200 which applies a similar cleanup to
headers when using in-tree libc++ to avoid accidentally picking up
the system headers.

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

2 years ago[clangd] Support "usedAsMutableReference" in member initializations
Christian Kandeler [Fri, 8 Jul 2022 08:12:31 +0000 (04:12 -0400)]
[clangd] Support "usedAsMutableReference" in member initializations

That is, mark constructor parameters being used to initialize
non-const reference members.

Reviewed By: nridge

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

2 years ago[libcxx] Uglify __support/openbsd
Brad Smith [Sat, 9 Jul 2022 01:33:57 +0000 (21:33 -0400)]
[libcxx] Uglify __support/openbsd

Uglify __support/openbsd

Reviewed By: philnik

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

2 years ago[NFC][OpenMP][Offloading] Fix compilation warning caused by misuse of `static_cast`
Shilei Tian [Sat, 9 Jul 2022 00:59:37 +0000 (20:59 -0400)]
[NFC][OpenMP][Offloading] Fix compilation warning caused by misuse of `static_cast`

2 years ago[mlir:LSP] Drop potentialy annoying completion commit characters
River Riddle [Sat, 9 Jul 2022 00:56:48 +0000 (17:56 -0700)]
[mlir:LSP] Drop potentialy annoying completion commit characters

These can result in accidentally accepting a completion when it isn't intended.

2 years ago[mlir:LSP] Add code completions for builtin signed/unsigned integers
River Riddle [Sat, 9 Jul 2022 00:55:30 +0000 (17:55 -0700)]
[mlir:LSP] Add code completions for builtin signed/unsigned integers

2 years ago[mlir:LSP] Add support for code completing attributes and types
River Riddle [Thu, 7 Jul 2022 05:54:36 +0000 (22:54 -0700)]
[mlir:LSP] Add support for code completing attributes and types

This required changing a bit of how attributes/types are parsed. A new
`KeywordSwitch` class was added to AsmParser that provides a StringSwitch
like API for parsing keywords with a set of potential matches. It intends to
both provide a cleaner API, and enable injection for code completion. This
required changing the API of `generated(Attr|Type)Parser` to handle the
parsing of the keyword, instead of having the user do it. Most upstream
dialects use the autogenerated handling and didn't require a direct update.

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

2 years ago[mlir:LSP] Add support for keyword code completions
River Riddle [Wed, 6 Jul 2022 09:49:58 +0000 (02:49 -0700)]
[mlir:LSP] Add support for keyword code completions

This commit adds code completion results to the MLIR LSP when
parsing keywords. Keyword support is currently limited to the
case where the expected keyword is provided, but a followup will
work on expanding the set of keyword cases we handle (e.g. to
allow capturing attribute/type mnemonics).

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

2 years ago[libc] add printf hexadecimal float conversion
Michael Jones [Wed, 6 Jul 2022 23:53:34 +0000 (16:53 -0700)]
[libc] add printf hexadecimal float conversion

This patch adds the %a/A conversions to printf, as well as the compiler
flag to disable floating point handling entirely. This will allow our
printf implementation to display every type of argument allowed by
printf, although some formats are still incomplete.

Reviewed By: sivachandra

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

2 years agoReplace hard coded number with regex so the test passes on downstream projects that...
Douglas Yung [Fri, 8 Jul 2022 22:47:03 +0000 (15:47 -0700)]
Replace hard coded number with regex so the test passes on downstream projects that may define additional opcodes.

2 years ago[libc] add dependencies to generic sqrt tests
Michael Jones [Fri, 8 Jul 2022 18:35:29 +0000 (11:35 -0700)]
[libc] add dependencies to generic sqrt tests

This adds dependencies on the corresponding sqrt function to each
generic sqrt test. This is so that on platforms that don't support the
math functions, the tests are not run.

Reviewed By: lntue

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

2 years ago[AIX][clang/test] Set/propagate AIXTHREAD_STK for AIX
Hubert Tong [Fri, 8 Jul 2022 22:30:48 +0000 (18:30 -0400)]
[AIX][clang/test] Set/propagate AIXTHREAD_STK for AIX

Some tests perform deep recursion, which requires a larger pthread stack
size than the relatively low default of 192 KiB for 64-bit processes on
AIX. The `AIXTHREAD_STK` environment variable provides a non-intrusive
way to request a larger pthread stack size for the tests. The required
pthread stack size depends on the build configuration.

A 4 MiB default is generous compared to the 512 KiB of macOS; however,
it is known that some compilers on AIX produce code that uses
comparatively more stack space.

This patch expands the solution from D65688 to apply to all Clang LIT
tests.

This also reverts commit c3c75d805c2174388417080f762230961b3433d6,
"[clang][test] Mark test arm-float-abi-lto.c unsupported on AIX".

The problem was caused by the test running up against the per-thread
stack limit on AIX. This is resolved by having the tests run with
`AIXTHREAD_STK` set for 4 MiB.

Reviewed By: xingxue

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

2 years ago[BOLT][Runtime] Fix memset definition
Vladislav Khmelevsky [Thu, 7 Jul 2022 11:48:47 +0000 (14:48 +0300)]
[BOLT][Runtime] Fix memset definition

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

2 years agojGetLoadedDynamicLibrariesInfos can inspect machos not yet loaded
Jason Molenda [Fri, 8 Jul 2022 21:01:15 +0000 (14:01 -0700)]
jGetLoadedDynamicLibrariesInfos can inspect machos not yet loaded

jGetLoadedDynamicLibrariesInfos normally checks with dyld to find
the list of binaries loaded in the inferior, and getting the filepath,
before trying to parse the Mach-O binary in inferior memory.
This allows for debugserver to parse a Mach-O binary present in memory,
but not yet registered with dyld.  This patch also adds some simple
sanity checks that we're reading a Mach-O header before we begin
stepping through load commands, because we won't have the sanity check
of consulting dyld for the list of loaded binaries before parsing.
Also adds a testcase.

Differential Revision: https://reviews.llvm.org/D128956
rdar://95737734

2 years ago[CMake] Option to select C++ library for runtimes that use it
Petr Hosek [Thu, 2 Jun 2022 21:52:56 +0000 (21:52 +0000)]
[CMake] Option to select C++ library for runtimes that use it

We currently have an option to select C++ ABI and C++ library for tests
but there are runtimes that use C++ library, specifically ORC and XRay,
which aren't covered by existing options. This change introduces a new
option to control the use of C++ libray for these runtimes.

Ideally, this option should become the default way to select C++ library
for all of compiler-rt replacing the existing options (the C++ ABI
option could remain as a hidden internal option).

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

2 years agoRemove unnecessary braces
David Blaikie [Fri, 8 Jul 2022 21:37:24 +0000 (21:37 +0000)]
Remove unnecessary braces

2 years agollvm-dwarfdump: Don't crash if DW_AT_{decl,call}_{file,line} uses signed form
Pedro Alves [Fri, 8 Jul 2022 21:15:52 +0000 (21:15 +0000)]
llvm-dwarfdump: Don't crash if DW_AT_{decl,call}_{file,line} uses signed form

The DWARF spec says:

 Any debugging information entry representing the declaration of an object,
 module, subprogram or type may have DW_AT_decl_file, DW_AT_decl_line and
 DW_AT_decl_column attributes, each of whose value is an unsigned integer
 ^^^^^^^^
 constant.

If however, a producer happens to emit DW_AT_decl_file /
DW_AT_decl_line using a signed integer form, llvm-dwarfdump crashes,
like so:

     (... snip ...)
     0x000000b4:   DW_TAG_structure_type
                     DW_AT_name      ("test_struct")
                     DW_AT_byte_size (136)
                     DW_AT_decl_file (llvm-dwarfdump: (... snip ...)/llvm/include/llvm/ADT/Optional.h:197: T& llvm::optional_detail::OptionalStorage<T, true>::getValue() &
 [with T = long unsigned int]: Assertion `hasVal' failed.
     PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
     Stack dump:
     0.      Program arguments: /opt/rocm/llvm/bin/llvm-dwarfdump ./testsuite/outputs/gdb.rocm/lane-pc-vega20/lane-pc-vega20-kernel.so
      #0 0x000055cc8e78315f PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
      #1 0x000055cc8e780d3d SignalHandler(int) Signals.cpp:0:0
      #2 0x00007f8f2cae8420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
      #3 0x00007f8f2c58d00b raise /build/glibc-SzIz7B/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
      #4 0x00007f8f2c56c859 abort /build/glibc-SzIz7B/glibc-2.31/stdlib/abort.c:81:7
      #5 0x00007f8f2c56c729 get_sysdep_segment_value /build/glibc-SzIz7B/glibc-2.31/intl/loadmsgcat.c:509:8
      #6 0x00007f8f2c56c729 _nl_load_domain /build/glibc-SzIz7B/glibc-2.31/intl/loadmsgcat.c:970:34
      #7 0x00007f8f2c57dfd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
      #8 0x000055cc8e58ceb9 llvm::DWARFDie::dump(llvm::raw_ostream&, unsigned int, llvm::DIDumpOptions) const (/opt/rocm/llvm/bin/llvm-dwarfdump+0x2e0eb9)
      #9 0x000055cc8e58bec3 llvm::DWARFDie::dump(llvm::raw_ostream&, unsigned int, llvm::DIDumpOptions) const (/opt/rocm/llvm/bin/llvm-dwarfdump+0x2dfec3)
     #10 0x000055cc8e5b28a3 llvm::DWARFCompileUnit::dump(llvm::raw_ostream&, llvm::DIDumpOptions) (.part.21) DWARFCompileUnit.cpp:0:0

Likewise with DW_AT_call_file / DW_AT_call_line.

The problem is that the code in llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
dumping these attributes assumes that
FormValue.getAsUnsignedConstant() returns an armed optional.  If in
debug mode, we get an assertion line the above.  If in release mode,
and asserts are compiled out, then we proceed as if the optional had a
value, running into undefined behavior, printing whatever random
value.

Fix this by checking whether the optional returned by
FormValue.getAsUnsignedConstant() has a value, like done in other
places.

In addition, DWARFVerifier.cpp is validating DW_AT_call_file /
DW_AT_decl_file, but not AT_call_line / DW_AT_decl_line.  This commit
fixes that too.

The llvm-dwarfdump/X86/verify_file_encoding.yaml testcase is extended
to cover these cases.  Current llvm-dwarfdump crashes running the
newly-extended test.

"make check-llvm-tools-llvm-dwarfdump" shows no regressions, on x86-64
GNU/Linux.

Reviewed By: dblaikie

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

2 years ago[Sanitizer][Darwin] Cleanup MaybeReexec() function and usage
Julian Lettner [Fri, 1 Jul 2022 18:05:40 +0000 (11:05 -0700)]
[Sanitizer][Darwin] Cleanup MaybeReexec() function and usage

While investigating another issue, I noticed that `MaybeReexec()` never
actually "re-executes via `execv()`" anymore.  `DyldNeedsEnvVariable()`
only returned true on macOS 10.10 and below.

Usually, I try to avoid "unnecessary" cleanups (it's hard to be certain
that there truly is no fallout), but I decided to do this one because:

* I initially tricked myself into thinking that `MaybeReexec()` was
  relevant to my original investigation (instead of being dead code).
* The deleted code itself is quite complicated.
* Over time a few other things were mushed into `MaybeReexec()`:
  initializing `MonotonicNanoTime()`, verifying interceptors are
  working, and stripping the `DYLD_INSERT_LIBRARIES` env var to avoid
  problems when forking.
* This platform-specific thing leaked into `sanitizer_common.h`.
* The `ReexecDisabled()` config nob relies on the "strong overrides weak
  pattern", which is now problematic and can be completely removed.
* `ReexecDisabled()` actually hid another issue with interceptors not
  working in unit tests.  I added an explicit `verify_interceptors`
  (defaults to `true`) option instead.

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

2 years ago[Clang] Fix the wrong features being derivec in the offload packager
Joseph Huber [Fri, 8 Jul 2022 19:59:10 +0000 (15:59 -0400)]
[Clang] Fix the wrong features being derivec in the offload packager

The offload packager embeds the features in the offloading binary when
performing LTO. This had an incorrect interaction with the
`--cuda-feature` option because we weren't deriving the features from
the CUDA toolchain arguments when it was being specified. This patch
fixes this so the features are correctly overrideen when using this
argument.

However, this brings up a question of how best to handle conflicting
target features. The user could compile many libraries with different
features, in this case we do not know which one to pick. This was not
previously a problem when we simply passed the features in from the CUDA
installation at link-link because we just defaulted to whatever was
current on the system.

Reviewed By: ye-luo

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

2 years ago[LinkerWrapper] Fix use of string savers and correctly pass bitcode libraries
Joseph Huber [Fri, 8 Jul 2022 17:33:46 +0000 (13:33 -0400)]
[LinkerWrapper] Fix use of string savers and correctly pass bitcode libraries

This patch removes some uses of string savers that are no-longer needed.
We also create a new string saver when linking bitcode files. It seems
that occasionally the symbol string references can go out of scope when
they are added to the LTO input so we need to save these names that are
used for symbol resolution. Additionally, a previous patch added new
logic for handling bitcode libraries, but failed to actually add them to
the input. This bug has been fixed.

Fixes #56445

Reviewed By: ye-luo

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

2 years ago[clang] [Serialization] Fix swapped PPOpts/ExistingPPOpts parameters. NFC.
Martin Storsjö [Wed, 25 May 2022 12:07:18 +0000 (15:07 +0300)]
[clang] [Serialization] Fix swapped PPOpts/ExistingPPOpts parameters. NFC.

The two first parameters of checkPreprocessorOptions are "PPOpts, ExistingPPOpts".
All other callers of the function pass them consistently.

This avoids confusion when working on the code.

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

2 years ago[ELF] Refactor ELFCOMPRESS_ZLIB handling and improve diagnostics
Fangrui Song [Fri, 8 Jul 2022 21:04:19 +0000 (14:04 -0700)]
[ELF] Refactor ELFCOMPRESS_ZLIB handling and improve diagnostics

And add some tests.

2 years ago[gn build] Port c945bd0da652
LLVM GN Syncbot [Fri, 8 Jul 2022 20:59:26 +0000 (20:59 +0000)]
[gn build] Port c945bd0da652

2 years ago[libc++] Always build c++experimental.a
Louis Dionne [Thu, 30 Jun 2022 15:24:43 +0000 (11:24 -0400)]
[libc++] Always build c++experimental.a

This is the first part of a plan to ship experimental features
by default while guarding them behind a compiler flag to avoid
users accidentally depending on them. Subsequent patches will
also encompass incomplete features (such as <format> and <ranges>)
in that categorization. Basically, the idea is that we always
build and ship the c++experimental library, however users can't
use what's in it unless they pass the `-funstable` flag to Clang.

Note that this patch intentionally does not start guarding
existing <experimental/FOO> content behind the flag, because
that would merely break users that might be relying on such
content being in the headers unconditionally. Instead, we
should start guarding new TSes behind the flag, and get rid
of the existing TSes we have by shipping their Standard
counterpart.

Also, this patch must jump through a few hoops like defining
_LIBCPP_ENABLE_EXPERIMENTAL because we still support compilers
that do not implement -funstable yet.

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

2 years ago[libc++][ranges] Implement modifying heap algorithms:
Konstantin Varlamov [Fri, 8 Jul 2022 20:46:27 +0000 (13:46 -0700)]
[libc++][ranges] Implement modifying heap algorithms:

- `ranges::make_heap`;
- `ranges::push_heap`;
- `ranges::pop_heap`;
- `ranges::sort_heap`.

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

2 years agoRevert "[llvm] cmake config groundwork to have ZSTD in LLVM"
Leonard Chan [Fri, 8 Jul 2022 20:48:05 +0000 (13:48 -0700)]
Revert "[llvm] cmake config groundwork to have ZSTD in LLVM"

This reverts commit f07caf20b9d35e45501c9d5d903fa182b3bdb95a which seems to break upstream https://lab.llvm.org/buildbot/#/builders/109/builds/42253.

2 years agoRevert "[llvm] cmake config groundwork to have ZSTD in LLVM"
Leonard Chan [Fri, 8 Jul 2022 20:46:44 +0000 (13:46 -0700)]
Revert "[llvm] cmake config groundwork to have ZSTD in LLVM"

This reverts commit adf1ffe95854a245cbc48bbaea55f60b003d5f76 and f07caf20b9d35e45501c9d5d903fa182b3bdb95a
which seem to break upstream https://lab.llvm.org/buildbot/#/builders/109/builds/42253.

2 years ago[clang] Introduce -Warray-parameter
serge-sans-paille [Thu, 23 Jun 2022 14:20:09 +0000 (16:20 +0200)]
[clang] Introduce -Warray-parameter

This warning exist in GCC[0] and warns about re-declarations of functions
involving arguments of array or pointer types of inconsistent kinds or forms.

This is not the exact same implementation as GCC's : there's no warning level
and that flag has no effect on -Warray-bounds.

[0] https://gcc.gnu.org/onlinedocs/gcc-12.1.0/gcc/Warning-Options.html#index-Wno-array-parameter

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

2 years ago[llvm] cmake config groundwork to have ZSTD in LLVM
Cole Kissane [Fri, 8 Jul 2022 19:36:27 +0000 (12:36 -0700)]
[llvm] cmake config groundwork to have ZSTD in LLVM

- added `FindZSTD.cmake`
- added a CMake option `LLVM_ENABLE_ZSTD` with behavior mirroring that of `LLVM_ENABLE_ZLIB`
- likewise added have_zstd to compiler-rt/test/lit.common.cfg.py, clang-tools-extra/clangd/test/lit.cfg.py, and several lit.site.cfg.py.in files mirroring have_zlib behavior

Reviewed By: leonardchan, MaskRay

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

2 years ago[llvm] cmake config groundwork to have ZSTD in LLVM
Cole Kissane [Fri, 8 Jul 2022 18:46:51 +0000 (11:46 -0700)]
[llvm] cmake config groundwork to have ZSTD in LLVM

- added `FindZSTD.cmake`
- added a CMake option `LLVM_ENABLE_ZSTD` with behavior mirroring that of `LLVM_ENABLE_ZLIB`
- likewise added have_zstd to compiler-rt/test/lit.common.cfg.py, clang-tools-extra/clangd/test/lit.cfg.py, and several lit.site.cfg.py.in files mirroring have_zlib behavior

Reviewed By: leonardchan, MaskRay

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

2 years ago[Libomptarget][NFC] Move legacy functions to a separate file
Joseph Huber [Thu, 7 Jul 2022 18:46:49 +0000 (14:46 -0400)]
[Libomptarget][NFC] Move legacy functions to a separate file

This patch moves the old legacy interfaces into `libomptarget` to a
separate file. These do not need to be included anywhere and are simply
provided for backwards compatibility with the ABI. This cleans up the
interface greatly.

Depends on D128817

Reviewed By: JonChesterfield

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

2 years ago[Libomptarget] Use new tripcount argument in the runtime.
Joseph Huber [Mon, 27 Jun 2022 16:26:58 +0000 (12:26 -0400)]
[Libomptarget] Use new tripcount argument in the runtime.

The previous patch added an argument to the `__tgt_target_kernel`
runtime function which includes the tripcount used for the loop clause.
This was originally passed in via the `__kmpc_push_target_tripcount`
function. Now we move this logic to the kernel launch itself and remove
the need for the push function.

Depends on D128816

Reviewed By: jdoerfert

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

2 years ago[OpenMP] Add loop tripcount argument to kernel launch and remove push function
Joseph Huber [Mon, 27 Jun 2022 16:23:50 +0000 (12:23 -0400)]
[OpenMP] Add loop tripcount argument to kernel launch and remove push function

Previously we added the `push_target_tripcount` function to send the
loop tripcount to the device runtime so we knew how to configure the
teams / threads for execute the loop for a teams distribute construct.
This was implemented as a separate function mostly to avoid changing the
interface for backwards compatbility. Now that we've changed it anyway
and the new interface can take an arbitrary number of arguments via the
struct without changing the ABI, we can move this to the new interface.
This will simplify the runtime by removing unnecessary state between
calls.

Depends on D128550

Reviewed By: jdoerfert

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

2 years ago[OpenMP] Change OpenMP code generation for target region entries
Joseph Huber [Fri, 24 Jun 2022 13:13:53 +0000 (09:13 -0400)]
[OpenMP] Change OpenMP code generation for target region entries

This patch changes the code we generate to enter a target region on the
device. This is in-line with the new definition in the runtime that was
added previously. Additionally we implement this in the OpenMPIRBuilder
so that this code can be shared with Flang in the future.

Reviewed By: ABataev

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

2 years ago[Libomptarget] Implement a unified kernel entry function
Joseph Huber [Thu, 23 Jun 2022 18:57:59 +0000 (14:57 -0400)]
[Libomptarget] Implement a unified kernel entry function

This patch implements a unified kernel entry function that will be
targeted from both teams and non-teams clauses. We introduce a new
interface and make the old functions call in using the new one. A
following patch will include the necessary changes to Clang to call
these new functions instead.

Reviewed By: jdoerfert

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

2 years ago[gn build] Port 23c7328bad92
LLVM GN Syncbot [Fri, 8 Jul 2022 18:34:42 +0000 (18:34 +0000)]
[gn build] Port 23c7328bad92

2 years ago[mlir] Add method to populate default attributes
Jacques Pienaar [Fri, 8 Jul 2022 18:31:12 +0000 (11:31 -0700)]
[mlir] Add method to populate default attributes

Previously default attributes were only usable by way of the ODS generated
accessors, but this was undesirable as
1. The ODS getters could construct Attribute each get request;
2. For non-C++ uses this would require either duplicating some of tee default
   attribute generating or generating additional bindings to generate methods;
3. Accessing op.getAttr("foo") and op.getFoo() would return different results;
Generate method to populate default attributes that can be used to address
these.

This merely adds this facility but does not employ by default on any path.

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

2 years ago[Clang][Docs] Update the clang-linker-wrapper documentation.
Joseph Huber [Fri, 8 Jul 2022 18:29:04 +0000 (14:29 -0400)]
[Clang][Docs] Update the clang-linker-wrapper documentation.

2 years ago[llvm-objdump] Fix alignment issues when dumping offloading sections
Joseph Huber [Fri, 8 Jul 2022 18:15:18 +0000 (14:15 -0400)]
[llvm-objdump] Fix alignment issues when dumping offloading sections

Summary:
The `.llvm.offloading` section should always be aligned by `8`. However,
we may want to show the offloading data stored in a static library. In
this case, even though the section's alignment is correct, the offset
inside the archive will result in the memory buffer being misaligned. TO
combat this we simply check if the buffer does not have the proper
alignment and copies it to a new buffer if not. This copy should have
the proper alignment.

2 years ago[objcxx] Fix `std::addressof` for `id`.
zoecarver [Fri, 8 Jul 2022 17:42:29 +0000 (10:42 -0700)]
[objcxx] Fix `std::addressof` for `id`.

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

2 years ago[libc++][ranges] Implement `ranges::nth_element`.
Konstantin Varlamov [Fri, 8 Jul 2022 03:35:51 +0000 (20:35 -0700)]
[libc++][ranges] Implement `ranges::nth_element`.

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

2 years ago[llvm] Remove unused and redundant crc32 funcction from llvm::compression::zlib namespace
Cole Kissane [Fri, 8 Jul 2022 18:24:45 +0000 (11:24 -0700)]
[llvm] Remove unused and redundant crc32 funcction from llvm::compression::zlib namespace

* Remove crc32 from zlib compression namespace, people should use the `llvm::crc32` instead.

Reviewed By: MaskRay, leonardchan

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

2 years ago[NFC] Fix cvt_f32_ubyte.ll test.
Daniil Fukalov [Fri, 8 Jul 2022 18:19:10 +0000 (21:19 +0300)]
[NFC] Fix cvt_f32_ubyte.ll test.

Remove (unintended) infinite loop in the test.

Reviewed By: vangthao

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

2 years ago[NFC] Refactor llvm::zlib namespace
Cole Kissane [Fri, 8 Jul 2022 18:19:05 +0000 (11:19 -0700)]
[NFC] Refactor llvm::zlib namespace

* Refactor compression namespaces across the project, making way for a possible
  introduction of alternatives to zlib compression.
  Changes are as follows:
  * Relocate the `llvm::zlib` namespace to `llvm::compression::zlib`.

Reviewed By: MaskRay, leonardchan, phosek

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

2 years agoUpdate references to Discourse instead of the mailing lists.
tlattner [Fri, 1 Jul 2022 21:07:48 +0000 (14:07 -0700)]
Update references to Discourse instead of the mailing lists.

Update the references to the old Mailman mailing lists to point to Discourse forums.

Reviewed By: aaron.ballman

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

2 years agoFix test: LLVMGetBitcodeModule takes ownership of memory buffer
Nicolai Hähnle [Mon, 4 Jul 2022 11:35:26 +0000 (13:35 +0200)]
Fix test: LLVMGetBitcodeModule takes ownership of memory buffer

Clarify this behavior in the C interface header file and fix a related
bug in a test.

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

2 years ago[C++20][Modules] Allow for redeclarations in partitions.
Iain Sandoe [Mon, 13 Jun 2022 09:15:50 +0000 (10:15 +0100)]
[C++20][Modules] Allow for redeclarations in partitions.

The existing provision is not sufficient, it did not allow for the cases
where an implementation partition includes the primary module interface,
or for the case that an exported interface partition is contains a decl
that is then implemented in a regular implementation unit.

It is somewhat unfortunate that we have to compare top level module names
to achieve this, since built modules are not necessarily available.

TODO: It might be useful to cache a hash of the primary module name if
this test proves to be a  significant load.

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

2 years ago[vscode-mlir] add tablegen <> bracket colorization
Ryan Thomas Lynch (@emosy) [Fri, 8 Jul 2022 17:58:20 +0000 (10:58 -0700)]
[vscode-mlir] add tablegen <> bracket colorization

Add support for colorizing angle brackets "<>" in TableGen files.

Reviewed By: rriddle

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

2 years ago[mlir][tosa] Enable decomposing Conv2D also where 1 input dim is dynamic
Jacques Pienaar [Fri, 8 Jul 2022 17:57:04 +0000 (10:57 -0700)]
[mlir][tosa] Enable decomposing Conv2D also where 1 input dim is dynamic

Restricted to just 1 dynamic input dim as that worked all the way through to
codegen.

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

2 years ago[RISCV] Switch to using get.active.lane.mask when tail folding
Philip Reames [Fri, 8 Jul 2022 17:19:49 +0000 (10:19 -0700)]
[RISCV] Switch to using get.active.lane.mask when tail folding

The motivation here is to a) bring us closer into alignment with AArch64 under the assumption that codepath is better tested, and b) simplify pattern matching in an upcoming change.

The immediate impact is a significant IR reduction but a fairly minimal change in the generated assembly. Due to a difference in expansion behavior we get a saturating add vs an unsaturating one for the old code, but that's about it. This difference comes down to different handling of overflow, which doesn't seem to be possible here anyways, so the assembly codegen is arguably a minor regression. I don't expect that to matter in practice.

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

2 years ago[RISCV] Mark fminnum_vl and fmaxnum_vl as commutable.
Craig Topper [Fri, 8 Jul 2022 17:14:27 +0000 (10:14 -0700)]
[RISCV] Mark fminnum_vl and fmaxnum_vl as commutable.

2 years ago[RISCV] Add commuted fixed vector vfmax.vf and vfmin.vf tests. NFC
Craig Topper [Fri, 8 Jul 2022 17:11:44 +0000 (10:11 -0700)]
[RISCV] Add commuted fixed vector vfmax.vf and vfmin.vf tests. NFC

The ISD opcodes aren't marked commutable so we don't match these
properly.

2 years ago[RISCV] Mark vsadd(u)_vl as commutable
Philip Reames [Fri, 8 Jul 2022 17:09:49 +0000 (10:09 -0700)]
[RISCV] Mark vsadd(u)_vl as commutable

This allows fixed length vectors involving splats on the LHS to commute into the _vx form of the instruction. Oddly, the generic canonicalization rules appear to catch the scalable vector cases. I haven't fully dug in to understand why, but I suspect it's because of a difference in how we represent splats (splat_vector vs build_vector).

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

2 years ago[DWARF] Add linkagename to hash
Alexander Yermolovich [Thu, 7 Jul 2022 18:41:51 +0000 (11:41 -0700)]
[DWARF] Add linkagename to hash

Originally encountered with RUST, but also there are cases with distributed LTO
where debug info dwo units contain structurally the same debug information, with
difference in DW_AT_linkage_name. This causes collision on DWO ID.

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

2 years ago[mlir] Fixed double-free bug in SymbolUserMap
Nandor Licker [Fri, 8 Jul 2022 05:57:37 +0000 (08:57 +0300)]
[mlir] Fixed double-free bug in SymbolUserMap

`SymbolUserMap` relied on `try_emplace` and `std::move` to relocate an entry to another key.  However, if this triggered the resizing of the `DenseMap`, the value was destroyed before it could be moved to the new storage location, leading to a dangling `users` reference to be inserted into the map. On destruction, since a new entry was created from one that was already freed, a double-free error occurred.

Fixed issue by re-fetching the iterator after the mutation of the container.

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

2 years ago[RISCV] Mark (s/u)min_vl and (s/u)max_vl as commutable.
Craig Topper [Fri, 8 Jul 2022 16:54:48 +0000 (09:54 -0700)]
[RISCV] Mark (s/u)min_vl and (s/u)max_vl as commutable.

2 years ago[RISCV] Add fixed vector vmin(u).vx and vmax(u).vx tests. NFC
Craig Topper [Fri, 8 Jul 2022 16:47:43 +0000 (09:47 -0700)]
[RISCV] Add fixed vector vmin(u).vx and vmax(u).vx tests. NFC

2 years ago[X86] Regenerate vec_shift6.ll to remove superfluous whitespace. NFC
Simon Pilgrim [Fri, 8 Jul 2022 16:59:10 +0000 (17:59 +0100)]
[X86] Regenerate vec_shift6.ll to remove superfluous whitespace. NFC

2 years ago[gn build] Manually port d2ead9e3
Arthur Eubanks [Fri, 8 Jul 2022 16:48:41 +0000 (09:48 -0700)]
[gn build] Manually port d2ead9e3

2 years ago[flang] Changed lowering for allocatable assignment to make array-value-copy correct.
Slava Zakharin [Fri, 1 Jul 2022 21:22:29 +0000 (14:22 -0700)]
[flang] Changed lowering for allocatable assignment to make array-value-copy correct.

Array-value-copy fails to generate a temporary array for case like this:
subroutine bug(b)
  real, allocatable :: b(:)
  b = b(2:1:-1)
end subroutine

Since LHS may need to be reallocated, lowering produces the following FIR:
%rhs_load = fir.array_load %b %slice

%lhs_mem = fir.if %b_is_allocated_with_right_shape {
   fir.result %b
} else {
   %new_storage = fir.allocmem %rhs_shape
   fir.result %new_storage
}

%lhs = fir.array_load %lhs_mem
%loop = fir.do_loop {
 ....
}
fir.array_merge_store %lhs, %loop to %lhs_mem
// deallocate old storage if reallocation occured,
// and update b descriptor if needed.

Since %b in array_load and %lhs_mem in array_merge_store are not the same SSA
values, array-value-copy does not detect the conflict and does not produce
a temporary array. This causes incorrect result in runtime.

The suggested change in lowering is to generate this:
%rhs_load = fir.array_load %b %slice
%lhs_mem = fir.if %b_is_allocated_with_right_shape {
   %lhs = fir.array_load %b
   %loop = fir.do_loop {
      ....
   }
   fir.array_merge_store %lhs, %loop to %b
   fir.result %b
} else {
   %new_storage = fir.allocmem %rhs_shape
   %lhs = fir.array_load %new_storage
   %loop = fir.do_loop {
      ....
   }
   fir.array_merge_store %lhs, %loop to %new_storage
   fir.result %new_storage
}
// deallocate old storage if reallocation occured,
// and update b descriptor if needed.

Note that there are actually 3 branches in FIR, so the assignment loops
are currently produced in three copies, which is a code-size issue.
It is possible to generate just two branches with two copies of the loops,
but it is not addressed in this change-set.

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

2 years ago[VPlan] Move VPWidenSelectRecipe::execute to VPlanRecipes.cpp (NFC).
Florian Hahn [Fri, 8 Jul 2022 16:33:17 +0000 (09:33 -0700)]
[VPlan] Move VPWidenSelectRecipe::execute to VPlanRecipes.cpp (NFC).

Depends on D127968.

Reviewed By: Ayal

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

2 years ago[libc++] Make parameter names consistent and enforce the naming style using readabili...
Nikolas Klauser [Fri, 8 Jul 2022 16:17:26 +0000 (18:17 +0200)]
[libc++] Make parameter names consistent and enforce the naming style using readability-identifier-naming

Ensure that parameter names have the style `__lower_case`

Reviewed By: ldionne, #libc

Spies: aheejin, sstefan1, libcxx-commits, miyuki

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