platform/upstream/llvm.git
16 months ago[flang][openacc] Support array slices when creating private recipe
Valentin Clement [Thu, 6 Jul 2023 21:07:45 +0000 (14:07 -0700)]
[flang][openacc] Support array slices when creating private recipe

The return type of the recipe must match the array slice provided by
the user. This patch enhance the recipe creation to take into account
the constant slices.

Depends on D154259

Reviewed By: razvanlupusoru

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

16 months ago[flang][openacc] Populate the init region for acc.private.recipe for simple type
Valentin Clement [Thu, 6 Jul 2023 20:55:21 +0000 (13:55 -0700)]
[flang][openacc] Populate the init region for acc.private.recipe for simple type

Generate code to allocate privates for trivial scalars and arrays.

Reviewed By: razvanlupusoru

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

16 months ago[libc++][NFC] Add 'const' to some operator()
Louis Dionne [Thu, 6 Jul 2023 14:45:55 +0000 (10:45 -0400)]
[libc++][NFC] Add 'const' to some operator()

This is NFC because the function object is stateless anyway. This is
done solely for consistency with surrounding code and this was probably
an oversight in https://reviews.llvm.org/D132505.

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

16 months ago[BOLT] Fix buildbot failure
Maksim Panchenko [Thu, 6 Jul 2023 20:28:35 +0000 (13:28 -0700)]
[BOLT] Fix buildbot failure

GCC requires "class" keyword when variable name matches class name.

Reviewed By: ayermolo

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

16 months ago[clang-format] Support block indenting array/struct list initializers
Gedare Bloom [Thu, 6 Jul 2023 20:37:42 +0000 (13:37 -0700)]
[clang-format] Support block indenting array/struct list initializers

C89 and C99 list initializers are treated differently than Cpp11 braced
initializers. This patch identifies the C array/struct initializer lists by
finding the preceding equal sign before a left brace, and applies formatting
rules for BracketAlignmentStyle.BlockIndent to those list initializers.

Fixes #57878.

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

16 months ago[WebAssembly] Add frexp{f,l} libcall signatures
Derek Schuff [Thu, 6 Jul 2023 17:24:07 +0000 (10:24 -0700)]
[WebAssembly] Add frexp{f,l} libcall signatures

The llvm.frexp.* family of intrinsics and their corresponding libcalls were
recently added, which means we need to know their signatures.

Differential Revision: https://reviews.llvm.org/D154639
Fixed: https://github.com/llvm/llvm-project/issues/63657

16 months ago[lldb-vscode] Adding support for column break points.
John Harrison [Thu, 6 Jul 2023 19:54:13 +0000 (15:54 -0400)]
[lldb-vscode] Adding support for column break points.

Reviewed By: wallace

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

16 months ago[flang][hlfir] Lower char length inquiry via hlfir.get_length.
Slava Zakharin [Thu, 6 Jul 2023 17:07:02 +0000 (10:07 -0700)]
[flang][hlfir] Lower char length inquiry via hlfir.get_length.

ApplyOp provides the type parameters in its argument, so we can
take it from there. For hlfir.expr block arguments (such as with
user-defined assignments) we use hlfir.get_length in lowering.

Depends on D154561

Reviewed By: jeanPerier

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

16 months ago[flang][hlfir] Codegen for hlfir.get_length.
Slava Zakharin [Thu, 6 Jul 2023 17:07:02 +0000 (10:07 -0700)]
[flang][hlfir] Codegen for hlfir.get_length.

Lower hlfir.get_length into the char length inquiry of the bufferized
entity. In some cases the codegen will fail with
`hlfir.associate of hlfir.expr with more than one use` - this will be fixed
separately (after D154521).

Depends on D154560

Reviewed By: tblah, jeanPerier

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

16 months ago[flang][hlfir] Added hlfir.get_length to inquire char length from hlfir.expr.
Slava Zakharin [Thu, 6 Jul 2023 17:06:57 +0000 (10:06 -0700)]
[flang][hlfir] Added hlfir.get_length to inquire char length from hlfir.expr.

We will use hlfir.get_length to lower inquiries of char length
applied to hlfir.expr character values.

Reviewed By: tblah, jeanPerier

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

16 months ago[DebugInfo] Enable debug info emission for extern variables in C++
Yuze Chi [Thu, 6 Jul 2023 19:59:05 +0000 (12:59 -0700)]
[DebugInfo] Enable debug info emission for extern variables in C++

Debug info emission for extern variables in C++ was previously disabled
when the functionality was added in https://reviews.llvm.org/D71818 and
originally in https://reviews.llvm.org/D70696, because there was no use
case. We are enabling it now, as we start to deploy BPF programs
compiled from C++, leveraging C++ features like templates to reduce code
complexity. This patch is required so that we can still use kconfig in
such BPF programs compiled from C++.

Reviewed By: rnk, dblaikie, MaskRay, yonghong-song

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

16 months ago[InstCombine] Add transforms for `(rem (shl Y, X), (shl Z, X))`
Noah Goldstein [Thu, 6 Jul 2023 18:16:53 +0000 (13:16 -0500)]
[InstCombine] Add transforms for `(rem (shl Y, X), (shl Z, X))`

This is just filling in a missing case from D144225.

We treat `(shl Y, X)` and `(shl Z, X)` as `(mul Z, 1 << X)` and `(mul
Y, 1 << X)` then reuse the same transformations that already exist.

Reviewed By: sdesmalen

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

16 months ago[InstCombine] Add test cases for `(rem (shl Y, X), (shl Z, X))`; NFC
Noah Goldstein [Wed, 29 Mar 2023 03:52:36 +0000 (22:52 -0500)]
[InstCombine] Add test cases for `(rem (shl Y, X), (shl Z, X))`; NFC

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

16 months ago[InstCombine] Add constant combines for `(urem/srem (shl X, Y), (shl X, Z))`
Noah Goldstein [Thu, 16 Feb 2023 23:03:09 +0000 (17:03 -0600)]
[InstCombine] Add constant combines for `(urem/srem (shl X, Y), (shl X, Z))`

Forked from D142901 to deduce more `nsw`/`nuw` flag for the output
`shl`.

We can handle the following cases + some `nsw`/`nuw` flags:

The rationale for doing this all in `InstCombine` rather than handling
the constant `shl` cases in `InstSimplify` is we often create a new
instruction because we are able to deduce more `nsw`/`nuw` flags than
the original instruction had.

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

16 months ago[emacs] Highlight 'zeroext' and 'signext' keywords as an attribute
Noah Goldstein [Thu, 6 Jul 2023 16:44:35 +0000 (11:44 -0500)]
[emacs] Highlight 'zeroext' and 'signext' keywords as an attribute

Seems natural to highlight 'nocapture' along with other attributes
like 'nonnull', 'noundef', etc..

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

16 months ago[OPENMP52] Support Support omp_cur_iteration modifier for doacross
Jennifer Yu [Wed, 5 Jul 2023 15:04:07 +0000 (08:04 -0700)]
[OPENMP52] Support Support omp_cur_iteration modifier for doacross
clause.

This is just syntax to make it easier for the user. It doesn't add any
new functionality.

for
doacross(sink: omp_cur_iteration - 1)
Equivalent to
doacross(sink: ConterVar - 1, ...)

doacross(source: omp_cur_iteration)
Equivalent to
doacross(source)

And restriction is:
OMP5.2 p.327

If vector is specified with the omp_cur_iteration keyword and with
sink as the dependence-type then it must be omp_cur_iteration - 1.

If vector is specified with source as the dependence-type then it must be
omp_cur_iteration.

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

16 months ago[BOLT][DWARF] Fix for .debug_line with DWARF5
Alexander Yermolovich [Thu, 6 Jul 2023 18:34:18 +0000 (11:34 -0700)]
[BOLT][DWARF] Fix for .debug_line with DWARF5

There was a bug in a code that pre-populated line string for a case where parts
of .debug_line are not processed by BOLT, but copied as raw data. We were not
switching sections. This resulted in parts of the binary being over-written with
debug data.

Reviewed By: maksfb

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

16 months ago[gn build] Port c9b1f062887d
LLVM GN Syncbot [Thu, 6 Jul 2023 18:30:23 +0000 (18:30 +0000)]
[gn build] Port c9b1f062887d

16 months ago[gn build] Port 98e2d630277e
LLVM GN Syncbot [Thu, 6 Jul 2023 18:30:22 +0000 (18:30 +0000)]
[gn build] Port 98e2d630277e

16 months ago[gn build] Port 43dce27c06e4
LLVM GN Syncbot [Thu, 6 Jul 2023 18:30:21 +0000 (18:30 +0000)]
[gn build] Port 43dce27c06e4

16 months ago[gn build] Port 38639a8159b2
LLVM GN Syncbot [Thu, 6 Jul 2023 18:30:20 +0000 (18:30 +0000)]
[gn build] Port 38639a8159b2

16 months ago[BOLT][NFCI] Migrate Linux Kernel handling code to MetadataRewriter
Maksim Panchenko [Wed, 28 Jun 2023 21:35:05 +0000 (14:35 -0700)]
[BOLT][NFCI] Migrate Linux Kernel handling code to MetadataRewriter

Create LinuxKernelRewriter and move kernel-specific code to this class.

Depends on D154023

Reviewed By: Amir

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

16 months ago[BOLT][NFCI] Migrate pseudo probes to MetadataRewriter interface
Maksim Panchenko [Wed, 28 Jun 2023 06:37:14 +0000 (23:37 -0700)]
[BOLT][NFCI] Migrate pseudo probes to MetadataRewriter interface

Use new MetdataRewriter interface to update pseudo probes and move
ProbeDecoder out of BinaryContext into new PseudoProbeRewriter class.

Depends on D154021

Reviewed By: Amir

Differential Revision: https://reviews.llvm.org/D154022
Differential Revision: https://reviews.llvm.org/D154023

16 months ago[BOLT][NFCI] Use MetadataRewriter interface to update SDT markers
Maksim Panchenko [Wed, 28 Jun 2023 05:56:47 +0000 (22:56 -0700)]
[BOLT][NFCI] Use MetadataRewriter interface to update SDT markers

Migrate SDT markers processing to the new MetadataRewriter interface.

Depends on D154020

Reviewed By: Amir

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

16 months ago[BOLT] Introduce MetadataRewriter interface
Maksim Panchenko [Wed, 28 Jun 2023 05:55:53 +0000 (22:55 -0700)]
[BOLT] Introduce MetadataRewriter interface

Introduce the MetadataRewriter interface to handle updates for various
types of auxiliary data stored in a binary file.

To implement metadata processing using this new interface, all metadata
rewriters should derive from the RewriterBase class and implement
one or more of the following methods, depending on the timing of metadata
read and write operations:

  * preCFGInitializer()
  * postCFGInitializer() // TBD
  * preEmitFinalizer()   // TBD
  * postEmitFinalizer()

By adopting this approach, we aim to simplify the RewriteInstance class
and improve its scalability to accommodate new extensions of file formats,
including various metadata types of the Linux Kernel.

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

16 months ago[gn build] Manually port 015dabd7
Arthur Eubanks [Thu, 6 Jul 2023 18:07:48 +0000 (11:07 -0700)]
[gn build] Manually port 015dabd7

16 months ago[MLIR][Tosa] Turn reshape(const()) from canonicalization into fold; fix dynamic shape...
Liam Fitzpatrick [Tue, 4 Jul 2023 16:00:57 +0000 (17:00 +0100)]
[MLIR][Tosa] Turn reshape(const()) from canonicalization into fold; fix dynamic shape case

1) Turns the canonicalization into a fold, so it can cleanup IR within other passes.

2) When the output of the reshape is a dynamic shaped tensor,
we cannot apply the fold to the constant, because constants are required to have
static shape.

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

16 months ago[msan] Fix -Wcast-qual error in msan_dl.cpp
Thurston Dang [Thu, 6 Jul 2023 17:58:04 +0000 (17:58 +0000)]
[msan] Fix -Wcast-qual error in msan_dl.cpp

Attempt 2 at fixing a buildbot error https://lab.llvm.org/buildbot#builders/57/builds/28143
that I had introduced in D154272

16 months ago[UTC] Add do-not-autogenerate capability
Paul Robinson [Mon, 3 Jul 2023 18:41:09 +0000 (11:41 -0700)]
[UTC] Add do-not-autogenerate capability

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

16 months ago[scudo] Try to release pages after unlocking the TSDs
Chia-hung Duan [Wed, 5 Jul 2023 20:39:21 +0000 (20:39 +0000)]
[scudo] Try to release pages after unlocking the TSDs

This increases the parallelism and the usage of TSDs

Reviewed By: cferris

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

16 months ago[scudo] Verify the size of free blocks in primary allocator
Chia-hung Duan [Wed, 5 Jul 2023 20:36:41 +0000 (20:36 +0000)]
[scudo] Verify the size of free blocks in primary allocator

When all the blocks (local caches are included) are freed, the size of
free blocks should be equal to `AllocatedUser`.

Reviewed By: cferris

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

16 months ago[OpenMP] Ensure socket layer is not first in CPUID topology detection
Jonathan Peyton [Thu, 6 Jul 2023 17:31:47 +0000 (12:31 -0500)]
[OpenMP] Ensure socket layer is not first in CPUID topology detection

* Return 0 length topology if socket layer is detected first
* Fix DEBUG ASSERT

16 months ago[ELF] Use compression::getReasonIfUnsupported for zlib/zstd unavailable error
Fangrui Song [Thu, 6 Jul 2023 17:31:45 +0000 (10:31 -0700)]
[ELF] Use compression::getReasonIfUnsupported for zlib/zstd unavailable error

The error message now matches llvm-objcopy --compress-debug-sections=[zlib|zstd].

16 months ago[Support] Use C++11 attribute syntax for visibility attributes
Tom Stellard [Thu, 6 Jul 2023 03:21:04 +0000 (20:21 -0700)]
[Support] Use C++11 attribute syntax for visibility attributes

The gnu extension __attribute syntax cannot be mixed with the
C++11 alignas specifier, so in order to use visibility attributes on
classes that also use alignas, we need to use the C++11 standard syntax.

Also fix a few warnings introduced by this change.

Reviewed By: compnerd

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

16 months agoFixing conflicting macro definitions between curses.h and the standard library.
Nicole Rabjohn [Thu, 6 Jul 2023 17:12:05 +0000 (17:12 +0000)]
Fixing conflicting macro definitions between curses.h and the standard library.

POSIX allows certain macros to exist with generic names (i.e. refresh(), move(), and erase()) to exist in `curses.h` which conflict with functions found in std::filesystem, among others. This patch undefs the macros in question and adds them to LIBCPP_PUSH_MACROS and LIBCPP_POP_MACROS.

Reviewed By: #libc, philnik, ldionne

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

16 months ago[libc++][hardening][NFC] Rename the `has-debug-mode` feature to `has-legacy-debug...
varconst [Thu, 6 Jul 2023 17:17:02 +0000 (10:17 -0700)]
[libc++][hardening][NFC] Rename the `has-debug-mode` feature to `has-legacy-debug-mode`.

This will allow reusing the `has-debug-mode` feature for the new debug
mode without accidentally reenabling old debug mode tests. The
`has-legacy-debug-mode` feature is deliberately never set -- the old
tests are left checked in to have a point of reference for the level of
checking that was supported by the legacy debug mode, making it easier
to verify we've reached feature parity in the future.

16 months ago[YAML][NFC] Replace if-else with switch in createHNodes
Amir Ayupov [Thu, 6 Jul 2023 17:16:20 +0000 (10:16 -0700)]
[YAML][NFC] Replace if-else with switch in createHNodes

BOLT YAML profile reading time gets marginally faster (14.1572->13.9207 s) for
a large YAML profile (121MB/31K functions). Not claiming stat significance
though.

Reviewed By: hintonda

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

16 months agoCodeGen: Optimize lowering of is.fpclass fcZero|fcSubnormal
Matt Arsenault [Thu, 2 Feb 2023 14:28:05 +0000 (10:28 -0400)]
CodeGen: Optimize lowering of is.fpclass fcZero|fcSubnormal

Combine the two checks into a check if the exponent bits are 0. The
inverted case isn't reachable until a future change, and GlobalISel
currently doesn't attempt the inversion optimization.

https://reviews.llvm.org/D143182

16 months ago[gn] Add check-lsan target for Mac
Leonard Grey [Fri, 23 Jun 2023 17:26:32 +0000 (13:26 -0400)]
[gn] Add check-lsan target for Mac

Only supports ASAN mode right now. Standalone requires a some more plumbing so it will be a follow-up.

Mac-only but I suspect this will be fine on Linux also since it's based on the check-asan file, will follow up after testing.

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

16 months agoDAG: Check isCondCodeLegal in is_fpclass expansion to fcmp eq 0
Matt Arsenault [Sun, 4 Jun 2023 10:55:04 +0000 (06:55 -0400)]
DAG: Check isCondCodeLegal in is_fpclass expansion to fcmp eq 0

Results in some x86 codegen diffs. Some look better, some look worse.

https://reviews.llvm.org/D152094

16 months ago[mlir][sparse][gpu] fix missing dealloc
Aart Bik [Thu, 6 Jul 2023 05:17:52 +0000 (22:17 -0700)]
[mlir][sparse][gpu] fix missing dealloc

This dealloc was incorrectly removed in
https://reviews.llvm.org/D153173

Reviewed By: K-Wu

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

16 months ago[OpenMP] Remove gcc-12 warnings from libomp
Jonathan Peyton [Thu, 6 Jul 2023 16:45:58 +0000 (11:45 -0500)]
[OpenMP] Remove gcc-12 warnings from libomp

16 months ago[Libomptarget] Disable the 'mapping/prelock.cpp' test on AMDGPU
Joseph Huber [Thu, 6 Jul 2023 16:40:13 +0000 (11:40 -0500)]
[Libomptarget] Disable the 'mapping/prelock.cpp' test on AMDGPU

Summary:
This test was not functional on the new plugins, now that the old ones
have been deleted it doesn't work. Disable until we get a fix.

16 months agoReland '[msan] Intercept dladdr1, and refactor dladdr'
Thurston Dang [Wed, 5 Jul 2023 20:49:42 +0000 (20:49 +0000)]
Reland '[msan] Intercept dladdr1, and refactor dladdr'

Reland with -Wcast-qual issue fixed

Original commit message:
This patch adds an msan interceptor for dladdr1 (with support for RTLD_DL_LINKMAP and RTLD_DL_SYMENT) and an accompanying test. It also adds a helper file, msan_dl.cpp, that contains UnpoisonDllAddrInfo (refactored out of the dladdr interceptor) and UnpoisonDllAddr1ExtraInfo.

Reviewed By: vitalybuka

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

16 months agoAMDGPU: Fix not applying the correct default memcpy expansion threshold
Matt Arsenault [Thu, 6 Jul 2023 15:58:35 +0000 (11:58 -0400)]
AMDGPU: Fix not applying the correct default memcpy expansion threshold

Fixes 3c848194f28decca41b7362f9dd35d4939797724. The TTI hook name got
renamed at some point in the process and the target implementation was
left behind.

Fixes: SWDEV-407329

16 months ago[SystemZ][z/OS] Address single comment in ADA patch for EmittedBytes unused in -Asserts
Yusra Syeda [Thu, 6 Jul 2023 16:01:53 +0000 (12:01 -0400)]
[SystemZ][z/OS] Address single comment in ADA patch for EmittedBytes unused in -Asserts

16 months ago[mlir] Add support for TF32 as a Builtin FloatType
Jeremy Furtek [Thu, 6 Jul 2023 15:56:05 +0000 (08:56 -0700)]
[mlir] Add support for TF32 as a Builtin FloatType

This diff adds support for TF32 as a Builtin floating point type. This
supplements the recent addition of the TF32 semantic to the LLVM APFloat class
by extending usage to MLIR.

https://reviews.llvm.org/D151923

More information on the TF32 type can be found here:

https://blogs.nvidia.com/blog/2020/05/14/tensorfloat-32-precision-format/

Reviewed By: jpienaar

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

16 months ago[lldb][NFCI] Minor cleanups to StructuredData::GetObjectForDotSeparatedPath
Alex Langford [Wed, 5 Jul 2023 18:18:23 +0000 (11:18 -0700)]
[lldb][NFCI] Minor cleanups to StructuredData::GetObjectForDotSeparatedPath

This accomplishes a few minor things:
- Removed unnecessary uses of `this->`
- Removed an unnecessary std::string allocation.
- Removed some nesting to improve readability using early returns where
  it makes sense.
- Replaced `strtoul` with `llvm::to_integer` which avoids another
  std::string allocation.
- Removed braces from single statement conditions, removed
  else-after-returns.

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

16 months ago[lldb][NFCI] Remove use of ConstString from OptionValue
Alex Langford [Mon, 3 Jul 2023 19:55:29 +0000 (12:55 -0700)]
[lldb][NFCI] Remove use of ConstString from OptionValue

Summary: No need to create a ConstString, `GetName` already returns a StringRef.

Reviewers: JDevlieghere, mib, jasonmolenda

Subscribers:

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

16 months ago[AIX][XCOFF] print out the traceback info
zhijian [Thu, 6 Jul 2023 15:47:08 +0000 (11:47 -0400)]
[AIX][XCOFF] print out the traceback info

Summary:

  Adding a new option -traceback-table to print out the traceback info of xcoff ojbect file.

Reviewers: James Henderson, Fangrui Song, Stephen Peckham, Xing Xue

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

16 months ago[Libomptarget] Fix tests after deleting the next-gen plugins
Joseph Huber [Thu, 6 Jul 2023 15:38:18 +0000 (10:38 -0500)]
[Libomptarget] Fix tests after deleting the next-gen plugins

The next-gen plugins didn't correctly configure tests and were never
actually being run. Since deleting the old plugin we stopped getting
`libomptarget` tests. This patch fixes the issue and allows the targets
to be built

Reviewed By: JonChesterfield

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

16 months agoEnable dynamic-sized VLAs for data sharing in OpenMP offloaded target regions.
Doru Bercea [Thu, 22 Jun 2023 22:25:05 +0000 (18:25 -0400)]
Enable dynamic-sized VLAs for data sharing in OpenMP offloaded target regions.

Review: https://reviews.llvm.org/D153883

16 months ago[RISCV] Use ClangBuiltin in IntrinsicsRISCV.td to map some scalar crypto builtins...
Craig Topper [Thu, 6 Jul 2023 14:53:31 +0000 (07:53 -0700)]
[RISCV] Use ClangBuiltin in IntrinsicsRISCV.td to map some scalar crypto builtins to IR intrinsic.

This is the way most targets do it for a simple mapping.

We can't do this for all builtins due to type overloading of the IR intrinsics.

Reviewed By: asb

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

16 months ago[CaptureTracking] Don't consider comparison of inbounds GEP with nonnull non-capturing
Nikita Popov [Thu, 29 Jun 2023 08:04:46 +0000 (10:04 +0200)]
[CaptureTracking] Don't consider comparison of inbounds GEP with nonnull non-capturing

This is required to bring CaptureTracking in line with the new
semantics from D154051, as gep inbounds p, 0 is now always non-poison.

There are many ways in which the inbounds special case could be
preserved: If the index is known non-zero, or there is an inbounds
chain down to an identified object, etc. However, I have opted to
drop the special case entirely, as it appears to be low value:
In cases where we can determine such things (e.g. the affected test
cases) we would end up removing the compare via isGEPKnownNonNull()
logic anyway.

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

16 months ago[libcxx] Only add -GR- option to MSVC or clang-cl builds
David Spickett [Thu, 6 Jul 2023 08:49:33 +0000 (08:49 +0000)]
[libcxx] Only add -GR- option to MSVC or clang-cl builds

Previously we added both `-GR-` and `-fno-rtti` if RTTI was disabled.
When building with clang 16.x, that caused this error in part of the build:
```
clang-16: error: argument unused during compilation: '-G R-' [-Werror,-Wunused-command-line-argument]
```
I think the strange message is because clang is seeing `R-` as the argument
to `-G`, which is a valid clang option.

`-GR-` is an alternate syntax for the `/GR-` option for MSVC
(the dash means disable RTTI):
https://learn.microsoft.com/en-us/cpp/build/reference/gr-enable-run-time-type-information?view=msvc-170

This error is sort of fixed by cd18efb61d759405956dbd30e4b5f2720d8e1783
but not intentionally. Also, we'd have to wait for 17.x to benefit from that.

The proper fix here is to only add `-GR-` if we are building with MSVC
or the MSVC-like clang-cl, and add `-fno-rtti` if not.

Reviewed By: #libc, simon_tatham, michaelplatings, ldionne

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

16 months ago[flang] Force the use of intrinsic builtins in type_info
Leandro Lupori [Tue, 4 Jul 2023 15:50:32 +0000 (15:50 +0000)]
[flang] Force the use of intrinsic builtins in type_info

This ensures that the __Fortran_builtins module is always used
as an intrinsic module by __Fortran_type_info, which avoids issues
when, for instance, the intrinsic modules dir is present in the
include paths.

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

Reviewed By: klausler

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

16 months ago[X86] isTargetShuffleEquivalent - ensure the reference operands are vector types
Simon Pilgrim [Thu, 6 Jul 2023 14:35:52 +0000 (15:35 +0100)]
[X86] isTargetShuffleEquivalent - ensure the reference operands are vector types

Fixes #63700

16 months ago[RISCV] Use 'long' in sha512 builtin tests. NFC
Craig Topper [Thu, 6 Jul 2023 14:37:19 +0000 (07:37 -0700)]
[RISCV] Use 'long' in sha512 builtin tests. NFC

This matches the data type of the intrinsics. This case be seen
from the removal of sext and trunc instructions from the IR.

Reviewed By: asb

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

16 months ago[analyzer] Fix false negative when pass implicit cast nil to nonnull
songruiwang [Thu, 6 Jul 2023 14:34:10 +0000 (22:34 +0800)]
[analyzer] Fix false negative when pass implicit cast nil to nonnull

We should look through implicit casts before determining the type of the arguments, and only allow explicit cast to _Nonnull to suppress warning

```
void foo(NSString *_Nonnull);

foo((NSString * _Nonnull)nil); // no-warning
id obj = nil;
foo(obj); // should warning here (implicit cast id to NSString *_Nonnull)

```

Reviewed By: xazax.hun, steakhal

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

16 months ago[Mips] Replace OperandMatchResultTy with ParseStatus (NFC)
Sergei Barannikov [Mon, 3 Jul 2023 04:06:33 +0000 (07:06 +0300)]
[Mips] Replace OperandMatchResultTy with ParseStatus (NFC)

ParseStatus is slightly more convenient to use due to implicit
conversion from bool, which allows to do something like:
```
  return Error(L, "msg");
```
when with MatchOperandResultTy it had to be:
```
  Error(L, "msg");
  return MatchOperand_ParseFail;
```
It also has more appropriate name since parse* methods are not only for
parsing operands.

Reviewed By: MaskRay

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

16 months ago[clang][CodeGenCXX] Improve handling of itanium ABI member function alignment require...
David Tenty [Wed, 29 Mar 2023 13:25:37 +0000 (09:25 -0400)]
[clang][CodeGenCXX] Improve handling of itanium ABI member function alignment requirements

The itanium ABI for certain platforms requires a minimum alignments for
member function pointers to reserve certain bits for distinguishing
virtual and non-virtual functions.

Our implementation of this however depends on the alignment of the
function involved, which may however not reflect the true alignment of
function pointers on certain targets for which the alignment is
independent of the function (e.g. AIX). Worse, the 2-byte alignment
we use may be less than the ABI minimum for the target, and in the case
we are using explicit sections will result in invalid codegen.

This patch attempts to correct this situation by considering the target
alignment of function pointers as part of making the decision about
whether we need to adjust the function alignment to conform to the ABI.
Targets which do not provide the function ptr alignment information
will return a value of 1 when queried and will conservatively retain
the old alignment.

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

16 months ago[lld] respect LLVM_EXTERNAL_LIT
Konrad Kleine [Thu, 6 Jul 2023 12:05:02 +0000 (14:05 +0200)]
[lld] respect LLVM_EXTERNAL_LIT

Consider a setup without a system-wide installation of lit.
Instead you pass the path to lit like this:

```
cmake ...
-DLLVM_EXTERNAL_LIT=<PATH_TO_LIT_BINARY> ...
```

Then you will run into this error:

```
ninja: error: unknown target 'check-lld'
```

I have a buildbot builder that fails with this message. Here's the
passage that triggers this error:

https://github.com/llvm/llvm-zorg/blob/d3bfd5ccbceb542098c350e4d071ceceac6854cb/zorg/buildbot/builders/annotated/standalone-build.sh#L194-L239

By using `LLVM_EXTERNAL_LIT` instead of `LLVM_LIT` we fix this problem.

See
[here](https://llvm.org/docs/GettingStarted.html#stand-alone-builds) for
a description:

> Both the LLVM_ROOT and LLVM_EXTERNAL_LIT options are required to do stand-alone builds for all sub-projects. Additional required options for each sub-project can be found in the table below.

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

16 months agoAdd missing semantic highlighing for concepts.
Jens Massberg [Thu, 6 Jul 2023 08:31:57 +0000 (10:31 +0200)]
Add missing semantic highlighing for concepts.

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

16 months agoAMDGPU: Make SIFixVGPRCopies preserve everything
Matt Arsenault [Sat, 1 Jul 2023 12:34:02 +0000 (08:34 -0400)]
AMDGPU: Make SIFixVGPRCopies preserve everything

All this does is add uses of reserved registers, which
aren't tracked by anything. Saves a loop info computation.

16 months agoAMDGPU: Fold out sign bit ops on frexp_exp
Matt Arsenault [Mon, 3 Jul 2023 14:38:04 +0000 (10:38 -0400)]
AMDGPU: Fold out sign bit ops on frexp_exp

The sign bit has no impact on the exponent, so strip these away. Saves
on the source modifier encoding cost. I left the GlobalISel handling
until there's a resolution to issue #62628.

We should do this in instcombine too, but legalization should be
introducing more frexps than it currently is where this would occur.

16 months ago[SVE] Add isel for 32-bit add/sub(cntp()) -> incp/decp.
Paul Walker [Mon, 3 Jul 2023 14:00:15 +0000 (15:00 +0100)]
[SVE] Add isel for 32-bit add/sub(cntp()) -> incp/decp.

Patterns already exist for 64-bit that I've simply copied and
converted to include the necessary truncation.

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

16 months ago[mlir][linalg][transform] Add verifier to MaskedVectorizeOp
Matthias Springer [Thu, 6 Jul 2023 14:20:30 +0000 (16:20 +0200)]
[mlir][linalg][transform] Add verifier to MaskedVectorizeOp

Verify that the correct number of `scalable_sizes` was provided.

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

16 months ago[LV] Add test case for incorrect shift truncation.
Florian Hahn [Thu, 6 Jul 2023 14:23:16 +0000 (15:23 +0100)]
[LV] Add test case for incorrect shift truncation.

Test for https://github.com/llvm/llvm-project/issues/47927

16 months ago[mlir][bufferization] Fix insertion point issue in EliminateEmptyTensors
Matthias Springer [Thu, 6 Jul 2023 14:12:52 +0000 (16:12 +0200)]
[mlir][bufferization] Fix insertion point issue in EliminateEmptyTensors

The replacement op insertion point was off by one.

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

16 months ago[Driver][MSVC] Support DWARF fission when using LTO on Windows
Haohai Wen [Thu, 6 Jul 2023 14:18:35 +0000 (22:18 +0800)]
[Driver][MSVC] Support DWARF fission when using LTO on Windows

D154070 has added /dwodir to lld/COFF to tells LTO backend to create dwo
directory and files. This patch makes clang to emit /dwodir to lld when
user specify -gsplit-dwarf with LTO. This behavior is simiar to DWARF
fission with LTO for ELF.

A simple use case:
$clang-cl -c -flto -gdwarf main.c -o main.o
$clang-cl -c -flto -gdwarf a.c -o a.o
$clang-cl -flto -fuse-ld=lld -gdwarf -gsplit-dwarf main.o a.o

This'll generate a dwo file: main.exe_dwo/0.dwo

Reviewed By: mstorsjo, MaskRay, hans

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

16 months ago[gn build] Port 7aafea001282
LLVM GN Syncbot [Thu, 6 Jul 2023 14:01:11 +0000 (14:01 +0000)]
[gn build] Port 7aafea001282

16 months ago[gn build] Port 4ade8b7ed997
LLVM GN Syncbot [Thu, 6 Jul 2023 14:01:10 +0000 (14:01 +0000)]
[gn build] Port 4ade8b7ed997

16 months ago[gn build] Port 2d8cd1951202
LLVM GN Syncbot [Thu, 6 Jul 2023 14:01:10 +0000 (14:01 +0000)]
[gn build] Port 2d8cd1951202

16 months ago[gn build] Port 163aad6bcbff
LLVM GN Syncbot [Thu, 6 Jul 2023 14:01:09 +0000 (14:01 +0000)]
[gn build] Port 163aad6bcbff

16 months ago[gn] port 3003da71540b
Nico Weber [Thu, 6 Jul 2023 14:00:33 +0000 (10:00 -0400)]
[gn] port 3003da71540b

16 months ago[mlir][LLVM] Make `SplitIntegerStores` capable of splitting vectors as well
Markus Böck [Thu, 6 Jul 2023 08:59:40 +0000 (10:59 +0200)]
[mlir][LLVM] Make `SplitIntegerStores` capable of splitting vectors as well

The original plan was to turn this into its own pattern, but one of the difficulties was deeming when splitting the vector is required.
`SplitIntegerStores` essentially already did that by checking for field overlap.
Therefore, it was renamed to `SplitStores` and extended to splitting stores with values of vector and integer type.

The vector splitting is done in a simple manner by simply using `extractelement` to get each vector element. Subsequent pattern applications are responsible for further cleaning up the output and making it type-consistent.

Worst case, if the code cannot be transformed into a type-consistent form (due to e.g. the code explicitly doing partial writes to elements or similar), we might needlessly do a vector split.

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

16 months ago[mlir][LLVM] Use `undef` operand instead of removing `llvm.intr.dbg.value`
Markus Böck [Wed, 5 Jul 2023 07:15:50 +0000 (09:15 +0200)]
[mlir][LLVM] Use `undef` operand instead of removing `llvm.intr.dbg.value`

Jeremy Morse noted in D154451 that LLVM doesn't drop a `dbg.value` when its value is being removed, but rather sets the operand to `undef`. This preserves the debug info and gives allows the debugger to instead inform the user that the variable has been optimized out, rather than not displaying the variable at all.

This patch fixes that mistake done in the previous revision by mirroring that behaviour in MLIR as well.

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

16 months ago[DemandedBits] Add tests for shl.
Florian Hahn [Thu, 6 Jul 2023 13:33:11 +0000 (14:33 +0100)]
[DemandedBits] Add tests for shl.

Add test coverage for demanded bit analysis of shl.

16 months ago[IRCE][Tests] Add more tests with range checks in the form of 'iv + offset vs limit'
Aleksandr Popov [Thu, 6 Jul 2023 13:29:55 +0000 (15:29 +0200)]
[IRCE][Tests] Add more tests with range checks in the form of 'iv + offset vs limit'

Added tests on range checks with non-strick predicate:
    * N - IV > limit
    * IV - N < limit
    * IV + N < limit

Also added tests with known to be non-negative N

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

16 months ago[BPF] Undo transformation for LICM.cpp:hoistMinMax()
Eduard Zingerman [Tue, 11 Apr 2023 03:31:27 +0000 (06:31 +0300)]
[BPF] Undo transformation for LICM.cpp:hoistMinMax()

Extended BPFCheckAndAdjustIR pass with sinkMinMax() transformation
that undoes LICM hoistMinMax pass.

The undo transformation converts the following patterns:

    x < min(a, b) -> x < a && x < b
    x > min(a, b) -> x > a || x > b
    x < max(a, b) -> x < a || x < b
    x > max(a, b) -> x > a && x > b

Where 'a' or 'b' is a constant.
Also supports `sext min(...) ...` and `zext min(...) ...`.

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

16 months ago[DemandedBits] Print function name when printing analysis.
Florian Hahn [Thu, 6 Jul 2023 13:17:20 +0000 (14:17 +0100)]
[DemandedBits] Print function name when printing analysis.

Include the function name + analysis when printing the analysis for
testing.

16 months ago[docs] Update 'please file a bug' link for clang-cl
Hans Wennborg [Thu, 6 Jul 2023 13:12:42 +0000 (15:12 +0200)]
[docs] Update 'please file a bug' link for clang-cl

16 months ago[GlobalISel][X86] Regenerate add/sub legalization tests
Simon Pilgrim [Thu, 6 Jul 2023 11:24:05 +0000 (12:24 +0100)]
[GlobalISel][X86] Regenerate add/sub legalization tests

16 months ago[InstSimplify] Fold gep inbounds undef to undef instead of poison
Nikita Popov [Fri, 30 Jun 2023 13:31:47 +0000 (15:31 +0200)]
[InstSimplify] Fold gep inbounds undef to undef instead of poison

With the semantics change from D154051, it is no longer valid to
fold gep inbounds undef to poison (unless we know the index is
non-zero). Fold it to undef instead.

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

16 months ago[MLIR][Linalg] Add more arith named ops to linalg (take 2)
Renato Golin [Thu, 6 Jul 2023 11:03:16 +0000 (12:03 +0100)]
[MLIR][Linalg] Add more arith named ops to linalg (take 2)

Re-apply eda47fdd258c after implementing __truediv__ for TensorUse.

[MLIR][Linalg] Add more arith named ops to linalg

Following up the 'add' named op, here are the remaining basic arithmetic
and maths, including a 'div_unsigned' for integer unsigned values. In the
same pattern as 'matmul_unsigned', the simply named 'div' assumes signed
values and the '_unsigned' variation handles the unsigned values.

It's a bit odd, but there doesn't seem to be a easy way to restrict to
specific types to make 'div_unsigned' only work with integers in the
structured ops framework.

Same as 'add', these have strict semantics regarding casts.

Unary math ops will need some massaging, so I split these ones for now
as I continue working on them.

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

16 months ago[AIX][TLS] Generate optimized local-exec access code sequence using X-Form loads...
Amy Kwan [Fri, 30 Jun 2023 16:01:02 +0000 (11:01 -0500)]
[AIX][TLS] Generate optimized local-exec access code sequence using X-Form loads/stores

This patch is a follow up to D149722, D152669 and D153645, where a slightly more
optimized code sequence is generated for 64-bit and 32-bit local-exec accesses
when optimizations are turned on.

Handling is added PPCISelDAGToDAG.cpp in order to check if any D-form loads or
stores that follow an PPCISD::ADD_TLS can be optimized to use an X-Form load or
store. In this particular situation, this allows the ADD_TLS node to be removed
completely.

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

16 months ago[clang][Interp][NFC] Move some declarations into the if condition
Timm Bäder [Thu, 6 Jul 2023 06:19:38 +0000 (08:19 +0200)]
[clang][Interp][NFC] Move some declarations into the if condition

16 months ago[clang][Interp][NFC] Fix some doc comment confusion
Timm Bäder [Thu, 6 Jul 2023 06:57:23 +0000 (08:57 +0200)]
[clang][Interp][NFC] Fix some doc comment confusion

These are supposed to be regular comments.

16 months ago[clang][Interp][NFC] Take a const Function pointer in Context::Run()
Timm Bäder [Thu, 6 Jul 2023 07:11:17 +0000 (09:11 +0200)]
[clang][Interp][NFC] Take  a const Function pointer in Context::Run()

16 months ago[clang][Interp][NFC] Make a local variable const
Timm Bäder [Thu, 6 Jul 2023 07:24:13 +0000 (09:24 +0200)]
[clang][Interp][NFC] Make a local variable const

And add some assertions.

16 months ago[clang][Interp][NFC] Return a const Descriptor from a getter
Timm Bäder [Thu, 6 Jul 2023 07:37:45 +0000 (09:37 +0200)]
[clang][Interp][NFC] Return a const Descriptor from a getter

They are generally immutable anyway. Also fix some doc comments.

16 months ago[LangRef] Always allow getelementptr inbounds with zero offset
Nikita Popov [Thu, 29 Jun 2023 08:46:44 +0000 (10:46 +0200)]
[LangRef] Always allow getelementptr inbounds with zero offset

Currently, our GEP specification has a special case that makes
gep inbounds (null, 0) legal. This patch proposes to expand this
special case to all gep inbounds (ptr, 0), where ptr is no longer
required to point to an allocated object.

This was previously discussed in some detail at
https://discourse.llvm.org/t/question-about-getelementptr-inbounds-with-offset-0/62533.

The motivation for this change is twofold:

 * Rust relies on getelementptr inbounds with zero offset to be
   legal for arbitrary pointers to support zero-sized types. The
   current rules are unclear on whether this is legal or not
   (saying that there is a zero-size "allocated object" at every
   address may be consistent with our current rules, but more
   clarity is desired here).
 * The current semantics require us to drop the inbounds flag
   when materializing zero-index GEPs, which is done by some
   InstCombine transforms. Preserving the inbounds flag can
   substantially improve optimization quality in some cases, as
   illustrated in D154055.

As far as I know, the only analysis/transforms affected by this
semantics change are:

 * A special-case for comparisons with null in CaptureTracking,
   which is fixed by D154054. As far as I can tell, that special
   case is not particularly valuable and should be recovered by
   other transforms.
 * Folding gep inbounds undef, idx to poison. We now need to fold
   to undef instead (D154215).

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

16 months ago[libc++] Fix thread annotations on shared_mutex and shared_timed_mutex
Louis Dionne [Mon, 3 Jul 2023 15:02:47 +0000 (11:02 -0400)]
[libc++] Fix thread annotations on shared_mutex and shared_timed_mutex

Based on the comment in https://reviews.llvm.org/D54290#4418958, these
attributes need to be on the top-level functions in order to work
properly. Also, add tests.

Fixes http://llvm.org/PR57035.

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

16 months ago[RISCV][test] Add RV32I and RV64I RUN lines to llvm.frexp.ll
Alex Bradbury [Thu, 6 Jul 2023 12:34:58 +0000 (13:34 +0100)]
[RISCV][test] Add RV32I and RV64I RUN lines to llvm.frexp.ll

Thanks to D154555, these intrinsics no longer crash when used with a
soft float ABI.

16 months ago[LV] Consider if scalar epilogue is required in getMaximizedVFForTarget.
Florian Hahn [Thu, 6 Jul 2023 12:31:44 +0000 (13:31 +0100)]
[LV] Consider if scalar epilogue is required in getMaximizedVFForTarget.

When a scalar epilogue is required, at least one iteration of the scalar loop
has to execute. Adjust ConstTripCount accordingly to avoid picking a max VF
that results in a dead vector loop.

Reviewed By: Ayal

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

16 months ago[lldb][NFC] Remove code duplication in InitOSO
Felipe de Azevedo Piovezan [Wed, 5 Jul 2023 12:44:52 +0000 (08:44 -0400)]
[lldb][NFC] Remove code duplication in InitOSO

Two identical loops were iterating over different ranges, leading to code
duplication. We replace this by a loop over the concatenation of the ranges.

We also use early returns to avoid deeply nested code and explicitly check for a
condition mentioned in comments.

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

16 months agoFix compile error in UnresolvedSetTest.cpp, hopefully the last one
John Brawn [Thu, 6 Jul 2023 10:48:10 +0000 (11:48 +0100)]
Fix compile error in UnresolvedSetTest.cpp, hopefully the last one

This test is failing to compile when LLVM_ENABLE_MODULES=ON due to
NamedDecl being multiply defined. Fix this by avoiding declaring our
own NamedDecl in the test and instead cast a struct of appropriate
size and alignment to NamedDecl.

16 months agoupdate_mir_test_checks.py - separate different prefix checks
Eddie Phillips [Thu, 6 Jul 2023 10:48:56 +0000 (11:48 +0100)]
update_mir_test_checks.py - separate different prefix checks

Matches behaviour in update_llc_test_checks.py etc.

Fixes #63112

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

16 months ago[AMDGPU] Add GlobalISel test coverage for floating-point truncations.
Ivan Kosarev [Thu, 6 Jul 2023 10:22:25 +0000 (11:22 +0100)]
[AMDGPU] Add GlobalISel test coverage for floating-point truncations.

Reviewed By: arsenm

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

16 months ago[compiler-rt] Fix __sanitizer_cpuset size on newer FreeBSD
Marco Elver [Thu, 6 Jul 2023 10:25:47 +0000 (12:25 +0200)]
[compiler-rt] Fix __sanitizer_cpuset size on newer FreeBSD

Current FreeBSD has increased size of cpuset. Match it to not break the
build on newer FreeBSD.

Patch by John F. Carr

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