platform/upstream/llvm.git
14 months ago[flang][openacc] Add basic support for derived type component in data operand
Valentin Clement [Mon, 1 May 2023 23:15:34 +0000 (16:15 -0700)]
[flang][openacc] Add basic support for derived type component in data operand

Add lowering support for derived type component appearing
in a data clause to the newly added data operand operations.

Depends on D149297

Reviewed By: razvanlupusoru, jeanPerier

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

14 months ago[mlir][sparse] relax constraints on tensor.cast with pre-rewriting
Aart Bik [Mon, 1 May 2023 19:56:26 +0000 (12:56 -0700)]
[mlir][sparse] relax constraints on tensor.cast with pre-rewriting

Reviewed By: wrengr

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

14 months ago[OpenMP] Make `libomptarget` link against `libomp`
Shilei Tian [Mon, 1 May 2023 23:01:33 +0000 (19:01 -0400)]
[OpenMP] Make `libomptarget` link against `libomp`

In `libomptarget` we use a couple of functions from `libomp`, but we didn't link
`libomptarget` against `libomp`. That will not work on some platforms such
as macOS. A linker error will be encountered because those symbols are not resolved
at link time when building `libomptarget`. This patch simply makes `libomptarget`
link agains `libomp`, makes it a "user" of `libomp`. I think this will not break
the policies between `libomp` and `libomptarget`.

Reviewed By: jdoerfert

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

14 months agoRevert "Introduce MLIR Op Properties"
Mehdi Amini [Mon, 1 May 2023 22:55:58 +0000 (15:55 -0700)]
Revert "Introduce MLIR Op Properties"

This reverts commit d572cd1b067f1177a981a4711bf2e501eaa8117b.

Some bots are broken and investigation is needed before relanding.

14 months ago[OpenMP] Handle function calls from `libomp` to `libomptarget` correctly
Shilei Tian [Mon, 1 May 2023 22:25:11 +0000 (18:25 -0400)]
[OpenMP] Handle function calls from `libomp` to `libomptarget` correctly

D132005 introduced function calls from `libomp` to `libomptarget` if offloading
is enabled. However, the external function declaration may not always work. For
example, it causes a link error on macOS. Currently it is guarded properly by
a macro, but in order to get OpenMP target offloading working on macOS, it has
to be handled correctly. This patch applies the same idea of how we support
target memory extension by using function pointer indirect call for that function.

Reviewed By: jdoerfert

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

14 months agoIntroduce MLIR Op Properties
Mehdi Amini [Sun, 26 Feb 2023 15:46:01 +0000 (10:46 -0500)]
Introduce MLIR Op Properties

This new features enabled to dedicate custom storage inline within operations.
This storage can be used as an alternative to attributes to store data that is
specific to an operation. Attribute can also be stored inside the properties
storage if desired, but any kind of data can be present as well. This offers
a way to store and mutate data without uniquing in the Context like Attribute.
See the OpPropertiesTest.cpp for an example where a struct with a
std::vector<> is attached to an operation and mutated in-place:

struct TestProperties {
  int a = -1;
  float b = -1.;
  std::vector<int64_t> array = {-33};
};

More complex scheme (including reference-counting) are also possible.

The only constraint to enable storing a C++ object as "properties" on an
operation is to implement three functions:

- convert from the candidate object to an Attribute
- convert from the Attribute to the candidate object
- hash the object

Optional the parsing and printing can also be customized with 2 extra
functions.

A new options is introduced to ODS to allow dialects to specify:

  let usePropertiesForAttributes = 1;

When set to true, the inherent attributes for all the ops in this dialect
will be using properties instead of being stored alongside discardable
attributes.
The TestDialect showcases this feature.

Another change is that we introduce new APIs on the Operation class
to access separately the inherent attributes from the discardable ones.
We envision deprecating and removing the `getAttr()`, `getAttrsDictionary()`,
and other similar method which don't make the distinction explicit, leading
to an entirely separate namespace for discardable attributes.

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

14 months ago[RISCV] Don't store CPUKind in CPUInfo. NFC
Craig Topper [Mon, 1 May 2023 22:26:17 +0000 (15:26 -0700)]
[RISCV] Don't store CPUKind in CPUInfo. NFC

This field is never used today. If you have a pointer to the row
you can find the CPUKind by subtracting the pointer from the start
of the array.

14 months ago[RISCV] Remove INVALID from the list of CPUs in RISCVTargetParser. NFC
Craig Topper [Mon, 1 May 2023 22:26:09 +0000 (15:26 -0700)]
[RISCV] Remove INVALID from the list of CPUs in RISCVTargetParser. NFC

This value is never used outside and is only used as a sentinel
internally which we can solve with other means.

14 months ago[RISCV] Remove or simplify some StringSwitches in RISCVTargetParser.cpp. NFC
Craig Topper [Mon, 1 May 2023 22:26:03 +0000 (15:26 -0700)]
[RISCV] Remove or simplify some StringSwitches in RISCVTargetParser.cpp. NFC

We can iterate over the RISCVCPUInfo table instead of using a
separate StringSwitch.

14 months agoRecommit "[ValueTracking] Use knownbits interface for determining if `div`/`rem`...
Noah Goldstein [Mon, 1 May 2023 20:37:23 +0000 (15:37 -0500)]
Recommit "[ValueTracking] Use knownbits interface for determining if `div`/`rem` are safe to speculate" (2nd Try)

Add `poison` checks that where missing.

Reviewed By: nikic

14 months ago[InstCombine] Fix bug in `FoldOpIntoSelect` where we would incorrectly fold `undef...
Noah Goldstein [Mon, 1 May 2023 20:37:11 +0000 (15:37 -0500)]
[InstCombine] Fix bug in `FoldOpIntoSelect` where we would incorrectly fold `undef` as constant

D146349 Introduced the ability to use the information from the
`select` condition to deduce constants as we folded a binop into
select. I.e if the `select` cond was `icmp eq %A, 10`, then in the
true-arm of `select`, we would be able to replace usage of `A` with
`10`.

This is broken for vectors that contain `undef` elements. I.e with
`icmp eq %A, <10, undef>`, subsituting `<10, undef>` for `A` can
result in creating a more undefined result than we otherwise would
have.

We fix the issue with simply checking if the candidate constant for
substituting may contain `undef` elements and don't do it in that
case.

Reviewed By: nikic

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

14 months ago[libc++][PSTL] Fix clang-tidy
Nikolas Klauser [Fri, 28 Apr 2023 18:02:46 +0000 (11:02 -0700)]
[libc++][PSTL] Fix clang-tidy

Reviewed By: ldionne, #libc

Spies: libcxx-commits, miyuki, carlosgalvezp

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

14 months agoRevert "[OpenMP] Handle function calls from `libomp` to `libomptarget` correctly"
Shilei Tian [Mon, 1 May 2023 22:22:23 +0000 (18:22 -0400)]
Revert "[OpenMP] Handle function calls from `libomp` to `libomptarget` correctly"

This reverts commit 479e335fc37c06767654141358ea076ac066de11.

The assertion at `kmp_tasking.cpp(29)` is triggered.

14 months ago[OpenMP] Handle function calls from `libomp` to `libomptarget` correctly
Shilei Tian [Mon, 1 May 2023 22:16:32 +0000 (18:16 -0400)]
[OpenMP] Handle function calls from `libomp` to `libomptarget` correctly

D132005 introduced function calls from `libomp` to `libomptarget` if offloading
is enabled. However, the external function declaration may not always work. For
example, it causes a link error on macOS. Currently it is guarded properly by
a macro, but in order to get OpenMP target offloading working on macOS, it has
to be handled correctly. This patch applies the same idea of how we support
target memory extension by using function pointer indirect call for that function.

Reviewed By: jdoerfert

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

14 months ago[gn build] Port ade9c3bdca2c
LLVM GN Syncbot [Mon, 1 May 2023 21:30:38 +0000 (21:30 +0000)]
[gn build] Port ade9c3bdca2c

14 months ago[libc++][NFC] Fix typos in documentation
Louis Dionne [Mon, 1 May 2023 21:25:14 +0000 (17:25 -0400)]
[libc++][NFC] Fix typos in documentation

14 months agoImprove the help output for `type XXX delete` where XXX is summary, format,
Jim Ingham [Mon, 24 Apr 2023 23:08:27 +0000 (16:08 -0700)]
Improve the help output for `type XXX delete` where XXX is summary, format,
etc...

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

14 months ago[Clang] Fix a crash when recursively callig a default member initializer.
Corentin Jabot [Mon, 23 Jan 2023 21:05:48 +0000 (22:05 +0100)]
[Clang] Fix a crash when recursively callig a default member initializer.

This fixes a regression introduced by ca61961380, that would lead
to a segfault due to stack exhaustion when recursively calling
a default member initializer.

Fixes #60082

I'm not able to  get clang to emit a stack exhaustion warning,
which it seems like it should be able to.

Reviewed By: shafik

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

14 months agoRevert "[lldb] Make the libcxx unique_ptr prettyprinter support custom deleters."
Jorge Gorbe Moya [Mon, 1 May 2023 21:13:28 +0000 (14:13 -0700)]
Revert "[lldb] Make the libcxx unique_ptr prettyprinter support custom deleters."

This reverts commit d366da97bd24ddfb91c9f260fa0aaf105d947652.

14 months ago[libc++][NFC] Fix synopsis in a few tests
Nikolas Klauser [Mon, 1 May 2023 21:11:07 +0000 (14:11 -0700)]
[libc++][NFC] Fix synopsis in a few tests

14 months ago[lldb] Add debugger.external-editor setting
Jonas Devlieghere [Mon, 1 May 2023 21:08:43 +0000 (14:08 -0700)]
[lldb] Add debugger.external-editor setting

Add a new setting (debugger.external-editor) to specify an external
editor. The setting takes precedence over the existing
LLDB_EXTERNAL_EDITOR environment variable.

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

14 months ago[mlir][linalg] Relax masked_vectorize(pad) to allow zero low Values.
Hanhan Wang [Fri, 28 Apr 2023 18:16:26 +0000 (11:16 -0700)]
[mlir][linalg] Relax masked_vectorize(pad) to allow zero low Values.

It only accepted zeros attributes before the revision. It now acccepts
constant-like zero values as well.

Reviewed By: dcaballe

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

14 months ago[libc++][PSTL] Implement std::fill{,_n}
Nikolas Klauser [Fri, 28 Apr 2023 23:00:14 +0000 (16:00 -0700)]
[libc++][PSTL] Implement std::fill{,_n}

Reviewed By: ldionne, #libc

Spies: libcxx-commits

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

14 months ago[LV] Refresh some auto-gen tests to reduce diff [nfc]
Philip Reames [Mon, 1 May 2023 20:54:09 +0000 (13:54 -0700)]
[LV] Refresh some auto-gen tests to reduce diff [nfc]

14 months ago[MemProf] Recognize hot/cold operator new as replaceable allocations
Teresa Johnson [Mon, 1 May 2023 18:04:59 +0000 (11:04 -0700)]
[MemProf] Recognize hot/cold operator new as replaceable allocations

Follow up to LLVM-side change to allow conversion to hot/cold hinted
operator new, not yet standard but supported by open source tcmalloc.
The LLVM change in a35206d78280e0ebcf48cd21bc5fff5c3b9c73fa added the
necessary support to recognize these as library functions, and we
subsequently found that a clang-side change is needed to give them
builtin/nobuiltin attributes as appropriate so they have consistent
removeability.

Based on discussion with Richard Smith, converted the parameter type to
a reserved identifier (39f7b48671dae5fbe3afc49f33f50c2b6340bb89) and
added support in this patch to recognize it in clang.

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

14 months ago[lldb] Make the libcxx unique_ptr prettyprinter support custom deleters.
Jorge Gorbe Moya [Tue, 18 Apr 2023 20:19:45 +0000 (13:19 -0700)]
[lldb] Make the libcxx unique_ptr prettyprinter support custom deleters.

The unique_ptr prettyprinter calls `GetValueOfLibCXXCompressedPair`,
which looks for a `__value_` child. However, when the second value in
the compressed pair is not an empty class, there are two `__value_`
children because `__compressed_pair` derives twice from
`__compressed_pair_elem`, one for each member of the pair. And then the
lookup fails because it's ambiguous.

This patch makes the following changes:

- Rename `GetValueOfLibCXXCompressedPair` to
  `GetFirstValueOfLibCXXCompressedPair`, and add a similar function to
  get the second value. Put both functions in
  Plugin/Language/CPlusPlus/LibCxx.cpp because it seems inappropriate to
  have libcxx-specific helpers separate from all the libcxx-dependent
  code.

- Read the second value of the `__ptr_` pair and display a "deleter"
  child in the unique_ptr synthetic child provider, when available.

- Add a test case for the non-empty deleter case.

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

14 months ago[RISCV] Merge RISCV::parseCPUKind and RISCV::checkCPUKind.
Craig Topper [Mon, 1 May 2023 20:00:05 +0000 (13:00 -0700)]
[RISCV] Merge RISCV::parseCPUKind and RISCV::checkCPUKind.

Similar for RISCV::parseTuneCPU and RISCV::checkTuneCPUKind.

This makes the CPUKind enum no longer part of the API. It wasn't
providing much value. It was only used to pass between the two
functions.

By removing it, we can remove a dependency on a tablegen generated
file from the RISCVTargetParser.h file. Then we can remove a
dependency from several CMakeLists.txt.

14 months agoReland [clang] Canonicalize system headers in dependency file when -canonical-prefixes
Arthur Eubanks [Tue, 25 Apr 2023 20:16:01 +0000 (13:16 -0700)]
Reland [clang] Canonicalize system headers in dependency file when -canonical-prefixes

Clang was writing paths to the dependency file that don't exist when using a sysroot with symlinks, causing everything to get rebuilt every time. This is reproducible on Linux by creating a symlink to '/', using that as the sysroot, and trying to build something with ninja that includes the C++ stdlib (e.g. a typical build of LLVM).

This fixes https://github.com/ninja-build/ninja/issues/1330 and somewhat matches gcc.

gcc canonicalizes system headers in dependency files under a -f[no-]canonical-system-headers, but it makes more sense to look at -canonical-prefixes.

D37954 was a previous attempt at this.

Fixed use of %T instead of %t in test, causing bots to fail the test on the initial commit.

Reviewed By: hans

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

14 months ago[libc++][PSTL] Remove _PSTL_HIDE_FROM_ABI_{PUSH,POP} macros
Nikolas Klauser [Sat, 29 Apr 2023 00:19:41 +0000 (17:19 -0700)]
[libc++][PSTL] Remove _PSTL_HIDE_FROM_ABI_{PUSH,POP} macros

Reviewed By: ldionne, #libc

Spies: libcxx-commits, miyuki

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

14 months ago[gn build] Port 13fe6733019a
LLVM GN Syncbot [Mon, 1 May 2023 19:12:51 +0000 (19:12 +0000)]
[gn build] Port 13fe6733019a

14 months ago[RISCV] Move NTLH hint emission into RISCVAsmPrinter.cpp.
Craig Topper [Mon, 1 May 2023 19:05:16 +0000 (12:05 -0700)]
[RISCV] Move NTLH hint emission into RISCVAsmPrinter.cpp.

Rather than having a separate pass to add the hint instructions,
emit them directly into the streamer during asm printing.

Reviewed By: BeMg, kito-cheng

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

14 months ago[mlir][sparse] fix compiler warning in release build.
Peiming Liu [Mon, 1 May 2023 18:58:22 +0000 (18:58 +0000)]
[mlir][sparse] fix compiler warning in release build.

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

14 months ago[gn build] Port a595b931f1f9
LLVM GN Syncbot [Mon, 1 May 2023 18:48:32 +0000 (18:48 +0000)]
[gn build] Port a595b931f1f9

14 months ago[libc++] cuchar redeclares ::mbstate_t when it's in its own clang module
Ian Anderson [Mon, 17 Apr 2023 16:38:38 +0000 (09:38 -0700)]
[libc++] cuchar redeclares ::mbstate_t when it's in its own clang module

When cuchar is compiled independently on platforms that don't have <uchar.h>, it doesn't get a declaration of mbstate_t, and so makes an empty declaration for ::mbstate_t. That conflicts with the declarations in __mbstate_t.h and cwchar since both of those headers do get mbstate_t before making ::mbstate_t.

Change `__mbstate_t.h` to just get the underlying declaration for mbstate_t and not make a declaration for ::mbstate_t. Include __mbstate_t.h in uchar.h and wchar.h when their next headers aren't available so that at least mbstate_t gets defined.

Add __std_mbstate_t.h to declare ::mbstate_t for headers that need that when cuchar or cwchar aren't available (because either _LIBCPP_HAS_NO_WIDE_CHARACTERS or _LIBCPP_CXX03_LANG).

Reviewed By: ldionne, Mordante, #libc, philnik

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

14 months ago[mlir][arith] Add narrowing patterns to commute more vector ops
Jakub Kuderski [Mon, 1 May 2023 18:31:20 +0000 (14:31 -0400)]
[mlir][arith] Add narrowing patterns to commute more vector ops

This commutes the extension (`arith.extsi`, `arith.extui`) over the
following vector ops: `vector.broadcast`, `vector.shape_cast`,
`vector.transpose`, `vector.flat_transpose`.

I focused on these as I saw them getting created by vector unroll
patterns. Maybe except `vector.flat_transpose`.

Reviewed By: antiagainst

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

14 months ago[mlir][arith] Add narrowing patterns for other insertion ops
Jakub Kuderski [Mon, 1 May 2023 18:29:01 +0000 (14:29 -0400)]
[mlir][arith] Add narrowing patterns for other insertion ops

Allow to commute extension ops over `vector.insertelement` and
`vector.insert_strided_slice`.

Reviewed By: antiagainst

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

14 months ago[flang][openacc][NFC] Fix typos segement -> segment
Valentin Clement [Mon, 1 May 2023 18:28:20 +0000 (11:28 -0700)]
[flang][openacc][NFC] Fix typos segement -> segment

14 months agoRevert "[ValueTracking] Use knownbits interface for determining if `div`/`rem` are...
Noah Goldstein [Mon, 1 May 2023 18:20:09 +0000 (13:20 -0500)]
Revert "[ValueTracking] Use knownbits interface for determining if `div`/`rem` are safe to speculate"

Appears to be causing out-of-tree test failures. Reverting while the
issue is investigated.

This reverts commit fbc7fcf5ae26fad7db3e7c861fc6447e02b39cf0.

14 months ago[mlir][sparse] extend unpack operation to support unpacking a batched COO type
Peiming Liu [Fri, 21 Apr 2023 20:06:36 +0000 (20:06 +0000)]
[mlir][sparse] extend unpack operation to support unpacking a batched COO type

Reviewed By: aartbik

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

14 months agoRevert "[clang] Canonicalize system headers in dependency file when -canonical-prefixes"
Arthur Eubanks [Mon, 1 May 2023 17:55:23 +0000 (10:55 -0700)]
Revert "[clang] Canonicalize system headers in dependency file when -canonical-prefixes"

This reverts commit 8f0dd4ef3ed2137d1e2554204127434fc46ee190.

Causes bot failures: https://lab.llvm.org/buildbot/#builders/139/builds/39964

14 months ago[LAA] Add command line flag to disable unit stride speculation
Philip Reames [Mon, 1 May 2023 17:38:44 +0000 (10:38 -0700)]
[LAA] Add command line flag to disable unit stride speculation

This is purely so that we can expose and work through downstream codegen issues.  My intention is to see if we can get this disabled by default, but that requires fixing a bunch of downstream issues first.

14 months ago[clang] Canonicalize system headers in dependency file when -canonical-prefixes
Arthur Eubanks [Tue, 25 Apr 2023 20:16:01 +0000 (13:16 -0700)]
[clang] Canonicalize system headers in dependency file when -canonical-prefixes

Clang was writing paths to the dependency file that don't exist when using a sysroot with symlinks, causing everything to get rebuilt every time. This is reproducible on Linux by creating a symlink to '/', using that as the sysroot, and trying to build something with ninja that includes the C++ stdlib (e.g. a typical build of LLVM).

This fixes https://github.com/ninja-build/ninja/issues/1330 and somewhat matches gcc.

gcc canonicalizes system headers in dependency files under a -f[no-]canonical-system-headers, but it makes more sense to look at -canonical-prefixes.

D37954 was a previous attempt at this.

Reviewed By: hans

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

14 months ago[mlir][arith][NFC] Simplify narrowing patterns with a wrapper type
Jakub Kuderski [Mon, 1 May 2023 17:31:30 +0000 (13:31 -0400)]
[mlir][arith][NFC] Simplify narrowing patterns with a wrapper type

Add a new wraper type that represents either of `ExtSIOp` or `ExtUIOp`.
This is to simplify the code by using a single type, so that we do not
have to use templates or branching to handle both extension kinds.

Reviewed By: antiagainst

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

14 months agoFix ReleaseNotes.rst unresolved merge conflict
Alan Zhao [Mon, 1 May 2023 17:26:05 +0000 (10:26 -0700)]
Fix ReleaseNotes.rst unresolved merge conflict

14 months agoRevert "Host: generalise `GetXcodeSDKPath`"
Douglas Yung [Mon, 1 May 2023 17:22:53 +0000 (10:22 -0700)]
Revert "Host: generalise `GetXcodeSDKPath`"

This reverts commit ade3c6a6a88ed3a9b06c076406f196da9d3cc1b9.

This breaks the build with GCC and affects at least 2 build bots:
https://lab.llvm.org/buildbot/#/builders/217/builds/20568
https://lab.llvm.org/buildbot/#/builders/243/builds/5576

14 months ago[LAA] Rework overflow checking in getPtrStride [nfc]
Philip Reames [Mon, 1 May 2023 17:16:32 +0000 (10:16 -0700)]
[LAA] Rework overflow checking in getPtrStride [nfc]

The previous code structure and comments were exceedingly confusing.  I have multiple times looked at this code and suspected a bug.  This time, I decided to take the time to reflow the code and comment out why it is correct.

The only suspect (to me) case left is that an underaligned access with a unit stride (in terms of the access type) might miss the undefined null pointer when wrapping.  This is unlikely to be an issue for C/C++ code with real page sizes, so I'm not bothering to fully convince myself whether that case is correct or not.

14 months ago[llvm-profdata] Deprecate Compact Binary Sample Profile Format
William Huang [Sat, 29 Apr 2023 00:30:25 +0000 (00:30 +0000)]
[llvm-profdata] Deprecate Compact Binary Sample Profile Format

Remove support for compact binary sample profile format

Reviewed By: davidxl, wenlei

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

14 months ago[clang] Fix overly aggressive lifetime checks for parenthesized aggregate initialization
Alan Zhao [Thu, 13 Apr 2023 18:04:59 +0000 (11:04 -0700)]
[clang] Fix overly aggressive lifetime checks for parenthesized aggregate initialization

Before this patch, initialized class members would have the LifetimeKind
LK_MemInitializer, which does not allow for binding a temporary to a
reference. Binding to a temporary however is allowed in parenthesized
aggregate initialization, even if it leads to a dangling reference. To
fix this, we create a new EntityKind, EK_ParenAggInitMember, which has
LifetimeKind LK_FullExpression.

This patch does *not* attempt to diagnose dangling references as a
result of using this feature.

This patch also refactors TryOrBuildParenListInitialization(...) to
accomodate creating different InitializedEntity objects.

Fixes #61567

[0]: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0960r3.html

Reviewed By: shafik

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

14 months ago[flang][hlfir] Fixed boxchar variables emboxing.
Slava Zakharin [Mon, 1 May 2023 16:53:45 +0000 (09:53 -0700)]
[flang][hlfir] Fixed boxchar variables emboxing.

We have to unbox the boxchar variables in order to get to
the raw address that can be used for emboxing.

Reviewed By: jeanPerier

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

14 months ago[flang][hlfir] Fixed lowering for optional dummy.
Slava Zakharin [Mon, 1 May 2023 16:06:02 +0000 (09:06 -0700)]
[flang][hlfir] Fixed lowering for optional dummy.

We have to keep it as a box, since taking box_addr of the optional
box may be invalid.

Reviewed By: jeanPerier

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

14 months ago[InstCombine] Combine const GEP chains
Yingwei Zheng [Mon, 1 May 2023 16:06:26 +0000 (00:06 +0800)]
[InstCombine] Combine const GEP chains

This patch reverts rGae739aefd7473517d3f08b5c8d08a66c7f469198 to address performance regressions reported by our [CI](https://github.com/dtcxzyw/llvm-ci/issues/137) after rG2ec1d0f427c7822540352c0c14d057e7bfe4f77b.

For example:
```
define ptr @const_gep_chain(ptr %p, i64 %a) {
    %p1 = getelementptr inbounds i8, ptr %p, i64 %a
    %p2 = getelementptr inbounds i8, ptr %p1, i64 1
    %p3 = getelementptr inbounds i8, ptr %p2, i64 2
    %p4 = getelementptr inbounds i8, ptr %p3, i64 3
    ret ptr %p4
}
```
The last three GEPs will not be folded since rG2ec1d0f427c7822540352c0c14d057e7bfe4f77b.

I think it is appropriate to remove this code because there is no compile-time regression reported in our benchmarks.

Reviewed By: nikic

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

14 months ago[clang] Fix default initializers being ignored when initializing templated aggregate...
Alan Zhao [Thu, 27 Apr 2023 22:31:51 +0000 (15:31 -0700)]
[clang] Fix default initializers being ignored when initializing templated aggregate types

Previously, when checking whether an in-class initializer exists when
performing parenthesized aggregate initialization, Clang checks that the
output of FieldDecl::getInClassInitializer() is non-null. This is
incorrect; if the field is part of a templated type, then
getInClassInitializer() will return nullptr if we haven't called
Sem::BuildCXXDefaultInitExpr(...) before, even if
FieldDecl::hasInClassInitializer() returns true. The end result is that
Clang incorrectly ignores the in class initializer and
value-initializes the field. The fix therefore is to instead call
FieldDecl::hasInClassInitializer(), which is what we do for braced init
lists [0].

Before this patch, Clang does correctly recognize the in-class field
initializer in certain cases. This is Sema::BuildCXXDefaultInitExpr(...)
populates the in class initializer of the corresponding FieldDecl
object. Therefore, if that method was previously called with the same
FieldDecl object, as can happen with a decltype(...) or a braced list
initialization, FieldDecl::getInClassInitializer() will return a
non-null expression, and the field becomes properly initialized.

Fixes 62266

[0]: https://github.com/llvm/llvm-project/blob/be5f35e24f4c15caf3c4aeccddc54c52560c28a0/clang/lib/Sema/SemaInit.cpp#L685

Reviewed By: shafik

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

14 months ago[gn build] Port 824391693cbb
LLVM GN Syncbot [Mon, 1 May 2023 16:04:47 +0000 (16:04 +0000)]
[gn build] Port 824391693cbb

14 months ago[libc++][PSTL] Implement std::find{,_if,_if_not}
Nikolas Klauser [Thu, 27 Apr 2023 23:28:22 +0000 (16:28 -0700)]
[libc++][PSTL] Implement std::find{,_if,_if_not}

Reviewed By: ldionne, #libc

Spies: libcxx-commits

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

14 months ago[LAA] Use early return [nfc]
Philip Reames [Mon, 1 May 2023 15:32:28 +0000 (08:32 -0700)]
[LAA] Use early return [nfc]

14 months ago[SystemZ][z/OS] Mark ecsymbols test as unsupported
Muiez Ahmed [Mon, 1 May 2023 15:25:14 +0000 (11:25 -0400)]
[SystemZ][z/OS] Mark ecsymbols test as unsupported

The llvm-lib tool is not yet supported on z/OS.

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

14 months agoSet EnableAIXExtendedAltivecABI in BackendUtils from LangOpts
Zarko Todorovski [Mon, 1 May 2023 14:30:29 +0000 (10:30 -0400)]
Set EnableAIXExtendedAltivecABI in BackendUtils from LangOpts

Fix a bug where after
github.com/llvm/llvm-project/commit/68dd51421f16f1e17cd453cb1730fcca99a6cfb7
refactor where we are not passing -mabi=vec-extabi to th backend.

14 months ago[RISCV] Rewrite isLegalElementTypeForRVV in terms of ValueTypes [nfc]
Philip Reames [Mon, 1 May 2023 14:32:55 +0000 (07:32 -0700)]
[RISCV] Rewrite isLegalElementTypeForRVV in terms of ValueTypes [nfc]

This was briefly mentioned as a possibility in review discussion on D149369.

One slightly surprising bit to call out - these interfaces can get invoked with non-vector typed arguments. LoopVectorizer likes to call the costing interfaces with scalar types when unrolling, but not vectorizing. I found that surprising, not sure if others do.

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

14 months ago[VPlan] Remove DeadInsts arg from VPInstructionsToVPRecipes (NFC)
Florian Hahn [Mon, 1 May 2023 14:03:15 +0000 (15:03 +0100)]
[VPlan] Remove DeadInsts arg from VPInstructionsToVPRecipes (NFC)

The argument isn't used. VPlan-based dead recipe removal can be used
instead.

14 months ago[clang] Temporarily enable debug output when uploading artifacts during CI jobs
Louis Dionne [Mon, 1 May 2023 13:48:13 +0000 (09:48 -0400)]
[clang] Temporarily enable debug output when uploading artifacts during CI jobs

This is an attempt to troubleshoot our excessive usage of network in
Clang jobs on Buildkite.

14 months agoEmit info message when use_device_address variable does not have a device counterpart.
Doru Bercea [Wed, 26 Apr 2023 14:41:10 +0000 (10:41 -0400)]
Emit info message when use_device_address variable does not have a device counterpart.

14 months agoFix the clang sphinx bot
Aaron Ballman [Mon, 1 May 2023 11:31:03 +0000 (07:31 -0400)]
Fix the clang sphinx bot

Addresses the issue found in:
https://lab.llvm.org/buildbot/#/builders/92/builds/43478

14 months ago[bazel] Fix layering check after 0610e2f
Christian Sigg [Mon, 1 May 2023 10:04:32 +0000 (12:04 +0200)]
[bazel] Fix layering check after 0610e2f

`BytecodeWriter.h` is now included in `IR.h`, and the corresponding dependency should be moved to `header_deps`. This change fixes Google's internal build, which seems to have a stricter layering check than bazel's, but it's still the right thing to do.

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

14 months ago[clangd][IncludeCleaner] Use a proper comparator for deduplicating findings
Kadir Cetinkaya [Mon, 1 May 2023 10:04:24 +0000 (12:04 +0200)]
[clangd][IncludeCleaner] Use a proper comparator for deduplicating findings

Previous one didn't have strict weak ordering guarantees.

14 months ago[compiler-rt][ASan] Fix description of __sanitizer_annotate_contiguous_container
Advenam Tacet [Mon, 1 May 2023 05:13:15 +0000 (22:13 -0700)]
[compiler-rt][ASan] Fix description of __sanitizer_annotate_contiguous_container

This revision updates the description of
`__sanitizer_annotate_contiguous_container` in includes. Possibilites of
the function were changed in D132522 and it supports:
  - unaligned beginning,
  - shared first/last granule with other objects.

Reviewed By: vitalybuka

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

14 months ago[mlir][bytecode] Return error instead of min version
Jacques Pienaar [Mon, 1 May 2023 05:11:02 +0000 (22:11 -0700)]
[mlir][bytecode] Return error instead of min version

Can't return a well-formed IR output while enabling version to be bumped
up during emission. Previously it would return min version but
potentially invalid IR which was confusing, instead make it return
error and abort immediately instead.

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

14 months ago[test][HWASAN] Auto-generate a few tests
Vitaly Buka [Mon, 1 May 2023 04:59:52 +0000 (21:59 -0700)]
[test][HWASAN] Auto-generate a few tests

14 months agoRevert "[NFC][HWASAN] Handle tags as Int8"
Vitaly Buka [Mon, 1 May 2023 03:59:05 +0000 (20:59 -0700)]
Revert "[NFC][HWASAN] Handle tags as Int8"

More tests need updates.

This reverts commit e876ba5db98830db427395ed9b3718d20bf519fb.

14 months ago[OpenMP] Only enable version script if supported
Shilei Tian [Mon, 1 May 2023 03:34:31 +0000 (23:34 -0400)]
[OpenMP] Only enable version script if supported

The linker flag `--version-script` may not be supported by all linkers, such as
macOS's linker. `libomp` is already capable of detecting whether the linker supports
it and append the linker flag accordingly. Since currently we assume `libomptarget`
only works on Linux, we don't do the check accordingly. This patch simply adds
the check before adding it to linker flag. This will be the first patch to make
OpenMP target offloading work on macOS. Note that CMake files in `plugins` are
not touched before they are going to be removed pretty soon anyway.

Reviewed By: jhuber6

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

14 months ago[NFC][HWASAN] Handle tags as Int8
Vitaly Buka [Sun, 30 Apr 2023 18:53:51 +0000 (11:53 -0700)]
[NFC][HWASAN] Handle tags as Int8

14 months ago[NFC][HWASAN] Rename local variable
Vitaly Buka [Mon, 1 May 2023 02:48:32 +0000 (19:48 -0700)]
[NFC][HWASAN] Rename local variable

14 months agoBasic documentation of -mrecip=... option
Tim Schmielau [Mon, 1 May 2023 01:54:20 +0000 (07:24 +0530)]
Basic documentation of -mrecip=... option

The documentation is still rather terse because it needs to fit
onto a single line of clang --help output.
But at least it lists what the user can specify and documents the
non-obvious syntax.

Reviewed By: craig.topper

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

14 months ago[NFC][HWASAN] Set constant type from another operand
Vitaly Buka [Mon, 1 May 2023 02:07:57 +0000 (19:07 -0700)]
[NFC][HWASAN] Set constant type from another operand

14 months ago[test][HWASAN] Remove update_test_checks note
Vitaly Buka [Sun, 30 Apr 2023 20:58:25 +0000 (13:58 -0700)]
[test][HWASAN] Remove update_test_checks note

This test is not autogenerated.

14 months ago[HWASAN] Untag before tagging alloca pointers
Vitaly Buka [Mon, 1 May 2023 01:10:40 +0000 (18:10 -0700)]
[HWASAN] Untag before tagging alloca pointers

This is folloup to b5595836, which missed the
Replacemen variable.

Before b5595836 the code assumed that alloca
ptrs are not tagged so tagging is implemented
as simple OR.

So this patch completes support of tagged SP
by passing untagged alloca pointers into
tagPointer.

14 months ago[LangRef] Fix broken tail call optimization link
Joshua Cao [Mon, 1 May 2023 01:17:48 +0000 (18:17 -0700)]
[LangRef] Fix broken tail call optimization link

14 months ago[MLIR][tensor] generate default builder for FromElementsOp
max [Sun, 30 Apr 2023 22:46:29 +0000 (17:46 -0500)]
[MLIR][tensor] generate default builder for FromElementsOp

Removed builder is the same as default builder, with the added benefit that python bindings will be generated for the default builder.

Reviewed By: ftynse

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

14 months agoDon't loop unswitch vector selects
Valentin Churavy [Sun, 30 Apr 2023 23:19:17 +0000 (19:19 -0400)]
Don't loop unswitch vector selects

Otherwise we could produce `br <2x i1>` which are of course not legal.

```
Branch condition is not 'i1' type!
  br <2 x i1> %cond.fr1, label %entry.split.us, label %entry.split
  %cond.fr1 = freeze <2 x i1> %cond
LLVM ERROR: Broken module found, compilation aborted!
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: /home/vchuravy/builds/llvm/bin/opt -passes=simple-loop-unswitch<nontrivial> -S
```

Fixes change introduced by https://reviews.llvm.org/D138526

Reviewed By: caojoshua

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

14 months ago[clang-format] Recognize Verilog type dimension in module header
sstwcw [Sun, 30 Apr 2023 22:26:41 +0000 (22:26 +0000)]
[clang-format] Recognize Verilog type dimension in module header

We had the function `verilogGroupDecl` for that.  However, the type
name would be incorrectly annotated in `isStartOfName` when it was not
a C++ keyword and followed another identifier.

Reviewed By: HazardyKnusperkeks, owenpan, MyDeveloperDay

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

14 months ago[clang-format] Correctly format goto labels followed by blocks
sstwcw [Sun, 30 Apr 2023 22:22:31 +0000 (22:22 +0000)]
[clang-format] Correctly format goto labels followed by blocks

There doesn't seem to be an issue on GitHub.  But previously, a space
would be inserted before the goto colon in the code below.

    switch (x) {
    case 0:
    goto_0: {
      action();
      break;
    }
    }

Previously, the colon following a goto label would be annotated as
`TT_InheritanceColon`.  A goto label followed by an opening brace
wasn't recognized.  It is easy to add another line to have
`spaceRequiredBefore` function recognize the case, but I believed it
is more proper to avoid doing the same thing in `UnwrappedLineParser`
and `TokenAnnotator`.  So now the label colons would be labeled in
`UnwrappedLineParser`, and `spaceRequiredBefore` would rely on that.

Previously we had the type `TT_GotoLabelColon` intended for both goto
labels and case labels.  But since handling of goto labels and case
labels differ somewhat, I split it into separate types for goto and
case labels.

This patch doesn't change the behavior for case labels.  I added the
lines annotating case labels because they would previously be
mistakenly annotated as `TT_InheritanceColon` just like goto labels.
And since I added the annotations, the checks for the `case` and
`default` keywords in `spaceRequiredBefore` are not necessary anymore.

Reviewed By: MyDeveloperDay

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

14 months agoRemove bug fix release note for a bug that was never released.
Richard Smith [Sun, 30 Apr 2023 22:13:22 +0000 (15:13 -0700)]
Remove bug fix release note for a bug that was never released.

In its place, add a description of a bug that the change introducing
the bug in question inadvertently fixed.

See BZ 62361 for more details.

14 months ago[gn build] Port 68ee014b15d3
LLVM GN Syncbot [Sun, 30 Apr 2023 20:27:26 +0000 (20:27 +0000)]
[gn build] Port 68ee014b15d3

14 months ago[libc++][PSTL] Implement std::for_each{, _n}
Nikolas Klauser [Thu, 19 Jan 2023 19:10:11 +0000 (20:10 +0100)]
[libc++][PSTL] Implement std::for_each{, _n}

Reviewed By: ldionne, #libc

Spies: libcxx-commits

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

14 months ago[LV] Clarify comment for selectVectorizationFactor (NFC).
Florian Hahn [Sun, 30 Apr 2023 20:12:15 +0000 (21:12 +0100)]
[LV] Clarify comment for selectVectorizationFactor (NFC).

The comment is stale, as UserVF is handled before selectVectorizationFactor
is called. Clarify the comment by remove the mention of UserVF.

Suggested as independent improvement in D143938.

14 months ago[LV] Remove loop arg from CM::isCandidateForEpilogueVectorization (NFC)
Florian Hahn [Sun, 30 Apr 2023 20:10:55 +0000 (21:10 +0100)]
[LV] Remove loop arg from CM::isCandidateForEpilogueVectorization (NFC)

LVP operates on the loop it stores in TheLoop. Use it instead of the
argument, to be in line with other member functions.

Suggested as independent improvement in D143938.

14 months ago[LV] Document selectEpilogueVectorizationFactor (NFC).
Florian Hahn [Sun, 30 Apr 2023 20:09:24 +0000 (21:09 +0100)]
[LV] Document selectEpilogueVectorizationFactor (NFC).

Add missing documentation for selectEpilogueVectorizationFactor.

Suggested as independent improvement in D143938.

14 months ago[clang-repl] Correctly disambiguate dtor declarations from statements.
Vassil Vassilev [Sun, 30 Apr 2023 19:43:38 +0000 (19:43 +0000)]
[clang-repl] Correctly disambiguate dtor declarations from statements.

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

14 months ago[clang-tidy] Ignore declarations in bugprone-exception-escape
Piotr Zegar [Sun, 30 Apr 2023 18:22:44 +0000 (18:22 +0000)]
[clang-tidy] Ignore declarations in bugprone-exception-escape

Warnings will now only be printed for function definitions, not declarations

Reviewed By: isuckatcs

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

14 months ago[LVP] Fix comment for hasPlanWithVF (NFC).
Florian Hahn [Sun, 30 Apr 2023 18:13:52 +0000 (19:13 +0100)]
[LVP] Fix comment for hasPlanWithVF (NFC).

The function checks if there's a plan with the specified VF. Update the
comment to match the implementation.

Pointed out as independent improvement in D143938.

14 months ago[ValueTracking] Use knownbits interface for determining if `div`/`rem` are safe to...
Noah Goldstein [Sun, 30 Apr 2023 15:16:55 +0000 (10:16 -0500)]
[ValueTracking] Use knownbits interface for determining if `div`/`rem` are safe to speculate

This just replaces the exact constant requirements with known-bits
which can prove better results.

Reviewed By: nikic

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

14 months ago[ValueTracking] Add tests for checking whether `div`/`rem` is safe to speculate; NFC
Noah Goldstein [Fri, 28 Apr 2023 04:21:29 +0000 (23:21 -0500)]
[ValueTracking] Add tests for checking whether `div`/`rem` is safe to speculate; NFC

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

14 months ago[ValueTracking] Slight refactor to avoid unnecessary work; NFC
Noah Goldstein [Sun, 30 Apr 2023 14:38:43 +0000 (09:38 -0500)]
[ValueTracking] Slight refactor to avoid unnecessary work; NFC

Two changes:
    1) Make some cases that conditionally returned unconditional.
    2) In cases of `Op0 != 0 || Op1 != 0` its better check `Op1` first
       as its more likely to be a constant due to canonicalization (so
       faster to get knownbits of).

Reviewed By: nikic

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

14 months ago[ValueTracking] Add additional cases for `isKnownNonZero(mul X, Y)`
Noah Goldstein [Sun, 30 Apr 2023 14:38:38 +0000 (09:38 -0500)]
[ValueTracking] Add additional cases for `isKnownNonZero(mul X, Y)`

If either `X` or `Y` is odd and the other is non-zero, the result is
non-zero.

Alive2 Link:
    https://alive2.llvm.org/ce/z/9V7-es

Reviewed By: nikic

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

14 months ago[ValueTracking] Add logic for `isKnownNonZero(smin/smax X, Y)`
Noah Goldstein [Sun, 30 Apr 2023 14:33:22 +0000 (09:33 -0500)]
[ValueTracking] Add logic for `isKnownNonZero(smin/smax X, Y)`

For `smin` if either `X` or `Y` is negative, the result is non-zero.
For `smax` if either `X` or `Y` is strictly positive, the result is
non-zero.

For both if `X != 0` and `Y != 0` the result is non-zero.

Alive2 Link:
    https://alive2.llvm.org/ce/z/7yvbgN
    https://alive2.llvm.org/ce/z/zizbvq

Reviewed By: nikic

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

14 months ago[ValueTracking] Add logic for `isKnownNonZero(umin X, Y)`
Noah Goldstein [Sun, 30 Apr 2023 14:33:18 +0000 (09:33 -0500)]
[ValueTracking] Add logic for `isKnownNonZero(umin X, Y)`

`(umin X, Y) != 0` -> `X != 0 && Y != 0`

Alive2 Link:
    https://alive2.llvm.org/ce/z/AQh67i

Reviewed By: nikic

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

14 months ago[ValueTracking] Add logic for `isKnownNonZero(umax X, Y)`
Noah Goldstein [Sun, 30 Apr 2023 14:33:14 +0000 (09:33 -0500)]
[ValueTracking] Add logic for `isKnownNonZero(umax X, Y)`

`(umax X, Y) != 0` -> `X != 0 || Y != 0`

Alive2 Link:
    https://alive2.llvm.org/ce/z/_Z9AUT

Reviewed By: nikic

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

14 months ago[ValueTracking] Add logic for `isKnownNonZero(sadd.sat X, Y)`
Noah Goldstein [Sun, 30 Apr 2023 14:33:10 +0000 (09:33 -0500)]
[ValueTracking] Add logic for `isKnownNonZero(sadd.sat X, Y)`

The logic here is the same for `add` so reuse the existing helper
`isNonZeroAdd`

Alive2 Link:
    https://alive2.llvm.org/ce/z/mhKvC5

Reviewed By: nikic

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

14 months ago[ValueTracking] Add logic for `isKnownNonZero(ssub.sat X, Y)`
Noah Goldstein [Sun, 30 Apr 2023 14:33:03 +0000 (09:33 -0500)]
[ValueTracking] Add logic for `isKnownNonZero(ssub.sat X, Y)`

The logic here is the same for normal `(sub X, Y)`, so just reused
`isNonZeroSub`.

Alive2 Link:
    https://alive2.llvm.org/ce/z/9kSkMv

Reviewed By: nikic

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

14 months ago[ValueTracking] Add logic for `isKnownNonZero(sshl.sat/ushl.sat X, Y)`
Noah Goldstein [Sun, 30 Apr 2023 14:33:00 +0000 (09:33 -0500)]
[ValueTracking] Add logic for `isKnownNonZero(sshl.sat/ushl.sat X, Y)`

`(sshl/ushl X, Y) != 0` -> `X != 0`

Alive2 Links
    https://alive2.llvm.org/ce/z/4WLM2p
    https://alive2.llvm.org/ce/z/BHFng4

Reviewed By: nikic

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

14 months ago[ValueTracking] Add logic for `isKnownNonZero(ctlz/cttz X)`
Noah Goldstein [Sun, 30 Apr 2023 14:32:57 +0000 (09:32 -0500)]
[ValueTracking] Add logic for `isKnownNonZero(ctlz/cttz X)`

for `cttz` if `X[0]` is non-zero, then the expression is non-zero.
for `ctlz` if `X[SignBit]` is non-zero, then the expression in
non-zero.

Alive2 Links:
    cttz (false): https://alive2.llvm.org/ce/z/ySQzbg
    cttz (true): https://alive2.llvm.org/ce/z/auiTCJ
    ctlz (false): https://alive2.llvm.org/ce/z/yk3sTJ
    ctlz (true): https://alive2.llvm.org/ce/z/-JuDty

Reviewed By: nikic

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