platform/upstream/llvm.git
22 months ago[mlir][sparse] introduce vectorization pass for sparse loops
Aart Bik [Fri, 18 Nov 2022 20:18:00 +0000 (12:18 -0800)]
[mlir][sparse] introduce vectorization pass for sparse loops

This brings back previous SIMD functionality, but in a separate pass.
The idea is to improve this new pass incrementally, going beyond for-loops
to while-loops for co-iteration as welll (masking), while introducing new
abstractions to make the lowering more progressive. The separation of
sparsification and vectorization is a very good first step on this journey.

Also brings back ArmSVE support

Still to be fine-tuned:
  + use of "index" in SIMD loop (viz. a[i] = i)
  + check that all ops really have SIMD support
  + check all forms of reductions
  + chain reduction SIMD values

Reviewed By: dcaballe

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

22 months agopr59000: Clarify packed-non-pod warning that it's pod-for-the-purposes-of-layout
David Blaikie [Mon, 21 Nov 2022 23:59:21 +0000 (23:59 +0000)]
pr59000: Clarify packed-non-pod warning that it's pod-for-the-purposes-of-layout

22 months ago[PowerPC] Add support for G_ADD and G_SUB.
Kai Nacke [Mon, 21 Nov 2022 20:47:52 +0000 (20:47 +0000)]
[PowerPC] Add support for G_ADD and G_SUB.

Extends the global isel implementation to support G_ADD and G_SUB.

Reviewed By: arsenm, amyk

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

22 months ago[libc++][NFC] Add missing conditionals for the existence of wide characters
Louis Dionne [Mon, 21 Nov 2022 14:50:31 +0000 (09:50 -0500)]
[libc++][NFC] Add missing conditionals for the existence of wide characters

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

22 months ago[mlir][MemRef] NFC rename simplify-extract-strided-metadata
Quentin Colombet [Mon, 21 Nov 2022 17:37:39 +0000 (17:37 +0000)]
[mlir][MemRef] NFC rename simplify-extract-strided-metadata

This pass has outgrown its original goal and is now going to be used to
expand certain memref operations before lowering.
Reflect that in the name.

The pass is now called expand-strided-metadata.

NFC

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

22 months agoparse: process GNU and standard attributes on top-level decls
Saleem Abdulrasool [Tue, 15 Nov 2022 15:44:34 +0000 (15:44 +0000)]
parse: process GNU and standard attributes on top-level decls

We would previously reject valid input where GNU attributes preceded the
standard attributes on top-level declarations. A previous attribute
handling change had begun rejecting this whilst GCC does honour this
layout. In practice, this breaks use of `extern "C"` attributed
functions which use both standard and GNU attributes as experienced by
the Swift runtime.

Objective-C deserves an honourable mention for requiring some additional
special casing. Because attributes on declarations and definitions
differ in semantics, we need to replicate some of the logic for
detecting attributes to declarations to which they appertain cannot be
attributed. This should match the existing case for the application of
GNU attributes to interfaces, protocols, and implementations.

Take the opportunity to split out the tooling tests into two cases: ones
which process macros and ones which do not.

Special thanks to Aaron Ballman for the many hints and extensive rubber
ducking that was involved in identifying the various places where we
accidentally dropped attributes.

Differential Revision: https://reviews.llvm.org/D137979
Fixes: #58229
Reviewed By: aaron.ballman, arphaman

22 months ago[libc++] <type_traits>: Avoid instantiating a pointer type.
John Baldwin [Mon, 21 Nov 2022 22:34:07 +0000 (14:34 -0800)]
[libc++] <type_traits>: Avoid instantiating a pointer type.

GCC expands the pointer type in this conditional expression even for
template types _Up that are not arrays.  This raises an error when
std::decay<> is used with reference types (as is done in LLVM's
sources).  Using add_pointer<> causes GCC to only instantiate a
pointer type for array types.

Reviewed By: #libc, philnik, ldionne

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

22 months ago[WebAssembly] Disable register coalescing at -O1
Heejin Ahn [Wed, 16 Nov 2022 01:30:07 +0000 (17:30 -0800)]
[WebAssembly] Disable register coalescing at -O1

This disables `RegisterCoalescer` pass at -O1, which currently runs for
all levels except for -O0, as a part of common optimization pipeline.

`RegisterCoalescer` pass degrades Wasm debug info quality by a
significant margin. When I use `LiveDebugValue` analysis, disabling this
increases the average PC ranges covered by 15% on Emscripten core
benchmarks (52% -> 66.8%). (Our code is currently not using
`LiveDebugValues` analysis at the moment, and the experiment was done on
a local setting that enabled it. I'm planning to upstream it soon.)

In Emscripten core benchmarks, disabling this at -O1 causes +4.5% in
code size and +1% in the number of locals. The number of globals stays
the same. I believe this tradeoff is acceptable given that -O1 is not
usually used in production builds and is often used for debugging when
the application size is very large.

The plan is to investigate and fix what's causing the degradation in
that pass, but for now disabling it seems like a low-hanging quick fix.

Reviewed By: dschuff

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

22 months ago[SCEV] Iteratively compute ranges for deeply nested expressions.
Florian Hahn [Mon, 21 Nov 2022 21:56:14 +0000 (21:56 +0000)]
[SCEV] Iteratively compute ranges for deeply nested expressions.

At the moment, getRangeRef may overflow the stack for very deeply nested
expressions.

This patch introduces a new getRangeRefIter function, which first builds
a worklist of N-ary expressions and phi nodes, followed by their
operands iteratively.

getRangeRef has been extended to also take a Depth argument and it
switches to use getRangeRefIter once the depth reaches a certain
threshold.

This ensures compile-time is not impacted in general. Note that
the iterative algorithm may lead to a slightly different evaluation
order, which could result in slightly worse ranges for cyclic phis.

https://llvm-compile-time-tracker.com/compare.php?from=23c3eb7cdf3478c9db86f6cb5115821a8f0f5f40&to=e0e09fa338e77e53242bfc846e1484350ad79773&stat=instructions

Fixes #49579.

Reviewed By: mkazantsev

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

22 months ago[libc++][math.h][NFC] Reformat functions
Nikolas Klauser [Fri, 4 Nov 2022 15:36:34 +0000 (16:36 +0100)]
[libc++][math.h][NFC] Reformat functions

This is just to make to follow-up diffs simpler

Reviewed By: ldionne, #libc, EricWF

Spies: EricWF, libcxx-commits

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

22 months ago[PowerPC] Move PPCGenRegisterBankInfo.def into the directory where it would be if...
Benjamin Kramer [Mon, 21 Nov 2022 21:21:22 +0000 (22:21 +0100)]
[PowerPC] Move PPCGenRegisterBankInfo.def into the directory where it would be if it was autogenerated

22 months ago[clang-format] Support new file formatting with vim
Ji, Jinsong [Mon, 21 Nov 2022 21:11:24 +0000 (13:11 -0800)]
[clang-format] Support new file formatting with vim

The vim Formatonsave integration is not working if we create a new file directly using vim.
eg: vi -V9t.log t.cpp

It will not able to format the buffer.

> Traceback (most recent call last):
>   File "<string>", line 1, in <module>
>   File "...clang/tools/clang-format/clang-format.py", line 156, in <module>
>     main()
>   File "...clang/tools/clang-format/clang-format.py", line 80, in main
>     with open(vim.current.buffer.name, 'r') as f:
> FileNotFoundError: [Errno 2] No such file or directory: '...t.cpp'

This patch check the file before we try to open it.

Reviewed By: owenpan

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

22 months ago[libc++] Don't workaround GCC issue on non-GCC compilers
Louis Dionne [Mon, 21 Nov 2022 16:04:05 +0000 (11:04 -0500)]
[libc++] Don't workaround GCC issue on non-GCC compilers

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

22 months ago[clangd] Mark "override" and "final" as modifiers
Christian Kandeler [Mon, 21 Nov 2022 21:00:23 +0000 (22:00 +0100)]
[clangd] Mark "override" and "final" as modifiers

... in semantic highlighting.
These specifiers cannot be identified by simple lexing (since e.g.
variables with these names can legally be declared), which means they
should be semantic tokens.

Reviewed By: sammccall

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

22 months agoRestore global descriptor demangling after D138095 "[asan] Keep Itanium mangled names...
Fangrui Song [Mon, 21 Nov 2022 20:51:52 +0000 (20:51 +0000)]
Restore global descriptor demangling after D138095 "[asan] Keep Itanium mangled names in global metadata"

This amends commit 00be3578e0841dd9abe408e5b4946180de0bf46b to demangle symbol
names in global descriptors. We keep the mangled name for the `__odr_gen_asan_*`
variables and the runtime __cxa_demangle call site change (which fixed possible
leaks for other scenarios: non-fatal diagnostics).

compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp uses
an undefined weak `__cxa_demangle` which does not pull in an archive definition.
A -static-libstdc++ executable link does not get demangled names.

Unfortunately this means we cannot rely on runtime demangling.
See compiler-rt/test/asan/TestCases/global-demangle.cpp

22 months agoReland "[lldb] Fix SBFileSpec.fullpath"
Dave Lee [Mon, 21 Nov 2022 20:31:59 +0000 (12:31 -0800)]
Reland "[lldb] Fix SBFileSpec.fullpath"

Update `fullpath` asserts in TestMiniDump.py.

This reverts commit 682fcc95f4149f00e9da961817fe2f5832e4b301.

22 months ago[WebAssembly] Update relaxed-simd instruction names
Thomas Lively [Mon, 21 Nov 2022 20:40:14 +0000 (12:40 -0800)]
[WebAssembly] Update relaxed-simd instruction names

Including builtin and intrinsic names. These should be the final names for the
proposal.
https://github.com/WebAssembly/relaxed-simd/blob/main/proposals/relaxed-simd/Overview.md

Reviewed By: aheejin, maratyszcza

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

22 months ago[clang-format] Fix a crash due to dereferencing null MatchingParen
Owen Pan [Sun, 20 Nov 2022 03:04:24 +0000 (19:04 -0800)]
[clang-format] Fix a crash due to dereferencing null MatchingParen

Fixes #59089.

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

22 months agoRevert "[lldb] Fix SBFileSpec.fullpath"
Dave Lee [Mon, 21 Nov 2022 20:31:24 +0000 (12:31 -0800)]
Revert "[lldb] Fix SBFileSpec.fullpath"

This reverts commit a59ed8fa86036efe66efcaddd5cd3e1d17856563.

22 months ago[Support] Use a custom base class for FormatVariadicTest.cpp (NFC)
Kazu Hirata [Mon, 21 Nov 2022 20:22:16 +0000 (12:22 -0800)]
[Support] Use a custom base class for FormatVariadicTest.cpp (NFC)

This patch replaces None with a custom base class in
FormatVariadicTest.cpp.

As part of the migration from llvm::Optional to std::optional, I'd
like to define None as std::nullopt, but FormatVariadicTest.cpp blocks
that.

When you specialize indexed_accessor_range with the base class being
None, the template instantiation eventually generates code to compare
two instances of None.  That's not guaranteed with std::nullopt.

Replacing None with a custom base class allows me to define None as
std::nullopt.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

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

22 months ago[lldb] Fix SBFileSpec.fullpath
Dave Lee [Sat, 19 Nov 2022 03:27:41 +0000 (19:27 -0800)]
[lldb] Fix SBFileSpec.fullpath

Reimplement `SBFileSpec.fullpath` to (indirectly) use `FileSpec::GetPath`.

Instead of hardcoding a `/` separator, use `GetPath`. This makes use of the
`FileSpec`'s internal style, which for example allows for backslash on Windows
where required.

It's not obvious from looking at the source, but the `fullpath` property is
implemented with `str`, which calls `GetDescription`, which finally calls
`GetPath`.

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

22 months ago[PowerPC] Extend GlobalISel implementation to emit and/or/xor.
Kai Nacke [Fri, 16 Sep 2022 23:55:53 +0000 (23:55 +0000)]
[PowerPC] Extend GlobalISel implementation to emit and/or/xor.

Adds some more code to GlobalISel to enable instruction selection for and/or/xor.

- Makes G_IMPLICIT_DEF, G_CONSTANT, G_AND, G_OR, G_XOR legal for 64bit register size.
- Implement lowerReturn in CallLowering
- Provides mapping of the operands to register banks.
- Adds register info to G_COPY operands.

The utility functions are all only implemented so far to support this use case.
Especially the functions in PPCGenRegisterBankInfo.def are too simple for
general use.

Reviewed By: nemanjai, shchenz, amyk

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

22 months ago[SCEV] Add range test with phi and division.
Florian Hahn [Mon, 21 Nov 2022 19:58:43 +0000 (19:58 +0000)]
[SCEV] Add range test with phi and division.

Extra test coverage for D130728.

22 months ago[test] Fix TestSourceManager when the source file is readonly.
Jordan Rupprecht [Mon, 21 Nov 2022 19:56:02 +0000 (11:56 -0800)]
[test] Fix TestSourceManager when the source file is readonly.

This test copies main.c to main-copy.c and modifies main-copy.c while debugging, but main.c may have come from a readonly location, which means writing to main-copy.c will fail because permissions are preserved. Run the equivalent of "chmod u+w" before attempting to modify it.

This effect can be seen by attempting to run this test after running `chmod u-w lldb/test/API/source-manager/main.c`

22 months ago[libc++] Add utilites for instantiating functions with multiple types
Nikolas Klauser [Sat, 5 Nov 2022 01:57:52 +0000 (02:57 +0100)]
[libc++] Add utilites for instantiating functions with multiple types

We currently call a lot of functions with the same list of types. To avoid forgetting any of them, this patch adds type_lists and utilities for it. Specifically, it adds
- `type_list` - This is just a list of types
- `concatenate` - This allows concatenating type_lists
- `for_each` - Iterate over a type_list

Reviewed By: ldionne, #libc

Spies: jloser, EricWF, libcxx-commits

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

22 months ago[PowerPC] Add new load/store with length instructions to Future CPU.
Maryam Moghadas [Fri, 28 Oct 2022 22:03:16 +0000 (17:03 -0500)]
[PowerPC] Add new load/store with length instructions to Future CPU.

This patch adds 8 news load and store with length instructions including
lxvrl, lxvrll, stxvrl, stxvrll, lxvprl, lxvprll, stxvprl, stxvprll.

Reviewed By: stefanp, amyk, saghir

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

22 months ago[clang] NFC: Robustify sret test regex
Nathan Sidwell [Mon, 14 Nov 2022 13:53:59 +0000 (08:53 -0500)]
[clang] NFC: Robustify sret test regex

Replace old-style, brittle, grep with new-fangled FileCheck technology.

Reviewed By: rnk

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

22 months ago[Passes][VectorCombine] enable early run generally and try load folds
Sanjay Patel [Mon, 21 Nov 2022 18:16:56 +0000 (13:16 -0500)]
[Passes][VectorCombine] enable early run generally and try load folds

An early run of VectorCombine was added with D102496 specifically to
deal with unnecessary vector ops produced with the C matrix extension.
This patch is proposing to try those folds in general and add a pair
of load folds to the menu.

The load transform will partly solve (see PhaseOrdering diffs) a
longstanding vectorization perf bug by removing redundant loads via GVN:
issue #17113

The main reason for not enabling the extra pass generally in the initial
patch was compile-time cost. The cost of VectorCombine was significantly
(surprisingly) improved with:
87debdadaf18
https://llvm-compile-time-tracker.com/compare.php?from=ffe05b8f57d97bc4340f791cb386c8d00e0739f2&to=87debdadaf18f8a5c7e5d563889e10731dc3554d&stat=instructions:u

...so the extra run is going to cost very little now - the total cost of
the 2 runs should be less than the 1 run before that micro-optimization:
https://llvm-compile-time-tracker.com/compare.php?from=5e8c2026d10e8e2c93c038c776853bed0e7c8fc1&to=2c4b68eab5ae969811f422714e0eba44c5f7eefb&stat=instructions:u

It may be possible to reduce the cost slightly more with a few more
earlier-exits like that, but it's probably in the noise based on timing
experiments.

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

22 months ago[VectorCombine] generalize pass param name for early combines; NFC
Sanjay Patel [Sat, 19 Nov 2022 15:04:49 +0000 (10:04 -0500)]
[VectorCombine] generalize pass param name for early combines; NFC

The option was added with https://reviews.llvm.org/D102496,
and currently the name is accurate, but I am hoping to add
a load transform that is not a scalarization. See issue #17113.

22 months ago[ELF] Test rejected --detect-odr-violations
Fangrui Song [Mon, 21 Nov 2022 18:57:29 +0000 (18:57 +0000)]
[ELF] Test rejected --detect-odr-violations

22 months agoUse poison instead of undef as placeholder for vector construction [NFC]
Manuel Brito [Mon, 21 Nov 2022 18:41:01 +0000 (18:41 +0000)]
Use poison instead of undef as placeholder for vector construction [NFC]

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

22 months ago[libc++][format] Makes format_context copyable.
Mark de Wever [Sun, 13 Nov 2022 17:51:36 +0000 (18:51 +0100)]
[libc++][format] Makes format_context copyable.

This was a bug discovered by @jwakely.

Reviewed By: #libc, ldionne

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

22 months ago[Support] Reduce Dependence on Host.h
Archibald Elliott [Mon, 21 Nov 2022 18:26:49 +0000 (18:26 +0000)]
[Support] Reduce Dependence on Host.h

The intention behind this commit is to reduce the use of Host.h/Host.cpp
in Support, to where it is only necessary.

In this case, the endian-detection and support functionality needed by
these implementations can be provided by `Support/SwapByteOrder.h` in a
cleaner manner.

This patch also changes the byte swap in SHA256.cpp to use the byte swap
function from that header, rather than an inlined implementation.

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

22 months ago[SLP]Fix PR59098: check if the vector type is scalarized for
Alexey Bataev [Mon, 21 Nov 2022 17:59:56 +0000 (09:59 -0800)]
[SLP]Fix PR59098: check if the vector type is scalarized for
extractelements.

If the resulting type is going to be scalarized, no need to adjust the
cost of removed extractelement and insert/extract subvector costs.
Otherwise, the compiler can crash because of the wrong type sizes.

22 months ago[AArch64][SME]: Generate streaming-compatible code for fp_to_int and int_to_fp.
Hassnaa Hamdi [Fri, 18 Nov 2022 10:50:37 +0000 (10:50 +0000)]
[AArch64][SME]: Generate streaming-compatible code for fp_to_int and int_to_fp.

1-To generate code compatible to streaming mode:
  - enable custom lowering fp_to_int, int_to_fp, fp_round, fmul, trunc.
  - disable fp_to_int combining into invalid NEON intrinsic.
2-Add testing files:
  fp_to_int.ll
  fp-convert.ll
  int_to_fp.ll
  trunc.ll

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

22 months ago[AArch64][SME]: Add precursory tests for D138281
Hassnaa Hamdi [Fri, 18 Nov 2022 09:42:43 +0000 (09:42 +0000)]
[AArch64][SME]: Add precursory tests for D138281

22 months ago[test] Remove named function arguments from TestSBEnvironment
Jordan Rupprecht [Mon, 21 Nov 2022 18:05:41 +0000 (10:05 -0800)]
[test] Remove named function arguments from TestSBEnvironment

This is not available in all versions of swig 3.

22 months ago[AArch64][NFC] SME2 Add missing tests for usvdot and sumlall instructions
Caroline Concatto [Mon, 21 Nov 2022 17:27:48 +0000 (17:27 +0000)]
[AArch64][NFC] SME2 Add missing tests for usvdot and sumlall instructions

22 months ago[MLIR] Hide FailureOr::hasValue()
Christian Sigg [Mon, 21 Nov 2022 06:40:54 +0000 (07:40 +0100)]
[MLIR] Hide FailureOr::hasValue()

`Optional<T>::hasValue()` is deprecated and should be private like `has_value()`.

Reviewed By: tpopp, bondhugula

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

22 months ago[RISCV] Add isel patterns to select slli+shXadd.uw.
Craig Topper [Mon, 21 Nov 2022 17:32:51 +0000 (09:32 -0800)]
[RISCV] Add isel patterns to select slli+shXadd.uw.

This matches what we get for something like.
%0 = shl i32 %x, C
%1 = zext i32 %0 to i64
%2 = getelementptr i32, ptr %y, %1

The shift before the zext and the shift implied by the GEP get
combined with an AND after them. We need to split it back into
2 shifts so we can fold one into shXadd.uw.

Reviewed By: reames

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

22 months ago[lldb] Disable looking at pointee types to find synthetic value for non-ObjC
Arthur Eubanks [Mon, 14 Nov 2022 21:45:44 +0000 (13:45 -0800)]
[lldb] Disable looking at pointee types to find synthetic value for non-ObjC

After D134378, we started seeing crashes with incomplete types (in the
context of shared libraries).

When trying to print a `std::vector<int> &` with only debug info for a
declaration, we now try to use the formatter after D134378. With an
incomplete type, this somehow goes into infinite recursion with the
frames

```
lldb_private::ValueObject::Dereference
lldb_private::ValueObjectSynthetic::CreateSynthFilter
lldb_private::ValueObjectSynthetic::ValueObjectSynthetic
lldb_private::ValueObject::CalculateSyntheticValue
lldb_private::ValueObject::HasSyntheticValue
```

This has to do with `FrontEndWantsDereference` that some STL formatters
set, causing recursion between the formatter (which tries to dereference),
and dereferencing (which wants to know if there's a formatter to avoid dereferencing).

The reason this only started appearing after D134378 was because
previously with incomplete types, for names with `<`, lldb would attempt
to parse template parameter DIEs, which were empty, then create an empty
`ClassTemplateSpecializationDecl` which overrode the name used to lookup
a formatter in `FormattersMatchData()` to not include template
parameters (e.g. `std::vector<> &`). After D134378 we don't create a
`ClassTemplateSpecializationDecl` when there are no template parameters
and the name to lookup a formatter is the original name (e.g.
`std::vector<int> &`).

The code to try harder with incomplete child compiler types was added in
D79554 for ObjC purposes.

Reviewed By: labath

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

22 months ago[bazel] Port d6abdf46bc
Benjamin Kramer [Mon, 21 Nov 2022 17:18:25 +0000 (18:18 +0100)]
[bazel] Port d6abdf46bc

22 months ago[X86] Synchronise scheduler classes of VPERM2F128/VBROADCASTF128/VEXTRACTF128/VINSERT...
Simon Pilgrim [Mon, 21 Nov 2022 17:15:38 +0000 (17:15 +0000)]
[X86] Synchronise scheduler classes of VPERM2F128/VBROADCASTF128/VEXTRACTF128/VINSERTF128 with I128 equivalents

znver1/znver2 has barely any difference in behaviour between the AVX1/2 variants of these instructions - it looks like it was a copy+paste mistake to miss the AVX2 integer domain instructions in the overrides.

Having said that the override numbers don't appear to match the numbers in the AMD 17h SoGs very well - for instance vperm2f128/vperm2i128 might be microcoded from the AMD sense of >3 uops, but it doesn't have a 100cy latency..... These will need to be further addressed.

22 months ago[mlir][AMDGPU] Remove buffer ops that are statically out of bounds
Krzysztof Drewniak [Wed, 9 Nov 2022 22:26:33 +0000 (22:26 +0000)]
[mlir][AMDGPU] Remove buffer ops that are statically out of bounds

When the bounds check attribute is true, the raw buffer load, store,
and atomic operations have well-defined behavior (returning 0 for
loads and ignoring stores) when the buffer access exceeds the bounds
of the memory being accessed.

Because of how LLVM currently implements these buffer operations (as
opaque intrinsics), the backend cannot optimize out this known
behavior and eliminate the memory operations. Therefore, use MLIR's
canonicalization system to eliminate these operations.

Reviewed By: nirvedhmeshram

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

22 months ago[AArch64][SME] Always allocate a lazy-save buffer if a function has ZA state.
Sander de Smalen [Mon, 21 Nov 2022 16:01:54 +0000 (16:01 +0000)]
[AArch64][SME] Always allocate a lazy-save buffer if a function has ZA state.

We already do this for most cases, with the exception of instructions that
get expanded to function calls (e.g. for lowering operations on fp128
values), in which case we temporarily allocate a lazy-save buffer.

The code that is generated in this case, is however incorrect, as it seems
to pass an incorrect address for the TPIDR2 object to the ZA restore
function. By always allocating the lazy-save buffer once, we avoid this
issue entirely.

The cost is that we also allocate such a buffer when it is not
needed. We could fix that in a follow-up patch, where we remove the
lazy-save buffer when it isn't used.

Reviewed By: paulwalker-arm

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

22 months ago[test][lldb-vscode] Un-realpath coreFile test.
Jordan Rupprecht [Mon, 21 Nov 2022 16:32:49 +0000 (08:32 -0800)]
[test][lldb-vscode] Un-realpath coreFile test.

TestVSCode_coreFile looks for an exe/core file in the same directory as the test. It first calls `realpath`, but I don't think it's necessary. Using `realpath` prevents this test from working when run as part of a build system that uses content-addressed-storage, i.e. all the files might all be symlinks in the same directory pointing to files in different directories elsewhere. If some amount of normalization is needed, maybe `os.path.normpath()` would be useful, although I wouldn't see why that's needed either.

(This is a fairly trivial patch, but I'm mailing it to see if there is a reason we need to keep `realpath`, and if so, if there's some other workaround we can do).

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

22 months ago[FPEnv] Enable strict fp for AArch64 in clang
John Brawn [Wed, 26 Oct 2022 13:00:45 +0000 (14:00 +0100)]
[FPEnv] Enable strict fp for AArch64 in clang

The AArch64 target now has the necessary support for strict fp, so
enable it in clang.

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

22 months ago[libc++][NFC] Add link to GCC bug report in <limits.h> workaround
Louis Dionne [Mon, 21 Nov 2022 16:01:13 +0000 (11:01 -0500)]
[libc++][NFC] Add link to GCC bug report in <limits.h> workaround

22 months ago[lld/ELF] Make plugin-opt=jobs= help text refer to --thinlto-jobs=
Nico Weber [Mon, 21 Nov 2022 15:55:39 +0000 (10:55 -0500)]
[lld/ELF] Make plugin-opt=jobs= help text refer to --thinlto-jobs=

22 months ago[flang] Accept BaseBoxType in couple of fir.array_* operations
Valentin Clement [Mon, 21 Nov 2022 15:53:48 +0000 (16:53 +0100)]
[flang] Accept BaseBoxType in couple of fir.array_* operations

Couple of operation are expecting BoxType but can totally handle
ClassType as well. This patch updates couple of locations to support
BaseBoxType instead of BoxType only.

Reviewed By: jeanPerier, PeteSteinfeld

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

22 months ago[lld/ELF] Fix grammar-o in a help string
Nico Weber [Mon, 21 Nov 2022 15:54:01 +0000 (10:54 -0500)]
[lld/ELF] Fix grammar-o in a help string

22 months ago[lld/ELF] Rename OPT_thinlto_jobs to OPT_thinlto_jobs_eq
Nico Weber [Mon, 21 Nov 2022 15:53:10 +0000 (10:53 -0500)]
[lld/ELF] Rename OPT_thinlto_jobs to OPT_thinlto_jobs_eq

The flag ends with a `=`, so its name should end with `_eq`.
No behavior change.

22 months ago[Assignment Tracking][25/*] Replace sunk address uses in dbg.assign intrinsics
OCHyams [Mon, 21 Nov 2022 15:46:52 +0000 (15:46 +0000)]
[Assignment Tracking][25/*] Replace sunk address uses in dbg.assign intrinsics

The Assignment Tracking debug-info feature is outlined in this RFC:

https://discourse.llvm.org/t/
rfc-assignment-tracking-a-better-way-of-specifying-variable-locations-in-ir

Reviewed By: StephenTozer

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

22 months ago[clangd] Add option to skip per-location checks.
Sam McCall [Mon, 21 Nov 2022 15:41:53 +0000 (16:41 +0100)]
[clangd] Add option to skip per-location checks.

This avoids a slow step after timing tidy checks for https://github.com/clangd/clangd/issues/1337

22 months ago[clangd] Move --check options into Check.cpp. Add --check-completion.
Sam McCall [Mon, 21 Nov 2022 15:37:32 +0000 (16:37 +0100)]
[clangd] Move --check options into Check.cpp. Add --check-completion.

This is less plumbing and clutter in ClangdMain.cpp.
Having --check-lines imply completion was just about minimizing plumbing
I think, so make that explicit.

22 months ago[X86] Pre-commit tests for pr58685 (negated cases)
Phoebe Wang [Mon, 21 Nov 2022 15:23:12 +0000 (23:23 +0800)]
[X86] Pre-commit tests for pr58685 (negated cases)

22 months ago[clangd] Extend --check to time clang-tidy checks, so we can block slow ones
Sam McCall [Mon, 17 Oct 2022 14:38:11 +0000 (16:38 +0200)]
[clangd] Extend --check to time clang-tidy checks, so we can block slow ones

misc-const-correctness is so catastrophically slow that we need to block it
from running. But we need a way to detect this without breaking users first.

This is part of a plan to run only fast checks by default.
More details in  https://github.com/clangd/clangd/issues/1337

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

22 months ago[XCOFF] llvm-readobj support display symbol table of loader section of xcoff object...
zhijian [Mon, 21 Nov 2022 15:11:12 +0000 (10:11 -0500)]
[XCOFF] llvm-readobj support display symbol table of loader section of xcoff object file.

Reviewers: James Henderson, Esme Yi

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

22 months ago[LoopFlatten] Add a test for incorrect IV increment uses. NFC
David Green [Mon, 21 Nov 2022 15:05:44 +0000 (15:05 +0000)]
[LoopFlatten] Add a test for incorrect IV increment uses. NFC

These are a couple of test cases from 58441, showing LCSSA uses on
the IV increment. Part of D138404.

22 months ago[NFC][InstCombine] Pre-commit tests for D137934
Thomas Symalla [Mon, 21 Nov 2022 15:04:26 +0000 (16:04 +0100)]
[NFC][InstCombine] Pre-commit tests for D137934

Various InstCombine tests to show diffs with the new
extractelement / select folding.

22 months ago[libc++][NFC] Rename folder for char_traits<wchar_t> tests
Louis Dionne [Mon, 21 Nov 2022 14:48:18 +0000 (09:48 -0500)]
[libc++][NFC] Rename folder for char_traits<wchar_t> tests

22 months ago[mlir][bufferization] Support general Attribute as memory space
Lei Zhang [Mon, 21 Nov 2022 14:33:13 +0000 (09:33 -0500)]
[mlir][bufferization] Support general Attribute as memory space

MemRef has been accepting a general Attribute as memory space for
a long time. This commits updates bufferization side to catch up,
which allows downstream users to plugin customized symbolic memory
space. This also eliminates quite a few `getMemorySpaceAsInt`
calls, which is deprecated.

Reviewed By: springerm

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

22 months agoRemove -cc1 -fconcepts-ts flag
Erich Keane [Mon, 21 Nov 2022 14:30:47 +0000 (06:30 -0800)]
Remove -cc1 -fconcepts-ts flag

The -fconcepts-ts flag has been deprecated for 5 releases now, so just
remove it, concepts is supported in C++20 mode.

22 months ago[DAGCombiner] fold or (and x, y), x --> x
chenglin.bi [Mon, 21 Nov 2022 14:10:55 +0000 (22:10 +0800)]
[DAGCombiner] fold or (and x, y), x --> x

Reviewed By: RKSimon

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

22 months ago[llvm,polly,clang] Stop setting config.enable_shared in most places
Nico Weber [Fri, 18 Nov 2022 15:47:34 +0000 (10:47 -0500)]
[llvm,polly,clang] Stop setting config.enable_shared in most places

Clang's lit.cfg.py reads this to add an "enable-shared" feature that
three of clang's lit tests use. Nothing else reads enable_shared, so
remove it from most lit.site.cfg.py.in files.

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

22 months ago[AArch64][SVE] Precommit tests for VSCALE/SVE CNTx demanded bits
Benjamin Maxwell [Mon, 21 Nov 2022 13:22:03 +0000 (13:22 +0000)]
[AArch64][SVE] Precommit tests for VSCALE/SVE CNTx demanded bits

22 months ago[libc++] Remove workarounds for systems that used to require __need_XXX macros
Louis Dionne [Mon, 8 Aug 2022 18:06:40 +0000 (14:06 -0400)]
[libc++] Remove workarounds for systems that used to require __need_XXX macros

Libc++ tried accomodating systems that need to be able to define various
__need_FOO macros before including C library headers, however it does not
appear to be needed anymore in most cases. Indeed, glibc used to use that
system to conditionally provide definitions, however almost all instances
of these macros have been removed from glibc years ago.

I think the next step would be to also fix Clang's own builtin headers
to stop needing these macros.

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

22 months agoMerge kDynamicSize and kDynamicSentinel into one constant.
Aliia Khasanova [Fri, 18 Nov 2022 18:00:10 +0000 (18:00 +0000)]
Merge kDynamicSize and kDynamicSentinel into one constant.

resolve conflicts

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

22 months ago[X86][NFC] Minor improvement in X86InstrInfo::optimizeCompareInstr
Shengchen Kan [Mon, 21 Nov 2022 12:59:22 +0000 (20:59 +0800)]
[X86][NFC] Minor improvement in X86InstrInfo::optimizeCompareInstr

Before this patch, the code enumerated `getCondFromBranch`, `getCondFromSETCC` and `getCondFromFromCMov` to get the condition code of a `MachineInstr`, and assigned the result to variable `OldCC` when `MI || IsSwapped || ImmDelta != 0` was satisfiled.

After this patch, the `if-else` structure is eliminated by using `getCondFromMI`. Since `OldCC` is only used when  `MI || IsSwapped || ImmDelta != 0`  is true, it is initialized with `getCondFromMI` directly outside the scope of `if` now.

Reviewed By: pengfei

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

22 months ago[NFC][IndVars] Add LLVM_DEBUG printout to replaceExitCond
Max Kazantsev [Mon, 21 Nov 2022 12:18:53 +0000 (19:18 +0700)]
[NFC][IndVars] Add LLVM_DEBUG printout to replaceExitCond

22 months ago[lldb] Enable TestTargetVar on non-darwin
Pavel Labath [Mon, 21 Nov 2022 12:13:34 +0000 (13:13 +0100)]
[lldb] Enable TestTargetVar on non-darwin

22 months ago[clang-format][NFC] Removed unused include
Björn Schäpers [Sun, 20 Nov 2022 14:08:28 +0000 (15:08 +0100)]
[clang-format][NFC] Removed unused include

22 months ago[clang-format][NFC] Don't add a load of 0es
Björn Schäpers [Sat, 19 Nov 2022 16:22:09 +0000 (17:22 +0100)]
[clang-format][NFC] Don't add a load of 0es

Shift is 0 for all non comments, maybe even for comments. Don't add the
0 up to three times.

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

22 months ago[clang-format][NFC] Format lambda in conditional
Björn Schäpers [Thu, 17 Nov 2022 20:07:31 +0000 (21:07 +0100)]
[clang-format][NFC] Format lambda in conditional

This sort of amends cdbe296853b1b3fc6415236f05770360e23f0d39

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

22 months ago[clang-format][NFC] Remove unneeded braces
Björn Schäpers [Thu, 17 Nov 2022 20:01:50 +0000 (21:01 +0100)]
[clang-format][NFC] Remove unneeded braces

Done by clang-format itself.

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

22 months ago[mlir][linalg] Change linalg.broadcast `dimensions` attribute to represent added...
Oleg Shyshkov [Mon, 21 Nov 2022 12:15:50 +0000 (13:15 +0100)]
[mlir][linalg] Change linalg.broadcast `dimensions` attribute to represent added dimensions.

Original [RFC](discourse.llvm.org/t/rfc-primitive-ops-add-broadcastop-to-linalg/66313) defined `dimensions` as a map from input to init, but a discussion in reviews.llvm.org/D138291 concluded that it's more natural for `dimensions` to represent added dims. Also this way is more consistent with `linalg.reduce`.

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

22 months agoMark test using -debug-only as requiring assertions
Benjamin Kramer [Mon, 21 Nov 2022 10:46:02 +0000 (11:46 +0100)]
Mark test using -debug-only as requiring assertions

22 months ago[MachineTraceMetrics] Pick the trace successor for an entry block
Anton Sidorenko [Fri, 18 Nov 2022 09:33:02 +0000 (12:33 +0300)]
[MachineTraceMetrics] Pick the trace successor for an entry block

We generate erroneous trace for a basic block if it does not have at least one
predecessor when MinInstr strategy is used. Currently only this strategy is
implemented, so we always have a wrong trace for any entry block. This results in
wrong instructions heights calculation and also leads to wrong critical path.

The described behavior is demonstrated on a simple test. It shows that early
if-conv pass makes wrong decisions due to incorrectly calculated critical path
lenght.

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

22 months ago[MachineTraceMetrics] Precommit test for D138272
Anton Sidorenko [Fri, 18 Nov 2022 09:31:28 +0000 (12:31 +0300)]
[MachineTraceMetrics] Precommit test for D138272

22 months ago[libc][test][NFC] bump mpfr version to 4.1.1
Guillaume Chatelet [Mon, 21 Nov 2022 09:38:42 +0000 (09:38 +0000)]
[libc][test][NFC] bump mpfr version to 4.1.1

22 months ago[mlir] bazel for D137997
Alex Zinenko [Mon, 21 Nov 2022 09:20:19 +0000 (10:20 +0100)]
[mlir] bazel for D137997

22 months ago[Test] Add some test showing limitations of makeIVComparisonInvariant
Max Kazantsev [Mon, 21 Nov 2022 09:19:01 +0000 (16:19 +0700)]
[Test] Add some test showing limitations of makeIVComparisonInvariant

The transform doesn't work if argument isn't immediately a Phi.

22 months ago[flang] Add hlfir.designate codegen for Fortran ArrayRef
Jean Perier [Mon, 21 Nov 2022 09:04:28 +0000 (10:04 +0100)]
[flang] Add hlfir.designate codegen for Fortran ArrayRef

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

22 months ago[flang][NFC] Update TODOs list
Valentin Clement [Mon, 21 Nov 2022 09:04:58 +0000 (10:04 +0100)]
[flang][NFC] Update TODOs list

22 months ago[ELF] InputFile: change symbols to unique_ptr<Symbol *[]>
Fangrui Song [Mon, 21 Nov 2022 09:02:04 +0000 (09:02 +0000)]
[ELF] InputFile: change symbols to unique_ptr<Symbol *[]>

We may try a custom allocator in the future.

22 months ago[flang] Add fir.select_type conversion to if-then-else ladder
Valentin Clement [Mon, 21 Nov 2022 09:00:17 +0000 (10:00 +0100)]
[flang] Add fir.select_type conversion to if-then-else ladder

Convert fir.select_type operation to an if-then-else ladder.
The type guards are sorted before the conversion so it follows the
execution of SELECT TYPE construct as mentioned in 11.1.11.2 point 4
of the Fortran standard.

Depends on D138279

Reviewed By: jeanPerier

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

22 months ago[LoongArch] AsmParser support for the li.[wd] pseudo instructions
wanglei [Mon, 21 Nov 2022 07:36:28 +0000 (15:36 +0800)]
[LoongArch] AsmParser support for the li.[wd] pseudo instructions

The `li.[wd]` pseudo instructions are used to load an immediate value
into a GPR. These expand directly during asm parsing. As the result,
only real MC instructions are emitted to the MCStreamer. The actual
expansion to real instructions is similar to the expansion performed by
the GAS.

Note: The `li.w` always treats the imm operand as a 32-bit signed value.

Reviewed By: SixWeining

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

22 months ago[RISCV] Enable reduction pattern SelectICmp and SelectFCmp.
Mel Chen [Mon, 14 Nov 2022 13:54:37 +0000 (05:54 -0800)]
[RISCV] Enable reduction pattern SelectICmp and SelectFCmp.

Reviewed By: david-arm

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

22 months ago[llvm] Use Optional::operator-> (NFC)
Kazu Hirata [Mon, 21 Nov 2022 08:15:35 +0000 (00:15 -0800)]
[llvm] Use Optional::operator-> (NFC)

Since std::optional does not offer getPointer(), this patch replaces
X.getPointer()->foo with X->foo to make the migration from
llvm::Optional to std::optional easier.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

22 months ago[Test] One more test for IndVars, showing imperfect work with context
Max Kazantsev [Mon, 21 Nov 2022 08:14:28 +0000 (15:14 +0700)]
[Test] One more test for IndVars, showing imperfect work with context

22 months ago[mlir][test] Fix how the number of flops is calculated
Andrzej Warzynski [Mon, 21 Nov 2022 07:15:26 +0000 (12:45 +0530)]
[mlir][test] Fix how the number of flops is calculated

Make sure that the number of repetitions is correctly incorporated when
calculating the number of floating point operations.

Reviewed By: bondhugula

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

22 months ago[MLIR][Transform] Transform dialect support for affine
Amy Wang [Sat, 19 Nov 2022 13:27:54 +0000 (14:27 +0100)]
[MLIR][Transform] Transform dialect support for affine

Create the directory and file structures to support transform ops for
the affine dialect in the future.  Enable affine.unroll and affine.get_parent_for
transform operations in this first batch of check in.

Reviewed By: ftynse

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

22 months ago[LoongArch] Support parsing la* pseudo instructions
wanglei [Mon, 21 Nov 2022 07:13:10 +0000 (15:13 +0800)]
[LoongArch] Support parsing la* pseudo instructions

This patch makes `IAS` compatible with `GAS`. It accepts `la*` pseudo
instructions, and expands `la{,.local,.global}` into different
instructions according to different features.

```
 Default:
     la = la.global = la.got
     la.local = la.pcrel
 With feature "+la-global-with-pcrel":
     la = la.global = la.pcrel
 With feature "+la-global-with-abs":
     la = la.global = la.abs
 With feature "+la-local-with-abs":
     la.local = la.abs
 With features "+la-global-with-pcrel,+la-global-with-abs"(disorder):
     la = la.global = la.pcrel
```
Note: To keep consistent with `GAS` behavior, the "la" can only have
      one register operand.

Reviewed By: SixWeining

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

22 months ago[Test] Add some examples where IndVars fails to turn condition into invariant
Max Kazantsev [Mon, 21 Nov 2022 06:14:13 +0000 (13:14 +0700)]
[Test] Add some examples where IndVars fails to turn condition into invariant

22 months ago[Scalar] Teach matchExpandedRem to return std::optional (NFC)
Kazu Hirata [Mon, 21 Nov 2022 06:38:43 +0000 (22:38 -0800)]
[Scalar] Teach matchExpandedRem to return std::optional (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

22 months ago[PowerPC] XCOFF exception section support on the integrated assembler path
Paul Scoropan [Mon, 21 Nov 2022 05:16:26 +0000 (00:16 -0500)]
[PowerPC] XCOFF exception section support on the integrated assembler path

Continuation of https://reviews.llvm.org/D132146 (direct assembly path support, needs to merge first). Adds support to the integrated assembler path for emitting XCOFF exception sections. Both features need https://reviews.llvm.org/D133030 to merge first

Reviewed By: shchenz, DiggerLin

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

22 months ago[ELF] Simplify postScanRelocations with in.got
Fangrui Song [Mon, 21 Nov 2022 06:04:18 +0000 (06:04 +0000)]
[ELF] Simplify postScanRelocations with in.got

22 months agoRevert "Revert "[clang-tblgen][NFC] renames Diagnostic.Text to Diagnostic.Summary""
Christopher Di Bella [Mon, 21 Nov 2022 04:36:14 +0000 (04:36 +0000)]
Revert "Revert "[clang-tblgen][NFC] renames Diagnostic.Text to Diagnostic.Summary""

This reverts commit 196edb9f3f4a036371af0013a3d8b857fe0924d5.

22 months agoRevert "[clang-tblgen][NFC] renames Diagnostic.Text to Diagnostic.Summary"
Christopher Di Bella [Mon, 21 Nov 2022 04:34:56 +0000 (04:34 +0000)]
Revert "[clang-tblgen][NFC] renames Diagnostic.Text to Diagnostic.Summary"

This reverts commit eb3f7880a272b818940e2bd2510ae04b0e32873f.

22 months ago[ELF] Add InputSectionBase::{addRelocs,relocs} and GotSection::addConstant to add...
Fangrui Song [Mon, 21 Nov 2022 04:12:03 +0000 (04:12 +0000)]
[ELF] Add InputSectionBase::{addRelocs,relocs} and GotSection::addConstant to add/access relocations

to prepare for changing `relocations` from a SmallVector to a pointer.

Also change the `isec` parameter in `addAddendOnlyRelocIfNonPreemptible` to `GotSection &`.