platform/upstream/llvm.git
20 months ago[M68k] Provide exception pointer and selector registers
Min-Yih Hsu [Thu, 19 Jan 2023 19:44:20 +0000 (11:44 -0800)]
[M68k] Provide exception pointer and selector registers

Using d0 for exception pointer and d1 for selector, as suggested by GCC.

20 months agoRevert "Revert "[Tooling/Inclusion] Handle std::get symbol.""
Kadir Cetinkaya [Fri, 24 Feb 2023 00:05:15 +0000 (01:05 +0100)]
Revert "Revert "[Tooling/Inclusion] Handle std::get symbol.""

This reverts commit 7c9b15fbaeb2846ad25e797d55ffe1ccef9e1379. Breakage
was in downstream code.

20 months ago[OpenMP] Fix the wrong use of `fopen`
Shilei Tian [Fri, 24 Feb 2023 00:12:51 +0000 (19:12 -0500)]
[OpenMP] Fix the wrong use of `fopen`

This patch fixes the wrong use of `fopen`.

Fix https://github.com/llvm/llvm-project/issues/60934

Reviewed By: jdoerfert

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

20 months ago[PGO] Setting ValueProfNode Array's Alignment
Qiongsi Wu [Thu, 23 Feb 2023 22:31:50 +0000 (17:31 -0500)]
[PGO] Setting ValueProfNode Array's Alignment

`instrprof` currently does not set `__llvm_prf_vnds`'s alignment after creating it. The consequence is that the alignment is set to 16 later (https://github.com/llvm/llvm-project/blob/c0f3ac1d0015fd051144a987ff500b888a32be86/llvm/lib/IR/DataLayout.cpp#L1019). This can lead to undefined behaviour when we calculate `NumVNodes` in `lprofGetLoadModuleSignature` (https://github.com/llvm/llvm-project/blob/c0f3ac1d0015fd051144a987ff500b888a32be86/compiler-rt/lib/profile/InstrProfilingMerge.c#L32). The reason is that when the `__llvm_prf_vnds` array is 16 byte aligned, `__llvm_profile_end_vnodes() - __llvm_profile_begin_vnodes()` may not be a multiple of the size of ValueProfNode (which is 24, 20 on 32 bit targets).

This patch sets `__llvm_prf_vnds`'s alignment to its ABI alignment, which always divides its size. Then `__llvm_profile_end_vnodes() - __llvm_profile_begin_vnodes()` will be a multiple of `sizeof(ValueProfNode)`.

Reviewed By: w2yehia, MaskRay

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

20 months ago[clang] fix intendation in newly added release note
Alex Lorenz [Thu, 23 Feb 2023 23:52:21 +0000 (15:52 -0800)]
[clang] fix intendation in newly added release note

This fixes the llvm docs build bot.

20 months ago[mlir][doc] Remove section about now removed `useFoldAPI` option
Markus Böck [Thu, 23 Feb 2023 23:25:17 +0000 (00:25 +0100)]
[mlir][doc] Remove section about now removed `useFoldAPI` option

20 months ago[RISCV] Add vendor-defined XTheadFMemIdx (FP Indexed Memory Operations) extension
Manolis Tsamis [Thu, 23 Feb 2023 23:18:55 +0000 (00:18 +0100)]
[RISCV] Add vendor-defined XTheadFMemIdx (FP Indexed Memory Operations) extension

The vendor-defined XTHeadFMemIdx (no comparable standard extension exists
at the time of writing) extension adds indexed load/store instructions
for floating-point registers.

It is supported by the C9xx cores (e.g., found in the wild in the
Allwinner D1) by Alibaba T-Head.

The current (as of this commit) public documentation for this
extension is available at:
  https://github.com/T-head-Semi/thead-extension-spec/releases/download/2.2.2/xthead-2023-01-30-2.2.2.pdf

Support for these instructions has already landed in GNU Binutils:
  https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=f511f80fa3fcaf6bcbe727fb902b8bd5ec8f9c20

Depends on D144249

Reviewed By: craig.topper

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

20 months ago[scudo] Mark all blocks in a range without visiting each of them
Chia-hung Duan [Thu, 23 Feb 2023 22:51:29 +0000 (22:51 +0000)]
[scudo] Mark all blocks in a range without visiting each of them

When all the blocks in the group are known to be used, we should just
mark the pages in the range as all counted instead of visiting each of
them. This will reduce the time of marking free blocks especially for
smaller size class.

Reviewed By: cferris

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

20 months agoRevert "[Tooling/Inclusion] Handle std::get symbol."
Caroline Tice [Thu, 23 Feb 2023 23:10:36 +0000 (15:10 -0800)]
Revert "[Tooling/Inclusion] Handle std::get symbol."

This reverts commit cbcb3eef70def3509bdffd4fe1ebfb6422afeaa2.

Causing many clangd test breakages, similar to:

error: no matching constructor for initialization of 'llvm::SmallVector<clang::tooling::stdlib::Header>'
                : llvm::SmallVector<clang::tooling::stdlib::Header>(
                  ^

20 months ago[RISCV] Add vendor-defined XTheadMemIdx (Indexed Memory Operations) extension
Manolis Tsamis [Thu, 23 Feb 2023 23:04:08 +0000 (00:04 +0100)]
[RISCV] Add vendor-defined XTheadMemIdx (Indexed Memory Operations) extension

The vendor-defined XTHeadMemIdx (no comparable standard extension exists
at the time of writing) extension adds indexed load/store instructions
as well as load/store and update register instructions.

It is supported by the C9xx cores (e.g., found in the wild in the
Allwinner D1) by Alibaba T-Head.

The current (as of this commit) public documentation for this
extension is available at:
  https://github.com/T-head-Semi/thead-extension-spec/releases/download/2.2.2/xthead-2023-01-30-2.2.2.pdf

Support for these instructions has already landed in GNU Binutils:
  https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=27cfd142d0a7e378d19aa9a1278e2137f849b71b

Depends on D144002

Reviewed By: craig.topper

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

20 months ago[clang][driver] Handle '-mrelax' and '-mno-relax' for AVR
Ben Shi [Thu, 23 Feb 2023 07:39:02 +0000 (15:39 +0800)]
[clang][driver] Handle '-mrelax' and '-mno-relax' for AVR

Reviewed By: MaskRay, aykevl

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

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

20 months ago[llvm] Teach GlobalDCE about dso_local_equivalent
Leonard Chan [Tue, 18 Oct 2022 18:23:48 +0000 (18:23 +0000)]
[llvm] Teach GlobalDCE about dso_local_equivalent

This way, C++ relative-vtables can also participate in GlobalDCE. This
depends on some TypeMetadataUtils.cpp bits in D134320, but that
dependency can be removed and included here if necessary.

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

20 months ago[Driver] Define BareMetal::HasNativeLLVMSupport to return true
Fangrui Song [Thu, 23 Feb 2023 23:06:02 +0000 (15:06 -0800)]
[Driver] Define BareMetal::HasNativeLLVMSupport to return true

D33259 switched the default linker to ld.lld which supports LLVM LTO.
We can support LTO compile/link in one command and drop the
`unable to pass LLVM bit-code files to linker` error.

Fix https://github.com/llvm/llvm-project/issues/52807

20 months ago[-Wunsafe-buffer-usage] Fixits for assignments to array subscript expressions
Ziqing Luo [Thu, 23 Feb 2023 22:53:43 +0000 (14:53 -0800)]
[-Wunsafe-buffer-usage] Fixits for assignments to array subscript expressions

Let generate fix-its to make assignments' left-hand side of the form
`dre[e]` safe if `e` is known to be non-negative.

Commit on behalf of jkorous (Jan Korous)

Reviewed by: NoQ (Artem Dergachev)

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

20 months ago[clang] extend external_source_symbol attribute with USR clause
Alex Lorenz [Thu, 23 Feb 2023 22:14:14 +0000 (14:14 -0800)]
[clang] extend external_source_symbol attribute with USR clause

Allow the user to specify a concrete USR in the external_source_symbol attribute.
That will let Clang's indexer to use Swift USRs for Swift declarations that are
represented with C++ declarations.

This new clause is used by Swift when generating a C++ header representation
of a Swift module:
https://github.com/apple/swift/pull/63002

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

20 months agoAdd tests to reproduce pointer/index width confusion crashes
Krzysztof Drewniak [Thu, 23 Feb 2023 21:47:48 +0000 (21:47 +0000)]
Add tests to reproduce pointer/index width confusion crashes

Some calls to GEPOperator::accumulateConstantOffset(APInt) passed the
pointer bitwidth as the width of the APInt, while the function asserts
that the width of its argument is equal to the index width of the GEP
pointer input. These values are almost always the same, so mixing up
which call to use doesn't usually cause issues. However, when dealing
with data layouts where these values are different, the passes tested
here can crash.

This will be fixed in D143437 .

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

20 months ago[-Wunsafe-buffer-usage] Create Fix-Its only if they are emitted
Ziqing Luo [Thu, 23 Feb 2023 22:43:21 +0000 (14:43 -0800)]
[-Wunsafe-buffer-usage] Create Fix-Its only if they are emitted

`-Wunsafe-buffer-usage` diagnostics shall not emit fix-its if fix-its
are globally disabled.

Commit on behalf of jkorous (Jan Korous)

Reviewed by: NoQ (Artem Dergachev)

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

20 months ago[mlir][LinAlg][Transform] Add a transform op for conv2d to im2col
Quentin Colombet [Thu, 23 Feb 2023 22:26:15 +0000 (22:26 +0000)]
[mlir][LinAlg][Transform] Add a transform op for conv2d to im2col

This patch adds patterns to convert `linalg.conv_2d_xxx` operations
into `linalg.generic` (for img2col packing) and `linalg.matmul`.

The meat of the patch comes straight from IREE
(https://github.com/iree-org/iree).
(To the original authors are you okay with that?)

What this patch adds is proper plumbing of the im2col patterns into the
transform dialect.

PS: Feel free to add more reviewers. I wanted to cover the original contributors of im2col in IREE but I'm not sure I got all of them.

Reviewed By: nicolasvasilache, ThomasRaoux

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

20 months ago[llvm] Teach whole program devirtualization about relative vtables
Leonard Chan [Mon, 26 Sep 2022 20:27:09 +0000 (20:27 +0000)]
[llvm] Teach whole program devirtualization about relative vtables

Prior to this patch, WPD was not acting on relative-vtables in C++. This
involves teaching WPD about these things:

- llvm.load.relative which is how relative-vtables are indexed (instead of GEP)
- dso_local_equivalent which is used in the vtable itself when taking the
  offset between a virtual function and vtable
- Update llvm/test/ThinLTO/X86/devirt.ll to use opaque pointers and add
  equivalent tests for RV

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

20 months agoAdd REQUIRES: riscv to riscv test
Leonard Chan [Thu, 23 Feb 2023 22:16:49 +0000 (22:16 +0000)]
Add REQUIRES: riscv to riscv test

This should fix builders like
https://lab.llvm.org/buildbot/#/builders/139/builds/36522

20 months ago[lld][RISCV] Introduce handling for R_RISCV_PLT32 relocation
Leonard Chan [Thu, 23 Feb 2023 22:05:11 +0000 (22:05 +0000)]
[lld][RISCV] Introduce handling for R_RISCV_PLT32 relocation

This introduces R_RISCV_PLT32, a PC-relative data relocation that takes
the 32-bit relative offset to a function or its PLT entry.

This is needed to support relative vtables on RISCV.

Github PR: https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/363

D143226 has the llvm parts.

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

20 months ago[LTO/WPD] Allow devirtualization to function alias in vtable
Teresa Johnson [Fri, 17 Feb 2023 15:38:01 +0000 (07:38 -0800)]
[LTO/WPD] Allow devirtualization to function alias in vtable

Follow on to D144209 to support single implementation devirtualization
for Regular LTO when the vtable holds a function alias.

For now I have prevented other optimizations performed in regular LTO
that need to analyze the contents of the function target when the vtable
holds an alias, as I'm not sure they are always correct to perform in
that case.

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

20 months ago[HWASAN][LSAN] Only initialize Symbolizer if leak checking is enabled
Kirill Stoimenov [Thu, 23 Feb 2023 20:30:53 +0000 (20:30 +0000)]
[HWASAN][LSAN] Only initialize Symbolizer if leak checking is enabled

Reviewed By: hctim

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

20 months ago[libc++] Run modules_include.sh.cpp compiles in parallel
Nikolas Klauser [Thu, 23 Feb 2023 12:33:55 +0000 (13:33 +0100)]
[libc++] Run modules_include.sh.cpp compiles in parallel

It's not pretty, but it makes the test run a lot faster.

Reviewed By: #libc, philnik

Spies: DavidSpickett, libcxx-commits

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

20 months ago[InstCombine] add tests for select of div/rem with common operand; NFC
Sanjay Patel [Thu, 23 Feb 2023 19:49:59 +0000 (14:49 -0500)]
[InstCombine] add tests for select of div/rem with common operand; NFC

issue #60906

20 months ago[MC][nfc] Don't use a value after it has been std::move()'d
Jez Ng [Thu, 23 Feb 2023 20:15:14 +0000 (15:15 -0500)]
[MC][nfc] Don't use a value after it has been std::move()'d

Reviewed By: serge-sans-paille

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

20 months ago[clang-tidy][doc] Remove unused variable
Björn Svensson [Thu, 23 Feb 2023 20:06:43 +0000 (20:06 +0000)]
[clang-tidy][doc] Remove unused variable

Remove mention of a variable that is not used in the example for checker:
cppcoreguidelines-avoid-non-const-global-variables

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

20 months ago[SCEV] Ensure SCEV does not replace aliases with their aliasees
Leonard Chan [Thu, 23 Feb 2023 19:58:29 +0000 (19:58 +0000)]
[SCEV] Ensure SCEV does not replace aliases with their aliasees

Passes in general shouldn't replace an alias with the aliasee (see
https://reviews.llvm.org/D66606). This can lead to situations where a
linkonce_odr symbol (which could be interposable if lowered to weak
linkage) can be replaced with a local aliasee which won't be
interposable. SVEC does this when the function is invoked by
FunctionPass Manager -> Loop Pass Manager -> Induction Variable Users in
the codegen pipeline. This was found in hwasan instrumented code where a
linonce_odr alias was replaced with its private aliasee.

This fixes the bug descriped at
https://github.com/llvm/llvm-project/issues/60668.

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

20 months ago[ASan][libcxx] Annotating std::vector with all allocators
Advenam Tacet [Thu, 23 Feb 2023 19:45:57 +0000 (20:45 +0100)]
[ASan][libcxx] Annotating std::vector with all allocators

This revision is a part of a series of patches extending
AddressSanitizer C++ container overflow detection
capabilities by adding annotations, similar to those existing
in std::vector, to std::string and std::deque collections.
These changes allow ASan to detect cases when the instrumented
program accesses memory which is internally allocated by
the collection but is still not in-use (accesses before or
after the stored elements for std::deque, or between the size and
capacity bounds for std::string).

The motivation for the research and those changes was a bug,
found by Trail of Bits, in a real code where an out-of-bounds read
could happen as two strings were compared via a std::equals function
that took iter1_begin, iter1_end, iter2_begin iterators
(with a custom comparison function).
When object iter1 was longer than iter2, read out-of-bounds on iter2
could happen. Container sanitization would detect it.

In revision D132522, support for non-aligned memory buffers (sharing
first/last granule with other objects) was added, therefore the
check for standard allocator is not necessary anymore.
This patch removes the check in std::vector annotation member
function (__annotate_contiguous_container) to support
different allocators.

Additionally, this revision fixes unpoisoning in std::vector.
It guarantees that __alloc_traits::deallocate may access returned memory.
Originally suggested in D144155 revision.

If you have any questions, please email:
 - advenam.tacet@trailofbits.com
 - disconnect3d@trailofbits.com

Reviewed By: #libc, #sanitizers, philnik, vitalybuka

Spies: hans, EricWF, philnik, #sanitizers, libcxx-commits

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

20 months ago[clangd/index/remote]NFC: Adapt code to newer grpc/protobuf versions
Matthias Braun [Wed, 22 Feb 2023 23:25:11 +0000 (15:25 -0800)]
[clangd/index/remote]NFC: Adapt code to newer grpc/protobuf versions

It seems newer grpc / protobuf versions renamed
`Status::error_message()` and `Status::error_code()` to `message()` and
`code()` to prepare for replacement with `absl::Status` with the same
names.

As far as I can tell the new names are already available in the
grpc-1.36 version mentioned in the `README` file.

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

20 months ago[Libomptarget] Adjust the info.c test now that printing is common
Joseph Huber [Thu, 23 Feb 2023 19:24:40 +0000 (13:24 -0600)]
[Libomptarget] Adjust the info.c test now that printing is common

Summary:
Ever since the change to the new plugins the information messages are
common between the major plugins. This allows us to test the info.c file
generically.

20 months ago[Libomptarget] Add the CUDA feature to the packager
Joseph Huber [Thu, 23 Feb 2023 19:22:54 +0000 (13:22 -0600)]
[Libomptarget] Add the CUDA feature to the packager

Summary:
Internally we need to know the feature that was used to build the CUDA.
This used to be added when the deviceRTL was build via the OpenMP
interface, but ever since it was moved to call the packager explicitly
it was not being added. This causes failured if the user attempts to use
the library without LTO enabled.

20 months ago[debugserver] Add one additional sleep before attaching after waiting
Alex Langford [Sat, 18 Feb 2023 01:27:14 +0000 (17:27 -0800)]
[debugserver] Add one additional sleep before attaching after waiting

It's possible for debugserver to attach to a process during the handoff
between /usr/lib/dyld and the dyld in the shared cache. When that
happens, we may end up in a state where there is no dyld in the process
and our debugging session is doomed. To make that scenario a lot less
likely, we can insert a sleep right before attaching after waiting to
find the right pid.

rdar://105513180

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

20 months ago[mlir][tensor] Improve size inference in tiling tensor.pack ops.
Hanhan Wang [Thu, 23 Feb 2023 00:58:37 +0000 (16:58 -0800)]
[mlir][tensor] Improve size inference in tiling tensor.pack ops.

The sizes of input operands need being clampled only when there are
incomplete tiles, i.e., the padding value is set. The shape input slice
can be folded into constants when they are static shapes and tiling
sizes.

Reviewed By: chelini

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

20 months ago[AMDGPU] Move V_FMA_MIX pattern matching into tablegen. NFC
Justin Bogner [Thu, 23 Feb 2023 01:45:58 +0000 (17:45 -0800)]
[AMDGPU] Move V_FMA_MIX pattern matching into tablegen. NFC

The matching for V_FMA_MIX was partially implemented with a C++
matcher (for fmas with 32 bit results and 16 bit inputs) and partially
in tablegen (for fmas with 16 bit results). Move the C++ matcher logic
into tablegen to make this more consistent and so we can remove the
duplication between SDAG and GISel.

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

20 months agoRevert "[Pipeline] Move ControlHeightReduction to module optimization pipeline"
Arthur Eubanks [Thu, 23 Feb 2023 17:47:58 +0000 (09:47 -0800)]
Revert "[Pipeline] Move ControlHeightReduction to module optimization pipeline"

This reverts commit b374423304a8d91d590d0ce5ab1b381296d6dfb2.

Causes regressions on some benchmarks.

20 months ago[Flang][Driver] NFC: Fix plugin test to work on Mac
Kiran Chandramohan [Thu, 23 Feb 2023 16:55:06 +0000 (16:55 +0000)]
[Flang][Driver] NFC: Fix plugin test to work on Mac

Minor modifications to Diagnostic expectation to match the error generated in Mac.
Tested on M1 Mac.

Reviewed By: awarzynski

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

20 months agoName threadpool threads.
Benoit Jacob [Thu, 16 Feb 2023 15:23:13 +0000 (15:23 +0000)]
Name threadpool threads.

This gives our worker threads some names that allow easily identifying them in tools such as profilers and debuggers.

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

20 months agoRevert "[DAGCombine] Fold redundant select"
Samuel Parker [Thu, 23 Feb 2023 14:29:35 +0000 (14:29 +0000)]
Revert "[DAGCombine] Fold redundant select"

This reverts commit c7f9344d0f8f6a00adab138037e2e7b406ef2b69.

20 months ago[scudo] Disable the GetRssFromBuffer scudo test on PPC
Amy Kwan [Thu, 23 Feb 2023 17:46:37 +0000 (11:46 -0600)]
[scudo] Disable the GetRssFromBuffer scudo test on PPC

The GetRssFromBuffer scudo test case fails intermittently on Power, so this test
is disabled on the platform because of this.

20 months ago[mlir][sparse] support sparse tensor element type conversion in codegen path
Peiming Liu [Wed, 22 Feb 2023 19:04:02 +0000 (19:04 +0000)]
[mlir][sparse] support sparse tensor element type conversion in codegen path

Reviewed By: aartbik

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

20 months ago[LegalizeTypes] Add a special case for (add X, 1) to ExpandIntRes_ADDSUB.
Craig Topper [Thu, 23 Feb 2023 17:47:42 +0000 (09:47 -0800)]
[LegalizeTypes] Add a special case for (add X, 1) to ExpandIntRes_ADDSUB.

On targets without ADDCARRY or ADDE, we need to emit a separate
SETCC to determine carry from the low half to the high half. Usually
we do (setult Lo, LHSLo). If RHSLo is 1 we can instead do (seteq Lo, 0).
This can reduce the live range of LHSLo.

20 months agoSkip using this[:1] map info for non-member variable.
Jennifer Yu [Thu, 23 Feb 2023 03:57:30 +0000 (19:57 -0800)]
Skip using this[:1] map info for non-member variable.

This fix runtime problem due to generate this[:1] map info for non member
variable.
To fix this check VD, if VD is not null, it is not member from current
or base classes.

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

20 months ago[mlir][GPU] Fix incorrect API usage in RewritePatterns
Matthias Springer [Thu, 23 Feb 2023 17:15:14 +0000 (18:15 +0100)]
[mlir][GPU] Fix incorrect API usage in RewritePatterns

Incorrect API usage was detected by D144552.

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

20 months ago[LegalizeTypes][RISCV] Add a special case to ExpandIntRes_UADDSUBO for (uaddo X, 1).
Craig Topper [Thu, 23 Feb 2023 17:16:54 +0000 (09:16 -0800)]
[LegalizeTypes][RISCV] Add a special case to ExpandIntRes_UADDSUBO for (uaddo X, 1).

On targets that lack ADDCARRY support we split a wide uaddo into
an ADD and a SETCC that both need to be split.

For (uaddo X, 1) we can observe that when the add overflows the result
will be 0. We can emit (seteq (or Lo, Hi), 0) to detect this.

This improves D142071.

There is an alternative here. We could use either ~(lo(X) & hi(X)) == 0 or
(lo(X) & hi(X)) == -1 before the addition. That would be closer to the
code before D142071.

Reviewed By: liaolucy

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

20 months agoMove the BySpelling map to IncludeStructure.
Viktoriia Bakalova [Tue, 7 Feb 2023 16:52:51 +0000 (16:52 +0000)]
Move the BySpelling map to IncludeStructure.

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

20 months ago[flang][NFC] Remove unused variable
Valentin Clement [Thu, 23 Feb 2023 17:06:34 +0000 (18:06 +0100)]
[flang][NFC] Remove unused variable

20 months ago[Clang] Teach buildFMulAdd to peek through fneg to find fmul.
Craig Topper [Thu, 23 Feb 2023 17:05:59 +0000 (09:05 -0800)]
[Clang] Teach buildFMulAdd to peek through fneg to find fmul.

Allows us to handle expressions like -(a * b) + c

Based on the examples from D144366 that gcc seems to get.

Reviewed By: kpn

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

20 months agoAvoid strict aliasing violation on type punning inside llvm::PointerIntPair
Breno Guimarães [Thu, 23 Feb 2023 15:29:47 +0000 (15:29 +0000)]
Avoid strict aliasing violation on type punning inside llvm::PointerIntPair

llvm::PointerIntPair has methods that when used together can invoke
undefined behavior by violating strict aliasing.

`getPointer()` uses the underlying storage as it's declared: `intptr_t`
`getAddrOfPointer()` casts the underlying storage as if it was a
`PointerTy`

This violates strict aliasing, so depending on how they are used, it's
possible to have the compiler to optimize the code in unwanted ways.
See the unit test in the patch. We declare a `PointerIntPair` and use
the `getAddrOfPointer` method to fill in the a pointer value.  Then,
when we use `getPointer` the compiler is thrown off, thinking that
`intptr_t` storage could not have possibly be changed, and the check
fails.

Reviewed By: efriedma

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

20 months ago[MLIR][OpenMP] Add conversion support from FIR to LLVM Dialect for OMP Target Data...
Akash Banerjee [Thu, 23 Feb 2023 16:58:04 +0000 (16:58 +0000)]
[MLIR][OpenMP] Add conversion support from FIR to LLVM Dialect for OMP Target Data with region

This enables conversion of OpenMP Target Data op with region from FIR Dialect to LLVM IR Dialect.

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

20 months ago[RISCV] Properly diagnose mixing RVV scalable vectors with GNU vectors.
Craig Topper [Thu, 23 Feb 2023 17:00:32 +0000 (09:00 -0800)]
[RISCV] Properly diagnose mixing RVV scalable vectors with GNU vectors.

This case was being picked up by SVE code and printing an SVE
specific message.

This patch distinquishes RVV from SVE and provides a correct error
message for RVV.

The use of the generic isSizelessBuiltinType was also picking up
WebAssembly reference types which was probably an accident so I've
removed that.

I've named the test similar to SVE's test that contains this check.
Their test also tests the arm_sve_vector_bits attribute. I plan to
add something similar for RISC-V soon so I've adopted this naming.

Reviewed By: c-rhodes

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

20 months ago[gn build] Port dcb834843ed4
LLVM GN Syncbot [Thu, 23 Feb 2023 16:39:43 +0000 (16:39 +0000)]
[gn build] Port dcb834843ed4

20 months ago[AMDGPU] Split SIModeRegisterDefaults out of AMDGPUBaseInfo. NFC.
Jay Foad [Thu, 23 Feb 2023 16:07:57 +0000 (16:07 +0000)]
[AMDGPU] Split SIModeRegisterDefaults out of AMDGPUBaseInfo. NFC.

This is only used by CodeGen. Moving it out of AMDGPUBaseInfo simplifies
future changes to make some of it depend on the subtarget.

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

20 months agoRevert "[clang] Add the check of membership for the issue #58674 and improve the...
Alexander Kornienko [Thu, 23 Feb 2023 16:08:47 +0000 (17:08 +0100)]
Revert "[clang] Add the check of membership for the issue #58674 and improve the lookup process"

The commit causes clang to crash. See https://reviews.llvm.org/D143840#4147234

This reverts commit 8498ba6c2860c838183f9951b63df26ab5f02265.

20 months ago[flang] Relax the check for polymorphic pointer in storage_size intrinsic
Valentin Clement [Thu, 23 Feb 2023 16:28:54 +0000 (17:28 +0100)]
[flang] Relax the check for polymorphic pointer in storage_size intrinsic

The runtime check was a too strong as the standard says.
> If it is polymorphic it shall not be an undefined pointer.
The check was checking if the pointer was associated.
Remove the check as other compilers do.

Depends on D144643

Reviewed By: PeteSteinfeld

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

20 months ago[flang] Accept polymorphic component element in storage_size
Valentin Clement [Thu, 23 Feb 2023 16:28:07 +0000 (17:28 +0100)]
[flang] Accept polymorphic component element in storage_size

When an element is extracted from a polymorphic array, it is
represented as a PolymorphicValue. The PolymorphicValue is
not a boxed value but holds the original polyrmophic array
and the element itself. This was raising an error in storage_size
lowering since we expect a boxed value to take advantage of
fir.box_elesize.
This patch handles PolymorphicValue correctly.

Reviewed By: PeteSteinfeld

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

20 months ago[flang] Fix element indexing in Destroy component deallocation
Valentin Clement [Thu, 23 Feb 2023 16:26:52 +0000 (17:26 +0100)]
[flang] Fix element indexing in Destroy component deallocation

Derived type `Destroy` function does not take step into consideration
when indexing the component element for deallocation. This leads to
incorrect deallocation in case like:

```
module mod1
  type :: t
    real, allocatable :: r(:)
  end type
contains
  subroutine do_smth(c)
    class(t), intent(out) :: c(:)
    do i = 1, size(c)
      if (allocated(c(i)%r)) then
        print*, i, 'not deallocated'
      end if
    end do
  end subroutine
end module

program test
  use mod1
  type(t) :: z(6)
  integer :: i
  do i = 1, 6
    Allocate(z(i)%r(i))
  end do
  call do_smth(z(::2))
end
```

Similar change was done in D142527

Reviewed By: klausler

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

20 months ago[RISCV][NFC] Reuse getDeinterleaveViaVNSRL to lower deinterleave intrinsics
Luke Lau [Wed, 22 Feb 2023 19:28:36 +0000 (19:28 +0000)]
[RISCV][NFC] Reuse getDeinterleaveViaVNSRL to lower deinterleave intrinsics

This modifies it to work on both scalable and fixed vectors

Reviewed By: reames

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

20 months ago[RISCV] Lower interleave and deinterleave intrinsics
Luke Lau [Mon, 20 Feb 2023 13:32:13 +0000 (13:32 +0000)]
[RISCV] Lower interleave and deinterleave intrinsics

Lower the two intrinsics introduced in D141924.

These intrinsics can be combined with loads and stores into the much more efficient segmented load and store instructions in a following patch.

Reviewed By: reames

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

20 months ago[Clang][NFC] Remove pointless defines from test command lines
John Brawn [Tue, 21 Feb 2023 15:43:32 +0000 (15:43 +0000)]
[Clang][NFC] Remove pointless defines from test command lines

A few tests use -D on the command line to define macros that are
already predefined. Remove these pointless defines, as an upcoming
patch will cause this to be a warning.

20 months ago[Assignment Tracking][NFC] Avoid doing some work when maps have same keys
OCHyams [Thu, 23 Feb 2023 15:50:51 +0000 (15:50 +0000)]
[Assignment Tracking][NFC] Avoid doing some work when maps have same keys

Where the new checks have been added, `SymmetricDifference` - still being built
- contains entries for variables present in `A` and not in `B`.  If
`SymmetricDifference` is empty at this point it means the variables (map keys)
in `A` are a subset of those in `B`, so if `A` and `B` are the same size then
we know they're identical.

This reduces the number of instructions retired building some of the CTMark
projects in a ReleaseLTO-g configuration (geomean change -0.05% with the best
improvement being -0.24% for tramp3d-v4)

Reviewed By: StephenTozer

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

20 months ago[InstCombine] NFC: Add implied condition to block in foldSelectInstWithICmp
Sander de Smalen [Thu, 23 Feb 2023 15:29:51 +0000 (15:29 +0000)]
[InstCombine] NFC: Add implied condition to block in foldSelectInstWithICmp

Added the condition 'TrueVal->getType()->isIntOrIntVectorTy' to a block of code
in foldSelectInstWithICmp which is only valid if the TrueVal is integer type.

This change was split off from D136861.

20 months ago[lldb] Skip test_stop_reply_contains_thread_pcs on Windows
David Spickett [Thu, 23 Feb 2023 16:08:44 +0000 (16:08 +0000)]
[lldb] Skip test_stop_reply_contains_thread_pcs on Windows

I marked this as expected to fail, but it doesn't always fail,
and an unexpected success is a failure.

Skip it instead.

20 months ago[LV] NFC: Move logic to query maximum vscale to its own function.
Sander de Smalen [Thu, 23 Feb 2023 12:20:36 +0000 (12:20 +0000)]
[LV] NFC: Move logic to query maximum vscale to its own function.

To query the maximum value for vscale, the LV queries the vscale_range
attribute or a TTI hook. To avoid having to reimplement the same behaviour
for multiple uses (such as in D142894), it makes sense to move this code
to a separate function.

20 months ago[clangd] Set diag data before emitting
Kadir Cetinkaya [Thu, 23 Feb 2023 13:47:55 +0000 (14:47 +0100)]
[clangd] Set diag data before emitting

Also fixes a benign use-after-free.

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

20 months ago[PS4/PS5] Specify no <complex.h> or <threads.h>
Paul Robinson [Wed, 22 Feb 2023 19:55:34 +0000 (11:55 -0800)]
[PS4/PS5] Specify no <complex.h> or <threads.h>

We've never provided these headers so set the preprocessor
toggles to reflect that.

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

20 months agoRevert "[Clang] Implement fix for DR2628"
Tobias Hieta [Tue, 21 Feb 2023 15:47:54 +0000 (16:47 +0100)]
Revert "[Clang] Implement fix for DR2628"

This reverts commit 368b6832de33b366d4eb155f940e7476daace6a8.

See https://github.com/llvm/llvm-project/issues/60777 for details

20 months ago[Flang] Don't crash when BOZ literals are on the rhs of an assignment
Peter Steinfeld [Wed, 22 Feb 2023 18:51:54 +0000 (10:51 -0800)]
[Flang] Don't crash when BOZ literals are on the rhs of an assignment

For BOZ literals, the rhsType will be empty.  Check for that before
trying to access its value.

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

20 months ago[SME2][AArch64] Add multi-vector rounding shift left intrinsics
Kerry McLaughlin [Thu, 23 Feb 2023 13:47:45 +0000 (13:47 +0000)]
[SME2][AArch64] Add multi-vector rounding shift left intrinsics

Adds intrinsics for the following SME2 instructions:
 - srshl (single, 2 & 4 vector)
 - srshl (multi, 2 & 4 vector)
 - urshl (single, 2 & 4 vector)
 - urshl (multi, 2 & 4 vector)

NOTE: These intrinsics are still in development and are subject to future changes.

Reviewed By: david-arm

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

20 months ago[SLP] Check with target before vectorizing GEP Indices.
Jonas Paulsson [Wed, 15 Feb 2023 18:46:38 +0000 (19:46 +0100)]
[SLP] Check with target before vectorizing GEP Indices.

The target hook prefersVectorizedAddressing() already exists to check with
target if address computations should be vectorized, so it seems like this
should be used in SLPVectorizer as well.

Reviewed By: ABataev, RKSimon

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

20 months ago[PatternMatch] Don't require DataLayout for m_VScale()
Nikita Popov [Wed, 22 Feb 2023 16:13:00 +0000 (17:13 +0100)]
[PatternMatch] Don't require DataLayout for m_VScale()

The m_VScale() matcher is unusual in that it requires a DataLayout.
It is currently used to determine the size of the GEP type. However,
I believe it is sufficient to check for the canonical
<vscale x 1 x i8> form here -- I don't think there's a need to
recognize exotic variations like <vscale x 1 x i4> as a vscale
constant representation as well.

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

20 months ago[Clang] Fix a crash when taking the address of a consteval lambda
Corentin Jabot [Thu, 23 Feb 2023 10:04:23 +0000 (11:04 +0100)]
[Clang] Fix a crash when taking the address of a consteval lambda

The `_invoke` function of lambdas was not respecting
the constexpr/consteval specifier of the call operator, so it was possible
to take its address in a non-immmediately invoked context,
even if the call operator was itself consteval.

In addition, we improve the diagnostic emmited in the lambda case
not to show that `invoke` method.

Fixes #57682

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

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

20 months ago(NFC)[ConstantFold][InstSimplify] add tests for folding load for patterned arrays...
khei4 [Thu, 23 Feb 2023 08:05:43 +0000 (17:05 +0900)]
(NFC)[ConstantFold][InstSimplify] add tests for folding load for patterned arrays and structs

20 months ago[LLDB] Mark test_stop_reply_contains_thread_pcs as an expected failure on Windows
David Spickett [Thu, 23 Feb 2023 14:08:01 +0000 (14:08 +0000)]
[LLDB] Mark test_stop_reply_contains_thread_pcs as an expected failure on Windows

This has been flaky on the Windows on Arm LLDB bot.

https://lab.llvm.org/buildbot/#/builders/219/builds/826

Given that test_stop_reply_reports_multiple_threads is already expected
to fail on Windows, this is not suprising.

20 months ago[AMDGPU] Add more tests for buffer intrinsics
Piotr Sobczak [Thu, 23 Feb 2023 13:39:10 +0000 (14:39 +0100)]
[AMDGPU] Add more tests for buffer intrinsics

Add more tests for buffer intrinsics with large voffsets.

20 months agoFix comment in `Vectorization.cpp` (NFC)
Lorenzo Chelini [Thu, 23 Feb 2023 12:46:38 +0000 (13:46 +0100)]
Fix comment in `Vectorization.cpp` (NFC)

kDynamicSize is now kDynamic, see: https://reviews.llvm.org/D138282

20 months agoRevert "[SCEV] Preserve divisibility and min/max information in applyLoopGuards"
komalon1 [Thu, 23 Feb 2023 12:40:50 +0000 (14:40 +0200)]
Revert "[SCEV] Preserve divisibility and min/max information in applyLoopGuards"

This reverts commit 219ba2fb7b0ae89101f3c81a47fe4fc4aa80dea4.

20 months ago[C++20] Stop claiming full support for consteval (for the moment!)
Aaron Ballman [Thu, 23 Feb 2023 12:40:17 +0000 (07:40 -0500)]
[C++20] Stop claiming full support for consteval (for the moment!)

During Clang 15, 3d2629dd3aab17098813c68b5b76bb864bc5e285 claimed we
achieved full support for consteval in C++20. However, further testing
shows that Clang doesn't correctly handle all of the examples from
https://wg21.link/P1073R3 and has several other known issues that are
preventing us from defining the `__cpp_consteval` macro.

I think we should only claim Partial support for the moment. Once we
correct the major outstanding issues, then I think we should change the
status back to full support and define __cpp_consteval at the same time
(even if it's only to the 201811L value instead of the latest value
from C++2b). This helps users understand the support situation more
clearly.

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

20 months ago[mlir][arith] Fold on extension of FP constants using arith.extf
Victor Perez [Fri, 17 Feb 2023 10:16:42 +0000 (10:16 +0000)]
[mlir][arith] Fold on extension of FP constants using arith.extf

It is safe to fold when extending, as we will not lose precision.

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

20 months ago[AMDGPU][GFX11] Legalize and select partial NSA MIMG instructions
Mirko Brkusanin [Thu, 23 Feb 2023 11:27:52 +0000 (12:27 +0100)]
[AMDGPU][GFX11] Legalize and select partial NSA MIMG instructions

If more registers are needed for VAddr then the NSA format allows then the
final register can act as a contigous set of remaining addresses. Update
legalizer to pack register for this new format and allow instruction
selection to use NSA encoding when number of addresses exceeds max size.
Also update SIShrinkInstructions to handle partial NSA.

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

20 months ago[AMDGPU][MC][GFX11] Add Partial NSA format for image sample instructions
Mirko Brkusanin [Thu, 23 Feb 2023 10:34:27 +0000 (11:34 +0100)]
[AMDGPU][MC][GFX11] Add Partial NSA format for image sample instructions

Image sample instructions that need more than 5 VGPRs for VAddr can use
partial NSA for NSA encoding format. VGPRs that can not fit into the
encoding are sequential after the last one.
This patch adds assembly and disassembly parts.

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

20 months ago[AMDGPU] Clean up MUBUF immediate offset
Piotr Sobczak [Thu, 23 Feb 2023 10:47:40 +0000 (11:47 +0100)]
[AMDGPU] Clean up MUBUF immediate offset

D143174 lifted the artificial type restriction by promoting
offset to i32. This patch handles more cases: those involving
immediate offset in MUBUF.

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

20 months agoClear read_fd_set if EINTR received
Emre Kultursay [Thu, 23 Feb 2023 11:55:25 +0000 (12:55 +0100)]
Clear read_fd_set if EINTR received

Leaving bits uncleared set causes callbacks to be triggered even
though there are no events to process. Starting with D131160
we have a callback that makes blocking read calls over pipe which
was causing the lldb-server main loop to become unresponsive / blocked
on Android.

Reviewed By: labath

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

20 months ago[MLIR][Vector] Add a dependency on `:DataLayoutInterfaces`
Michal Terepeta [Thu, 23 Feb 2023 11:11:04 +0000 (12:11 +0100)]
[MLIR][Vector] Add a dependency on `:DataLayoutInterfaces`

Reviewed By: tpopp

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

20 months agoRevert "(NFC)[ConstantFold][InstSimplify] add tests for folding load for patterned...
khei4 [Thu, 23 Feb 2023 10:36:11 +0000 (19:36 +0900)]
Revert "(NFC)[ConstantFold][InstSimplify] add tests for folding load for patterned arrays and structs"

This reverts commit 9636bcd3a0091b0bb77250182ac0c549112f9196.

20 months ago[AMDGPU][NFC] Add getMaxMUBUFImmOffset
Piotr Sobczak [Thu, 23 Feb 2023 07:46:18 +0000 (08:46 +0100)]
[AMDGPU][NFC] Add getMaxMUBUFImmOffset

Replace magic constant 4095 with the function getMaxMUBUFImmOffset().

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

20 months ago[mlir] Fix folding for scf.for(tensor.cast).
Alexander Belyaev [Thu, 23 Feb 2023 10:12:14 +0000 (11:12 +0100)]
[mlir] Fix folding for scf.for(tensor.cast).

We should only fold tensor.casts that provide some new static information about
shapes, instead of looking for a symmetric pattern cast(for(cast)).

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

20 months agoInstCombine: Fold and/or of fcmp into class
Matt Arsenault [Wed, 30 Nov 2022 05:29:39 +0000 (00:29 -0500)]
InstCombine: Fold and/or of fcmp into class

This is motivated by patterns like !isfinite || zero. The AMDGPU math
libraries have a lot of patterns like this, and I'm trying to fix the
code to be more portable and less dependent on directly calling class
intrinsics.

I believe this is the first place where new is.fpclass calls are
introduced. There are more class-like compares that could be
recognized; this is a set I currently care about plus a few extras.

Keep the == 0 cases disabled for now. It depends on the denormal
mode. If we just check IEEE mode now, it will break my use case
without another patch I'm working on.

20 months ago[Tooling/Inclusion] Handle std::get symbol.
Haojian Wu [Tue, 21 Feb 2023 14:48:11 +0000 (15:48 +0100)]
[Tooling/Inclusion] Handle std::get symbol.

Currently, we handle it as a symbol without a header. In general, for
the include-cleaner case, the std::get comes with the type header, it is
safe to ignore it.

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

20 months ago[SCEV] Preserve divisibility and min/max information in applyLoopGuards
Alon Kom [Tue, 31 Jan 2023 08:21:53 +0000 (10:21 +0200)]
[SCEV] Preserve divisibility and min/max information in applyLoopGuards

applyLoopGuards doesn't always preserve information when there are multiple assumes.

This patch tries to deal with multiple assumes regarding a SCEV's divisibility and min/max values, and rewrite it into a SCEV that still preserves all of the information.
For example, let the trip count of the loop be TC. Consider the 3 following assumes:

1. __builtin_assume(TC % 8 == 0);
2. __builtin_assume(TC > 0);
3. __builtin_assume(TC < 100);

Before this patch, depending on the assume processing order applyLoopGuards could create the following SCEV:
max(min((8 * (TC / 8)) , 99), 1)

Looking at this SCEV, it doesn't preserve the divisibility by 8 information.

After this patch, depending on the assume processing order applyLoopGuards could create the following SCEV:
max(min((8 * (TC / 8)) , 96), 8)

By aligning up 1 to 8, and aligning down 99 to 96, the new SCEV still preserves all of the original assumes.

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

20 months ago[Modules] Don't check [temp.friend]p9 in ASTContext::isSameEntity
Chuanqi Xu [Thu, 23 Feb 2023 09:04:42 +0000 (17:04 +0800)]
[Modules] Don't check [temp.friend]p9 in ASTContext::isSameEntity

[temp.friend]p9 says

> Such a constrained friend function or function template declaration does
not declare the same function or function template as a declaration in
any other scope.

But the friend declaration in the same scope shouldn't fall into this
catagory. Although the logic is handled in 'FriendsDifferByConstraints',
the compiler may haven't merged the lexcial declcontext in time.
Also the code removed is not covered by test too.

Let's handle the logic in sema as we've done now.

20 months ago[include-cleaner] Dont pass llvm::StringRef to gtest APIs
Kadir Cetinkaya [Thu, 23 Feb 2023 09:03:59 +0000 (10:03 +0100)]
[include-cleaner] Dont pass llvm::StringRef to gtest APIs

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

20 months ago[include-cleaner] Always treat constructor calls as implicit
Kadir Cetinkaya [Wed, 22 Feb 2023 19:15:40 +0000 (20:15 +0100)]
[include-cleaner] Always treat constructor calls as implicit

Treating constructor calls when the type name isn't explicitly spelled
can cause spurious results, so turn them into implicit references.
This doesn't change the behaviour for constructor calls that explicitly spell
the type name, as we should see a reference through the typeloc.

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

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

20 months ago[NFC] test commit
Alon Kom [Thu, 23 Feb 2023 08:13:56 +0000 (10:13 +0200)]
[NFC] test commit

20 months ago[AMDGPU] Add GISel RUN lines to 2 existing tests. NFC
Diana Picus [Wed, 22 Feb 2023 12:24:36 +0000 (13:24 +0100)]
[AMDGPU] Add GISel RUN lines to 2 existing tests. NFC

This adds a bit of coverage for GlobalISel.

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

20 months ago[include-cleaner] Check macros against stdlib database
Kadir Cetinkaya [Wed, 22 Feb 2023 19:09:02 +0000 (20:09 +0100)]
[include-cleaner] Check macros against stdlib database

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

20 months ago[MLIR][Linalg] Change insertion point for `bubbleUpPackOpThroughElemGenericOp`
Lorenzo Chelini [Fri, 17 Feb 2023 10:00:07 +0000 (11:00 +0100)]
[MLIR][Linalg] Change insertion point for `bubbleUpPackOpThroughElemGenericOp`

Currently, the insertion point for `bubbleUpPackOpThroughElemGenericOp`
is after the tensor.pack this means that the new generic will be created
right after the tensor.pack. This is inconvenient because we are moving
the position of the generic; the idea is to move pack/unpack around, not
linalg.generics. This PR changes the insertion point to preserve the
position of the generic.

Additionally, it restricts the pattern to fire if the generic has a
single user (`tensor.pack`) to avoid introducing recomputation.

Reviewed By: hanchung

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

20 months ago[flang][hlfir] Simplify hlfir.assign default codegen for arrays
Jean Perier [Thu, 23 Feb 2023 08:10:09 +0000 (09:10 +0100)]
[flang][hlfir] Simplify hlfir.assign default codegen for arrays

The previous code was always emitting two genAssign calls to create
a temporary copy of the RHS if it could overlap with the LHS.

This inline temporary creation is not needed anymore after:
https://github.com/llvm/llvm-project/commit/755535b5eb5f6d60e9cc347cecd9e057231b92bb
that updated the assignment runtime to detect overlap and make a
temporary copy in the runtime directly.

Note that optimized inlined assignment will still have to do the alias
analysis to skip the copy when added later.

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

20 months ago(NFC)[ConstantFold][InstSimplify] add tests for folding load for patterned arrays...
khei4 [Thu, 23 Feb 2023 08:05:43 +0000 (17:05 +0900)]
(NFC)[ConstantFold][InstSimplify] add tests for folding load for patterned arrays and structs

20 months ago[mlir][IR] Use Listener for IR callbacks in OperationFolder
Matthias Springer [Thu, 23 Feb 2023 07:55:29 +0000 (08:55 +0100)]
[mlir][IR] Use Listener for IR callbacks in OperationFolder

Remove the IR modification callbacks from `OperationFolder`. Instead, an optional `RewriterBase::Listener` can be specified.
* `processGeneratedConstants` => `notifyOperationCreated`
* `preReplaceAction` => `notifyOperationReplaced`

This simplifies the GreedyPatternRewriterDriver because we no longer need special handling for IR modifications due to op folding.

A folded operation is now enqueued on the GreedyPatternRewriteDriver's worklist if it was modified in-place. (There may be new patterns that apply after folding.)

Also fixes a bug in `TestOpInPlaceFold::fold`. The folder could previously be applied over and over and did not return a "null" OpFoldResult if the IR was not modified. (This is similar to a pattern that returns `success` without modifying IR; it can trigger an infinite loop in the GreedyPatternRewriteDriver.)

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