platform/upstream/llvm.git
20 months ago[clang] Fix missing diagnostic of declaration use when accessing TypeDecls through...
Matheus Izvekov [Sat, 22 Oct 2022 13:51:54 +0000 (15:51 +0200)]
[clang] Fix missing diagnostic of declaration use when accessing TypeDecls through typename access

Fixes GH58547.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>
Differential Revision: https://reviews.llvm.org/D136533

20 months ago[ASAN] Remove asserts introduced in https://reviews.llvm.org/D136197
Roy Sundahl [Mon, 24 Oct 2022 23:01:40 +0000 (16:01 -0700)]
[ASAN] Remove asserts introduced in https://reviews.llvm.org/D136197

Additional calls were introduced for outlining (opposite of inlining)
in https://reviews.llvm.org/D136197 which contain asserts that partial
poisoning of a single byte wouldn't happen consecutively but this is
too strong and actually does occur in Windows. Removing those asserts
as they are unnecessary

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

20 months ago[MSAN] Add handleCountZeroes for ctlz and cttz.
Kevin Athey [Tue, 25 Oct 2022 00:08:52 +0000 (17:08 -0700)]
[MSAN] Add handleCountZeroes for ctlz and cttz.

This addresses a bug where vector versions of ctlz are creating false positive reports.

Depends on D136369

Reviewed By: vitalybuka

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

20 months ago[libc] Add the header sys/types.h.
Siva Chandra Reddy [Mon, 24 Oct 2022 22:18:58 +0000 (22:18 +0000)]
[libc] Add the header sys/types.h.

Reviewed By: michaelrj

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

20 months ago[MSAN] Count Zeroes test for covering ctlz and cttz under MSAN. (NFC)
Kevin Athey [Sat, 22 Oct 2022 09:12:53 +0000 (02:12 -0700)]
[MSAN] Count Zeroes test for covering ctlz and cttz under MSAN. (NFC)

Reviewed By: vitalybuka

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

20 months agoFix breakpoint setting so it always works when there is a line entry in a compile...
Greg Clayton [Tue, 18 Oct 2022 21:59:26 +0000 (14:59 -0700)]
Fix breakpoint setting so it always works when there is a line entry in a compile unit's line table.

Prior to this fix, if the compile unit function:

  void CompileUnit::ResolveSymbolContext(const SourceLocationSpec &src_location_spec, SymbolContextItem resolve_scope, SymbolContextList &sc_list);

was called with a resolve scope that wasn't just eSymbolContextLineEntry, we would end up calling:

  line_entry.range.GetBaseAddress().CalculateSymbolContext(&sc, resolve_scope);

This is ok as long as the line entry's base address is able to be resolved back to the same information, but there were problems when it didn't. The example I found was we have a file with a bad .debug_aranges section where the address to compile unit mapping was incomplete. When this happens, the above function call to calculate the symbol context would end up matching the module and it would NULL out the compile unit and line entry, which means we would fail to set this breakpoint. We have many other clients that ask for eSymbolContextEverything as the resolve_scope, so all other locations could end up failing as well.

The solutions is to make sure the compile unit matches the current compile unit after calling the calculate symbol context. If the compile unit is NULL, then we report an error via the module/debugger as this indicates an entry in the line table fails to resolve back to any compile unit. If the compile unit is not NULL and it differs from the current compile unit, we restore the current compile unit and line entry to ensure the call to .CalculateSymbolContext doesn't match something completely different, as can easily happen if LTO or other link time optimizations are enabled that could end up outlining or merging functions.

This patch allows breakpoint succeeding to work as expected and not get short circuited by our address lookup logic failing.

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

20 months ago[libc] Build fix.
Raman Tenneti [Mon, 24 Oct 2022 23:16:40 +0000 (16:16 -0700)]
[libc] Build fix.

Build fix.

Reviewed By: rtenneti

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

20 months agoNFC: [clang] Template argument cleanups.
Matheus Izvekov [Mon, 24 Oct 2022 12:18:46 +0000 (14:18 +0200)]
NFC: [clang] Template argument cleanups.

Removes a bunch of obsolete methods in favor of a single one returning
an ArrayRef of TemplateArgument.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>
Differential Revision: https://reviews.llvm.org/D136602

20 months ago[libc] Add implementation of difftime function.
Raman Tenneti [Mon, 24 Oct 2022 18:42:43 +0000 (11:42 -0700)]
[libc] Add implementation of difftime function.

The difftime function computes the difference between two calendar
times: time1 - time0 as per as per 7.27.2.2 section in
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2478.pdf.

  double difftime(time_t time1, time_t time0);

Tested:
Unit tests

Co-authored-by: Jeff Bailey <jeffbailey@google.com>
Reviewed By: jeffbailey

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

20 months ago[DirectX backend] set target triple to "dxil-ms-dx"
Xiang Li [Mon, 24 Oct 2022 17:58:05 +0000 (10:58 -0700)]
[DirectX backend] set target triple to "dxil-ms-dx"

Set target triple to "dxil-ms-dx" for DXIL at the end of DXILTranslateMetadata.

Reviewed By: beanz

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

20 months ago[ASAN] Don't inline when -asan-max-inline-poisoning-size=0
Roy Sundahl [Tue, 18 Oct 2022 18:52:52 +0000 (14:52 -0400)]
[ASAN] Don't inline when -asan-max-inline-poisoning-size=0

When -asan-max-inline-poisoning-size=0, all shadow memory access should be
outlined (through asan calls). This was not occuring when partial poisoning
was required on the right side of a variable's redzone. This diff contains
the changes necessary to implement and utilize  __asan_set_shadow_01() through
__asan_set_shadow_07(). The change is necessary for the full abstraction of
the asan implementation and will enable experimentation with alternate strategies.

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

20 months ago[ORC] Allow EPCEHFrameRegistrar clients to specify registration function dylib.
Lang Hames [Mon, 24 Oct 2022 20:46:10 +0000 (13:46 -0700)]
[ORC] Allow EPCEHFrameRegistrar clients to specify registration function dylib.

Previously, EPCEHFrameRegistrar always used the
ExecutorProcessControl::loadDylib(nullptr) method to obtain a handle for the
process, but this doesn't work if the registration functions aren't visible in
a standard search of the process (e.g. if the JIT is in a plugin that is loaded
with RTLD_LOCAL).

This patch retains the old behavior by default, but allows clients to supply
their own handle for the library containing the registration functions if they
need to (e.g. to work around limitations like RDLD_LOCAL above, which aren't
expressible within the existing loadDylib / DynamicLibrary APIs).

20 months ago[ORC] Use raw OS handle values, ExecutorAddr for EPC dylib handles.
Lang Hames [Mon, 24 Oct 2022 19:41:45 +0000 (12:41 -0700)]
[ORC] Use raw OS handle values, ExecutorAddr for EPC dylib handles.

Updates tpctypes::DylibHandle to be an ExecutorAddr (rather than a uint64_t),
and SimpleExecutorDylibManager to hold and return raw OS handle values (as
ExecutorAddrs) rather than index values into a map of DynamicLibrary instances.

This will allow clients to use EPCGenericDylibManager in contexts where the
existing DynamicLibrary interface is too limited to be used. (e.g. to look up
JIT symbols in a dylib that was loaded with RTLD_LOCAL).

20 months ago[InstCombine] allow more commutative matches for logical-and to select fold
Sanjay Patel [Mon, 24 Oct 2022 20:21:53 +0000 (16:21 -0400)]
[InstCombine] allow more commutative matches for logical-and to select fold

This is a sibling transform to the fold just above it. That was changed
to allow the corresponding commuted patterns with:
307307456277
e1bd759ea567
8628e6df7000

20 months agoFix a failing C DR test case found by post-commit CI
Aaron Ballman [Mon, 24 Oct 2022 20:24:11 +0000 (16:24 -0400)]
Fix a failing C DR test case found by post-commit CI

This should address the failure found by:
https://lab.llvm.org/buildbot/#/builders/231/builds/4152

20 months ago[Instcombine] Add coverage for demanded bits of insertelement
Philip Reames [Mon, 24 Oct 2022 20:13:36 +0000 (13:13 -0700)]
[Instcombine] Add coverage for demanded bits of insertelement

20 months agoreland e5581df60a35 [SimplifyCFG] accumulate bonus insts cost
Yaxun (Sam) Liu [Sat, 17 Sep 2022 21:57:35 +0000 (17:57 -0400)]
reland e5581df60a35 [SimplifyCFG] accumulate bonus insts cost

Fixed compile time increase due to always constructing LocalCostTracker.
Now only construct LocalCostTracker when needed.

20 months ago[clang][CodeGen] Consistently return nullptr Values for void builtins and scalar...
Markus Böck [Mon, 24 Oct 2022 18:55:52 +0000 (20:55 +0200)]
[clang][CodeGen] Consistently return nullptr Values for void builtins and scalar initalization

A common post condition of the various visitor functions in CodeGen is that instructions, that do not return any values, simply return a nullptr Value as a sentinel. This has not been the case however for calls to some builtins returning void, as well as for an initializer expression of the form `void()`. This would then lead to ICEs in CodeGen on code relying on nullptr being returned for void values, which is eg. the case for conditional expressions [0].
This patch fixes that by returning nullptr Values for intrinsics known not to return any values as well as for a scalar initializer returning void.

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

[0] https://github.com/llvm/llvm-project/blob/266ec801fb23f9f5f1d61ca9466e0805fbdb78a7/clang/lib/CodeGen/CGExprScalar.cpp#L4849-L4892

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

20 months ago[RISCV][clang] Support RISC-V vectors in UninitializedValues.
Craig Topper [Mon, 24 Oct 2022 19:30:36 +0000 (12:30 -0700)]
[RISCV][clang] Support RISC-V vectors in UninitializedValues.

RISC-V vectors are basically vectors, but we use builtin types to
restrict the possible types. Treat them the same as vectors and scalars
for this analysis.

Reviewed By: reames

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

20 months ago"Reapply "GH58368: Correct concept checking in a lambda defined in concept""
Erich Keane [Mon, 24 Oct 2022 19:20:36 +0000 (12:20 -0700)]
"Reapply "GH58368: Correct concept checking in a lambda defined in concept""

This reverts commit cecc9a92cfca71c1b6c2a35c5e302ab649496d11.

The problem ended up being how we were handling the lambda-context in
code generation: we were assuming any decl context here would be a
named-decl, but that isn't the case.  Instead, we just replace it with
the concept's owning context.

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

20 months ago[mlir] Update Location to use new casting infra
Nick Kreeger [Mon, 24 Oct 2022 19:32:12 +0000 (14:32 -0500)]
[mlir] Update Location to use new casting infra

This allows for using the llvm namespace cast methods instead of the ones on the Location class. The Location class method are kept for now, but we'll want to remove these eventually (with a really long lead time).

Related change: https://reviews.llvm.org/D135870

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

20 months ago[clang][Toolchains][Gnu] pass -g through to assembler
Nick Desaulniers [Mon, 24 Oct 2022 19:21:12 +0000 (12:21 -0700)]
[clang][Toolchains][Gnu] pass -g through to assembler

We've been working around this for a long time in the Linux kernel; we
bend over backwards to continue to support CC=clang (w/
-fno-integrated-as) for architectures where clang can't yet be used to
assemble the kernel's assembler sources. Supporting debug info for the
combination of CC=clang w/ GNU binutils as "GAS" has been painful.

Fix this in clang so that we can work towards dropping complexity in the
Linux kernel's build system, Kbuild, for supporting this combination of
tools.

GAS added support for -g in 2004 2.16 release via
commit 329e276daf98 ("Add support for a -g switch to GAS")

Reviewed By: MaskRay

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

20 months ago[InstCombine] Explicitly check for scalable TypeSize.
Craig Topper [Mon, 24 Oct 2022 18:35:24 +0000 (11:35 -0700)]
[InstCombine] Explicitly check for scalable TypeSize.

Instead of assuming it is a fixed size.

Reviewed By: peterwaller-arm

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

20 months ago[clang-format][NFC] Handle language specific stuff at the top...
Björn Schäpers [Mon, 10 Oct 2022 13:01:51 +0000 (15:01 +0200)]
[clang-format][NFC] Handle language specific stuff at the top...

... of TokenAnnotator::splitPenalty. That is in my eyes a bit clearer
in the workflow.

As a drive-by introduce (but not adapt anywhere else) isProto().

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

20 months ago[clang-format] Handle unions like structs and classes
Björn Schäpers [Tue, 11 Oct 2022 07:04:28 +0000 (09:04 +0200)]
[clang-format] Handle unions like structs and classes

There is no reason why unions should be handled differently, I think
they are just forgotten since they are not used that often.

No test case added, since that would be complicated to produce.

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

20 months ago[clang-format][NFC] Fix comment grammer in ContinuationIndenter
Björn Schäpers [Mon, 10 Oct 2022 12:54:54 +0000 (14:54 +0200)]
[clang-format][NFC] Fix comment grammer in ContinuationIndenter

Now all comments (for which id makes sense) end with a punctuation.

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

20 months ago[AArch64]]SME2 multi-vec to multi-vec FP/INT down convert 2/4 registers
Caroline Concatto [Mon, 10 Oct 2022 15:34:27 +0000 (16:34 +0100)]
[AArch64]]SME2 multi-vec to multi-vec FP/INT down convert 2/4 registers

This patch implements:
 FCVTZS: Multi-vector floating-point convert to signed integer, rounding
         toward zero.
 FCVTZU: Multi-vector floating-point convert to unsigned integer,
        rounding toward zero.
 SCVTF: Multi-vector signed integer convert to floating-point.
 UCVTF: Multi-vector unsigned integer convert to floating-point.
for 2 and 4 registers

The reference can be found here:
    https://developer.arm.com/documentation/ddi0602/2022-09

    Depends on: D135563

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

20 months agoRevert "Reapply "GH58368: Correct concept checking in a lambda defined in concept"""
Erich Keane [Mon, 24 Oct 2022 19:15:05 +0000 (12:15 -0700)]
Revert "Reapply "GH58368: Correct concept checking in a lambda defined in concept"""

This reverts commit b876f6e2f28779211a829d7d4e841fe68885ae20.

Still getting build failures on PPC AIX that aren't obvious what is causing
them, so reverting while I try to figure this out.

20 months agoFix failing test case
Aaron Ballman [Mon, 24 Oct 2022 19:18:38 +0000 (15:18 -0400)]
Fix failing test case

This amends f43ef6b2dced4c5fa4fa7676142d9a20f7dbe733 with some warnings
that got dropped before I commit the test.

20 months ago[mlir][NVGPU] Documentation only update to nvgpu dialect (NFC).
Manish Gupta [Wed, 19 Oct 2022 04:33:09 +0000 (21:33 -0700)]
[mlir][NVGPU] Documentation only update to nvgpu dialect (NFC).

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

20 months ago[lldb] Skip TestFullLtoStepping in older clangs
Augusto Noronha [Mon, 24 Oct 2022 19:11:56 +0000 (12:11 -0700)]
[lldb] Skip TestFullLtoStepping in older clangs

20 months agoUpdate the status of more C99 DRs
Aaron Ballman [Mon, 24 Oct 2022 19:09:36 +0000 (15:09 -0400)]
Update the status of more C99 DRs

This adds test coverage and updates the related entries for five more
C99 DRs.

20 months agoCorrect a typo in the release notes; NFC
Aaron Ballman [Mon, 24 Oct 2022 19:01:46 +0000 (15:01 -0400)]
Correct a typo in the release notes; NFC

I intended to fix this when landing the changes, but forgot to add the
file to the commit.

20 months ago[PGO] Make emitted symbols hidden
Alex Brachet [Mon, 24 Oct 2022 19:05:10 +0000 (19:05 +0000)]
[PGO] Make emitted symbols hidden

This was reverted because it was breaking when targeting Darwin which
tried to export these symbols which are now hidden. It should be safe
to just stop attempting to export these symbols in the clang driver,
though Apple folks will need to change their TAPI allow list described
in the commit where these symbols were originally exported
https://github.com/llvm/llvm-project/commit/f5380185623be243ba0f1b18d4bd594ac5cc7163

Bug: https://github.com/llvm/llvm-project/issues/58265

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

20 months ago[mlir][sparse] add some APIs for merger to query the tensor id for output tensor...
Peiming Liu [Mon, 24 Oct 2022 18:41:19 +0000 (18:41 +0000)]
[mlir][sparse] add some APIs for merger to query the tensor id for output tensor and synthetic tensor.

Reviewed By: aartbik

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

20 months agoReapply "GH58368: Correct concept checking in a lambda defined in concept""
Erich Keane [Mon, 24 Oct 2022 18:16:28 +0000 (11:16 -0700)]
Reapply "GH58368: Correct concept checking in a lambda defined in concept""

This reverts commit 52930162870fee52d0d9c07c5d66e5dce32b08e8.

Now with updating the ASTBitcodes to show that this AST is incompatible
from the last.

20 months ago[flang] Carry dynamic type in fir.rebox code generation
Valentin Clement [Mon, 24 Oct 2022 18:42:31 +0000 (20:42 +0200)]
[flang] Carry dynamic type in fir.rebox code generation

Load the pointer of the dynamic type descriptor from the
original box and update the destination descriptor with this pointer.

Reviewed By: PeteSteinfeld

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

20 months ago[ARM] Support -mexecute-only with -mlong-calls.
Zhiyao Ma [Mon, 24 Oct 2022 18:01:10 +0000 (11:01 -0700)]
[ARM] Support -mexecute-only with -mlong-calls.

Instead of using constant pools, use movw movt pair.

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

20 months ago[mlir][Translation] Make commandline option registration optional
rkayaith [Sun, 23 Oct 2022 19:35:18 +0000 (15:35 -0400)]
[mlir][Translation] Make commandline option registration optional

This moves the commandline option registration into its own function, so
that users can register translations without registering the options.

Reviewed By: cota

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

20 months ago[ARM] Add a test demonstrating reductions with reused extend. NFC
David Green [Mon, 24 Oct 2022 18:38:19 +0000 (19:38 +0100)]
[ARM] Add a test demonstrating reductions with reused extend. NFC

D136227 showed that tests for this case in getReductionPatternCost were
missing.

20 months ago[libc] add performance options for string to float
Michael Jones [Fri, 21 Oct 2022 20:57:01 +0000 (13:57 -0700)]
[libc] add performance options for string to float

This allows the client to set compile flags to disable the passes that
the string to float function uses. A client may be willing to trade off
performance for a reduction in code size, and this allows for that
fine-tuning.

Reviewed By: sivachandra

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

20 months ago[mlir] Fix INSTALL_INTERFACE path for MLIRSparseTensorEnums
Michał Górny [Mon, 24 Oct 2022 11:08:00 +0000 (13:08 +0200)]
[mlir] Fix INSTALL_INTERFACE path for MLIRSparseTensorEnums

Fix INSTALL_INTERFACE path for exported MLIRSparseTensorEnums target
to include the include directory.  Otherwise, CMake attempts to find it
relatively to CMAKE_INSTALL_PREFIX rather than the include directory,
resulting in flang failing to configure with the following error:

    CMake Error at /usr/lib/llvm/16/lib64/cmake/llvm/AddLLVM.cmake:581 (add_library):
      Cannot find source file:

        /usr/lib/llvm/16/mlir/Dialect/SparseTensor/IR/Enums.h

      Tried extensions .c .C .c++ .cc .cpp .cxx .cu .mpp .m .M .mm .ixx .cppm .h
      .hh .h++ .hm .hpp .hxx .in .txx .f .F .for .f77 .f90 .f95 .f03 .hip .ispc
    Call Stack (most recent call first):
      cmake/modules/AddFlang.cmake:64 (llvm_add_library)
      lib/Lower/CMakeLists.txt:3 (add_flang_library)

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

20 months ago[llvm-debuginfo-analyzer] (07/09) - Compare elements
Carlos Alberto Enciso [Mon, 24 Oct 2022 11:28:52 +0000 (12:28 +0100)]
[llvm-debuginfo-analyzer] (07/09) - Compare elements

The test case 'CompareElements' caused a failure in:

  https://lab.llvm.org/buildbot#builders/5/builds/28502
  https://lab.llvm.org/buildbot#builders/168/builds/9671
  SUMMARY: AddressSanitizer: 2144 byte(s) leaked in 14 allocation(s).

The 'Insert' function conditionally adds the 'Child' logical
element to a logical scope. The not added logical elements,
caused the memory leak. Just record them to be destroyed
when the logical reader is destroyed.

Changed 'EXPECT_NE' with 'ASSERT_NE'.
Missing in the main review.

20 months ago[lldb] Fix stale diagnostic event comments (NFC)
Jonas Devlieghere [Mon, 24 Oct 2022 18:13:51 +0000 (11:13 -0700)]
[lldb] Fix stale diagnostic event comments (NFC)

The diagnostic events were heavily inspired by the progress events and
several comments incorrectly referenced "progress" rather than
"diagnostic" events.

20 months ago[mlir][Tensor] Add a helper build method for pad operations with constant padding.
Mahesh Ravishankar [Mon, 24 Oct 2022 17:31:06 +0000 (17:31 +0000)]
[mlir][Tensor] Add a helper build method for pad operations with constant padding.

Drop the `createPadScalarOp` from Utils.h since it is a duplicate of
the `build` method added here.

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

20 months ago[ELF] Add --no-warnings/-w
Fangrui Song [Mon, 24 Oct 2022 17:54:09 +0000 (10:54 -0700)]
[ELF] Add --no-warnings/-w

Mach-O ld64 supports -w to suppress warnings. GNU ld 2.40 will support the
option as well (https://sourceware.org/bugzilla/show_bug.cgi?id=29654).

This feature has some small value. E.g. when analyzing a large executable with
relocation overflow issues, we may use --noinhibit-exec --emit-relocs to get an
output file with static relocations despite relocation overflow issues. -w can
significantly improve the link time as printing the massive warnings is slow.

Reviewed By: peter.smith

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

20 months ago[X86] New test case for reassociation of ADD instructions.
Guozhi Wei [Mon, 24 Oct 2022 17:46:46 +0000 (17:46 +0000)]
[X86] New test case for reassociation of ADD instructions.

This is a pre-commit test case for D136396.

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

20 months ago[XCOFF] llvm-readobj support decoding the loader section header field for XCOFF objec...
zhijian [Mon, 24 Oct 2022 17:31:01 +0000 (13:31 -0400)]
[XCOFF] llvm-readobj support decoding the loader section header field for XCOFF object file.

Reviewers: James Henderson, Esme Yi

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

20 months ago[X86] `DAGTypeLegalizer::ModifyToType()`: when widening w/ zeros, insert into undef...
Roman Lebedev [Mon, 24 Oct 2022 17:11:19 +0000 (20:11 +0300)]
[X86] `DAGTypeLegalizer::ModifyToType()`: when widening w/ zeros, insert into undef and `and`-mask the padding away

We can expect that the sequence of inserting-of-extracts-into-undef
will be successfully lowered back into widening of the source vector,
but it seems that at least for X86 mask vectors, we have a really hard time
recovering from inserting-into-zero.

I've looked into alternative fix injection points, and they are much more
involved, by the time of `LowerBUILD_VECTORvXi1()`/`LowerINSERT_VECTOR_ELT()`
the constants might be obscured, so it does not seem like we can easily
deal with this by lowering into bit math later on,
some other pieces are missing.

Instead, it seems like just clearing the padding away via an `AND`-mask
is at least not a worse choice. Why create a problem where there wasn't one.
Though yes, it is possible that there are cases where constants originate
from the source IR, so some other fix may still be needed.

Reviewed By: pengfei

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

20 months agoRevert "GH58368: Correct concept checking in a lambda defined in concept"
Erich Keane [Mon, 24 Oct 2022 17:15:41 +0000 (10:15 -0700)]
Revert "GH58368: Correct concept checking in a lambda defined in concept"

This reverts commit b7c922607c5ba93db8b893d4ba461052af8317b5.

This seems to cause some problems with some modules related things,
which makes me think I should have updated the version-major in
ast-bit-codes?  Going to revert to confirm this was a problem, then
change that and re-try a commit.

20 months ago[SLP][NFC]Fix PR58476: Fix compile time for reductions, NFC.
Alexey Bataev [Thu, 20 Oct 2022 19:54:32 +0000 (12:54 -0700)]
[SLP][NFC]Fix PR58476: Fix compile time for reductions, NFC.

Improve O(N^2) to O(N) in some cases, reduce number of allocations by
reserving memory.
Also, improve analysis of loads reduction values to avoid analysis
of not vectorizable cases.

20 months ago[lit][REQUIRES] Fix REQUIRES on an NVPTX test so it will run
Paul Robinson [Mon, 24 Oct 2022 16:50:02 +0000 (09:50 -0700)]
[lit][REQUIRES] Fix REQUIRES on an NVPTX test so it will run

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

20 months ago[InstCombine] Fold series of instructions into mull
zhongyunde [Mon, 24 Oct 2022 17:04:59 +0000 (01:04 +0800)]
[InstCombine] Fold series of instructions into mull

The following sequence should be folded into in0 * in1
      In0Lo = in0 & 0xffffffff; In0Hi = in0 >> 32;
      In1Lo = in1 & 0xffffffff; In1Hi = in1 >> 32;
      m01 = In1Hi * In0Lo; m10 = In1Lo * In0Hi; m00 = In1Lo * In0Lo;
      addc = m01 + m10;
      ResLo = m00 + (addc >> 32);

Reviewed By: spatel, RKSimon
Differential Revision: https://reviews.llvm.org/D136015

20 months agoRecommit "[TargetLowering][RISCV][X86] Support even divisors in expandDIVREMByConstant."
Craig Topper [Mon, 24 Oct 2022 14:16:24 +0000 (07:16 -0700)]
Recommit "[TargetLowering][RISCV][X86] Support even divisors in expandDIVREMByConstant."

This reverts commit 65aaecca8842dec30d03734a7fe8ce33c5afec81.

There was an ordering problem in the calculation of the partial
remainder.

Original commit message:

If the divisor is even, we can first shift the dividend and divisor
right by the number of trailing zeros. Now the divisor is odd and we
can do the original algorithm to calculate a remainder. Then we shift
that remainder left by the number of trailing zeros and add the bits
that were shifted out of the dividend.

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

20 months agoFix MSVC "not all control paths return a value" warning. NFC.
Simon Pilgrim [Mon, 24 Oct 2022 16:54:53 +0000 (17:54 +0100)]
Fix MSVC "not all control paths return a value" warning. NFC.

20 months ago[X86] 2012-01-12-extract-sv.ll - add AVX2 test coverage
Simon Pilgrim [Mon, 24 Oct 2022 16:47:52 +0000 (17:47 +0100)]
[X86] 2012-01-12-extract-sv.ll - add AVX2 test coverage

20 months ago[mlir][sparse] fix bufferizableOpInterface for InsertOp
Peiming Liu [Fri, 21 Oct 2022 23:21:53 +0000 (23:21 +0000)]
[mlir][sparse] fix bufferizableOpInterface for InsertOp

Address comments in D136372

Reviewed By: aartbik, springerm

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

20 months ago[lldb-tests] Force use of system stdlib for Objective-C test
Felipe de Azevedo Piovezan [Mon, 24 Oct 2022 14:27:46 +0000 (10:27 -0400)]
[lldb-tests] Force use of system stdlib for Objective-C test

The test TestObjCDirectMethods loads the Objective C runtime, which
doesn't work well with custom a libcxx, resulting in two copies of the
standard library being loaded at runtime.

Like what was done for `TestObjCExceptions`, this commit forces the
usage of the system's library instead. The minimum required Clang
version is set to the oldest Clang that can compile the libraries
available in the lldb-matrix bots.

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

20 months ago[lldb-tests] Remove libstdc++ requirement from test
Felipe de Azevedo Piovezan [Mon, 24 Oct 2022 15:02:26 +0000 (15:02 +0000)]
[lldb-tests] Remove libstdc++ requirement from test

This requirement dates back to ten years ago and the test seems to work
nowadays with either libc++ or libstdc++.

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

20 months ago[flang] Fix building against LLVM dylib
Michał Górny [Mon, 24 Oct 2022 14:45:23 +0000 (16:45 +0200)]
[flang] Fix building against LLVM dylib

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

20 months ago[Clang] Implement P2513
Corentin Jabot [Fri, 21 Oct 2022 12:33:26 +0000 (14:33 +0200)]
[Clang] Implement P2513

Implement P2513

This change allows initializing an array of unsigned char,
or char from u8 string literals.
This was done both to support legacy code and for compatibility
with C where char8_t will be typedef to unsigned char.

This is backported to C++20 as per WG21 guidance.

Reviewed By: aaron.ballman

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

20 months ago[StrictFP][IPSCCP] Constant fold intrinsics with metadata arguments
Kevin P. Neal [Mon, 24 Oct 2022 15:33:05 +0000 (11:33 -0400)]
[StrictFP][IPSCCP] Constant fold intrinsics with metadata arguments

This teaches the SCCP Solver how to constant fold more intrinsics. Constant
folding appears to be just as good as D115737 but much, much lower in code
change impact as suggested by nikic.

The constrained floating-point intrinsics all take at least one metadata
argument and were the motivation for the change.

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

20 months ago[AArch64][PAC] Select XPAC for ptrauth.strip intrinsic.
Ahmed Bougacha [Mon, 24 Oct 2022 15:12:24 +0000 (08:12 -0700)]
[AArch64][PAC] Select XPAC for ptrauth.strip intrinsic.

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

20 months ago[AArch64][PAC] Add helper enum/functions to handle PAC keys/ops.
Ahmed Bougacha [Mon, 24 Oct 2022 15:08:33 +0000 (08:08 -0700)]
[AArch64][PAC] Add helper enum/functions to handle PAC keys/ops.

20 months ago[IncludeCleaner] Add public API
Kadir Cetinkaya [Wed, 19 Oct 2022 21:16:38 +0000 (23:16 +0200)]
[IncludeCleaner] Add public API

Introduces walkUsed, a very simple version of the public API to enable
incremental development on rest of the pieces.

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

20 months ago[InstCombine] Combine ptrauth sign/resign + auth/resign intrinsics.
Ahmed Bougacha [Mon, 24 Oct 2022 15:02:11 +0000 (08:02 -0700)]
[InstCombine] Combine ptrauth sign/resign + auth/resign intrinsics.

(sign|resign) + (auth|resign) can be folded by omitting the middle
sign+auth component if the key and discriminator match.

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

20 months ago[PowerPC] Fix invalid cast for vector shuffles when lowering to the xxsplti32dx instr...
Amy Kwan [Sat, 22 Oct 2022 22:33:14 +0000 (17:33 -0500)]
[PowerPC] Fix invalid cast for vector shuffles when lowering to the xxsplti32dx instruction.

When lowering vector shuffles into the xxsplti32dx instruction on Power10, we
canonicalize the right operand to be a BUILD_VECTOR and as a result, get the
commuted vector shuffle node.

However, a vector shuffle will not always be returned as the result for a
commuted vector shuffle. In such a scenario, this patch updates the original
cast of a shuffle into a dyn_cast<> and checks if the shuffle is a valid vector
shuffle node prior to obtaining the commuted shuffle mask.

This patch also adds a new test case that demonstrates this scenario (primarily
seen on 32-bit), and was originally a crash prior to this fix.

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

20 months agoRevert "[TargetLowering][RISCV][X86] Support even divisors in expandDIVREMByConstant."
Craig Topper [Mon, 24 Oct 2022 14:05:21 +0000 (07:05 -0700)]
Revert "[TargetLowering][RISCV][X86] Support even divisors in expandDIVREMByConstant."

This reverts commit f6a7b47820904c5e69cc4f133d382c74a87c44e8.

I received a report that this fails on 32-bit X86.

20 months ago[AMDGPU][MC] Correct definition of aliases
Dmitry Preobrazhensky [Mon, 24 Oct 2022 10:30:25 +0000 (13:30 +0300)]
[AMDGPU][MC] Correct definition of aliases

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

20 months ago[lldb] Include gtest in standalone build only if LLDB_INCLUDE_TESTS
Michał Górny [Sun, 23 Oct 2022 12:47:50 +0000 (14:47 +0200)]
[lldb] Include gtest in standalone build only if LLDB_INCLUDE_TESTS

Build gtest targets when building standalone only if LLDB_INCLUDE_TESTS
is true.  Prior to this change, they were built whenever
LLVM_MAIN_SRC_DIR was available, independently whether tests themselves
would be run.

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

20 months ago[X86] Treat PSLLDQ/PSRLDQ as a shuffle not a shift
Simon Pilgrim [Mon, 24 Oct 2022 13:42:40 +0000 (14:42 +0100)]
[X86] Treat PSLLDQ/PSRLDQ as a shuffle not a shift

This appears to be a copy+paste typo in the znver1/2 AMD SoG tables, treating the byte shift instructions like bit shifts

Older AMD SoG referred to PSLLDQ/PSRLDQ as shuffles, and Agner/instlatx64 both report they are integer shuffles

20 months ago[flang] Add kernel to lower expressions to HLFIR
Jean Perier [Mon, 24 Oct 2022 13:35:19 +0000 (15:35 +0200)]
[flang] Add kernel to lower expressions to HLFIR

This patch adds the kernel to lower evaluate::Expr to HLFIR to a
hlfir::FortranEntity (a single mlir::Value that can be interpreted as
a Fortran variable or the value of a Fortram expression).

It implements lowering of simple name designators ("x") and starts
adding a translation layer in AbstractConverter::genExprBox and
AbstractConverter::genExprAddr so that the new expression lowering
can be used without any changes for now in the current statement and
construct lowering.

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

20 months agoGH58368: Correct concept checking in a lambda defined in concept
Erich Keane [Thu, 20 Oct 2022 18:55:01 +0000 (11:55 -0700)]
GH58368: Correct concept checking in a lambda defined in concept

As that bug reports, the problem here is that the lambda's
'context-decl' was not set to the concept, and the lambda picked up
template arguments from the concept.  SO, we failed to get the correct
template arguments in SemaTemplateInstantiate.

However, a Concept Specialization is NOT a decl, its an expression, so
we weren't able to put the concept in the decl tree like we needed.
This patch introduces a ConceptSpecializationDecl, which is the smallest
type possible to use for this purpose, containing only the template
arguments.

The net memory impliciation of this is turning a
trailing-objects into a pointer to a type with trailing-objects,  so it
should be minor.

As future work, we may consider giving this type more responsibility, or
figuring out how to better merge duplicates, but as this is just a
template-argument collection at the moment, there isn't much value to
it.

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

20 months ago[mlir] Apply ClangTidy performance fix (NFC)
Adrian Kuegel [Mon, 24 Oct 2022 13:24:42 +0000 (15:24 +0200)]
[mlir] Apply ClangTidy performance fix (NFC)

20 months ago[InstCombine] vary commuted patterns for mul fold; NFC
Sanjay Patel [Mon, 24 Oct 2022 13:13:28 +0000 (09:13 -0400)]
[InstCombine] vary commuted patterns for mul fold; NFC

Try to get better coverage for the pattern-matching
possibilities in D136015.

20 months ago[InstCombine] adjust mul tests to avoid reliance on other folds; NFC
Sanjay Patel [Mon, 24 Oct 2022 12:54:43 +0000 (08:54 -0400)]
[InstCombine] adjust mul tests to avoid reliance on other folds; NFC

This gets the tests closer to the form that we are
trying to test in D136015. Note that the IR has
changed, but the check lines have not changed.

This also shows that the desired commuted pattern
coverage is not as expected.

20 months agoFix caret position to be on the non null parameter
Arthur Grillo [Mon, 24 Oct 2022 12:38:21 +0000 (08:38 -0400)]
Fix caret position to be on the non null parameter

When checking for non null arguments the wrong SourceLocation was given,
this fix to pass the proper argument's location.

Fixes #58273

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

20 months ago[mlir][scf][bufferize] Fix bufferizesToMemoryRead with 0 loop iterations
Matthias Springer [Mon, 24 Oct 2022 12:19:31 +0000 (14:19 +0200)]
[mlir][scf][bufferize] Fix bufferizesToMemoryRead with 0 loop iterations

There was a bug in scf.for loop bufferization that could lead to a missing buffer copy (alloc was there, but not the copy).

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

20 months ago[Clang][AArch64] Add support for -mcpu=grace
Sjoerd Meijer [Mon, 24 Oct 2022 12:00:34 +0000 (17:30 +0530)]
[Clang][AArch64] Add support for -mcpu=grace

This adds Clang command line support for the NVIDIA Grace CPU [1], which
we would like to target with -mcpu=grace.

Grace is based on the Arm Neoverse V2 CPU [1], which is why, in the
driver, we pass neoverse-v2 to the compiler when grace is requested.
Thus, for now, it's an alias to Neoverse V2.

This adds support for grace in user-facing tool Clang, but not yet the
developer tools like opt and llc, so we probably want to follow up on
this.

[1] https://www.nvidia.com/en-us/data-center/grace-cpu/

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

20 months agoGlobalISel: Artifact combine merge-like and unmerges into merge-like
Petar Avramovic [Mon, 24 Oct 2022 10:54:41 +0000 (12:54 +0200)]
GlobalISel: Artifact combine merge-like and unmerges into merge-like

Recognize when sub-vectors have been split to elements which are used to
build large vector.
This happens when instructions have different vector sizes available.
For example a few arithmetic instruction are required to process all
elements of larger vector that can be stored using one instruction.

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

20 months agoGlobalISel: Artifact combine merge-like and unmerge into unmerge
Petar Avramovic [Mon, 24 Oct 2022 10:52:39 +0000 (12:52 +0200)]
GlobalISel: Artifact combine merge-like and unmerge into unmerge

Recognize when source could have been unmerged to pieces with DstTy
without having to split source to smaller elements
and then merge small elements into DstTy pieces.
This happens when vector was meant to be split to sub-vectors but there
was leftover. At this point artifact combiner have already dealt with
leftover and we can continue to use sub-vectors.

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

20 months agoGlobalISel: Artifact combine merge-like and unmerge into copy
Petar Avramovic [Mon, 24 Oct 2022 10:51:10 +0000 (12:51 +0200)]
GlobalISel: Artifact combine merge-like and unmerge into copy

Recognize copy that is represented as split of a source register to
elements that were reassembled to another register with the same type.

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

20 months agoGlobalISel: Precommit for artifact combine patches
Petar Avramovic [Mon, 24 Oct 2022 10:49:05 +0000 (12:49 +0200)]
GlobalISel: Precommit for artifact combine patches

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

20 months ago[gn build] port 97bd44f436ea
Nico Weber [Mon, 24 Oct 2022 11:32:13 +0000 (07:32 -0400)]
[gn build] port 97bd44f436ea

20 months agoAdd nocapture to pointer parameters of masked stores/loads
Benjamin Maxwell [Mon, 24 Oct 2022 09:41:19 +0000 (09:41 +0000)]
Add nocapture to pointer parameters of masked stores/loads

The lack of this attribute (particularly on the load intrinsics)
prevented InstCombine from optimizing away allocas and memcpys
for arrays that could be read directly from rodata.

This now also includes a new test to check the masked load/store
intrinsics have the expected attributes (specifically nocapture).

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

20 months ago[llvm-exegesis] Fix missing dependency in BUILD.bazel
Guillaume Chatelet [Mon, 24 Oct 2022 10:39:33 +0000 (10:39 +0000)]
[llvm-exegesis] Fix missing dependency in BUILD.bazel

This was broken by https://reviews.llvm.org/D136351

20 months ago[libc] Fix BUILD.bazel missing dependency
Guillaume Chatelet [Mon, 24 Oct 2022 10:33:58 +0000 (10:33 +0000)]
[libc] Fix BUILD.bazel missing dependency

20 months ago[libc] Use cpp::byte instead of char in mem* functions
Guillaume Chatelet [Mon, 24 Oct 2022 10:27:53 +0000 (10:27 +0000)]
[libc] Use cpp::byte instead of char in mem* functions

`cpp::byte` is better than `char` which -depending on platform- can be `signed char` or `unsigned char`.  This has introduced subtle arithmetic errors.

20 months ago[AArch64] Alter v8.5a FRINT neon intrinsics to be target-based, not preprocessor...
David Green [Mon, 24 Oct 2022 10:22:06 +0000 (11:22 +0100)]
[AArch64] Alter v8.5a FRINT neon intrinsics to be target-based, not preprocessor based

This switches the v8.5-a FRINT intrinsics over to be target-gated,
behind preprocessor defines. This one is pretty simple, being AArch64
only.

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

20 months ago[lldb] Add LLVM include dirs prior to gtest target in standalone build
Michał Górny [Sun, 23 Oct 2022 12:52:22 +0000 (14:52 +0200)]
[lldb] Add LLVM include dirs prior to gtest target in standalone build

Move include_directories() declaration before gtest targets are created
in standalone build.  This fixes build failure due to gtest targets
being unable to find LLVM headers, e.g.:

    /var/tmp/portage/dev-util/lldb-16.0.0_pre20221023/work/llvm/utils/unittest/googletest/include/gtest/internal/custom/raw-ostream.h:43:10: fatal error: llvm/ADT/Optional.h: No such file or directory

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

20 months ago[LLDB] Check that RegisterInfo and ContextInfo are trivial
David Spickett [Mon, 24 Oct 2022 08:54:33 +0000 (08:54 +0000)]
[LLDB] Check that RegisterInfo and ContextInfo are trivial

RegisterInfo is often initialised with a memcpy, and ContextInfo
does not run destructors for anything within it.

This was discussed in https://reviews.llvm.org/D134041.

Reviewed By: labath

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

20 months ago[libc] Fix generic 32-bit implementation of Bcmp/Memcmp
Guillaume Chatelet [Mon, 24 Oct 2022 10:15:28 +0000 (10:15 +0000)]
[libc] Fix generic 32-bit implementation of Bcmp/Memcmp

20 months ago[libc] Fix broken tests on arm32
Guillaume Chatelet [Mon, 24 Oct 2022 09:54:19 +0000 (09:54 +0000)]
[libc] Fix broken tests on arm32

20 months ago[llvm-exegesis] getNonRedundantWriteProcRes - perform basic toplogical sorting (PR58500)
Simon Pilgrim [Mon, 24 Oct 2022 09:46:04 +0000 (10:46 +0100)]
[llvm-exegesis] getNonRedundantWriteProcRes - perform basic toplogical sorting (PR58500)

getNonRedundantWriteProcRes was assuming that tblgen topologically sorted the cpu ModelProcResources[] arrays so that resource units were declared before the resource groups that used them, but unfortunately that doesn't appear to be true - in most cases it was just getting lucky based off the alphanumeric sorting that was being performed and the choice of the resource pipe names in most scheduler models (Intel models in particular).

This patch adds an explicit sort, based off llvm-mca's initializeUsedResources, that sorts by resource mask - I'm hoping this basic sorting is enough, I don't think overlapping groups or Super resources are a problem.

I'd like to take this further in the future and start sharing more code between llvm-mca and llvm-exegesis - while triaging this bug I saw how similar both approaches are, but are just dissimilar enough that any refactor isn't going to be trivial :(

Working with @courbet on a follow up unit test

Fixes #58500
Fixes #37045

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

20 months ago[DAG] Fold (abs (sign_extend_inreg x)) -> (zero_extend (abs (truncate x))) (PR43370)
Simon Pilgrim [Mon, 24 Oct 2022 09:27:00 +0000 (10:27 +0100)]
[DAG] Fold (abs (sign_extend_inreg x)) -> (zero_extend (abs (truncate x))) (PR43370)

If the upper half of an abs() is all sign bits, then we can perform the abs() using just the lower half and then zero extend.

I've limited the DAG combine to only sign_extend_inreg (and free truncate/zero_extend) to minimise any later promotion issues, but for legalization a similar fold can use ComputeNumSignBits to be more aggressive.

Alive2: https://alive2.llvm.org/ce/z/y32fS4

Fixes #43370

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

20 months ago[libc] mem* framework v3
Guillaume Chatelet [Sat, 22 Oct 2022 11:23:04 +0000 (11:23 +0000)]
[libc] mem* framework v3

This version is more composable and also simpler at the expense of being more explicit and more verbose.

This patch provides rationale for the framework, implementation and unit tests but the functions themselves are still using the previous version. The change in implementation will come in a follow up patch.

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

20 months ago[RISCV] Add Svnapot extension
Piyou Chen [Mon, 24 Oct 2022 08:26:46 +0000 (01:26 -0700)]
[RISCV] Add Svnapot extension

Reviewed By: kito-cheng

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

20 months ago[gn build] Port e98a4c5acb37
LLVM GN Syncbot [Mon, 24 Oct 2022 07:30:12 +0000 (07:30 +0000)]
[gn build] Port e98a4c5acb37

20 months ago[llvm-debuginfo-analyzer] (07/09) - Compare elements
Carlos Alberto Enciso [Mon, 24 Oct 2022 06:18:36 +0000 (07:18 +0100)]
[llvm-debuginfo-analyzer] (07/09) - Compare elements

llvm-debuginfo-analyzer is a command line tool that processes debug
info contained in a binary file and produces a debug information
format agnostic “Logical View”, which is a high-level semantic
representation of the debug info, independent of the low-level
format.

The code has been divided into the following patches:

1) Interval tree
2) Driver and documentation
3) Logical elements
4) Locations and ranges
5) Select elements
6) Warning and internal options
7) Compare elements
8) ELF Reader
9) CodeView Reader

Full details:
https://discourse.llvm.org/t/llvm-dev-rfc-llvm-dva-debug-information-visual-analyzer/62570

This patch:

Compare elements
- Support for logical elements comparison. See '--compare' options.
  LVCompare

Reviewed By: psamolysov, probinson

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

20 months ago[mlir][interfaces] Remove getDestinationOperands from TilingInterface
Matthias Springer [Mon, 24 Oct 2022 07:17:44 +0000 (09:17 +0200)]
[mlir][interfaces] Remove getDestinationOperands from TilingInterface

`getDestinationOperands` was almost a duplicate of `DestinationStyleOpInterface::getOutputOperands`. Now that the interface has been moved to mlir/Interfaces, it is no longer needed.

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