platform/upstream/llvm.git
15 months ago[flang] Handle correctly user defined assignment for allocatable component
Valentin Clement [Fri, 7 Apr 2023 18:47:35 +0000 (11:47 -0700)]
[flang] Handle correctly user defined assignment for allocatable component

In the Fortran standard 2018 section 10.2.1.3 (13), it is mentioned
that all noncoarray allocatable component must follow this sequence of
operations:

1) If the component of the variable is allocated, it is deallocated.
2) If the component of the value of expr is allocated, the corresponding
   component of the variable is allocated with the same dynamic type and
   type parameters as the component of the value of expr. If it is an
   array, it is allocated with the same bounds. The value of the
   component of the value of expr is then assigned to the corresponding
   component of the variable using defined assignment if the declared type
   of the component has a type-bound defined assignment consistent with the
   component, and intrinsic assignment for the dynamic type of that component
   otherwise.

This patch updates the code to make use of the user defined assignment for
allocatable component and make sure the component is allocated correctly.

Reviewed By: klausler

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

15 months agoRevert "[Clang][Sema] Fix comparison of constraint expressions"
Alexander Shaposhnikov [Fri, 7 Apr 2023 18:32:49 +0000 (18:32 +0000)]
Revert "[Clang][Sema] Fix comparison of constraint expressions"

This temporarily reverts commit
60bee9ff544541e83ffbd4be31923d0e8b644690.
The diff will be recommitted once the newly discovered
regressions are fixed.

15 months ago[Clang] Improve designated inits diagnostic location
Bill Wendling [Fri, 7 Apr 2023 18:35:29 +0000 (11:35 -0700)]
[Clang] Improve designated inits diagnostic location

A "null" designator won't have a valid location. Try to approximate this
location as best we can in that situation.

Closes 61118
Closes 46132

Reviewed By: shafik

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

15 months ago[mlir] Add tests accidentally removed from arith expand-ops
Robert Suderman [Fri, 7 Apr 2023 18:12:12 +0000 (18:12 +0000)]
[mlir] Add tests accidentally removed from arith expand-ops

Some tests were accidentally removed due to debug code being included.
Readding the tests to guarantee coverage.

Reviewed By: NatashaKnk

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

15 months ago[gn build] Port 376168babb51
LLVM GN Syncbot [Fri, 7 Apr 2023 17:38:29 +0000 (17:38 +0000)]
[gn build] Port 376168babb51

15 months ago[clang-tidy] Add modernize-type-traits check
Nathan James [Fri, 7 Apr 2023 17:38:13 +0000 (18:38 +0100)]
[clang-tidy] Add modernize-type-traits check

This check will look for usages of standard library type traits of the form `traits<...>::type` and `traits<...>::value` and convert them into `traits_t<...>` and `traits_v<...>` respectively.
This expands on the work in D135404 by supporting dependent traits with no instantiations as well as types.

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

15 months ago[support] Revise ScopedPrinter formatting tests for floats
Paul Kirth [Fri, 24 Mar 2023 22:10:11 +0000 (22:10 +0000)]
[support] Revise ScopedPrinter formatting tests for floats

Previously there were several attempts to make the format checks for NaN
and Inf work across platforms, like AIX and Solaris, that print these
values slightly differently. This resulted in a number of forward fixes,
until we finally disabled the tests for NaN and Inf. This change should
make the test robust across different platforms, and reduce the overall
amount of code by delegating to helper functions that use the same
format strings as the implementations used by PrintNumber().

This additionally reverts commit 5a9bad171be5dfdf9430a0f6cbff14d29ca54181
and fa56e362af475e0758cfb41c42f78db50da7235c.

Reviewed By: jhenderson

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

15 months ago[libc++] Module fixes for __synth_three_way.
Mark de Wever [Tue, 21 Mar 2023 17:05:35 +0000 (18:05 +0100)]
[libc++] Module fixes for __synth_three_way.

These changes make it possible to use __synth_three_way in modules. The
change from a lambda to a function is a Clang issue.

The change is list was needed since the compiler couldn't deduce the
comparison template argument.

Adds a few missing includes too.

Reviewed By: #libc, ldionne

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

15 months ago[Clang] Fix buildbots after Fix filtering of inline namespaces for friend functions...
Shafik Yaghmour [Fri, 7 Apr 2023 16:18:15 +0000 (09:18 -0700)]
[Clang] Fix buildbots after Fix filtering of inline namespaces for friend functions commit

In commit cffadbd951e9 the test I added was using a C++17 feature and this
breaking some build bots. I don't need the feature and so I will modify
the test to not use it.

15 months ago[Clang] Fix filtering of inline namespaces for friend functions
Shafik Yaghmour [Fri, 7 Apr 2023 15:57:24 +0000 (08:57 -0700)]
[Clang] Fix filtering of inline namespaces for friend functions

PR D135370 implemented a performance improvement but it restricted the filtering
of declaration from inline namespace too much. In particular it did not filter
for the function template case.

This led to a regression and this PR removes that check.

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

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

15 months ago[libc++][format][chrono] Addresses LWG3842.
Mark de Wever [Sat, 18 Feb 2023 13:54:29 +0000 (14:54 +0100)]
[libc++][format][chrono] Addresses LWG3842.

  LWG3842 Unclear wording for precision in chrono-format-spec

Note there is nothing to do, the issue clarifies the wording in the Standard.
The new wording matches my interpretation of the previous wording and this has
already been implemented in libc++.

Reviewed By: #libc, ldionne

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

15 months ago[libc++][format] Use granularized charconv.
Mark de Wever [Thu, 16 Mar 2023 16:59:42 +0000 (17:59 +0100)]
[libc++][format] Use granularized charconv.

This reduces the number of transitive includes when using format.

Reviewed By: #libc, ldionne

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

15 months ago[libc++] Qualifies intmax_t and uintmax_t.
Mark de Wever [Fri, 24 Mar 2023 16:18:11 +0000 (17:18 +0100)]
[libc++] Qualifies intmax_t and uintmax_t.

This has been done using the following command

  find libcxx/test -type f -exec perl -pi -e 's|^([^/]+?)((?<!::)(?<!::u)u?intmax_t)|\1std::\2|' \{} \;

The std module doesn't export declarations in the global namespaace.
This is a preparation for that module.

Reviewed By: #libc, ldionne

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

15 months ago[Doc][NFC] Fix a typo
Phoebe Wang [Fri, 7 Apr 2023 15:34:26 +0000 (23:34 +0800)]
[Doc][NFC] Fix a typo

15 months ago[mlir-cpu-runner] Add `export_executable_symbols` in CMake
Andrzej Warzynski [Thu, 30 Mar 2023 08:54:54 +0000 (08:54 +0000)]
[mlir-cpu-runner] Add `export_executable_symbols` in CMake

This patch is primarily about the change in
"mlir/tools/mlir-cpu-runner/CMakeLists.txt". LLJIT needs access to
symbols (e.g. llvm_orc_registerEHFrameSectionWrapper) that will be
defined in the executable when LLVM is linked statically. This change is
consistent with how other tools within LLVM use LLJIT. It is required to
make sure that:
```
 $ mlir-cpu-runner --host-supports-jit
```
correctly returns `true` on platforms that do support JITting (in my
case that's AArch64 Linux).

The change in "mlir/lib/ExecutionEngine/CMakeLists.txt" is required to
avoid ODR violations when symbols from `mlir-cpu-runner` are exported
and when loading `libmlir_async_runtime.so` in `mlir-cpu-runner`.
Specifically, to avoid `EnableABIBreakingChecks` being defined twice.
For more context:
  * https://github.com/llvm/llvm-project/issues/61712
  * https://github.com/llvm/llvm-project/issues/61856
  * https://reviews.llvm.org/D146935 (this PR)

This change relands ccdcfad0815296d8952438632d9abe6bc0a5258a

Fixes #61856

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

15 months ago[clang] Add test for CWG607
Vlad Serebrennikov [Fri, 7 Apr 2023 13:58:11 +0000 (17:58 +0400)]
[clang] Add test for CWG607

[[https://wg21.link/p1787 | P1787]]: CWG607 is resolved by looking up unqualified names in a mem-initializer-id from outside the parameter scope.
Wording: Lookup for an unqualified name in a mem-initializer-id ignores the constructor’s function parameter scope. ([class.base.init]/2)

Reviewed By: #clang-language-wg, shafik

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

15 months ago[clang] Mark CWG562 as N/A
Vlad Serebrennikov [Fri, 7 Apr 2023 13:57:09 +0000 (17:57 +0400)]
[clang] Mark CWG562 as N/A

[[https://wg21.link/p1787 | P1787]]: CWG562 is resolved by defining lookup as occurring from a program point.
Wording: A single search in a scope S for a name N from a program point P finds all declarations that precede P to which any name that is the same as N ([basic.pre]) is bound in S. ([basic.lookup]/2)

Reviewed By: #clang-language-wg, cor3ntin, shafik

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

15 months ago[clang] Add test for CWG255
Vlad Serebrennikov [Fri, 7 Apr 2023 13:56:12 +0000 (17:56 +0400)]
[clang] Add test for CWG255

[[https://wg21.link/p1787 | P1787]]: CWG255 (partially resolved by N3778 is resolved by generally specifying the restriction to usual deallocation functions.
Wording: In any case, any declarations other than of usual deallocation functions ([basic.stc.dynamic.deallocation]) are discarded. ([expr.delete]/9)

Reviewed By: #clang-language-wg, cor3ntin

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

15 months ago[libc][math] Update range reduction step for log10f and reduce its latency.
Tue Ly [Thu, 6 Apr 2023 13:26:16 +0000 (09:26 -0400)]
[libc][math] Update range reduction step for log10f 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: zimmermann6

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

15 months ago[mlir][llvm] Fix bswap naming (NFC)
Christian Ulmann [Fri, 7 Apr 2023 14:19:10 +0000 (16:19 +0200)]
[mlir][llvm] Fix bswap naming (NFC)

As pointed out in https://reviews.llvm.org/D147711#inline-1427665, the
bswap intrinsic is called byteswap, not bitswap.

15 months ago[doc][clang-tidy] Sort release notes by check name.
Clement Courbet [Fri, 7 Apr 2023 14:10:47 +0000 (16:10 +0200)]
[doc][clang-tidy] Sort release notes by check name.

15 months ago[X86] Fix problem in D147541
Phoebe Wang [Fri, 7 Apr 2023 09:37:53 +0000 (17:37 +0800)]
[X86] Fix problem in D147541

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

15 months ago[clang] Add test for CWG191
Vlad Serebrennikov [Fri, 7 Apr 2023 13:50:23 +0000 (17:50 +0400)]
[clang] Add test for CWG191

Also mark CWG1200 as "na."

[[https://wg21.link/p1787 | P1787]]: CWG191 and CWG1200 are resolved by defining unqualified lookup in terms of every enclosing scope.
Wording: If no declarations are found, the results of the unqualified search are the results of an unqualified search in the parent scope of S, if any, from P. ([basic.lookup.unqual]/2)

Reviewed By: #clang-language-wg, shafik

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

15 months ago[clang-format] NFC Document the other space before colon option
sstwcw [Fri, 7 Apr 2023 13:49:55 +0000 (13:49 +0000)]
[clang-format] NFC Document the other space before colon option

There are two options that do much the same thing, but for different
languages.  With the addition to the doc, the user is less likely to
configure the wrong option and get frustrated that it doesn't work.

Reviewed By: MyDeveloperDay

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

15 months ago[mlir][llvm] Add missing bit manipulation intrs
Christian Ulmann [Fri, 7 Apr 2023 12:18:28 +0000 (14:18 +0200)]
[mlir][llvm] Add missing bit manipulation intrs

This commit adds three missing bit manipulation intrinsics.
LangRef: https://llvm.org/docs/LangRef.html#bit-manipulation-intrinsics

Reviewed By: gysit

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

15 months agoUpdate static_assert message for redundant cases
Krishna Narayanan [Fri, 7 Apr 2023 12:08:47 +0000 (08:08 -0400)]
Update static_assert message for redundant cases

There are some simple messages where an expansion isn't particularly
helpful or needed. We aim to eliminate expansions that don't add much
value for user (this will give us slightly more room or prioritise to
have longer diagnostics elsewhere).

The test case for which it has been tested:
```
constexpr auto is_gitlab = false;
constexpr auto is_weekend = false;
static_assert(is_gitlab or is_weekend);
```

Previous warning/error message:
```
<source>:4:1: error: static assertion failed due to requirement 'is_gitlab || is_weekend'
static_assert(is_gitlab or is_weekend);
^             ~~~~~~~~~~~~~~~~~~~~~~~
<source>:4:25: note: expression evaluates to 'false || false'
static_assert(is_gitlab or is_weekend);
              ~~~~~~~~~~^~~~~~~~~~~~~
```
Currrent warning/error message:
```
<source>:4:1: error: static assertion failed due to requirement 'is_gitlab'
static_assert(is_gitlab or is_weekend);
^             ~~~~~~~~~
```
This patch aims to remove some redundant cases of static assert messages
where the expansions are particularly unhelpful. In this particular
patch, we have ignored the printing of diagnostic warnings for binary
operators with logical OR operations.

This is done to prioritise and prefer to emit longer diagnostic
warnings for more important concerns elsewhere.

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

15 months ago[clang-tidy]bugprone-fold-init-type
Clement Courbet [Thu, 10 Nov 2022 09:03:14 +0000 (10:03 +0100)]
[clang-tidy]bugprone-fold-init-type

Handle iterators that do not define a `value_type` type alias.

Get the value type from the return type of `Iter::operator*` instead.

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

15 months ago[VPlan] Add VPInterleaveRecipe::NeedsMaskForGaps field (NFCI).
Florian Hahn [Fri, 7 Apr 2023 12:11:03 +0000 (13:11 +0100)]
[VPlan] Add VPInterleaveRecipe::NeedsMaskForGaps field (NFCI).

This patch adds a NeedsMaskForGaps field to VPInterleaveRecipe to record
whether a mask for gaps is needed. This removes a dependence on the cost
model in VPlan code-generation.

Reviewed By: Ayal

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

15 months ago[libc][NFC] Simplify op_generic
Guillaume Chatelet [Fri, 7 Apr 2023 11:58:20 +0000 (11:58 +0000)]
[libc][NFC] Simplify op_generic

15 months ago[libc] Use SFINAE to implement is_signed/is_unsigned
Guillaume Chatelet [Fri, 7 Apr 2023 11:57:39 +0000 (11:57 +0000)]
[libc] Use SFINAE to implement is_signed/is_unsigned

This allows to use the type traits with types that are non constructible from integers.

15 months ago[libc] Add value_type to cpp::array
Guillaume Chatelet [Fri, 7 Apr 2023 11:24:12 +0000 (11:24 +0000)]
[libc] Add value_type to cpp::array

15 months ago[mlir][ODS] Verify type constraint in `TypeAttrOf`
Markus Böck [Fri, 7 Apr 2023 10:29:55 +0000 (12:29 +0200)]
[mlir][ODS] Verify type constraint in `TypeAttrOf`

The current implementation does not verify the type constraint, meaning that any type that happens to be of the same C++ type would pass the verifier.
E.g. a `TypeAttrOf<I64>` would happily accept a `i32` since both satisfy `isa<IntegerType>()`.

This patch fixes that by adding an optional type predicate parameter to `TypeAttrBase` that the type within `TypeAttr` has to satisfy. `TypeAttrOf` then simply passes the predicate of its type parameter as argument.

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

15 months ago[AMDGPU] Fix comment in SIOptimizeExecMaskingPreRA
Jay Foad [Fri, 7 Apr 2023 10:07:50 +0000 (11:07 +0100)]
[AMDGPU] Fix comment in SIOptimizeExecMaskingPreRA

15 months agoFix Bazel build after "Implement Pass and Dialect plugins for mlir-opt"
Tomás Longeri [Fri, 7 Apr 2023 08:09:12 +0000 (10:09 +0200)]
Fix Bazel build after "Implement Pass and Dialect plugins for mlir-opt"

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

15 months ago[libc][NFC] Simplify type_traits
Guillaume Chatelet [Fri, 7 Apr 2023 08:07:51 +0000 (08:07 +0000)]
[libc][NFC] Simplify type_traits

15 months ago[Test] Add one more test on IRCE & regenerate checks
Max Kazantsev [Fri, 7 Apr 2023 07:58:26 +0000 (14:58 +0700)]
[Test] Add one more test on IRCE & regenerate checks

15 months ago[JITLink][RISCV] ADD/SUB relocs: read value from working memory
Job Noorman [Fri, 7 Apr 2023 07:47:41 +0000 (09:47 +0200)]
[JITLink][RISCV] ADD/SUB relocs: read value from working memory

The various ADD/SUB relocations work by reading the current value the
relocation points to, transforming it, and then writing it back to
memory. While the current implementation writes the value back to
working memory, it reads the current value from the execution address of
the relocation. This causes at least wrong results, but often crashes,
when the addresses of working memory are not equal to execution
addresses. This patch fixes this by reading the current value from
working memory.

Reviewed By: lhames

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

15 months ago[Clang] Fix markup in cxx_status
Corentin Jabot [Fri, 7 Apr 2023 07:42:54 +0000 (09:42 +0200)]
[Clang] Fix markup in cxx_status

This reverts the changes to cxx_status introduced
by https://reviews.llvm.org/D146178, as it did
break the html markup

While This PR resolves a bug related to concepts,
it doesn't seem useful to change the advertised implementation
of that paper many years after the fact, especially as the
paper encompasses many issue resolution.

15 months agoFix the two gmoules-prefered-name-* tests
YongKang Zhu [Fri, 7 Apr 2023 05:17:35 +0000 (22:17 -0700)]
Fix the two gmoules-prefered-name-* tests

Add missing "REQUIRES: asserts" for the two tests added in commit
711a64412749ae73709562b591ab1609a3ee7751 (Diff: D145803).

Reviewed By: chapuni

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

15 months ago[mlir][affine] Vectorizer test notifies the case with the unparallel loop with reduction
Kai Sasaki [Fri, 7 Apr 2023 06:55:55 +0000 (15:55 +0900)]
[mlir][affine] Vectorizer test notifies the case with the unparallel loop with reduction

Vectorizer test does not support unparallel loop since no parallel reduction is available. We can emit the informational message instead of crashing the cli in such a case.
Fixes https://github.com/llvm/llvm-project/issues/61842

Reviewed By: mehdi_amini

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

15 months ago[libunwind][LoongArch] Restore $r1 before $r4 in `jumpto`
Weining Lu [Fri, 7 Apr 2023 05:38:44 +0000 (13:38 +0800)]
[libunwind][LoongArch] Restore $r1 before $r4 in `jumpto`

$ra should be restored before $a0, otherwise the baseaddress ($a0) would
be destroyed. See file `UnwindRegistersSave.S` for reference.

This also makes libcxx and libcxxabi regtest pass for the `-DLIBCXXABI_USE_LLVM_UNWINDER=ON` build.

Reviewed By: MaskRay, xen0n, #libunwind

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

15 months ago[libunwind][test] Add test to check for unw_resume()
zhanglimin [Fri, 7 Apr 2023 05:40:58 +0000 (13:40 +0800)]
[libunwind][test] Add test to check for unw_resume()

This is here for local unwinding, which unw_resume() restores
the machine state and then directly resumes execution in the
target stack frame.

Reviewed By: wangleiat

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

15 months ago[InstCombine] Add support for maximum(a,b) + minimum(a,b) => a + b
Serguei Katkov [Fri, 31 Mar 2023 05:40:42 +0000 (12:40 +0700)]
[InstCombine] Add support for maximum(a,b) + minimum(a,b) => a + b

Unfortunately alive2 cannot prove the correctness due to fails by timeout even for
float type half.

However it should be correct. If a and b are not NaN, maximum and minimum will just
return different values (a and b) and take into account a + b == b + a this is the same.
If a or b is NaN, than maximum and minimum are equal to NaN and NaN + NaN is NaN.
a + b is also a NaN.

In terms of preserving fast flags, we cannot preserve ninf due to
minimum(NaN, Infinity) == maximum(NaN, Infinity) == NaN,
minimum(NaN, Infinity) +ninf maximum(NaN, Infinity) == NaN +ninf NaN = NaN
However transformation will change
minimum(NaN, Infinity) + maximum(NaN, Infinity) to NaN +ninf Infinity == poison.

But if fadd is marked as nnan, we can preserve because NaN +ninf/nnan NaN = poison as well.

The same optimization for
  maximum(a,b) * minimum(a,b) => a * b
is added.
All said above for fadd is correct for fmul.

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

15 months agoRevert "[ORC] LLJIT updates: ExecutorNativePlatform, default link order, ..."
Lang Hames [Fri, 7 Apr 2023 05:32:21 +0000 (05:32 +0000)]
Revert "[ORC] LLJIT updates: ExecutorNativePlatform, default link order, ..."

This reverts commit 371cb1af61d668234a242b34c773c146cb9077e7, which broke some
unit tests (see e.g. https://lab.llvm.org/buildbot#builders/139/builds/38754).

15 months ago[InstCombine] Add support for max(a,b) + min(a,b) => a + b. Re-land.
Serguei Katkov [Fri, 7 Apr 2023 04:16:29 +0000 (11:16 +0700)]
[InstCombine] Add support for max(a,b) + min(a,b) => a + b. Re-land.

The same optimization for
  max(a,b) * min(a,b) => a * b
is added.

Correctness check:
uadd: https://alive2.llvm.org/ce/z/2rXDek
sadd: https://alive2.llvm.org/ce/z/zNu_er
uadd + nuw/nsw: https://alive2.llvm.org/ce/z/EaiNjB
sadd + nuw/nsw: https://alive2.llvm.org/ce/z/w_2Nrs

umul: https://alive2.llvm.org/ce/z/dgXRLr
smul: https://alive2.llvm.org/ce/z/hBjGzz
umul + nuw/nsw: https://alive2.llvm.org/ce/z/EaiNjB
smul + nuw/nsw: https://alive2.llvm.org/ce/z/87MNeS

Reviewed By: goldstein.w.n
Differential Revision: https://reviews.llvm.org/D147296

15 months ago[ORC] LLJIT updates: ExecutorNativePlatform, default link order, Process JD.
Lang Hames [Thu, 6 Apr 2023 18:28:25 +0000 (18:28 +0000)]
[ORC] LLJIT updates: ExecutorNativePlatform, default link order, Process JD.

This commit includes several related ergonomic improvements to LLJIT.

(1) Adds a default JITDylibSearchOrder to be appended to the initial link order
of JITDylibs created via LLJIT::createJITDylib (dropping any duplicate entries).

This was introduced to support automatic reflection of process symbols (see
(2) below), but has been made visible to clients as it's generically useful,
e.g. if clients have some extra set of libraries that they want to be visible
to JIT'd code by default.

The default JITDylibSearchOrder is only appended to the link order of JITDylibs
created via LLJIT::createJITDylib, and will not be apply to JITDylibs created by
directly calling the underlying ExecutionSession -- in that case clients can set
up the link order manually.

(2) Makes process symbols visible to JIT'd code by default via the new "Process"
JITDylib, which is added to the default link order.

LLJIT clients usually want symbols in the executor process to be accessible to
JIT'd code. Until now clients have been left to set this up themselves by adding
a DynamicLibrarySearchGenerator to the Main JITDylib. This patch adds a new
process symbols JITDylib that will be created by default (with an
EPCDynamicLibrarySearchGenerator attached) and added to the default link order,
making process symbols available to JIT'd code.

Clients who do not want process symbols to be visible to JIT'd code by default
can call setLinkProcessSymbolsByDefault(false) on their LLJITBuilder to disable
this:

LLJITBuilder()
  ...
  .setLinkProcessSymbolsByDefault(false)
  ...
  .create();

Clients can also call setProcessSymbolsJITDylibSetup to take over responsibility
for configuring the process symbols JITDylib (the callback that the client
supplies will be called on the bare process symbols JITDylib immediately after
it is created).

If setLinkProcessSymbolsByDefault(false) is called and no JITDylib setup
callback has been set then the process symbols JITDylib will not be created and
LLJIT::getProcessSymbolsJITDylib will return null.

(3) Adds an ExecutorNativePlatform utility that makes it easier to enable
native platform features.

Some object format features (e.g. native static initializers and thread locals)
require runtime support in the executing process. Support for these features in
ORC is implemented cooperatively between the ORC runtime and the LLVM Platform
subclasses (COFFPlatform, ELFNixPlatform, and MachOPlatform).
ExecutorNativePlatfrom simplifies the process of loading the ORC runtime and
creating the appropriate platform class for the executor process.

ExecutorNativePlatform takes a path to the ORC runtime (or a MemoryBuffer
containing the runtime) and other required runtimes for the executor platform
(e.g. MSVC on Windows) and then configures LLJIT with an appropriate platform
class based on the executor's target triple:

LLJITBuilder()
  .setPlatformSetUp(ExecutorNativePlatform("/path/to/orc-runtime.a"));

(The ORC runtime is built as part of compiler-rt, and the exact name of the
archive is platform dependent).

The ORC runtime and platform symbols will be added to a new "Platform" JITDylib,
which will be added to the *front* of the default link order (so JIT'd code will
prefer symbol definitions in the platform/runtime to definitions in the executor
process).

ExecutorNativePlatform assumes that the Process JITDylib is available, as
the ORC runtime may depend on symbols provided by the executor process.

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

15 months agoRevert "[InstCombine] Add support for max(a,b) + min(a,b) => a + b."
Serguei Katkov [Fri, 7 Apr 2023 04:14:28 +0000 (11:14 +0700)]
Revert "[InstCombine] Add support for max(a,b) + min(a,b) => a + b."

Revert commit due to failure on buildbot:
error: 'match_combine_or' may not intend to support class template argument deduction

This reverts commit b86a06ef284f2637bef89bf5bb20157a8b195568.

15 months ago[InstCombine] Add support for max(a,b) + min(a,b) => a + b.
Serguei Katkov [Fri, 31 Mar 2023 02:35:06 +0000 (09:35 +0700)]
[InstCombine] Add support for max(a,b) + min(a,b) => a + b.

The same optimization for
  max(a,b) * min(a,b) => a * b
is added.

Correctness check:
uadd: https://alive2.llvm.org/ce/z/2rXDek
sadd: https://alive2.llvm.org/ce/z/zNu_er
uadd + nuw/nsw: https://alive2.llvm.org/ce/z/EaiNjB
sadd + nuw/nsw: https://alive2.llvm.org/ce/z/w_2Nrs

umul: https://alive2.llvm.org/ce/z/dgXRLr
smul: https://alive2.llvm.org/ce/z/hBjGzz
umul + nuw/nsw: https://alive2.llvm.org/ce/z/EaiNjB
smul + nuw/nsw: https://alive2.llvm.org/ce/z/87MNeS

Reviewed By: goldstein.w.n
Differential Revision: https://reviews.llvm.org/D147296

15 months ago[mlir][tblgen] Emit interface decls in definition order in the .td file
Matthias Springer [Fri, 7 Apr 2023 03:02:17 +0000 (12:02 +0900)]
[mlir][tblgen] Emit interface decls in definition order in the .td file

Interface decls were previously sorted by name. This lead to problems when using interface inheritance when both interfaces are defined in the same .td file. The derived interface must appear after the base interface, otherwise the generated C++ will not compile.

With this change, interfaces will compile as long as the base interface is defined before derived interfaces in the .td file.

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

15 months agoReland D146570 "[scudo] Switch to use MemMap in tests"
Chia-hung Duan [Thu, 6 Apr 2023 00:08:10 +0000 (00:08 +0000)]
Reland D146570 "[scudo] Switch to use MemMap in tests"

This reverts commit 89cc5304969ded574550e0ad113f59f3d4f50303 and fix the
variable shadowing bug.

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

15 months ago[mlir][SCF] ValueBoundsOpInterface: Support `scf.for` results and iter_args
Matthias Springer [Fri, 7 Apr 2023 02:43:41 +0000 (11:43 +0900)]
[mlir][SCF] ValueBoundsOpInterface: Support `scf.for` results and iter_args

If an `scf.for` loop yields an equal index-typed value or a shaped value with the same dimension sizes (in comparison to the corresponding iter_arg), bounds can be computed for the iter_arg and the OpResult of the `scf.for` op.

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

15 months ago[ORC] Add a JITDylib::addToLinkOrder convenience method.
Lang Hames [Thu, 6 Apr 2023 19:10:33 +0000 (19:10 +0000)]
[ORC] Add a JITDylib::addToLinkOrder convenience method.

This appends the given JITDylibSearchOrder to the JITDylib's existing one.

15 months ago[mlir][Interfaces] ValueBoundsOpInterface: Compute constant bounds
Matthias Springer [Fri, 7 Apr 2023 02:33:55 +0000 (11:33 +0900)]
[mlir][Interfaces] ValueBoundsOpInterface: Compute constant bounds

Add a helper function that computes a constant (`int64_t`) bound. The `stopCondition` is optional: If none is provided, the traversal continues until a constant bound could be computed.

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

15 months ago[mlir][linalg] ValueBoundsOpInterface: Add LinalgOps
Matthias Springer [Fri, 7 Apr 2023 02:05:14 +0000 (11:05 +0900)]
[mlir][linalg] ValueBoundsOpInterface: Add LinalgOps

Also add a few more complex test cases.

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

15 months agoRevert "[mlir][sparse][gpu] end-to-end example with sparse GPU pipeline"
Mehdi Amini [Fri, 7 Apr 2023 02:11:11 +0000 (19:11 -0700)]
Revert "[mlir][sparse][gpu] end-to-end example with sparse GPU pipeline"

This reverts commit bf94afa10e5101f401f191f0386a9316cf0a5cda.

The bot is broken: https://lab.llvm.org/buildbot/#/builders/61/builds/42062

15 months agoRevert "[mlir][sparse][gpu] end-to-end test for 2:4 sparsity on NVidia GPUs"
Mehdi Amini [Fri, 7 Apr 2023 02:10:28 +0000 (19:10 -0700)]
Revert "[mlir][sparse][gpu] end-to-end test for 2:4 sparsity on NVidia GPUs"

This reverts commit a2c63d7f0b77ae92c97974d0630625d83a0745ce.

The bot is broken: https://lab.llvm.org/buildbot/#/builders/61/builds/42062

15 months ago[mlir][SCF] Add ValueBoundsOpInterface impl for scf.for
Matthias Springer [Fri, 7 Apr 2023 01:56:18 +0000 (10:56 +0900)]
[mlir][SCF] Add ValueBoundsOpInterface impl for scf.for

Only induction variables are supported. iter_args will be supported in a
subsequent change.

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

15 months ago[mlir][Interfaces] ValueBoundsOpInterface: Support LB and UB bounds
Matthias Springer [Fri, 7 Apr 2023 01:47:22 +0000 (10:47 +0900)]
[mlir][Interfaces] ValueBoundsOpInterface: Support LB and UB bounds

This change also adds support for `affine.min` and `affine.max` ops.

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

15 months ago[mlir][tensor] Fix gcc build (ValueBoundsOpInterface)
Matthias Springer [Fri, 7 Apr 2023 01:33:13 +0000 (10:33 +0900)]
[mlir][tensor] Fix gcc build (ValueBoundsOpInterface)

The order of evaluation of a sum (e.g., `a() + b()`) is unspecified in
C++. clang evaluates left-to-right. gcc evaluate right-to-left. This led
to slighly different (but equivalent) affine_map in a test and the
FileCheck did not match anymore.

15 months agoImplement Pass and Dialect plugins for mlir-opt
Fabian Mora [Fri, 7 Apr 2023 00:01:00 +0000 (17:01 -0700)]
Implement Pass and Dialect plugins for mlir-opt

Implementation of Pass and Dialect Plugins that mirrors LLVM Pass Plugin
implementation from the new pass manager.

Currently the implementation only supports using the pass-pipeline option
for adding passes. This restriction is imposed by the `PassPipelineCLParser`
variable in mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:114 that loads the
parse options statically before parsing the cmd line args.

```
mlir-opt stanalone-plugin.mlir --load-dialect-plugin=lib/libStandalonePlugin.so --pass-pipeline="builtin.module(standalone-switch-bar-foo)"
```

Reviewed By: rriddle, mehdi_amini

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

15 months agoRevert "Implement Pass and Dialect plugins for mlir-opt"
Mehdi Amini [Fri, 7 Apr 2023 01:28:11 +0000 (18:28 -0700)]
Revert "Implement Pass and Dialect plugins for mlir-opt"

This reverts commit e9b415870dc3036f989c03eb553473aed614658a.

This landed without the right authorship.

15 months agoImplement Pass and Dialect plugins for mlir-opt
Mehdi Amini [Fri, 7 Apr 2023 00:01:00 +0000 (17:01 -0700)]
Implement Pass and Dialect plugins for mlir-opt

Implementation of Pass and Dialect Plugins that mirrors LLVM Pass Plugin  implementation from the new pass manager.

Currently the implementation only supports using the pass-pipeline option for adding passes. This restriction is imposed by the `PassPipelineCLParser` variable in mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:114 that loads the parse options statically before parsing the cmd line args.

```
mlir-opt stanalone-plugin.mlir --load-dialect-plugin=lib/libStandalonePlugin.so --pass-pipeline="builtin.module(standalone-switch-bar-foo)"
```

Reviewed By: rriddle

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

15 months agoAMDGPU: mark SET_INACTIVE_* as convergent operation
Ruiling Song [Thu, 6 Apr 2023 06:31:55 +0000 (14:31 +0800)]
AMDGPU: mark SET_INACTIVE_* as convergent operation

set_inactive is actually a kind of operation that is passing certain
value from active threads to inactive threads. In later WWM operation,
the activated threads which were disabled before would read such
values passed to them by set_inactive operation. So I think the
set_inactive is a convergent operation.

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

15 months agoAMDGPU: Add a test to show bad compilation to set_inactive
Ruiling Song [Thu, 6 Apr 2023 06:04:50 +0000 (14:04 +0800)]
AMDGPU: Add a test to show bad compilation to set_inactive

The set_inactive was originally inside a if branch, but was incorrectly
hoisted out of the loop. So the lanes that were disabled later after the
if() branch inside the loop were not set correctly. It should stay in
the if branch.

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

15 months agoReject attempts to initialize non-aggregate types from a designated
Richard Smith [Fri, 7 Apr 2023 00:50:46 +0000 (17:50 -0700)]
Reject attempts to initialize non-aggregate types from a designated
initializer list.

This previously led to some weird behaviors where we would unwrap the
initializer list expression and then try to use the DesignatedInitExprs
as constructor arguments.

Under the C++20 language rules, it's not valid to initialize a
reference-to-aggregate from a designated initializer list, but we have
historically accepted that, as do other compilers, and we continue to
accept that with this change. I've asked WG21 whether this should be
considered a wording defect.

15 months ago[RISCV] Add DAG combine to fold (sub 0, (setcc x, 0, setlt)) -> (sra x , xlen - 1)
LiaoChunyu [Fri, 7 Apr 2023 00:37:21 +0000 (08:37 +0800)]
[RISCV] Add DAG combine to fold (sub 0, (setcc x, 0, setlt)) -> (sra x , xlen - 1)

The result of sub + setcc is 0 or 1 for all bits.
The sra instruction get the same result.

Reviewed By: craig.topper

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

15 months ago[LoongArch] Optimize multiplication with immediates
Ben Shi [Mon, 3 Apr 2023 07:58:39 +0000 (15:58 +0800)]
[LoongArch] Optimize multiplication with immediates

Optimize "(mul r, c)" to "(SLLI (ALSL r, r, i0), i1)", in which
"c = (1 + (1 << i0)) << i1".

Reviewed By: SixWeining

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

15 months ago[LoongArch][NFC] Add tests of multiplication with immediates (for D147428)
Ben Shi [Mon, 3 Apr 2023 07:29:32 +0000 (15:29 +0800)]
[LoongArch][NFC] Add tests of multiplication with immediates (for D147428)

Reviewed By: SixWeining

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

15 months ago[ReleaseNotes] DebugInfo: preferred_name attribute changes
Michael Buch [Thu, 6 Apr 2023 10:06:54 +0000 (11:06 +0100)]
[ReleaseNotes] DebugInfo: preferred_name attribute changes

Describes changes made in D145803.

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

15 months ago[lldb][test] Add tests for clang::PreferredNameAttr formatting
Michael Buch [Sat, 11 Mar 2023 00:48:53 +0000 (00:48 +0000)]
[lldb][test] Add tests for clang::PreferredNameAttr formatting

Add some tests to make sure we're formatting structures
with preferred names correctly.

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

15 months ago[clang][DebugInfo] Emit DW_AT_type of preferred name if available
Michael Buch [Fri, 10 Mar 2023 16:46:47 +0000 (16:46 +0000)]
[clang][DebugInfo] Emit DW_AT_type of preferred name if available

With this patch, whenever we emit a `DW_AT_type` for some declaration
and the type is a template class with a `clang::PreferredNameAttr`, we
will emit the typedef that the attribute refers to instead. I.e.,

```
0x123 DW_TAG_variable
        DW_AT_name "var"
        DW_AT_type (0x123 "basic_string<char>")

0x124 DW_TAG_structure_type
        DW_AT_name "basic_string<char>"
```
...becomes
```
0x123 DW_TAG_variable
        DW_AT_name "var"
        DW_AT_type (0x124 "std::string")

0x124 DW_TAG_structure_type
        DW_AT_name "basic_string<char>"

0x125 DW_TAG_typedef
        DW_AT_name "std::string"
        DW_AT_type (0x124 "basic_string<char>")
```

We do this by returning the preferred name typedef `DIType` when
we create a structure definition. In some cases, e.g., with `-gmodules`,
we don't complete the structure definition immediately but do so later
via `completeClassData`, which overwrites the `TypeCache`. In such cases
we don't actually want to rewrite the cache with the preferred name. We
handle this by returning both the definition and the preferred typedef
from `CreateTypeDefinition` and let the callee decide what to do with
it.

Essentially we set up the types as:
```
TypeCache[Record] => DICompositeType
ReplaceMap[Record] => DIDerivedType(baseType: DICompositeType)
```

For now we keep this behind LLDB tuning.

**Testing**

- Added clang unit-test
- `check-llvm`, `check-clang` pass
- Confirmed that this change correctly repoints
  `basic_string` references in some of my test programs.
- Will add follow-up LLDB API tests

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

15 months ago[lldb][NFC] Delete unused function Breakpoint::GetEventIdentifier
Alex Langford [Thu, 6 Apr 2023 21:47:29 +0000 (14:47 -0700)]
[lldb][NFC] Delete unused function Breakpoint::GetEventIdentifier

This is unused

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

15 months ago[libc] Add strxfrm Implementation
Caslyn Tonelli [Mon, 3 Apr 2023 21:56:49 +0000 (21:56 +0000)]
[libc] Add strxfrm Implementation

Introduce `strxfrm` and unit tests. The current implementation is
introduced without locale support.

The simplified function performs a `memcpy` if the `n` value is large
enough to store the source len + '\0', otherwise `dest` is unmodified.

Ticket: https://fxbug.dev/124217

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

15 months ago[ORC-RT] Fix testcase after 4c7f53b99c0.
Lang Hames [Fri, 7 Apr 2023 00:00:51 +0000 (17:00 -0700)]
[ORC-RT] Fix testcase after 4c7f53b99c0.

4c7f53b99c0 changed the debug logging for GDB registration. This testcase just
needed to be updated to look for the new string.

15 months ago[SLP][NFC]Make adjustExtracts/needToDelay members of ShuffleInstructionBuilder.
Alexey Bataev [Thu, 6 Apr 2023 18:02:10 +0000 (11:02 -0700)]
[SLP][NFC]Make adjustExtracts/needToDelay members of ShuffleInstructionBuilder.

Make adjustExtracts/needToDelay lambdas members of ShuffleInstructionBuilder to allow to overload them later for cost model.

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

15 months ago[LV][NFC] Improve complexity of fixing users of recurrences
Michael Maitland [Mon, 27 Mar 2023 20:14:38 +0000 (13:14 -0700)]
[LV][NFC] Improve complexity of fixing users of recurrences

The original loop has O(MxN) since `is_contained` iterates over
all incoming values. This change makes it so only the phis
which use the value as an incoming value are iterated over so
it is now O(M).

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

15 months agoRevert "Revert "[Modules] Remove unnecessary check when generating name lookup table...
Richard Smith [Thu, 6 Apr 2023 22:22:06 +0000 (15:22 -0700)]
Revert "Revert "[Modules] Remove unnecessary check when generating name lookup table in ASTWriter""

This re-lands commit db987b9589be1eb604fcb74c85b410469e31485f,
previously reverted in commit 1e0709167f5edd330889f51bb203c458bdb5e359,
with a fix for a pre-existing bug in how we write constructor names into
lookup tables that was exposed by that change.

As yet, we've been unable to produce a reduced testcase for this bug,
but we understand the problem: if we write out a lookup table for a
class which has two constructor names, and we only have local lookup
results for one of those constructor names, then we will write out a
lookup table where the "all the constructors" lookup result contains
results for only one of the constructor names.

15 months ago[lldb] Add an LLDB_DEPRECATED macro similar to LLVM_DEPRECATED
Jonas Devlieghere [Thu, 6 Apr 2023 19:47:14 +0000 (12:47 -0700)]
[lldb] Add an LLDB_DEPRECATED macro similar to LLVM_DEPRECATED

Add an LLDB_DEPRECATED macro similar to LLVM_DEPRECATED. We cannot
directly reuse the LLVM one, because it's defined in Compiler.h which is
not something we can include in the SB API.

For the SB API, the macro is undef'd if:

  1. We're building the SWIG bindings. We might still want to expose
     deprecated methods to our scripting users.

  2. We're targeting anything older than C++14 as the [[deprecated]]
     attribute was added for C++14 and the SB API can be used by
     projects compiling against an older language version.

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

15 months ago[Clang][Attributes] Add MeaningfulToClassTemplateDefinition to unavailable attribute
Shafik Yaghmour [Thu, 6 Apr 2023 21:40:39 +0000 (14:40 -0700)]
[Clang][Attributes] Add MeaningfulToClassTemplateDefinition to unavailable attribute

There may be cases in which we want to diagnose a type as unavailable but it may
not be complete at the time. Setting MeaningfulToClassTemplateDefinition fixes
this issue.

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

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

15 months ago[lldb] Rename test module.map files to module.modulemap (NFC)
Dave Lee [Thu, 6 Apr 2023 20:50:05 +0000 (13:50 -0700)]
[lldb] Rename test module.map files to module.modulemap (NFC)

The name `module.modulemap` is convention.

> Clang will also search for a file named `module.map`. This behavior is deprecated and
> we plan to eventually remove it.

15 months ago[LV] Move conditional MaskForGaps construction to load case.
Florian Hahn [Thu, 6 Apr 2023 20:16:37 +0000 (21:16 +0100)]
[LV] Move conditional MaskForGaps construction to load case.

Conditionally setting MaskForGaps is only needed for loads. This avoid
re-computing MaskForGaps for stores.

Suggested as independent cleanup in D147467.

15 months agoAdd gpu::HostUnregisterOp
max [Thu, 6 Apr 2023 20:07:12 +0000 (15:07 -0500)]
Add gpu::HostUnregisterOp

Without explicitly unregistering you will get

```
'cuMemHostRegister(ptr, sizeBytes, 0)' failed with 'CUDA_ERROR_HOST_MEMORY_ALREADY_REGISTERED'
```

in CUDA (for example) after repeated runs (e.g., during benchmarking the same kernel).

Reviewed By: ftynse

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

15 months ago[SLP][NFC]Evaluate FMF for reductions before the loop, no need to
Alexey Bataev [Thu, 6 Apr 2023 18:56:19 +0000 (11:56 -0700)]
[SLP][NFC]Evaluate FMF for reductions before the loop, no need to
reevaluate it.

15 months ago[mlir][math] Update math arith expansions for vectorization
Robert Suderman [Thu, 6 Apr 2023 18:33:29 +0000 (18:33 +0000)]
[mlir][math] Update math arith expansions for vectorization

The math arithmetic expansions do not support vectorized types.
Updated the lowerings so that they support vectorized types. This
includes a different implementation for `math.ctlz` to be a binary
search and not have variable termination time.

Reviewed By: jpienaar, NatashaKnk

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

15 months agoPrecommit test from D147662
Anna Thomas [Thu, 6 Apr 2023 18:35:02 +0000 (14:35 -0400)]
Precommit test from D147662

15 months ago[mlir][arith] Add expansion pattern for ext/trunc of bf16
Robert Suderman [Thu, 6 Apr 2023 18:23:52 +0000 (18:23 +0000)]
[mlir][arith] Add expansion pattern for ext/trunc of bf16

bf16 has a trivial truncation/extension behavior with F32 that
can be described in elementary arith operations. Include some
expansions to efficiently convert including rounding towards
infinity for f32 to bf16 truncation.

Reviewed By: jpienaar

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

15 months ago[M68k] Add subtarget features for M68881/2 FPU
Min-Yih Hsu [Mon, 3 Apr 2023 20:18:17 +0000 (13:18 -0700)]
[M68k] Add subtarget features for M68881/2 FPU

Note that technically both M68000/010 can use M68881, despite the fact
that usually only M68020 and newer ISAs are equipped with M68881/2.
M68040 and newer processors have builtin M68882.

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

15 months ago[libc] Implement strsep
Alex Brachet [Thu, 6 Apr 2023 17:48:28 +0000 (17:48 +0000)]
[libc] Implement strsep

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

15 months ago[lldb] Add an overload to SetModuleLoadAddress that takes an unsigned value
Jonas Devlieghere [Thu, 6 Apr 2023 17:27:06 +0000 (10:27 -0700)]
[lldb] Add an overload to SetModuleLoadAddress that takes an unsigned value

Currently, SBTarget::SetModuleLoadAddress does not accept large slides
needed to load images in high memory. This function should always have
taken an unsigned as the slide, as it immediately passes it to
Target::SetSectionLoadAddress which takes an unsigned.

This patch adds an overload and exposes that to SWIG instead of the
signed variant. I've marked the signed variant as deprecated and added
check that the slide is positive.

rdar://101355155

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

15 months ago[SLP]Fix emission of the masks in shuffles for undefs.
Alexey Bataev [Thu, 6 Apr 2023 13:03:03 +0000 (06:03 -0700)]
[SLP]Fix emission of the masks in shuffles for undefs.

If the value is used in the expression, need to adjust the mask before
applying the mask. Plus, need to fix the analysis of the phi nodes for
reused scalars.

15 months ago[Sema] Populate declarations inside TypeLocs for some invalid types
Ilya Biryukov [Thu, 6 Apr 2023 16:59:45 +0000 (18:59 +0200)]
[Sema] Populate declarations inside TypeLocs for some invalid types

This also reverts 282cae0b9a602267ad7ef622f770066491332a11 as the
particular crash is now handled by the new code.

Before this change Clang would always leave declarations inside the
type-locs as `null` if the declarator had an invalid type. This patch
populates declarations even for invalid types if the structure of the
type and the type-locs match.

There are certain cases that may still cause crashes. These happen when
Clang recovers the type in a way that is not reflected in the
declarator's structure, e.g. adding a pointer when it was not present in
the code for ObjC interfaces or ignoring pointers written in the code
in C++ with auto return type (`auto* foo() -> int`). Those cases look
fixable with a better recovery strategy and I plan to follow up with
more patches to address those.

The first attempt caused 31 tests from `check-clang` to crash due to
different structure of the types and type-locs after certain errors. The
good news is that the failure is localized and mismatch in structures is
discovered by assertions inside `DeclaratorLocFiller`. Some notable
cases caught by existing tests:
- Invalid chunks when type is fully ignored and replace with int or now.
  Crashed in `C/C2x/n2838.c`.
- Invalid return types in lambdas. Crashed in `CXX/drs/dr6xx.cpp`.
- Invalid member pointers. Crashed in `CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3-generic-lambda-1y.cpp`
- ObjC recovery that adds pointers. Crashed in `SemaObjC/blocks.m`

This change also updates the output of `Index/complete-blocks.m`.
Not entirely sure what causes the change, but the new function signature
is closer to the source code, so this seems like an improvement.

Reviewed By: aaron.ballman, erichkeane

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

15 months ago[lld-macho] Add new -reproducible flag
Keith Smiley [Wed, 5 Apr 2023 21:46:06 +0000 (14:46 -0700)]
[lld-macho] Add new -reproducible flag

As of Xcode 14.3 it passes -reproducible by default to ld64. It seems
this flag was added in ld64 with Xcode 14.0, but it is not documented.
Through my testing the only thing I have seen it do is the same as
ZERO_AR_DATE, but it's possible it does more, or will do more in the
future. Since we already default to this option, this is more about
handling the command line flag to maintain Xcode compatibility than
anything else.

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

15 months ago[Docs][typo] Done the required fix for the #61690
aabhinavg [Sun, 26 Mar 2023 05:57:46 +0000 (11:27 +0530)]
[Docs][typo]  Done the required fix for the #61690

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

15 months agoRevert "Implement Pass and Dialect plugins for mlir-opt"
Jacques Pienaar [Thu, 6 Apr 2023 16:41:22 +0000 (09:41 -0700)]
Revert "Implement Pass and Dialect plugins for mlir-opt"

Breaks bot.

This reverts commit d4c873b044aeebaa43e6989fb1f9606530ec60cf.

15 months ago[RISCV] Lower scalar_to_vector
Luke Lau [Wed, 5 Apr 2023 12:14:51 +0000 (13:14 +0100)]
[RISCV] Lower scalar_to_vector

Loads of fixed length vectors with irregular element counts are
sometimes emitted as a scalar load + scalar_to_vector.
Previously the scalar_to_vector wasn't legal and so was scalarized
further. This patch handles it by lowering it to a vmv.s.x.

Reviewed By: craig.topper

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

15 months ago[RISCV] Add tests for loads and stores of illegal fixed length vectors
Luke Lau [Wed, 5 Apr 2023 10:02:41 +0000 (11:02 +0100)]
[RISCV] Add tests for loads and stores of illegal fixed length vectors

I was investigating why getMemoryOpCost was so expensive for these fixed length vector types, so I've added these tests to see what was going on.
It looks like there's some room for codegen improvement before we adjust the cost model.

Reviewed By: craig.topper

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

15 months ago[InstCombine] Regenerate all test checks (NFC)
Nikita Popov [Thu, 6 Apr 2023 16:29:32 +0000 (18:29 +0200)]
[InstCombine] Regenerate all test checks (NFC)

Due to an improvement to name preservation, a lot of InstCombine
tests now show spurious diffs when regenerated.

Rather than regenerating individual files when they get touched,
mass-regenerate all UTC-based InstCombine tests. I have then reset
a number of files showing suspicious diffs where the UTC output
has clearly been manually adjusted. I apologize if I missed
anything in the mass of changes.

15 months agoRevert "[AMDGPU] Add Lower Bound to PipelineSolver"
Nico Weber [Thu, 6 Apr 2023 16:35:44 +0000 (12:35 -0400)]
Revert "[AMDGPU] Add Lower Bound to PipelineSolver"

This reverts commit 3c42a58c4f20ae3b621733bf5ee6d57c912994a9.
Breaks tests on mac, see https://reviews.llvm.org/rG3c42a58c4f20ae3b621733bf5ee6d57c912994a9#1191724

15 months agoImplement Pass and Dialect plugins for mlir-opt
Fabian Mora [Thu, 6 Apr 2023 16:09:00 +0000 (09:09 -0700)]
Implement Pass and Dialect plugins for mlir-opt

Implementation of Pass and Dialect Plugins that mirrors LLVM Pass Plugin  implementation from the new pass manager.

Currently the implementation only supports using the pass-pipeline option for adding passes. This restriction is imposed by the `PassPipelineCLParser` variable in mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:114 that loads the parse options statically before parsing the cmd line args.

```
mlir-opt stanalone-plugin.mlir --load-dialect-plugin=lib/libStandalonePlugin.so --pass-pipeline="builtin.module(standalone-switch-bar-foo)"
```

Reviewed By: rriddle

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

15 months ago[RISCV] Use PseudoInstExpansion for PseudoReadVLENB and PseudoReadVL. NFC
Craig Topper [Thu, 6 Apr 2023 16:33:01 +0000 (09:33 -0700)]
[RISCV] Use PseudoInstExpansion for PseudoReadVLENB and PseudoReadVL. NFC

This lets tablegen generated the code and avoids a string lookup
of the CSR name at runtime.