platform/upstream/llvm.git
16 months ago[Sema] Fix null pointer dereference handleAlwaysInlineAttr.
Craig Topper [Thu, 16 Mar 2023 22:52:39 +0000 (15:52 -0700)]
[Sema] Fix null pointer dereference handleAlwaysInlineAttr.

It's possible for `getCalleeDecl()` to return a null pointer.

This was encountered by a user of our downstream compiler.

The case involved a DependentScopeDeclRefExpr.

Since this seems to only be for a warning diagnostic, I skipped
the diagnostic check if it returned null. But mabye there's a
different way to fix this.

Reviewed By: erichkeane

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

16 months ago[runtimes] Synchronize warnings flags between libc++/libc++abi/libunwind
Nikolas Klauser [Fri, 17 Feb 2023 10:31:41 +0000 (11:31 +0100)]
[runtimes] Synchronize warnings flags between libc++/libc++abi/libunwind

This mostly keeps the same warning flags. The most important exceptions are `-Wpedantic` and `-Wconversion`, which are now removed from libc++abi and libunwind.

Reviewed By: ldionne, #libunwind, #libc, #libc_abi

Spies: mikhail.ramalho, phosek, libcxx-commits

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

16 months agoRemove #if guards from AppendBounds to fix compile on old POSIX.
Daniel Thornburgh [Thu, 16 Mar 2023 23:15:38 +0000 (16:15 -0700)]
Remove #if guards from AppendBounds to fix compile on old POSIX.

16 months ago[AMDGPU] Simplify AGPR reservation. NFC.
Stanislav Mekhanoshin [Thu, 16 Mar 2023 23:14:02 +0000 (16:14 -0700)]
[AMDGPU] Simplify AGPR reservation. NFC.

The intent of the code was to reserve all AGPRs on a target without
AGPRs, so just do exactly that. Existing code was unsound.

16 months ago[mlir][transform] change RaggedArray internals
Alex Zinenko [Thu, 16 Mar 2023 16:58:53 +0000 (16:58 +0000)]
[mlir][transform] change RaggedArray internals

Change the internal storage scheme from storing a MutableArrayRef to
storing an explicit offset+length pair. Storing an ArrayRef is dangerous
because it contains the pointer to the first element in the range, but
the entire storage vector may be reallocated, making the pointer
dangling. We don't know when the reallocation happends, so we can't
update the ArrayRefs. Store the explicit offset instead and construct
ArrayRefs on-the-fly.

Reviewed By: Peiming

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

16 months ago[TableGen] Fix test on macOS
Shoaib Meenai [Thu, 16 Mar 2023 22:43:36 +0000 (15:43 -0700)]
[TableGen] Fix test on macOS

macOS cmp requires the option to appear before the file names.

16 months ago[clang] Unconditionally add autolink hints for frameworks.
Juergen Ributzka [Thu, 16 Mar 2023 22:28:48 +0000 (15:28 -0700)]
[clang] Unconditionally add autolink hints for frameworks.

Clang infers framework autolink hints when parsing a modulemap. In order to do
so, it checks if the module is a framework and if there is a framework binary
or TBD file in the SDK. Only when Clang finds the filei, then the autolink hint
is added to the module metadata.

During a project build many clang processes perform this check, which causes
many stat calls - even for modules/frameworks that are not even used.

The linker is already resilient to non-existing framework links that come from
the autolink metadata, so there is no need for Clang to do this check.

Instead the autolink hints are now added unconditionally and the linker only
needs to do the check once. This reduces the overall number of stat calls.

This fixes rdar://106578342.

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

16 months ago[lldb] Make MemoryCache::Read more resilient
Alex Langford [Tue, 7 Mar 2023 18:12:14 +0000 (10:12 -0800)]
[lldb] Make MemoryCache::Read more resilient

MemoryCache::Read is not resilient to partial reads when reading memory
chunks less than or equal in size to L2 cache lines. There have been
attempts in the past to fix this but nothing really solved the root of
the issue.

I first created a test exercising MemoryCache's implementation and
documenting how I believe MemoryCache::Read should behave. I then
rewrote the implementation of MemoryCache::Read as needed to make sure
that the different scenarios behaved correctly.

rdar://105407095

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

16 months ago[RISCV] Remove ExtName from RISCVExtensionInfo.
Craig Topper [Thu, 16 Mar 2023 22:20:25 +0000 (15:20 -0700)]
[RISCV] Remove ExtName from RISCVExtensionInfo.

This field is never used in the compiler and was only used in
unit tests added recently.

It's only used as the value in a map where the extension name
is the key. If we need the string we can get it from the key.

Reviewed By: asb

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

16 months agoMark test added in D145155 as requiring asserts since it uses the "-debug-only" option.
Douglas Yung [Thu, 16 Mar 2023 22:01:58 +0000 (15:01 -0700)]
Mark test added in D145155 as requiring asserts since it uses the "-debug-only" option.

This should fix the test failure in Release builds.

16 months ago[mlir][StorageUniquer] Use allocators per thread instead of per shard
River Riddle [Tue, 14 Mar 2023 00:32:10 +0000 (17:32 -0700)]
[mlir][StorageUniquer] Use allocators per thread instead of per shard

This greatly reduces the number of allocators we create, while still
retaining thread safety. Reducing the number of allocators is much
better for locality and memory usage; this revision drops memory
usage for some MLIR heavy workloads (with lots of attributes/types)
by >=5%. This is due to the observation that the number of threads
is effectively always smaller than the number of parametric attributes/types.

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

16 months ago[Inliner] clang-format InlineCost.cpp and Inliner.cpp (NFC)
Kazu Hirata [Thu, 16 Mar 2023 21:55:28 +0000 (14:55 -0700)]
[Inliner] clang-format InlineCost.cpp and Inliner.cpp (NFC)

16 months ago[HWASAN] Remove RUN statements, which have to effect on the test
Kirill Stoimenov [Thu, 16 Mar 2023 21:50:59 +0000 (21:50 +0000)]
[HWASAN] Remove RUN statements, which have to effect on the test

16 months ago[LSR] Add tests which demonstrate miscompiles in the current term-fold code
Philip Reames [Thu, 16 Mar 2023 21:03:27 +0000 (14:03 -0700)]
[LSR] Add tests which demonstrate miscompiles in the current term-fold code

16 months ago[DAE] Don't DAE if we musttail call a "live" (non-DAE-able) function
Mircea Trofin [Fri, 3 Mar 2023 02:45:34 +0000 (18:45 -0800)]
[DAE] Don't DAE if we musttail call a "live" (non-DAE-able) function

There are 2 such base cases: indirect calls and calls to functions external
to the module; and then any musttail calls to live functions (because of
the first 2 reasons or otherwise).

The IR validator reports, in these cases, that it "cannot guarantee tail
call due to mismatched parameter counts".

The fix is two-fold: first, we mark as "live" (i.e. non-DAE-able)
functions that make an indirect musttail call.

Then, we propagate live-ness to musttail callers of live functions.

Declared functions are already marked "live".

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

16 months ago[SPIRV] fix several issues in builds with expensive checks
Ilia Diachkov [Mon, 27 Feb 2023 18:16:48 +0000 (21:16 +0300)]
[SPIRV] fix several issues in builds with expensive checks

The patch fixes "Virtual register does not match instruction constraint"
and partly "Illegal virtual register for instruction" fails in the SPIRV
backend builds with LLVM_ENABLE_EXPENSIVE_CHECKS enabled. As a result,
the number of passed LIT tests with enabled checks is doubled.

Also, support for ndrange_*D builtins is placed in a separate function.

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

16 months ago[mlir][sparse] add new sparisification option for dependent index reduction-based...
Peiming Liu [Wed, 18 Jan 2023 19:24:42 +0000 (19:24 +0000)]
[mlir][sparse] add new sparisification option for dependent index reduction-based codegen

Reviewed By: aartbik

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

16 months ago[mlir][sparse] add a coo slices matmul integration test.
Peiming Liu [Thu, 16 Mar 2023 17:57:02 +0000 (17:57 +0000)]
[mlir][sparse] add a coo slices matmul integration test.

Reviewed By: wrengr

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

16 months ago[mlir] Fix a warning
Kazu Hirata [Thu, 16 Mar 2023 20:02:55 +0000 (13:02 -0700)]
[mlir] Fix a warning

This patch fixes:

  mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp:479:13:
  error: unused variable 'tiledOp' [-Werror,-Wunused-variable]

16 months ago[AIX] unset bit "IsBackChainStored" of traceback table for leaf functions with no...
zhijian [Thu, 16 Mar 2023 19:26:12 +0000 (15:26 -0400)]
[AIX] unset bit "IsBackChainStored" of traceback table for leaf functions with no stack frame

Summary:

  In function PPCAIXAsmPrinter::emitTracebackTable() ,the bit "IsBackChainStored" of traceback
table always set true, it will cause aix debug tools "dbx" emit an error info
"libdebug assertion "(framep->getGpr(STKP, &addr) == DB_SUCCESS && *nextStkpp == addr)"
when debug a leaf functions with no stack frame.

If a a leaf functions with no stack frame , the bit IsBackChainStored should be unset.

Reviewers: ChenZheng
Differential Revision: https://reviews.llvm.org/D146071

16 months ago[libc] [test] Add missing <cstdint> include
Sam James [Thu, 16 Mar 2023 19:03:42 +0000 (19:03 +0000)]
[libc] [test] Add missing <cstdint> include

Fixes build w/ GCC 13:
```
[587/7274] Building CXX object projects/libc/test/src/__support/CMakeFiles/libc_system_str_to_float_comparison_test.dir/str_to_float_comparison_test.cpp.o
FAILED: projects/libc/test/src/__support/CMakeFiles/libc_system_str_to_float_comparison_test.dir/str_to_float_comparison_test.cpp.o
/usr/lib/llvm/16/bin/clang++ -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/sam/git/llvm-project/build/projects/libc/test/src/__support -I/home/sam/git/llvm-project/libc/test/src/__support -I/home/sam/git/llvm-project/build/include -I/home/sam/git/llvm-project/llvm/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -g -std=c++17 -MD -MT projects/libc/test/src/__support/CMakeFiles/libc_system_str_to_float_comparison_test.dir/str_to_float_comparison_test.cpp.o -MF projects/libc/test/src/__support/CMakeFiles/libc_system_str_to_float_comparison_test.dir/str_to_float_comparison_test.cpp.o.d -o projects/libc/test/src/__support/CMakeFiles/libc_system_str_to_float_comparison_test.dir/str_to_float_comparison_test.cpp.o -c /home/sam/git/llvm-project/libc/test/src/__support/str_to_float_comparison_test.cpp
/home/sam/git/llvm-project/libc/test/src/__support/str_to_float_comparison_test.cpp:34:15: error: unknown type name 'uint32_t'
static inline uint32_t hexCharToU32(char in) {
              ^
/home/sam/git/llvm-project/libc/test/src/__support/str_to_float_comparison_test.cpp:39:15: error: unknown type name 'uint32_t'
static inline uint32_t fastHexToU32(const char *inStr) {
              ^
```

Reviewed By: michaelrj

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

16 months ago[Driver] Allow to collect `-save-stats` data to a file specified in the environment...
Volodymyr Sapsai [Tue, 28 Feb 2023 03:35:44 +0000 (19:35 -0800)]
[Driver] Allow to collect `-save-stats` data to a file specified in the environment variable.

Using two environment variables `CC_PRINT_INTERNAL_STAT` and
`CC_PRINT_INTERNAL_STAT_FILE` to work like `CC_PRINT_PROC_STAT`.

The purpose of the change is to allow collecting the internal stats
without modifying the build scripts. Write all stats to a single file
to simplify aggregating the data.

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

16 months ago[DebugInfo][SROA] Correct debug info for global variables spanning multiple fragments...
alosharm [Thu, 3 Nov 2022 05:19:28 +0000 (10:49 +0530)]
[DebugInfo][SROA] Correct debug info for global variables spanning multiple fragments in case of SROA

The function transferSRADebugInfo is modified to include missing cases.

Reviewed By: aprantl

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

16 months ago[scudo] Test ScudoReleaseTest.BufferPool with a buffer pool allocated on the heap
Fabio D'Urso [Thu, 16 Mar 2023 18:07:32 +0000 (18:07 +0000)]
[scudo] Test ScudoReleaseTest.BufferPool with a buffer pool allocated on the heap

The previous code resulted in 252 KiB being allocated on the stack,
which caused a stack overflow on Fuchsia.

Reviewed By: Chia-hungDuan

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

16 months agoFix asan error uncovered after landing D145133.
Mahesh Ravishankar [Thu, 16 Mar 2023 18:01:03 +0000 (18:01 +0000)]
Fix asan error uncovered after landing D145133.

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

16 months agoFix LLVM Sphinx build
Aaron Ballman [Thu, 16 Mar 2023 18:03:04 +0000 (14:03 -0400)]
Fix LLVM Sphinx build

This addresses the issue found by:
https://lab.llvm.org/buildbot/#/builders/30/builds/33006

16 months ago[HWASAN] Disable leak checking for forced_unwind2.pass.cpp
Kirill Stoimenov [Thu, 16 Mar 2023 18:01:14 +0000 (18:01 +0000)]
[HWASAN] Disable leak checking for forced_unwind2.pass.cpp

16 months ago[InstCombine] Add constant combines for `(urem/srem (mul X, Y), (mul X, Z))`
Noah Goldstein [Wed, 15 Mar 2023 21:53:13 +0000 (16:53 -0500)]
[InstCombine] Add constant combines for `(urem/srem (mul X, Y), (mul X, Z))`

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

`(srem (mul X, Y), (mul X, Z))`
    [If `srem(Y, Z) == 0`]
        -> 0
            - https://alive2.llvm.org/ce/z/PW4XZ-
    [If `srem(Y, Z) == Y`]
        -> `(mul nuw nsw X, Y)`
            - https://alive2.llvm.org/ce/z/DQe9Ek
        -> `(mul nsw X, Y)`
            - https://alive2.llvm.org/ce/z/Nr_MdH

    [If `Y`/`Z` are constant]
        -> `(mul/shl nuw nsw X, (srem Y, Z))`
            - https://alive2.llvm.org/ce/z/ccTFj2
            - https://alive2.llvm.org/ce/z/i_UQ5A
        -> `(mul/shl nsw X, (srem Y, Z))`
            - https://alive2.llvm.org/ce/z/mQKc63
            - https://alive2.llvm.org/ce/z/uERkKH

`(urem (mul X, Y), (mul X, Z))`
    [If `urem(Y, Z) == 0`]
        -> 0
            - https://alive2.llvm.org/ce/z/LL7UVR
    [If `srem(Y, Z) == Y`]
        -> `(mul nuw nsw X, Y)`
            - https://alive2.llvm.org/ce/z/9Kgs_i
        -> `(mul nuw X, Y)`
            - https://alive2.llvm.org/ce/z/ow9i8u

    [If `Y`/`Z` are constant]
        -> `(mul nuw nsw X, (srem Y, Z))`
            - https://alive2.llvm.org/ce/z/mNnQqJ
            - https://alive2.llvm.org/ce/z/Bj_DR-
            - https://alive2.llvm.org/ce/z/X6ZEtQ
        -> `(mul nuw X, (srem Y, Z))`
            - https://alive2.llvm.org/ce/z/SJYtUV

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

Reviewed By: MattDevereau, sdesmalen

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

16 months ago[InstCombine] Add tests for combining (urem/srem (mul/shl X, Y), (mul/shl X, Z))...
Noah Goldstein [Tue, 31 Jan 2023 17:33:11 +0000 (11:33 -0600)]
[InstCombine] Add tests for combining (urem/srem (mul/shl X, Y), (mul/shl X, Z)); NFC

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

16 months ago[NFC][libc++] Formats granularized charconv.
Mark de Wever [Wed, 15 Mar 2023 17:19:25 +0000 (18:19 +0100)]
[NFC][libc++] Formats granularized charconv.

Reviewed By: #libc, Mordante

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

16 months ago[libc][Obvious] Remove the STARTUP attribute from the api test listing.
Siva Chandra Reddy [Thu, 16 Mar 2023 17:47:31 +0000 (17:47 +0000)]
[libc][Obvious] Remove the STARTUP attribute from the api test listing.

16 months ago[docs] Mention removal of legacy optimization pipeline and inliner alloca merging
Arthur Eubanks [Thu, 16 Mar 2023 17:05:34 +0000 (10:05 -0700)]
[docs] Mention removal of legacy optimization pipeline and inliner alloca merging

Reviewed By: asbirlea

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

16 months ago[NFC][ADT] Tweaked some functions in StringRef
Shao-Ce SUN [Thu, 16 Mar 2023 13:01:57 +0000 (21:01 +0800)]
[NFC][ADT] Tweaked some functions in StringRef

Reduced the usage of variables in the `rfind` and `count` functions.

Replaced calls to `drop_front` with direct use of `substr` in `consume_front`,
since `starts_with` already performs length check on the string. Did the same
for other functions.

Using the `std::clamp` in `slice` makes the code more straightforward.

Reviewed By: bkramer

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

16 months ago[libc] Remove unused startup source file
Joseph Huber [Thu, 16 Mar 2023 17:41:28 +0000 (12:41 -0500)]
[libc] Remove unused startup source file

Summary:
This was not removed from the previous patch. Fix that.

16 months ago[HWASAN] Disable leak checking for test_vector2.pass.cpp
Kirill Stoimenov [Thu, 16 Mar 2023 17:36:53 +0000 (17:36 +0000)]
[HWASAN] Disable leak checking for test_vector2.pass.cpp

16 months ago[libc] Remove startup option from integration tests
Joseph Huber [Thu, 16 Mar 2023 16:50:39 +0000 (11:50 -0500)]
[libc] Remove startup option from integration tests

This generalizes handling of the integration tests. We now implicitly
depend on the `libc.startup.${LIBC_TARGET_OS}.crt1` file rather than
passing it in manually. This simplifies the interface.

Reviewed By: sivachandra

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

16 months ago[TTI] Add X86 target specific version of getPointersChainCost.
Valery N Dmitriev [Fri, 24 Feb 2023 01:39:23 +0000 (17:39 -0800)]
[TTI] Add X86 target specific version of getPointersChainCost.

When all the pointers are off the same base address and have known
distances to each other these differences can be encoded into displacements
in x86 arch. So the only cost that matters is cost of the base GEP.

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

16 months ago[AMDGPU] Select flat atomic fmin/fmax
Mirko Brkusanin [Thu, 16 Mar 2023 13:44:26 +0000 (14:44 +0100)]
[AMDGPU] Select flat atomic fmin/fmax

Also disables global atomic fmin/fmax x2 patterns on gfx11

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

16 months ago[VPlan] Consolidate replicate region optimizations (NFC).
Florian Hahn [Thu, 16 Mar 2023 17:06:44 +0000 (17:06 +0000)]
[VPlan] Consolidate replicate region optimizations (NFC).

As suggested in D143865, consolidate replicate region creation and
optimization in a single helper that's exposed and used by LV.

16 months ago[Inliner] Remove alloca merging
Arthur Eubanks [Tue, 14 Mar 2023 20:52:57 +0000 (13:52 -0700)]
[Inliner] Remove alloca merging

See https://discourse.llvm.org/t/rfc-we-should-stop-merging-allocas-in-the-inliner/41975 for the RFC from 2016 around this.

Backend stack coloring takes care of what this initially set out to help with.

This only affects the legacy inliner, which for the most part doesn't matter anymore. The new PM inliner never looked at this flag.

There are some backends running the legacy always-inline pass, but that's unlikely to matter.

Reviewed By: asbirlea

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

16 months ago[opt] Rename -enable-new-pm -> -bugpoint-enable-legacy-pm
Arthur Eubanks [Tue, 14 Mar 2023 23:23:53 +0000 (16:23 -0700)]
[opt] Rename -enable-new-pm -> -bugpoint-enable-legacy-pm

-enable-new-pm is no longer necessary except for bugpoint. Make the name more clunky so it hopefully won't be used.

Reviewed By: nikic

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

16 months ago[Debugify] Use ModuleAnalysisManager in instrumentation
Arthur Eubanks [Thu, 16 Mar 2023 16:47:21 +0000 (09:47 -0700)]
[Debugify] Use ModuleAnalysisManager in instrumentation

In preparation for doing module checks of PreservedAnalyses.

16 months agoworkflows: Don't try and run llvm-bugs in forks
Jessica Clarke [Thu, 16 Mar 2023 16:47:07 +0000 (16:47 +0000)]
workflows: Don't try and run llvm-bugs in forks

Most forks won't have an LLVM_BUGS_KEY secret, so Mailgun will error out
with a missing key, and if forks do happen to have such a secret then we
still don't want to be getting emails to LLVM's mailing lists for
downstream forks.

Reviewed By: tstellar

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

16 months ago[mlir][sparse] add test cases for sparse tensor slices on COO tensors
Peiming Liu [Tue, 14 Mar 2023 18:18:20 +0000 (18:18 +0000)]
[mlir][sparse] add test cases for sparse tensor slices on COO tensors

Reviewed By: aartbik, bixia

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

16 months ago[HWAsan] Fix returned PreservedAnalyses
Arthur Eubanks [Thu, 16 Mar 2023 16:38:35 +0000 (09:38 -0700)]
[HWAsan] Fix returned PreservedAnalyses

Initialization modifies the module.

16 months ago[FunctionImport] Fix returned PreservedAnalyses
Arthur Eubanks [Thu, 16 Mar 2023 16:37:26 +0000 (09:37 -0700)]
[FunctionImport] Fix returned PreservedAnalyses

16 months ago[Annotation2Metadata] Fix returned PreservedAnalyses
Arthur Eubanks [Thu, 16 Mar 2023 16:36:48 +0000 (09:36 -0700)]
[Annotation2Metadata] Fix returned PreservedAnalyses

16 months ago[flang] Make tests depend on llvm-readobj not llvm-readelf
David Spickett [Thu, 16 Mar 2023 16:29:18 +0000 (16:29 +0000)]
[flang] Make tests depend on llvm-readobj not llvm-readelf

d4320cb2a5ef1680e519fa6b7cfd3a2f88cfed16 fixed a regular build
issue by making the flang tests depend on llvm-readelf.

Turns out llvm-readelf is a symlink to llvm-readobj and for
whatever reason, doesn't have the right exports at the moment
to be picked up in a standalone build.

https://lab.llvm.org/buildbot/#/builders/175/builds/26448

Maybe we should fix that, but for now, just require llvm-readobj
instead.

16 months ago[AMDGPUCtorDtorLowering] Fix returned PreservedAnalyses
Arthur Eubanks [Thu, 16 Mar 2023 16:35:52 +0000 (09:35 -0700)]
[AMDGPUCtorDtorLowering] Fix returned PreservedAnalyses

16 months ago[RISCV] Fix missing addi in test to validate lower inline asm m with offset
Mikhail R. Gadelha [Thu, 16 Mar 2023 16:24:22 +0000 (13:24 -0300)]
[RISCV] Fix missing addi in test to validate lower inline asm m with offset

16 months ago[Coroutines] Add remarks in CoroSplit and CoroElide passes
Wei Wang [Thu, 23 Feb 2023 00:58:23 +0000 (16:58 -0800)]
[Coroutines] Add remarks in CoroSplit and CoroElide passes

Add remarks to show frame size and alignment.

Reviewed By: ChuanqiXu

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

16 months ago[flang] Do not try to rebox for assumed type
Valentin Clement [Thu, 16 Mar 2023 16:16:18 +0000 (17:16 +0100)]
[flang] Do not try to rebox for assumed type

Just use conversion from assuemd type to assumed type
because a rebox needs more information that are not available
with assumed type.

Also use `isAssumedType` instead of `isBoxNone` since assumed
type can have sequence information.

Depends on D146207

Reviewed By: PeteSteinfeld

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

16 months ago[AMDGPUUnifyDivergentExitNodes] Add NewPM support
Anshil Gandhi [Thu, 16 Mar 2023 16:09:42 +0000 (16:09 +0000)]
[AMDGPUUnifyDivergentExitNodes] Add NewPM support

Meanwhile, use UniformityAnalysis instead of LegacyDivergenceAnalysis to collect divergence info.

Reviewed By: arsenm, sameerds

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

16 months ago[RISCV] Added tests to validate lower inline asm m and A with offsets
Mikhail R. Gadelha [Thu, 16 Mar 2023 16:06:50 +0000 (13:06 -0300)]
[RISCV] Added tests to validate lower inline asm m and A with offsets

16 months ago[flang] Embox argument for assumed type dummy argument to !fir.box<none>
Valentin Clement [Thu, 16 Mar 2023 16:10:26 +0000 (17:10 +0100)]
[flang] Embox argument for assumed type dummy argument to !fir.box<none>

When passing an argument to an assumed type dummy argument, embox
it directly to a !fir.box<none> box.

Reviewed By: PeteSteinfeld

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

16 months ago[LICM] Add additional single thread promotion test (NFC)
Nikita Popov [Thu, 16 Mar 2023 15:58:24 +0000 (16:58 +0100)]
[LICM] Add additional single thread promotion test (NFC)

16 months ago[RISCV] Enable interleaved access vectorization
Luke Lau [Thu, 9 Mar 2023 16:18:28 +0000 (16:18 +0000)]
[RISCV] Enable interleaved access vectorization

The loop vectorizer supports generating interleaved loads and stores via
shuffle patterns for fixed length vectors.
This enables it for RISC-V, since interleaved shuffle patterns can be
lowered to vlseg/vsseg in https://reviews.llvm.org/D145022

Reviewed By: reames

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

16 months ago[RISCV] Don't accidentally match deinterleave masks as interleaves
Luke Lau [Wed, 15 Mar 2023 22:47:40 +0000 (22:47 +0000)]
[RISCV] Don't accidentally match deinterleave masks as interleaves

Consider a shuffle mask of <0, 2>:
This is one of two deinterleave masks to deinterleave a vector of 4
elements with factor 2.
Unfortunately, this is also technically an interleave mask, where
two subvectors of length 1 at indexes 0 and 2 will be interleaved.
This is because a mask can interleave non-contiguous subvectors:
e.g. <0, 6, 4, 1, 7, 5> on a vector of size 8:

```
<0 1 2 3 4 5 6 7> indices
 ^ ^     ^ ^ ^ ^
 0 0     2 2 1 1  deinterleaved subvector
```

This means that deinterleaving shuffles can accidentally be costed as
interleaves.
And it's incorrect in the context of interleaves, because the
only interleave shuffles we model at the moment are single permutation
shuffles, i.e. we are interleaving the first vector below and ignoring
the second:

shufflevector <2 x i32> %v0, <2 x i32> poison, <2 x i32> <i32 0, i32 2>

A mask of <0, 2> interleaves across both vectors.

The fix here is to set NumInputElts correctly: We were setting it to
twice the mask length, i.e. using both input vectors. But in fact we're
actually only using the first vector here, and isInterleaveMask actually
already has logic to ensure that the mask indices stay within the bounds
of the input vectors.

This lacks a test case due to how we're unable to test deinterleave
shuffles (because they are length changing), but is covered in the tests
in D145155

Reviewed By: reames

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

16 months ago[RISCV][MC][NFC] Refactor RISCVAsmPrinter::PrintAsmMemoryOperand to use early return
Alex Bradbury [Thu, 16 Mar 2023 15:02:53 +0000 (15:02 +0000)]
[RISCV][MC][NFC] Refactor RISCVAsmPrinter::PrintAsmMemoryOperand to use early return

16 months ago[mlir][Vector] Canonicalize create_mask(transpose)
Diego Caballero [Thu, 16 Mar 2023 04:14:16 +0000 (04:14 +0000)]
[mlir][Vector] Canonicalize create_mask(transpose)

When applying vector masking we may create a mask and then transpose it.
Transpositions are extremely expensive so this patch introduces a new
canonicalization pattern that remove the tranpose operation and create a
new transposed mask.

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

16 months ago[TLI] getMemValueType - break apart if-else chain and use auto with dyn_cast (style...
Simon Pilgrim [Thu, 16 Mar 2023 14:32:58 +0000 (14:32 +0000)]
[TLI] getMemValueType - break apart if-else chain and use auto with dyn_cast (style). NFC.

More closely matches getValueType

16 months ago[mlir][TilingInterface] Modify `TilingInterface` methods to better return the state...
Mahesh Ravishankar [Thu, 2 Mar 2023 00:33:14 +0000 (16:33 -0800)]
[mlir][TilingInterface] Modify `TilingInterface` methods to better return the state of the transformed IR.

Currently the `getTiledImplementation` and `generateResultTileValue`
return just `SmallVector<Operation *>` and `FailureOr<Value>`.

- For `getTiledImplementation` returning empty implies tiling wasnt
  done. There is also an implicit assumption that the tiled operation
  results correspond to the tiled values of the result of the original
  operation. This cannot handle cases where the tiled implementation
  might use multiple operations to compute the tiled value for the
  results of the untiled operation. Sometimes, the tiled operation
  might not directly give the tiled values, and might require casts,
  etc to get a replacement.
- For `generateResultTileValue`, it is assumed that the op defining
  the returned `Value` is the operation that represents the tiled
  computation. Again presence of casts, etc violate this.

Instead make these methods return
```
struct TilingResult {
  SmallVector<Operation *> tiledOps;
  SmallVector<Value> tiledValues;
};
```

The `tiledOps` represent the operations generated that are relevant
for subsequent transformations. The `tiledValues` represent the tiled
values for the results of the original operation. This better
transmits the state of the transformed IR.

As a consequence the following methods also return `FailureOr<TilingResult>`
- `tensor::replaceExtractSliceWithTiledProducer`
- `tensor::bubbleUpPadSlice`

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

16 months ago[mlir][vector] Add mask fold test for gather lowering
Jakub Kuderski [Thu, 16 Mar 2023 14:16:14 +0000 (10:16 -0400)]
[mlir][vector] Add mask fold test for gather lowering

Check that `scf.if` checks are folded when the mask is all set / not
set.

This to address post-commit feedback for
https://reviews.llvm.org/D145942.

Reviewed By: dcaballe

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

16 months ago[libc] Add missing dependencies to RISC-V startup implementation
Joseph Huber [Thu, 16 Mar 2023 14:12:36 +0000 (09:12 -0500)]
[libc] Add missing dependencies to RISC-V startup implementation

Summary:
Just like the last patch, the threads and envrion dependencies were
missing. This lead to linker failures when building the tests.

16 months ago[TLI] Bring isZExtFree declarations together. NFC.
Simon Pilgrim [Thu, 16 Mar 2023 14:06:23 +0000 (14:06 +0000)]
[TLI] Bring isZExtFree declarations together. NFC.

Don't spread them out over the header.

16 months agoRecommit DwarfEHPrepare: insert extra unwind paths for stack protector to instrument
Tim Northover [Tue, 7 Feb 2023 12:26:29 +0000 (12:26 +0000)]
Recommit DwarfEHPrepare: insert extra unwind paths for stack protector to instrument

This is a mitigation patch for
https://bugs.chromium.org/p/llvm/issues/detail?id=30, where existing stack
protection is skipped if a function is returned through by an unwinder rather
than the normal call/return path. The recent patch D139254 added the ability to
instrument a visible unwind path, at least in the IR case (I'm working on the
SelectionDAG instrumentation too) but there are still invisible unwinds it
can't reach.

So this patch adds logic to DwarfEHPrepare that goes through a function,
converting any call that might throw into an invoke to a simple resume cleanup,
and adding cleanup clauses to existing landingpads that lack them. Obviously we
don't really want to do this if it's wasted effort, so I also exposed
requiresStackProtector from the actual StackProtector code to skip the extra
paths if they won't be used.

Changes:
  * Move test to AArch64 directory as it relies on target presence.
  * Re-add Dominator-tree maintenance. Accidentally cherry-picked wrong patch.
  * Skip adding paths on Windows EH functions.

https://reviews.llvm.org/D143637

16 months ago[ARM][NFC] Use FPUKind enum instead of unsigned
Michael Platings [Wed, 15 Mar 2023 13:37:07 +0000 (13:37 +0000)]
[ARM][NFC] Use FPUKind enum instead of unsigned

Also rename some FPUID variables to FPUKind now it's clear that's what
they are.

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

16 months ago[ValueTracking] Return ConstantRange for intrinsic ranges (NFC)
Nikita Popov [Thu, 16 Mar 2023 13:24:18 +0000 (14:24 +0100)]
[ValueTracking] Return ConstantRange for intrinsic ranges (NFC)

Instead of setting Lower and Upper, return a ConstantRange.
Should do this for the others as well.

16 months ago[InstCombine] Add more vscale icmp tests (NFC)
Nikita Popov [Thu, 16 Mar 2023 13:10:47 +0000 (14:10 +0100)]
[InstCombine] Add more vscale icmp tests (NFC)

In particular cover cases where vscale_range entries are larger
than the vscale bitwidth.

16 months ago[mlir] Fix legal/illegal ops in TosaToTensor & TosaToLinalg
Maya Amrami [Thu, 16 Mar 2023 10:59:38 +0000 (12:59 +0200)]
[mlir] Fix legal/illegal ops in TosaToTensor & TosaToLinalg

tosa.reshape and tosa.concat were moved from TosaToLinalg to TosaToTensor
(D145119 & D145952). So now they are legal after applying TosaToLinalg patterns,
and illegal after applying TosaToTensor patterns.

This includes D146174 (thanks @ramiro050!)

Reviewed By: krzysz00

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

16 months ago[libc] Add missing environ dependency to AArch64 startup implementation
Joseph Huber [Thu, 16 Mar 2023 13:06:14 +0000 (08:06 -0500)]
[libc] Add missing environ dependency to AArch64 startup implementation

Summary:
Just like the last patch, this dependency was missing. This lead to
linker failures when building the tests.

16 months ago[libc] Add missing threads dependency to AArch64 startup implementation
Joseph Huber [Thu, 16 Mar 2023 13:00:14 +0000 (08:00 -0500)]
[libc] Add missing threads dependency to AArch64 startup implementation

Summary:
The changes in D146184 made the integration tests use the inhereted
dependencies from the startup code like a normal target. For the AArch64
target this resulted in the threads depenency not being pulled in
because it was not present in the original code.

16 months ago[libc] Inherit integration test dependencies from the startup target
Joseph Huber [Thu, 16 Mar 2023 01:12:16 +0000 (20:12 -0500)]
[libc] Inherit integration test dependencies from the startup target

All integration tests rely on the startup code to be run. Currently we
manually include a few of these dependencies that are relevant for the
Linux target. This patch changes this to make the integration test's
dependencies include all the dependencies of the startup code. This
simplifies the code and makes it easier to support different targets.
The changes here cause the integration test to be dependent on more
targets than previously necessary, but it should be fine.

Reviewed By: sivachandra

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

16 months ago[llvm][Bazel] Include .inc files in tblgen target.
Adrian Kuegel [Thu, 16 Mar 2023 12:11:24 +0000 (13:11 +0100)]
[llvm][Bazel] Include .inc files in tblgen target.

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

16 months ago[DAG] TargetLowering::ShrinkDemandedOp - move SmallVTBits iterator inside for loop...
Simon Pilgrim [Thu, 16 Mar 2023 12:05:23 +0000 (12:05 +0000)]
[DAG] TargetLowering::ShrinkDemandedOp - move SmallVTBits iterator inside for loop. NFC

16 months ago[DAG] TargetLowering::ShrinkDemandedOp - pull out repeated getValueType calls. NFC
Simon Pilgrim [Thu, 16 Mar 2023 11:57:29 +0000 (11:57 +0000)]
[DAG] TargetLowering::ShrinkDemandedOp - pull out repeated getValueType calls. NFC

16 months ago[clang] Fix a UsingTemplate regression after 3e78fa860235431323aaf08c8fa922d75a7cfffa
Haojian Wu [Thu, 16 Mar 2023 08:42:41 +0000 (09:42 +0100)]
[clang] Fix a UsingTemplate regression after 3e78fa860235431323aaf08c8fa922d75a7cfffa

TemplateName::getAsTemplateDecl() returns the underlying TemplateDecl
for a UsingTemplate kind template name. We should respect that in the
Profile method otherwise we might desugar the template name unexpectedly
(e.g. for template argument deduction with deduciton guides).

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

16 months agoRevert "DwarfEHPrepare: insert extra unwind paths for stack protector to instrument"
Tim Northover [Thu, 16 Mar 2023 11:55:53 +0000 (11:55 +0000)]
Revert "DwarfEHPrepare: insert extra unwind paths for stack protector to instrument"

It's caused more failures than are trivially fixable.

This reverts commit 203b6f31bb71ce63488eb96b303e000e91aee376.

16 months agoDwarfEHPrepare: insert extra unwind paths for stack protector to instrument
Tim Northover [Tue, 7 Feb 2023 12:26:29 +0000 (12:26 +0000)]
DwarfEHPrepare: insert extra unwind paths for stack protector to instrument

This is a mitigation patch for
https://bugs.chromium.org/p/llvm/issues/detail?id=30, where existing stack
protection is skipped if a function is returned through by an unwinder rather
than the normal call/return path. The recent patch D139254 added the ability to
instrument a visible unwind path, at least in the IR case (I'm working on the
SelectionDAG instrumentation too) but there are still invisible unwinds it
can't reach.

So this patch adds logic to DwarfEHPrepare that goes through a function,
converting any call that might throw into an invoke to a simple resume cleanup,
and adding cleanup clauses to existing landingpads that lack them. Obviously we
don't really want to do this if it's wasted effort, so I also exposed
requiresStackProtector from the actual StackProtector code to skip the extra
paths if they won't be used.

https://reviews.llvm.org/D143637

16 months agoStackProtector: expose RequiresStackProtector publicly. NFC.
Tim Northover [Tue, 7 Feb 2023 11:28:00 +0000 (11:28 +0000)]
StackProtector: expose RequiresStackProtector publicly. NFC.

16 months agoclang: Use ptrmask for pointer alignment
Matt Arsenault [Thu, 12 Jan 2023 14:33:37 +0000 (09:33 -0500)]
clang: Use ptrmask for pointer alignment

Avoid using ptrtoint/inttoptr.

16 months ago[docs] Document "PGO" (Profile-Guided Optimization) in the lexicon.
Frederic Cambus [Thu, 16 Mar 2023 11:14:44 +0000 (12:14 +0100)]
[docs] Document "PGO" (Profile-Guided Optimization) in the lexicon.

16 months ago[RFC][X86][MemFold] Upgrade the mechanism of auto-generated Memory Folding Table
Bing1 Yu [Wed, 8 Mar 2023 07:29:08 +0000 (15:29 +0800)]
[RFC][X86][MemFold] Upgrade the mechanism of auto-generated Memory Folding Table

1. Align ManualMapSet with X86MemoryFoldTableEntry instead of using UnfoldStrategy
2. ManualMapSet able to update the existing record in auto-generated MemFold table

Reviewed By: skan

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

16 months ago[InstCombine] Add additional vscale icmp tests (NFC)
Nikita Popov [Thu, 16 Mar 2023 10:36:42 +0000 (11:36 +0100)]
[InstCombine] Add additional vscale icmp tests (NFC)

The existing tests don't test the precise range bounds implied
by the vscale_range attribute.

16 months ago[SCEV] Add additional tests for vscale (NFC)
Nikita Popov [Thu, 16 Mar 2023 10:03:36 +0000 (11:03 +0100)]
[SCEV] Add additional tests for vscale (NFC)

16 months agoEmit const globals with constexpr destructor as constant LLVM values
Hans Wennborg [Mon, 6 Mar 2023 12:37:32 +0000 (13:37 +0100)]
Emit const globals with constexpr destructor as constant LLVM values

This follows 2b4fa53 which made Clang not emit destructor calls for such
objects. However, they would still not get emitted as constants since
CodeGenModule::isTypeConstant() returns false if the destructor is
constexpr. This change adds a param to make isTypeConstant() ignore the
dtor, allowing the caller to check it instead.

Fixes Issue #61212

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

16 months ago[Assignment Tracking] Allow salvaging with variadic expressions [4/x]
OCHyams [Thu, 16 Mar 2023 09:28:05 +0000 (09:28 +0000)]
[Assignment Tracking] Allow salvaging with variadic expressions [4/x]

Allow the value-component of a dbg.assign to be salvaged using a variadic
DIExpression.

Reviewed By: StephenTozer

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

16 months ago[Assignment Tracking] Do not convert variadic locations to kill locations [3/x]
OCHyams [Thu, 16 Mar 2023 09:25:01 +0000 (09:25 +0000)]
[Assignment Tracking] Do not convert variadic locations to kill locations [3/x]

Reviewed By: StephenTozer

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

16 months ago[Assignment Tracking][NFC] Use RawLocationWrapper in VarLocInfo [2/x]
OCHyams [Thu, 16 Mar 2023 08:48:36 +0000 (08:48 +0000)]
[Assignment Tracking][NFC] Use RawLocationWrapper in VarLocInfo [2/x]

Use RawLocationWrapper rather than a Value to represent the location operand(s)
so that it's possible to represent multiple location
operands. AssignmentTrackingAnalysis still converts variadic debug intrinsics
to kill locations so this patch is NFC.

Reviewed By: StephenTozer

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

16 months ago[DebugInfo][NFC] Add RawLocationWrapper to wrap location operand metadata [1/x]
OCHyams [Thu, 16 Mar 2023 08:46:02 +0000 (08:46 +0000)]
[DebugInfo][NFC] Add RawLocationWrapper to wrap location operand metadata [1/x]

RawLocationWrapper wraps the location operand of a debug intrinsic which may be
either (wrapped in MetadataAsValue) a DIArgList, ValueAsMetadata, or an empty
MDTuple. This class lets us avoid duplicating location handling code in a later
patch in this stack.

Reviewed By: StephenTozer

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

16 months ago[flang] Fix build error caused by missing llvm-readelf
Shao-Ce SUN [Thu, 16 Mar 2023 09:26:40 +0000 (17:26 +0800)]
[flang] Fix build error caused by missing llvm-readelf

Fix build error in D145883. Thanks @awarzynski!

Reviewed By: awarzynski

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

16 months ago[ConstantsTest] Fix unused variable warning (NFC)
Nikita Popov [Thu, 16 Mar 2023 09:43:13 +0000 (10:43 +0100)]
[ConstantsTest] Fix unused variable warning (NFC)

16 months ago[IR] Remove unused ConstantExpr::getOffsetOf() methods (NFC)
Nikita Popov [Thu, 16 Mar 2023 09:34:18 +0000 (10:34 +0100)]
[IR] Remove unused ConstantExpr::getOffsetOf() methods (NFC)

These are not used and should not be used (just like anything that
creates a constant expression only due to lack of DL-awareness).

16 months ago[ConstExpr] Remove select constant expression
Nikita Popov [Mon, 6 Mar 2023 09:46:22 +0000 (10:46 +0100)]
[ConstExpr] Remove select constant expression

This removes the select constant expression, as part of
https://discourse.llvm.org/t/rfc-remove-most-constant-expressions/63179.
Uses of this expressions have already been removed in advance,
so this just removes related infrastructure and updates tests.

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

16 months ago[clang][Lexer] Fix crash/assert clang::HeaderSearch::search_dir_nth
Dmitry Polukhin [Wed, 15 Mar 2023 17:45:07 +0000 (10:45 -0700)]
[clang][Lexer] Fix crash/assert clang::HeaderSearch::search_dir_nth

The issue was introduced in D135801. When there are only header maps in the SearchDirs,
the out of bounds value is assigned to FirstNonHeaderMapSearchDirIdx.

Test Plan: check-clang

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

16 months ago[libc] Enable __llvm_libc_syscall and fork
Mikhail R. Gadelha [Wed, 15 Mar 2023 17:10:54 +0000 (14:10 -0300)]
[libc] Enable __llvm_libc_syscall and fork

This patch enables the remaining calls from unistd.

The test cases had to be updated to:
1. Use SYS_symlinkat if SYS_symlink is not available
2. Use SYS_readlinkat if SYS_readlink is not available
3. Use SYS_unlinkat if SYS_unlink is not available
4. Use SYS_openat if SYS_open is not available

We also abort compilation if neither of the syscalls mentioned above are
available.

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

16 months ago[libc] Enable spawn lib in riscv
Mikhail R. Gadelha [Tue, 14 Mar 2023 20:50:09 +0000 (17:50 -0300)]
[libc] Enable spawn lib in riscv

In this patch we add support for the spawn lib in riscv.

Only small changes were required, the biggest one was to use of dup3
instead of dup2, if the latter is not available. This follows our
implementation of dup2.

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

16 months ago[libc] Update supported riscv libs
Mikhail R. Gadelha [Tue, 14 Mar 2023 17:06:01 +0000 (14:06 -0300)]
[libc] Update supported riscv libs

This patch removes some duplicated libs added to entrypoints.txt, adds
new libs supported to entrypoints.txt and updates header.txt

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

16 months ago[Test] Add test showing difference in behavior of Guard Widening depending on form
Max Kazantsev [Thu, 16 Mar 2023 09:09:41 +0000 (16:09 +0700)]
[Test] Add test showing difference in behavior of Guard Widening depending on form

Guards can be represented differently (as intrinsic calls and as explicit branches),
and the expectation is that Guard Widening should do the same things for them, no
matter what form it was suggested. Currently it seems to be not so.

We also don't want LICM to prevent guard widening.

16 months ago[Metarenamer] Distinguish instructions by opcodes
Max Kazantsev [Thu, 16 Mar 2023 06:23:11 +0000 (13:23 +0700)]
[Metarenamer] Distinguish instructions by opcodes

This should improve readability of metarenamed code.

Differential Revision: https://reviews.llvm.org/D145896
Reviewed By: nikic