platform/upstream/llvm.git
15 months agoAdd tracing for pattern application in a ApplyPatternAction
Mehdi Amini [Tue, 11 Apr 2023 00:39:34 +0000 (18:39 -0600)]
Add tracing for pattern application in a ApplyPatternAction

Reviewed By: rriddle

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

15 months ago[Updated commit] Fix Transpose Check in MMA.SYNC Path.
Manish Gupta [Thu, 6 Apr 2023 23:58:17 +0000 (23:58 +0000)]
[Updated commit] Fix Transpose Check in MMA.SYNC Path.

Pushed a stale commit for the same review in my previous commit.
I am updating the main-line with the latest commit including
review commits. Apologies for the redundant commit.

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

15 months agoFix Transpose Check in MMA.SYNC Path
Manish Gupta [Thu, 6 Apr 2023 23:58:17 +0000 (23:58 +0000)]
Fix Transpose Check in MMA.SYNC Path

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

15 months ago[flang][NFC] Move TypeConverter.h header file to include dir
Valentin Clement [Tue, 11 Apr 2023 00:01:10 +0000 (17:01 -0700)]
[flang][NFC] Move TypeConverter.h header file to include dir

After the extraction of the TypeConverter, move the header files
to the include dir so the shared library build is fine.

Reviewed By: PeteSteinfeld

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

15 months ago[clang-tidy][NFC] Remove redundant allOf matcher calls
Nathan James [Mon, 10 Apr 2023 23:38:37 +0000 (00:38 +0100)]
[clang-tidy][NFC] Remove redundant allOf matcher calls

Remove calls to the `allOf` matcher in all matchers that are derived from the `VariadicDynCastAllOfMatcher`.

15 months ago[libc] Add swab implementation
Caslyn Tonelli [Mon, 10 Apr 2023 20:24:58 +0000 (20:24 +0000)]
[libc] Add swab implementation

Swab implementation is added to libc/src/unistd.

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

15 months ago[ifs] Print an error when llvm-ifs is supplied with an unknown arch
Haowei Wu [Wed, 22 Mar 2023 23:41:47 +0000 (16:41 -0700)]
[ifs] Print an error when llvm-ifs is supplied with an unknown arch

This patch makes llvm-ifs print an error when the arch string from
'--arch' flag or the IFS file 'Arch' field is unknown.

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

15 months ago[TableGen] Pass TreePatternNodePtr to InlinePatternFragments by const reference. NFC
Craig Topper [Mon, 10 Apr 2023 20:36:52 +0000 (13:36 -0700)]
[TableGen] Pass TreePatternNodePtr to InlinePatternFragments by const reference. NFC

Not all paths through this function require the reference count
to be incremened. Pass by reference so we don't increase the count
unnecessarily.

15 months ago[flang][openacc] Add missing piece to translate to LLVM IR dialect
Valentin Clement [Mon, 10 Apr 2023 21:29:58 +0000 (14:29 -0700)]
[flang][openacc] Add missing piece to translate to LLVM IR dialect

Add missing pieces to translate handle OpenACC dialect in the translation.

Depends on D147825

Reviewed By: PeteSteinfeld, razvanlupusoru

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

15 months ago[libcxxabi, libunwind] [test] Place output from tests under a 'test' subdir
Martin Storsjö [Wed, 5 Apr 2023 10:56:54 +0000 (13:56 +0300)]
[libcxxabi, libunwind] [test] Place output from tests under a 'test' subdir

Previously, all the output from the tests were placed directly in
the build directory. The tests produce a couple directories named
`__config_{exec,cache,src}__` which are easy to distinguish, and
the output from the individual tests were placed directly in a
directory named `Output`.

This is the same change as
736c6e246f5398331d83edd204a846cc967ad5c6, but for the libcxxabi
and libunwind test suites.

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

15 months ago[mlir][math] Expand math.floorf to truncate, compares and increments
Balaji V. Iyer [Mon, 10 Apr 2023 21:01:26 +0000 (21:01 +0000)]
[mlir][math] Expand math.floorf to truncate, compares and increments

Floorf are pushed directly to libm. This is problematic for
situations where libm is not available. This patch will break down
a floorf function to truncate followed by an increment for negative
values, if necessary.

Reviewed By: rsuderman

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

15 months ago[compiler-rt] [test] Generalize the triple regex for windows XFAILs
Martin Storsjö [Fri, 31 Mar 2023 05:47:59 +0000 (08:47 +0300)]
[compiler-rt] [test] Generalize the triple regex for windows XFAILs

Don't hardcode the vendor field in the triples to "pc"; for mingw
environments the triple is often "<arch>-w64-windows-gnu".

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

15 months ago[compiler-rt] [test] [ubsan] Build .cpp files with %clangxx
Martin Storsjö [Thu, 6 Apr 2023 10:11:46 +0000 (13:11 +0300)]
[compiler-rt] [test] [ubsan] Build .cpp files with %clangxx

This fixes linker errors in mingw configurations, where the ubsan
runtime needs the C++ standard library when instrumenting C++ code.

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

15 months ago[compiler-rt] [test] Use %clangxx for tests that use -x c++
Martin Storsjö [Wed, 5 Apr 2023 21:41:51 +0000 (21:41 +0000)]
[compiler-rt] [test] Use %clangxx for tests that use -x c++

When instrumenting C++ code, ubsan ends up referencing
the ubsan_type_hash_* object files, which require linking against
the C++ ABI library. When building with "clang -x c++", the code
is handled as C++, but the compiler still only links as if it was
C.

Change all cases of "%clang -x c++" into "%clangxx -x c++".

This fixes a lot of ubsan tests in mingw mode.

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

15 months ago[compiler-rt] [builtins] Don't use assembly floatundi*f on x86_64 mingw
Martin Storsjö [Thu, 6 Apr 2023 07:51:35 +0000 (07:51 +0000)]
[compiler-rt] [builtins] Don't use assembly floatundi*f on x86_64 mingw

The x86 assembly is entirely skipped for MSVC build configurations,
since the assembly uses GAS syntax (which MSVC proper can't
assemble, but clang-cl can). But for mingw configurations, the
assembly is used.

On x86_64 Windows, the general calling convention is entirely different
than on other platforms (passing arguments in different registers),
so we can't use this assembly for mingw targets (unless adapted to
handle that calling convention). Thus skip these few assembly routines
for Windows targets. (For i386, we can keep using the assembly
functions.)

This fixes the builtins tests that test these routines. They aren't
used in practice though, as LLVM expands code inline for doing such
conversions anyway.

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

15 months ago[libcxxabi] [test] Mark thread_local_destruction_order.pass.cpp unsupported for mingw...
Martin Storsjö [Mon, 3 Apr 2023 12:52:46 +0000 (15:52 +0300)]
[libcxxabi] [test] Mark thread_local_destruction_order.pass.cpp unsupported for mingw targets

With current versions of mingw-w64, TLS destructors that are registered
while executing TLS destructors are lost and leaked.

The root cause does get fixed further upstream in mingw-w64 in
https://github.com/mingw-w64/mingw-w64/commit/71eddccd746c56d9cde28bb5620d027d49259de9
though, but mark the test as unsupported for now. The marking can be
removed later when the version used in the CI runner has been updated
to include the fix.

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

15 months ago[libunwind] [test] Mark the signal_frame test as unsupported on Windows
Martin Storsjö [Fri, 31 Mar 2023 21:52:05 +0000 (00:52 +0300)]
[libunwind] [test] Mark the signal_frame test as unsupported on Windows

Mark it as unsupported on x86_64, arm and aarch64. On i686, DWARF
is used as the default unwinding format, and there, the CFI
directives are supported.

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

15 months ago[libunwind] [SEH] Handle ExceptionContinueExecution in forced unwinding
Martin Storsjö [Wed, 5 Apr 2023 10:42:22 +0000 (10:42 +0000)]
[libunwind] [SEH] Handle ExceptionContinueExecution in forced unwinding

This fixes the libcxxabi test force_unwind3.pass.cpp when run on native
Windows.

When unwinding past the main thread function into the system functions
that brought up the thread, we can hit functions whose personality
functions return ExceptionContinueExecution (instead of the regular
ExceptionContinueSearch). Interpret this as a signal to stop the
unwind.

Curiously, in this case, it does return ExceptionContinueSearch if
running within a debugger.

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

15 months ago[libunwind] [SEH] Sync LSDA and handler between unw_proc_info_t and DISPATCHER_CONTEXT
Martin Storsjö [Tue, 4 Apr 2023 20:26:20 +0000 (20:26 +0000)]
[libunwind] [SEH] Sync LSDA and handler between unw_proc_info_t and DISPATCHER_CONTEXT

For normal C++ unwinding, we get _dispContext initialized by the
prepopulated DISPATCHER_CONTEXT in _GCC_specific_handler, which
we set with __unw_seh_set_disp_ctx.

When doing force unwinding, we step and populate the unw_proc_info_t
struct _info with getInfoFromSEH, but when we execute the handler
via the __libunwind_seh_personality wrapper function, we execute
the handler set in DISPATCHER_CONTEXT.

Whenever updating these fields in either _info or _dispContext,
sync them to the other one too.

This fixes one aspect of the libcxxabi force_unwind*.pass.cpp tests on
x86_64.

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

15 months ago[libunwind] Increase the external value of _LIBUNWIND_CURSOR_SIZE for SEH/x86_64
Martin Storsjö [Wed, 5 Apr 2023 11:12:24 +0000 (14:12 +0300)]
[libunwind] Increase the external value of _LIBUNWIND_CURSOR_SIZE for SEH/x86_64

For x86_64 Windows targets (that use SEH), _LIBUNWIND_CURSOR_SIZE
is 204; this fixes corruption in test cases that include libunwind.h
without manually defining _LIBUNWIND_IS_NATIVE_ONLY.

If the libunwind.h header is included without defining
_LIBUNWIND_IS_NATIVE_ONLY (like in the libunwind test cases), the
sizes are set to accommodate the maximum possible cursors and
contexts.

(Alternatively, __libunwind_config.h should be changed to default
to native unwinding unless cross unwinding has been requested.
Cross unwinding isn't implemented as far as I know anyway.)

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

15 months ago[lldb][NFC] Update syntax description for language cplusplus demangle
Alex Langford [Sat, 8 Apr 2023 05:50:45 +0000 (22:50 -0700)]
[lldb][NFC] Update syntax description for language cplusplus demangle

Also added some tests because this is completely untested.

rdar://107780577

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

15 months ago[flang][openacc] Add data operands conversion from FIR
Valentin Clement [Mon, 10 Apr 2023 20:32:37 +0000 (13:32 -0700)]
[flang][openacc] Add data operands conversion from FIR

This patch revive an old PR attempt [1] to perform the
data operands conversion needed for translation to LLVMIR.

This is currently not supporting box/class type since they will
normally not reach this pass when the proposed change in this RFC [2]
are implemented.

[1] https://github.com/flang-compiler/f18-llvm-project/pull/915
[2] https://discourse.llvm.org/t/rfc-openacc-dialect-data-operation-improvements/69825/2

Depends on D147824

Reviewed By: PeteSteinfeld, razvanlupusoru

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

15 months ago[LV] Re-use already computed runtime VF in fixFixedOrderRecurrence.
Florian Hahn [Mon, 10 Apr 2023 20:25:11 +0000 (21:25 +0100)]
[LV] Re-use already computed runtime VF in fixFixedOrderRecurrence.

This was suggested as independent cleanup in D147472.

This removes a redundant runtime VF computation when using scalable
vectors.

15 months ago[LV] Turn check into assert in fixFixedOrderRecurrence (NFCI).
Florian Hahn [Mon, 10 Apr 2023 20:11:40 +0000 (21:11 +0100)]
[LV] Turn check into assert in fixFixedOrderRecurrence (NFCI).

Suggested as independent cleanup in D147567. Either VF or UF need to be
> 1. Note that if the condition would be false, the code below would use
a nullptr and crash.

15 months ago[VPlan] Only create extracts for recurrence exits if there are live-outs.
Florian Hahn [Mon, 10 Apr 2023 20:08:33 +0000 (21:08 +0100)]
[VPlan] Only create extracts for recurrence exits if there are live-outs.

Move the code to collect live-out earlier and only generate extracts for
exit values if there are any live-outs that use them.

Depends on D147472.

Reviewed By: Ayal

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

15 months agoRevert "[flang][openacc] Add data operands conversion from FIR"
Valentin Clement [Mon, 10 Apr 2023 20:05:37 +0000 (13:05 -0700)]
Revert "[flang][openacc] Add data operands conversion from FIR"

This reverts commit 68bcd647c9c006b707bc9a675a874658cd085d13.

15 months agoRevert "[flang][openacc] Add missing piece to translate to LLVM IR dialect"
Valentin Clement [Mon, 10 Apr 2023 20:05:23 +0000 (13:05 -0700)]
Revert "[flang][openacc] Add missing piece to translate to LLVM IR dialect"

This reverts commit 03289dc7af257684a4278ce4c38b0b07ad749b71.

15 months ago[clang-tidy] Support specifying checks as a list in the config file
Carlos Galvez [Sat, 8 Apr 2023 17:43:34 +0000 (17:43 +0000)]
[clang-tidy] Support specifying checks as a list in the config file

Specifying checks as a string is convenient for quickly using
clang-tidy to run a handful of checks. However it is not
suitable for projects that have a long list of enabled or
disabled checks. It is specially troublesome in case one
wants to interleave comments with the checks, to explain
why they are enabled or disabled.

Currently this can be achieved via multiline strings in YAML,
but it's error-prone. For example, comments must end with a
comma for clang-tidy to continue processing the list of globs;
a missing comma will make clang-tidy silently ignore the rest
of the list.

Instead, enable passing a native YAML list to the "Checks"
option in the config file. The implementation is done such
that the old behavior is kept: a user can pass a string
or a list. We can consider deprecating passing the checks
as a string altogether in a future release, to simplify
the internal logic of the YAML parser.

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

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

15 months ago[mlgo][inl] Interactive mode: optionally tell the default decision
Mircea Trofin [Fri, 7 Apr 2023 17:36:26 +0000 (10:36 -0700)]
[mlgo][inl] Interactive mode: optionally tell the default decision

This helps training algorithms that may want to sometimes replicate the
default decision. The default decision is presented as an extra feature
called `inlining_default`. It's not normally exported to save
computation time.

This is only available in interactive mode.

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

15 months ago[flang][NFC] Fix invalid op result access
Valentin Clement [Mon, 10 Apr 2023 19:19:26 +0000 (12:19 -0700)]
[flang][NFC] Fix invalid op result access

Fix invalid op result access. This will trigger
assertion introduced in D147883.

Reviewed By: frgossen

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

15 months ago[flang][openacc] Add missing piece to translate to LLVM IR dialect
Valentin Clement [Mon, 10 Apr 2023 19:18:37 +0000 (12:18 -0700)]
[flang][openacc] Add missing piece to translate to LLVM IR dialect

Add missing pieces to translate handle OpenACC dialect in the translation.

Depends on D147825

Reviewed By: PeteSteinfeld, razvanlupusoru

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

15 months ago[flang][openacc] Add data operands conversion from FIR
Valentin Clement [Mon, 10 Apr 2023 19:17:42 +0000 (12:17 -0700)]
[flang][openacc] Add data operands conversion from FIR

This patch revive an old PR attempt [1] to perform the
data operands conversion needed for translation to LLVMIR.

This is currently not supporting box/class type since they will
normally not reach this pass when the proposed change in this RFC [2]
are implemented.

[1] https://github.com/flang-compiler/f18-llvm-project/pull/915
[2] https://discourse.llvm.org/t/rfc-openacc-dialect-data-operation-improvements/69825/2

Depends on D147824

Reviewed By: PeteSteinfeld, razvanlupusoru

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

15 months ago[Clang] Fix cast to BigIntType in hasUniqueObjectRepresentations
Roy Jacobson [Mon, 10 Apr 2023 04:26:30 +0000 (07:26 +0300)]
[Clang] Fix cast to BigIntType in hasUniqueObjectRepresentations

A bad QualType cast caused us not to detect _BigInt types if they were wrapped inside sugar types like SubstTemplateTypeParm.
Fix https://github.com/llvm/llvm-project/issues/62019

Reviewed By: cjdb

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

15 months ago[Docs][llvm-exegesis] Add documentation for --use-dummy-perf-counters
Aiden Grossman [Mon, 10 Apr 2023 19:08:27 +0000 (19:08 +0000)]
[Docs][llvm-exegesis] Add documentation for --use-dummy-perf-counters

This patch adds in documentation for the --use-dummy-perf-counters
option (introduced in D146301).

Reviewed By: kpdev42

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

15 months ago[-Wunsafe-buffer-usage] Improve fix-its for local variable declarations with null...
ziqingluo-90 [Mon, 10 Apr 2023 18:54:11 +0000 (11:54 -0700)]
[-Wunsafe-buffer-usage] Improve fix-its for local variable declarations with null pointer initializers

For a local pointer declaration of the form `T * p = 0` or `T * p = std::nullptr`,

Before this patch, we generate fix-its that convert the declaration to
`std::span<T> p{nullptr, <# placeholder #>}`, in cases where `p` is
used in some unsafe operations.  This patch improves the fix-its to
result in a simpler form `std::span<T> p`. It gets rid of the
placeholder and keeps the result concise.

Reviewed by: NoQ (Artem Dergachev)

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

15 months ago[bazel][NFC] Replace @bazel_tools//src/conditions with equivalent @platforms rules
Jordan Rupprecht [Mon, 10 Apr 2023 18:42:58 +0000 (11:42 -0700)]
[bazel][NFC] Replace @bazel_tools//src/conditions with equivalent @platforms rules

Followup to D147354. Using src/conditions is discouraged in favor of using rules from the `@platforms` repository directly.

This replaces three conditions:
* `@bazel_tools//src/conditions:windows` -> `@platforms//os:windows`
* `@bazel_tools//src/conditions:darwin` -> `@platforms//os:macos`
* `@bazel_tools//src/conditions:freebsd` -> `@platforms//os:freebsd`

`llvm/config.bzl` has a non-trivial OS+CPU selection config, so that is omitted from this patch. There is intentionally no equivalent for that in `@platforms` because every project will have their own opinions about what a platform is, and it is not feasible for the bazel selection list to include every possible combination. The recommended idiom there is for projects to define their own supported platforms list, e.g. in a separate BUILD file or platform mapping.

Reviewed By: GMNGeoffrey

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

15 months ago[TableGen] Simplify how commuted variants are generated in GenerateVariantsOf. NFC
Craig Topper [Mon, 10 Apr 2023 18:29:01 +0000 (11:29 -0700)]
[TableGen] Simplify how commuted variants are generated in GenerateVariantsOf. NFC

We don't need to copy the ChildVariants vector into a new vector.
We're using std::move on every entry we copy so they clearly
aren't needed again. We can swap entries in the vector and reuse
it instead.

15 months ago[gn build] Port eb65912e41a1
Nico Weber [Mon, 10 Apr 2023 18:10:59 +0000 (14:10 -0400)]
[gn build] Port eb65912e41a1

15 months agoAMDGPU: Created a subclass for the return address operand in the tail call return...
Changpeng Fang [Mon, 10 Apr 2023 17:53:33 +0000 (10:53 -0700)]
AMDGPU: Created a subclass for the return address operand in the tail call return instruction

Summary:
  This is to avoid using the callee saved registers for the return address
of the tail call return instruction.

Reviewers:
  arsenm, cdevadas

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

15 months ago[clang][driver] Pass `-femulated-tls` through to the linker in LTO mode
Paul Kirth [Mon, 13 Feb 2023 18:18:33 +0000 (18:18 +0000)]
[clang][driver] Pass `-femulated-tls` through to the linker in LTO mode

Currently the driver does not propagate the `-f[no-]emulated-tls` flags
to the linker under LTO. This can be surprising when the platform
defaults differ from the flags being passed. A related discussion can be
found in https://reviews.llvm.org/D143619. While the focus there was
RISC-V support, the root cause was that setting `-femualted-tls` and
`-flto` when compiling with Clang resulted in missing symbols because
the platform defaults for Android differed from the flags being passed
to Clang.

This patch changes the Clang driver's behavior to pass the emulated-tls
flags through to the linker when compiling with LTO/ThinLTO.

Reviewed By: phosek, vit9696

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

15 months ago[libc++] Move __errc to __system_error/errc.h
Nikolas Klauser [Sun, 19 Mar 2023 22:10:37 +0000 (23:10 +0100)]
[libc++] Move __errc to __system_error/errc.h

This file was added before we started granularizing the headers, but is essentially just a granularized header. This moves the header to the correct place.

Reviewed By: #libc, EricWF

Spies: libcxx-commits, arichardson, mikhail.ramalho

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

15 months ago[lldb] Implement SymbolFile::GetCompileOptions
Augusto Noronha [Fri, 7 Apr 2023 22:46:33 +0000 (15:46 -0700)]
[lldb] Implement SymbolFile::GetCompileOptions

Implement SymbolFile::GetCompileOptions, which returns a map from
compilation units to compilation arguments associated with that unit.

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

15 months agoFix warnings
Kazu Hirata [Mon, 10 Apr 2023 17:11:41 +0000 (10:11 -0700)]
Fix warnings

This patch fixes:

  mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp:1334:51:
  warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]

  lld/wasm/Writer.cpp:250:39: warning: suggest parentheses around ‘&&’
  within ‘||’ [-Wparentheses]

15 months ago[libc][obvious] fix new assert typo
Michael Jones [Mon, 10 Apr 2023 17:01:31 +0000 (10:01 -0700)]
[libc][obvious] fix new assert typo

15 months agoAdd support for math.ctlz in convert-math-to-funcs
Jeremy Kun [Mon, 10 Apr 2023 15:57:34 +0000 (08:57 -0700)]
Add support for math.ctlz in convert-math-to-funcs

This change adds a software implementation of the `math.ctlz` operation
and includes it in `--convert-math-to-funcs`.

This is my first change to MLIR, so please bear with me as I'm still learning
the idioms of the codebase.

The context for this change is that I have some larger scale project in which
I'd like to lower from a mix of MLIR dialects to CIRCT, but many of the CIRCT
passes don't support the `math` dialect.

I noticed the content of `convert-math-to-funcs` was limited entirely to
the `pow` functions, but otherwise provided the needed structure to implement
this feature with minimal changes.

Highlight of the changes:

- Add a dependence on the SCF dialect for this lower. I could have lowered
  directly to cf, following the pow lowerings in the same pass, but I felt it
  was not necessary given the existing support for lowering scf to cf.
- Generalize the DenseMap storing op implementations: modify the callback
  function hashmap to be keyed by both OperationType (for me this effectively
  means the name of the op being implemented in software) and the type
  signature of the resulting function.
- Implement the ctlz function as a loop. I had researched a variety of
  implementations that claimed to be more efficient (such as those based on a
  de Bruijn sequence), but it seems to me that the simplest approach would make
  it easier for later compiler optimizations to do a better (platform-aware)
  job optimizing this than I could do by hand.

Questions I had for the reviewer:

- [edit: found mlir-cpu-runner and added two tests] What would I add to the filecheck invocation to actually run the resulting MLIR on a value and assert the output is correct? I have done this manually with the C implementation but I'm not confident my port to MLIR is correct.
- Should I add a test for a vectorized version of this lowering? I followed suit with the ` VecOpToScalarOp` but I admit I don't fully understand what it's doing.

Reviewed By: vzakhari

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

15 months ago[libc][math] Update range reduction step for logf and reduce its latency.
Tue Ly [Fri, 7 Apr 2023 01:45:45 +0000 (21:45 -0400)]
[libc][math] Update range reduction step for logf and reduce its latency.

Simplify the range reduction steps by choosing the reduction constants
carefully so that the reduced arguments v = r*m_x - 1 and v^2 are exact in double
precision, even without FMA instructions, and -2^-8 <= v < 2^-7. This allows the
polynomial evaluations to be parallelized more efficiently.

Reviewed By: santoshn, zimmermann6

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

15 months ago[libc] clean up ctype negative handling
Michael Jones [Fri, 7 Apr 2023 21:02:39 +0000 (14:02 -0700)]
[libc] clean up ctype negative handling

The ctype functions will sometimes be passed negative numbers, such as
EOF. Some of the previous implementations didn't handle these properly.
Additionally, the tests did not check any negative numbers. These
problems have been fixed.

This patch fixes https://github.com/llvm/llvm-project/issues/62000

Reviewed By: lntue

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

15 months agoFix wording in a release note; NFC
Aaron Ballman [Mon, 10 Apr 2023 16:53:50 +0000 (12:53 -0400)]
Fix wording in a release note; NFC

This change happened due to post-commit feedback on the review.

15 months agoFix invalid op result access in SparseTensorCodegen
Frederik Gossen [Mon, 10 Apr 2023 16:30:27 +0000 (12:30 -0400)]
Fix invalid op result access in SparseTensorCodegen

This trigges an assertion introduced in https://reviews.llvm.org/D147883

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

15 months ago[AMDGPU] Fix AddedComplexity for s_buffer_load patterns. NFCI.
Jay Foad [Mon, 6 Mar 2023 16:33:49 +0000 (16:33 +0000)]
[AMDGPU] Fix AddedComplexity for s_buffer_load patterns. NFCI.

We set AddedComplexity = 100 for s_load patterns to prefer them over
global loads, but for s_buffer_load patterns there is no need to do
this and it was quietly overriding the AddedComplexity of each
individual GCNPat that is defined inside SMLoad_Pattern (but in practice
that did not appear to make any difference).

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

15 months agoChange dyn_cast to cast
Bing1 Yu [Mon, 10 Apr 2023 16:14:04 +0000 (00:14 +0800)]
Change dyn_cast to cast

Reviewed By: pengfei

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

15 months ago[mlir][tosa] Lowering of tosa.gather operations with dynamic dimensions
Spenser Bauman [Mon, 10 Apr 2023 15:55:54 +0000 (15:55 +0000)]
[mlir][tosa] Lowering of tosa.gather operations with dynamic dimensions

The existing TOSA->Linalg lowering of tosa.gather only supports gathers
with either a static shape or a single dynamic batch dimension.
This change extends support to arbitrary number of dynamic dimensions on
both the values and indices of the gather operation.

Reviewed By: rsuderman

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

15 months ago[flang][NFC] Extract TypeConverter from header file
Valentin Clement [Mon, 10 Apr 2023 15:33:52 +0000 (08:33 -0700)]
[flang][NFC] Extract TypeConverter from header file

Extract the type converter definitions into its own .cpp
file so the type converter can be used by passes.

Reviewed By: PeteSteinfeld

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

15 months ago[Clang] Check type-constraints applied to placeholder types
Corentin Jabot [Mon, 10 Apr 2023 09:52:30 +0000 (11:52 +0200)]
[Clang] Check type-constraints applied to placeholder types

(and deduced return types)

Previously, only type constraints applied to type parameter
were semantically checked.

A diagnostic would still be emitted on instantiation, but it was
too late, lacked clarity, and was inconsistent with type parameters.

Reviewed By: erichkeane

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

15 months ago[asan][test] Fix two test cases on Windows
Alvin Wong [Sun, 2 Apr 2023 18:26:30 +0000 (02:26 +0800)]
[asan][test] Fix two test cases on Windows

Fixes global-location-nodebug and heavy_uar_test for both MSVC and MinGW
targets.

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

15 months ago[sanitizer][win] Fix `Atexit()` on MinGW asan_dynamic runtime
Alvin Wong [Sun, 2 Apr 2023 15:19:23 +0000 (23:19 +0800)]
[sanitizer][win] Fix `Atexit()` on MinGW asan_dynamic runtime

Some functions of asan depends on `Atexit()` handlers. On Windows, this
is implemented in ad3ec82bb1c7217b0187a1e16bb22642e194ce94 to queue the
handlers in a vector then register them with `atexit()` only after the
CRT is fully initialized. However, this is broken on MinGW with
asan_dynamic runtime due to different initialization order. This change
fixes the issue by making sure that `Atexit()` can call `atexit()`
directly past the pre-initialization phase.

This fixes two asan test cases on MinGW.

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

15 months ago[clang-tidy] Added IgnoreVirtual option to misc-unused-parameters
Piotr Zegar [Mon, 10 Apr 2023 14:41:32 +0000 (14:41 +0000)]
[clang-tidy] Added IgnoreVirtual option to misc-unused-parameters

Added option to ignore virtual methods in this check.
This allows to quickly get rid of big number of
potentialy false-positive issues without inserting
not-needed comments.

Fixes #55665.

Reviewed By: njames93

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

15 months ago[LoopPredication] Fix where we generate widened condition. PR61963
Anna Thomas [Thu, 6 Apr 2023 18:42:14 +0000 (14:42 -0400)]
[LoopPredication] Fix where we generate widened condition. PR61963

Loop predication's predicateLoopExit pass does two incorrect things:

It sinks the widenable call into the loop, thereby converting an invariant condition to a variant one
It widens the widenable call at a branch thereby converting the branch into a loop-varying one.

The latter is problematic when the branch may have been loop-invariant
and prior optimizations (such as indvars) may have relied on this
fact, and updated the deopt state accordingly.

Now, when we widen this with a loop-varying condition, the deopt state
is no longer correct.
https://github.com/llvm/llvm-project/issues/61963 fixed.

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

15 months agoSimplify test with deopt state in D147662. NFC
Anna Thomas [Mon, 10 Apr 2023 14:28:19 +0000 (10:28 -0400)]
Simplify test with deopt state in D147662. NFC

15 months ago[NFC][tests] Disable new gmodules-preferred-name-* tests on AIX and z/OS
Jake Egan [Mon, 10 Apr 2023 13:43:31 +0000 (09:43 -0400)]
[NFC][tests] Disable new gmodules-preferred-name-* tests on AIX and z/OS

Objective-C is not supported on AIX and z/OS. Precedent here: D109060

15 months ago[AMDGPU][NFC] Regenerate test checks for merge-tbuffer.mir
skc7 [Mon, 10 Apr 2023 13:07:17 +0000 (18:37 +0530)]
[AMDGPU][NFC] Regenerate test checks for merge-tbuffer.mir

15 months agoFix the buildbots after 636dd1e8a1782e22f9bdee640428ed5c50a4a4f2
Aaron Ballman [Mon, 10 Apr 2023 12:45:56 +0000 (08:45 -0400)]
Fix the buildbots after 636dd1e8a1782e22f9bdee640428ed5c50a4a4f2

This addresses issues found by:
http://45.33.8.238/linux/103908/step_4.txt
https://lab.llvm.org/buildbot/#/builders/216/builds/19607
and others

15 months ago[clang-tidy][NFC] Remove trailing spaces from ReleaseNotes.rst
Piotr Zegar [Mon, 10 Apr 2023 12:42:24 +0000 (12:42 +0000)]
[clang-tidy][NFC] Remove trailing spaces from ReleaseNotes.rst

Cleanup some trailing whitespaces from ReleaseNotes.rst

15 months agoMake explicit the single-argument constructors of AttributeCommonInfo; NFC
Aaron Ballman [Mon, 10 Apr 2023 12:29:21 +0000 (08:29 -0400)]
Make explicit the single-argument constructors of AttributeCommonInfo; NFC

The single-argument constructors of this class were not marked explicit
and that led to some incorrect uses that slipped under the radar (see
changes in SemaDeclAttr.cpp). This makes the constructors explicit,
changes the benignly incorrect uses, and updates the tablegen code to
emit the correct support code to call the explicit constructors.

While this does correct a misuse, that incorrect usage could not be
observed except via a debugger and so no additional tests are added.

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

15 months ago[TableGen] Fix compile fail when compiling llvm with MSVC due to typo in 931418667063
Shengchen Kan [Mon, 10 Apr 2023 12:21:06 +0000 (20:21 +0800)]
[TableGen] Fix compile fail when compiling llvm with MSVC due to typo in 931418667063

15 months ago[VPlan] Use VPLiveOut to update FOR live-out users.
Florian Hahn [Mon, 10 Apr 2023 12:02:44 +0000 (13:02 +0100)]
[VPlan] Use VPLiveOut to update FOR live-out users.

Instead of iterating over all LCSSA phis in the exit block, collect all
LiveOut users of the FOR splice VPInstruction and only update those
users.

Building on top of D147471, this removes an access to the cost model
after VPlan execution.

Depends on D147471.

Reviewed By: Ayal, michaelmaitland

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

15 months ago[clang-tidy] avoid colon in namespace cause false positve
Congcong Cai [Mon, 10 Apr 2023 11:42:32 +0000 (13:42 +0200)]
[clang-tidy] avoid colon in namespace cause false positve

Refactor the Namespaces with NamespaceDecl[][].
First level stores non nested namepsace.
Second level stores nested namespace.

Reviewed By: PiotrZSL

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

15 months ago[AMDGPU] Extend tbuffer_load_format merge
mmarjano [Fri, 7 Apr 2023 11:27:27 +0000 (13:27 +0200)]
[AMDGPU] Extend tbuffer_load_format merge

Add support for merging _IDXEN and _BOTHEN variants of
TBUFFER_LOAD_FORMAT instruction.

15 months ago[clang] Mark CWG536 as N/A
Vlad Serebrennikov [Mon, 10 Apr 2023 10:17:04 +0000 (13:17 +0300)]
[clang] Mark CWG536 as N/A

[[https://wg21.link/p1787 | P1787]]: CWG536 (long partially resolved) is resolved by specifying that unqualified lookup occurs for any kind of unqualified-id as an id-expression.
Wording: An unqualified name is a name that <...>. Unless otherwise specified, such a name undergoes unqualified name lookup from the point where it appears. ([basic.lookup.unqual]/4)

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

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

15 months ago[clang-tidy][NFC] Rename test files for simplify-boolean-expr to match check name
Piotr Zegar [Mon, 10 Apr 2023 09:50:00 +0000 (09:50 +0000)]
[clang-tidy][NFC] Rename test files for simplify-boolean-expr to match check name

Change simplify-bool-expr -> simplify-boolean-expr

15 months ago[SCEV] Improve AddRecs' range computation in Expensive Range Sharpening mode
Max Kazantsev [Mon, 10 Apr 2023 09:37:10 +0000 (16:37 +0700)]
[SCEV] Improve AddRecs' range computation in Expensive Range Sharpening mode

Apply loop guards to AddRec's start in range computation for
non-self-wrapping AddRecs.

According to CT measurements, this has a wide negative compile time impact,
so we hold it in expensive range sharpening mode where it's not so critical.
However, we need to find a way to share benefits of this mode with default mode.

Patch by Aleksandr Popov!

Differential Revision: https://reviews.llvm.org/D147557
Reviewed By: mkazantsev

15 months ago[Coverity] avoid array overflow when use -1 as index.
Luo, Yuanke [Mon, 10 Apr 2023 07:37:05 +0000 (15:37 +0800)]
[Coverity] avoid array overflow when use -1 as index.

15 months ago[TableGen] Pass size to std::vector constructor instead of using resize. NFC
Craig Topper [Mon, 10 Apr 2023 06:13:51 +0000 (23:13 -0700)]
[TableGen] Pass size to std::vector constructor instead of using resize. NFC

15 months ago[TableGen] Make TreePatternNode::InlinePatternFragments a static method. NFC
Craig Topper [Mon, 10 Apr 2023 04:39:57 +0000 (21:39 -0700)]
[TableGen] Make TreePatternNode::InlinePatternFragments a static method. NFC

Previously we were passing 'this' and the std::shared_ptr version
of 'this'. This replaces all uses of 'this' with the shared_ptr and
makes the method static.

15 months ago[TableGen] Move vectors into DAGInstruction instead of copying them. NFC
Craig Topper [Mon, 10 Apr 2023 03:53:45 +0000 (20:53 -0700)]
[TableGen] Move vectors into DAGInstruction instead of copying them. NFC

15 months ago[NFC][IRCE] Do not store latch exit count
Max Kazantsev [Mon, 10 Apr 2023 06:57:51 +0000 (13:57 +0700)]
[NFC][IRCE] Do not store latch exit count

It is not actually used for any computations. Its only purpose is to
check that the loop is finite and find out the type of computed exit
count. Refactor code so that we only store this type.

15 months ago[AMDGPU] Introduce SIInstrWorklist to process instructions in moveToVALU
skc7 [Tue, 28 Mar 2023 18:05:02 +0000 (23:35 +0530)]
[AMDGPU] Introduce SIInstrWorklist to process instructions in moveToVALU

Reviewed By: arsenm

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

15 months ago[X86] Add inst fixup for `unpckps` -> `unpckdq`.
Noah Goldstein [Mon, 10 Apr 2023 00:23:30 +0000 (19:23 -0500)]
[X86] Add inst fixup for `unpckps` -> `unpckdq`.

`unpckps` has the same performance as `unpckpd` (only port5) wereas
`unpckdq` can run on p15 on some newer architectures.

`unpckdq` is in the integer domain, so only do the transform if the
target has no bypass delay on shuffles (SKL+).

Reviewed By: RKSimon

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

15 months ago[X86] Add inst fixup for `unpckpd` -> `unpckqdq`.
Noah Goldstein [Mon, 10 Apr 2023 00:23:26 +0000 (19:23 -0500)]
[X86] Add inst fixup for `unpckpd` -> `unpckqdq`.

`unpckqdq` seems to be treated as a shuffle from bypass delay
perspective (which makes sense it appears to have shared shuffle units
for all micro-arch).

`unpckqdq` is slightly preferable to `shufpd` as it saves 1-byte of
code size and can be used to replace the micro-fused `rm` version. So,
if the target has no bypass delay, we should do `unpckpd` ->
`unpckqdq` instead of `shufpd.

Reviewed By: pengfei

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

15 months ago[X86] Fix perf bug in `permilps` -> `shufd` in X86FixupInstTuning.
Noah Goldstein [Mon, 10 Apr 2023 00:23:23 +0000 (19:23 -0500)]
[X86] Fix perf bug in `permilps` -> `shufd` in X86FixupInstTuning.

We shouldn't do the transformation if we either have bypass delay OR
the new opcode has worse performance. Previous code was incorrectly
using AND.

Reviewed By: RKSimon

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

15 months ago[X86] Improve inst tuning tests for X86FixupInstTuning Pass; NFC
Noah Goldstein [Mon, 10 Apr 2023 00:23:19 +0000 (19:23 -0500)]
[X86] Improve inst tuning tests for X86FixupInstTuning Pass; NFC

1) Add tests for `unpckps`.
2) Add explicit test for fast shuffles (ICX+) but WITH bypass delay.

Reviewed By: RKSimon

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

15 months ago[GlobalISelEmitter] add case for D141247, NFC.
Chen Zheng [Mon, 10 Apr 2023 05:11:26 +0000 (01:11 -0400)]
[GlobalISelEmitter] add case for D141247, NFC.

15 months agoRevert "[MLIR] Add an assert in Operation::getOpResultImpl for out of range result"
Mehdi Amini [Mon, 10 Apr 2023 04:21:56 +0000 (21:21 -0700)]
Revert "[MLIR] Add an assert in Operation::getOpResultImpl for out of range result"

This reverts commit 13b21971fbf5cd47dc3acb0c593aae8ae980c8d8.
Multiple bots are broken.

15 months ago[mlir][affine] Fix crash on -affine-loop-invariant-code-motion pass with affine.prefe...
Anoop J S [Mon, 10 Apr 2023 03:40:49 +0000 (09:10 +0530)]
[mlir][affine] Fix crash on -affine-loop-invariant-code-motion pass with affine.prefetch Op

Affine Prefetch Op impelements AffineMapAccessInterface but does not implement
AffineReadOpInterface or AffineWriteOpInterface. Prefetch Op was cast to
AffineWriteOpinterface causing the crash.

Reviewed By: bondhugula

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

15 months ago[RISCV] Support assembler and dis-assembler for VCIX extension.
Nelson Chu [Fri, 15 Apr 2022 04:25:36 +0000 (21:25 -0700)]
[RISCV] Support assembler and dis-assembler for VCIX extension.

Spec: https://sifive.cdn.prismic.io/sifive/c3829e36-8552-41f0-a841-79945784241b_vcix-spec-software.pdf

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

15 months ago[AVR][NFC] Fix errors in commit 6e57f68e41c92936b9ef3a4e6fb286e8805a9fbc
Ben Shi [Mon, 10 Apr 2023 03:13:07 +0000 (11:13 +0800)]
[AVR][NFC] Fix errors in commit 6e57f68e41c92936b9ef3a4e6fb286e8805a9fbc

15 months ago[MachineOutliner] Add IsOutlined to MachineFunction
wangpc [Mon, 10 Apr 2023 02:57:00 +0000 (10:57 +0800)]
[MachineOutliner] Add IsOutlined to MachineFunction

We add a field `IsOutlined` to indicate whether a MachineFunction
is outlined and set it true for outlined functions in MachineOutliner.

Reviewed By: paquette

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

15 months ago[AVR] Reject invalid LDD instruction with explicit error
Ben Shi [Sun, 9 Apr 2023 09:37:32 +0000 (17:37 +0800)]
[AVR] Reject invalid LDD instruction with explicit error

We should reject "ldd Rn, X" with explicit error message
rather than "llvm_unreachable" in llvm's release build.

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

Reviewed By: Miss_Grape

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

15 months ago[AMDGPU][Global-ISel] reuse extension related patterns in td file
Chen Zheng [Fri, 7 Apr 2023 10:22:31 +0000 (10:22 +0000)]
[AMDGPU][Global-ISel] reuse extension related patterns in td file

However the imported rules can not be used for now because Global ISel
selectImpl() seems has some bug/limitation to create a illegl COPY
from VGPR to SGPR. So currently workaround this by not auto selecting these
patterns.

Fixes #61468

Reviewed By: arsenm

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

15 months ago[X86] Add an additional ReadAfterLoad to EVEX FMA instructions.
Craig Topper [Mon, 10 Apr 2023 00:12:27 +0000 (17:12 -0700)]
[X86] Add an additional ReadAfterLoad to EVEX FMA instructions.

These instructions have 3 sources. 2 of them are registers when
the load is folded. So we need 2 ReadAfterLoad SchedReads.

15 months ago[X86] Correct the scheduling information for AVX-VNNI and AVX512-VNNI instructons.
Craig Topper [Sun, 9 Apr 2023 23:33:47 +0000 (16:33 -0700)]
[X86] Correct the scheduling information for AVX-VNNI and AVX512-VNNI instructons.

The AVXVNNI load instructions weren't using the Folded load write
class and they had no ReadAdvance.
The YMM versions were using the XMM schedule class.

The AVX512VNNI instructions had the right classes, but not enough
ReadAdvances to account for the 2 sources.

Noticed while investigating #62026.

Reviewed By: pengfei

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

15 months ago[TableGen] Use map::try_emplace to construction DAGInstruction in the Instructions...
Craig Topper [Sun, 9 Apr 2023 23:32:54 +0000 (16:32 -0700)]
[TableGen] Use map::try_emplace to construction DAGInstruction in the Instructions map. NFC

We add entries to the map in two places. One already used
std::piecewise_construct with map::emplace. The other was using
map::insert. Change both to map::try_emplace.

15 months ago[MLIR] Add an assert in Operation::getOpResultImpl for out of range result
Shivam Gupta [Sun, 9 Apr 2023 12:57:07 +0000 (18:27 +0530)]
[MLIR] Add an assert in Operation::getOpResultImpl for out of range result

This fix https://github.com/llvm/llvm-project/issues/61962.

Calling op->getResult(0) on a function like operation with no results
returned a garbage pointer.

This patch add assert to check number is in range.

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

15 months ago[VPlan] Don't assign slots for external defs (NFCI).
Florian Hahn [Sun, 9 Apr 2023 20:01:10 +0000 (21:01 +0100)]
[VPlan] Don't assign slots for external defs (NFCI).

External defs are VPValues wrapping an IR value and hence will get
printed as ir<>. We don't need to assign a slot for a VPValue number.

15 months ago[clang][AST] Fix `-Wuninitialized`. NFC
Michael Liao [Sun, 9 Apr 2023 19:55:38 +0000 (15:55 -0400)]
[clang][AST] Fix `-Wuninitialized`. NFC

- Adjust the declaration order as non-static member are initialized in
  order of declaration in the class definition.

15 months ago[LV] Update tests checking VPlans to use patterns for VPValues.
Florian Hahn [Sun, 9 Apr 2023 19:32:09 +0000 (20:32 +0100)]
[LV] Update tests checking VPlans to use patterns for VPValues.

This makes the tests more robust to changes in value numbering for
VPValues.

15 months ago[TableGen] Remove TypeSetByHwMode::isDefaultOnly(). Use InfoByHwMode<T>::isSimple...
Craig Topper [Sun, 9 Apr 2023 17:56:06 +0000 (10:56 -0700)]
[TableGen] Remove TypeSetByHwMode::isDefaultOnly(). Use InfoByHwMode<T>::isSimple(). NFC

InfoByHwMode is the base class of TypeSetByHwMode. The two methods
did the same thing. No reason to have two ways to do it.

Also use the getSimple() access instead of Map.begin()->second.

15 months ago[gn build] Port e8cfbfd05a95
LLVM GN Syncbot [Sun, 9 Apr 2023 15:57:26 +0000 (15:57 +0000)]
[gn build] Port e8cfbfd05a95

15 months ago[libc++] Granularize system_error.
Mark de Wever [Sat, 8 Apr 2023 15:29:31 +0000 (17:29 +0200)]
[libc++] Granularize system_error.

Reviewed By: #libc, philnik

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

15 months ago[clang-tidy] fix false positve for namespace with attrs in modernize-concat-nested...
Congcong Cai [Sun, 9 Apr 2023 14:23:28 +0000 (16:23 +0200)]
[clang-tidy] fix false positve for namespace with attrs in modernize-concat-nested-namespaces

Fixed https://github.com/llvm/llvm-project/issues/57530
Add pre check to avoid false positive for namespace with attributes like
```
namespace [[deprecated]] ns {}
```

Reviewed By: PiotrZSL

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