platform/upstream/llvm.git
17 months ago[llvm-cov] Add split-file to compiler-rt test requirements.
Daniel Thornburgh [Mon, 30 Jan 2023 21:17:17 +0000 (13:17 -0800)]
[llvm-cov] Add split-file to compiler-rt test requirements.

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

17 months ago[libc++] Remove <experimental/coroutine>
Chuanqi Xu [Thu, 23 Sep 2021 14:33:45 +0000 (10:33 -0400)]
[libc++] Remove <experimental/coroutine>

We've been shipping <coroutine> since LLVM 14, so LLVM 17 won't ship
the <experimental/coroutine> header per our policy for removing TSes.

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

17 months ago[Clang] Fix unconditional access to Attr pointer when checking if _Nullable is applic...
Shafik Yaghmour [Mon, 30 Jan 2023 21:26:02 +0000 (13:26 -0800)]
[Clang] Fix unconditional access to Attr pointer when checking if _Nullable is applicable to a type

In TransformAttributedType(...) when checking if _Nullable can be applied to a
type it dereferences TL.getAttr() unconditionally which we can see from the code
earlier in the function is not correct since it is expected to be nullptr in
some cases.

It looks like the correct course of action is to use TL.getModifiedLoc() over
TL.getAttr()->getLocation() in the case that TL.getAttr() returns a nullptr.

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

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

17 months ago[Pseudo Probe] Do not instrument EH blocks.
Hongtao Yu [Thu, 26 Jan 2023 06:26:47 +0000 (22:26 -0800)]
[Pseudo Probe] Do not instrument EH blocks.

This change avoids inserting probes to EH blocks. Pseudo probe can prevent block merging when probes in the blocks look different. This has a chained effect to passes incurring exponential IR growth (such as jump threading) and as a consequence the compilation may time out.  Not inserting probes to EH blocks could mitigate the issue. Another benefit is that both IR size and binary size are smaller. Since EH blocks are usually cold, the change should have minimal impact to profile quality.

Testing:

Out of two internal large benchmarks, no perf impact seen. 1% size savings to both the `text` and the `pseudo_probe` section.

Reviewed By: wenlei

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

17 months ago[libc++] Add missing include promote.h in <cmath>
Louis Dionne [Thu, 26 Jan 2023 19:46:53 +0000 (14:46 -0500)]
[libc++] Add missing include promote.h in <cmath>

As a fly-by, also remove a superfluous <cstddef> include in promote.h.

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

17 months ago[InstCombine] reduce icmp_eq0-of-and-of-select-of-constants
Sanjay Patel [Mon, 30 Jan 2023 20:34:29 +0000 (15:34 -0500)]
[InstCombine] reduce icmp_eq0-of-and-of-select-of-constants

This is the most basic patch to handle fixing issue #57666.

D133919 proposes to handle much more than this in a single patch,
but I've used 10 regression tests just to make sure this part is
doing what I expected and nothing more, and it already shows even
more potential TODO items.

The more general proofs from D133919 are correct, but I want to
enable this in smaller steps to reduce risk:
https://alive2.llvm.org/ce/z/RrVEyX

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

17 months ago[InstCombine] add tests for icmp-of-and-of-select-of-constants; NFC
Sanjay Patel [Sun, 29 Jan 2023 16:53:38 +0000 (11:53 -0500)]
[InstCombine] add tests for icmp-of-and-of-select-of-constants; NFC

This overlaps with the tests proposed in D134064
and providing coverage for D133919, but it is
both limited in scope and more comprehensive
because there are many potential ways to transform
these kinds of patterns.

17 months ago[mlir][Pass] Handle spaces in pipeline strings
Bruno Schmitt [Mon, 30 Jan 2023 20:49:19 +0000 (12:49 -0800)]
[mlir][Pass] Handle spaces in pipeline strings

An user might want to add extra spaces for better readability, e.g:
```
mypm = pm.PassManager.parse(f"""builtin.module(
    mypass1,
        func.func(mypass2,mypass3)
)""")
```
GitHub issue #59151

The parser was not taking into account the possibility of spaces after
`)`or `}`

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

17 months ago[mlir][AsmPrinter] Gracefully handle empty symbol
Bruno Schmitt [Mon, 30 Jan 2023 20:48:07 +0000 (12:48 -0800)]
[mlir][AsmPrinter] Gracefully handle empty symbol

The GenericOp printer should support malformed IR without crashing

GitHub issue #59529

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

17 months ago[RISCV] Use custom operand parsing for FenceArg.
Craig Topper [Mon, 30 Jan 2023 20:20:07 +0000 (12:20 -0800)]
[RISCV] Use custom operand parsing for FenceArg.

Rather than parsing a symbol and checking its name, look for an
identifier during parsing.

I've also handled the 0 immediate during parsing, though we could
let that go through the normal immediate parsing if we need to support
expressions that evaluate to 0. We don't have tests for that currently.

Reviewed By: asb, frasercrmck

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

17 months agoAMDGPU: Update machine divergence analysis test
Matt Arsenault [Mon, 30 Jan 2023 20:07:40 +0000 (16:07 -0400)]
AMDGPU: Update machine divergence analysis test

17 months agoAMDGPU/GlobalISel: Add stub custom regbankselect pass
Matt Arsenault [Wed, 18 Jan 2023 11:02:30 +0000 (06:02 -0500)]
AMDGPU/GlobalISel: Add stub custom regbankselect pass

Uniformity analysis needs to be the fundamental basis for
regbank decisions. The considerations of the default pass
are secondary, but potentially useful for some edge cases (e.g.
selecting AGPRs when arbitrary loads and stores can directly use
them). This needs to be a separate pass since it requires new
analysis dependencies.

Boilerplate to subclass the existing pass which does nothing
different.

17 months agoRecommit "[SCCP] Support NUW/NSW inference for all overflowing binary operators."
Florian Hahn [Mon, 30 Jan 2023 20:15:28 +0000 (20:15 +0000)]
Recommit "[SCCP] Support NUW/NSW inference for all overflowing binary operators."

This reverts commit 43acb61a08fffada31fb2e20e45fcc8492ef76b9.

Recommit the patch after fixing the issue causing the revert in 4e607ec4987.
Extra tests have been added in 5c6cb61ad416a544.

Original commit message:

   Extend the NUW/NSW inference logic add in 72121a20cd and cdeaf5f28c3dc
    to all overflowing binary operators.

    Reviewed By: nikic

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

17 months ago[test] Require asserts in count-visits.ll
Arthur Eubanks [Mon, 30 Jan 2023 19:58:33 +0000 (11:58 -0800)]
[test] Require asserts in count-visits.ll

-stats doesn't work in release builds without stats enabled.

Followup to D142853

17 months agoRevert "[LSAN][HWASAN] Run LSAN tests with HWASAN enabled"
Hans Wennborg [Mon, 30 Jan 2023 19:39:38 +0000 (20:39 +0100)]
Revert "[LSAN][HWASAN] Run LSAN tests with HWASAN enabled"

This broke the sanitizer tests on Mac, see e.g.
https://green.lab.llvm.org/green/job/clang-stage1-RA/32739/ and comment on the
code review.

> A lot of tests are disabled by using UNSUPPORTED. The plan is to remove UNSUPPORTED for tests that are fixed.
>
> Reviewed By: vitalybuka
>
> Differential Revision: https://reviews.llvm.org/D142676

This reverts commit f9a01630988716f1b52afe6727f34fe86c07c58a.
and follow-up commit bf47ffaa76fbda1ba96d41ee2681e45d2445be1e
(https://reviews.llvm.org/D142812).

17 months agoImprove example documentation for __builtin_offsetof; NFC
Aaron Ballman [Mon, 30 Jan 2023 19:54:59 +0000 (14:54 -0500)]
Improve example documentation for __builtin_offsetof; NFC

This implements some post-commit feedback from D142723

17 months agoFix handling of braced-init temporaries for modernize-use-emplace
BigPeet [Mon, 30 Jan 2023 19:52:20 +0000 (14:52 -0500)]
Fix handling of braced-init temporaries for modernize-use-emplace

Fixes #55870

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

17 months agoAMDGPU/GlobalISel: Partially fix getGenericInstructionUniformity
Matt Arsenault [Wed, 18 Jan 2023 15:57:53 +0000 (10:57 -0500)]
AMDGPU/GlobalISel: Partially fix getGenericInstructionUniformity

This was broken for the common case of instructions which are uniform
if their inputs are uniform. This is broken for control flow intrinsics
since the API currently does not express which result operand is in question.

This generates failures in just about every intrinsic test when uniformity
analysis is performed without this.

17 months agoAMDGPU: Partially fix machine uniformity for inline asm
Matt Arsenault [Wed, 18 Jan 2023 13:58:00 +0000 (08:58 -0500)]
AMDGPU: Partially fix machine uniformity for inline asm

This was assuming virtual registers only, and asserting on physical.
This was also ignoring AGPRs, and only considering VGPRs.

Reporting the instruction as uniform or not is conceptually wrong,
this should be reported per-operand. An inline asm statement could
include uniform and non-uniform components. This should report
purely for the register defs and ignore the uses.

Fixes asserting on most of the inline asm tests when uniformity
analysis is used.

17 months agoAMDGPU: Fix null dereference in getInstructionUniformity
Matt Arsenault [Wed, 18 Jan 2023 13:20:09 +0000 (08:20 -0500)]
AMDGPU: Fix null dereference in getInstructionUniformity

This was failing when it couldn't find an allocatable class
for special physical register inputs (like $mode), which are all
scalars.

This avoids numerous test failures when regbankselect is updated
to use uniformity analysis.

17 months ago[SCCP] Add sub tests for NUW/NSW flag inference.
Florian Hahn [Mon, 30 Jan 2023 19:40:36 +0000 (19:40 +0000)]
[SCCP] Add sub tests for NUW/NSW flag inference.

Those tests add coverage for a miscompile with 024115ab14822a97c.

17 months ago[MC] Allow .pushsection between .cfi_startproc/.cfi_endproc
Alex Brachet [Mon, 30 Jan 2023 19:27:18 +0000 (19:27 +0000)]
[MC] Allow .pushsection between .cfi_startproc/.cfi_endproc

This follows the behavior of gnu assemblers. This is useful when
writing inline assembly.

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

17 months agoReland [LTO] Demangle the function name in DiagnosticInfoDontCall message
Kyuwon Cho [Mon, 30 Jan 2023 18:10:50 +0000 (10:10 -0800)]
Reland [LTO] Demangle the function name in DiagnosticInfoDontCall message

Previously, dontcall attribute message on LTO prints the mangled function name.

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

Relanded with proper IR -> Demangle dependency.

Reviewed By: aeubanks

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

17 months agoRevert "[LTO] Demangle the function name in DiagnosticInfoDontCall message"
Arthur Eubanks [Mon, 30 Jan 2023 19:16:41 +0000 (11:16 -0800)]
Revert "[LTO] Demangle the function name in DiagnosticInfoDontCall message"

This reverts commit cb05c2ffc79eefe74c569263e27fcb5fad167ba3.

Breaks https://lab.llvm.org/buildbot/#/builders/121/builds/27524/steps/4/logs/stdio

17 months agoclang/OpenCL: Apply default attributes to enqueued blocks
Matt Arsenault [Thu, 12 Jan 2023 15:07:18 +0000 (10:07 -0500)]
clang/OpenCL: Apply default attributes to enqueued blocks

This was missing important environment context, like denormal-fp-math
and target-features. Curiously this seems to be losing nounwind. Note
this only fixes the actual invoke kernel. The invoke function is
already setting the default attribute set for internal
functions. However that is still buggy since it's not applying any use
function attributes (it's also missing uniform-work-group-size).

There seem to be too many different functions for setting attributes
with inconsistent behavior. The Function overload of
addDefaultFunctionAttributes seems to miss the target-cpu and
target-features. The AttrBuilder one seems to miss optnone (but that
seems to be disallowed on blocks anyway). Neither one calls
setTargetAttributes, when it probably should. uniform-work-group-size
is also set through AMDGPU code when it should be emitting generically
as a language property.

I also noticed update_cc_test_checks for attributes seem to not
connect the captured attribute variables to the attributes at the end
(although I think the numbers happen to work out correctly).

17 months agoclang/OpenCL: Extend tests for enqueued block attributes
Matt Arsenault [Thu, 12 Jan 2023 15:05:28 +0000 (10:05 -0500)]
clang/OpenCL: Extend tests for enqueued block attributes

Baseline tests showing that enqueued blocks are not getting the
correct attributes applied.

17 months agoclang/OpenCL: Fix not setting convergent on block invoke kernels
Matt Arsenault [Wed, 11 Jan 2023 01:08:00 +0000 (20:08 -0500)]
clang/OpenCL: Fix not setting convergent on block invoke kernels

Yet another example how convergent not being the default is dangerous
and backwards.

17 months agoclang/OpenCL: Don't use a Function for the block type
Matt Arsenault [Wed, 11 Jan 2023 00:25:48 +0000 (19:25 -0500)]
clang/OpenCL: Don't use a Function for the block type

The AMDGPU value for this is not really a function. Currently we're
emitting IR that isn't true to what will eventually be emitted.

17 months ago[OpenMP][NVPTX] Guard the target name macro definition
Shilei Tian [Mon, 30 Jan 2023 19:02:22 +0000 (14:02 -0500)]
[OpenMP][NVPTX] Guard the target name macro definition

17 months ago[LTO] Demangle the function name in DiagnosticInfoDontCall message
Kyuwon Cho [Mon, 30 Jan 2023 18:10:50 +0000 (10:10 -0800)]
[LTO] Demangle the function name in DiagnosticInfoDontCall message

Previously, dontcall attribute message on LTO prints the mangled function name.

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

Reviewed By: aeubanks

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

17 months ago[CGSCC] Add pass which counts the max number of times we visit a function
Arthur Eubanks [Sun, 29 Jan 2023 23:48:04 +0000 (15:48 -0800)]
[CGSCC] Add pass which counts the max number of times we visit a function

This will help with finding potential pathological CGSCC cases.

Reviewed By: asbirlea

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

17 months ago[SCCP] Flip range arguments for NSW region check.
Florian Hahn [Mon, 30 Jan 2023 18:03:18 +0000 (18:03 +0000)]
[SCCP] Flip range arguments for NSW region check.

This brings the operand order in line with the NUW handling, which was
missed out in 72121a20cda4dc91d0ef5548f930.

At the moment this is NFC as we only additions, but it
should fix miscompiles with 024115ab14822a recommitted.

17 months ago[RISCV] Replace multiple ifs with a switch. NFC
Craig Topper [Mon, 30 Jan 2023 17:53:48 +0000 (09:53 -0800)]
[RISCV] Replace multiple ifs with a switch. NFC

D108961 will add more instructions to this.

17 months agoRevert "[AIX][BigArchive] Treat the archive is empty if the first child member offset...
Mitch Phillips [Mon, 30 Jan 2023 17:41:55 +0000 (09:41 -0800)]
Revert "[AIX][BigArchive] Treat the archive is empty if the first child member offset is zero"

This reverts commit 7f0003c19c3a47f484ea9cc929728808b27ace32.

Reason: This broke the ASan buildbot, see the comments in
https://reviews.llvm.org/D138986 for more information.

17 months ago[libc++] Add [[clang::lifetimebound]] to min/max algorithms
Nikolas Klauser [Tue, 10 Jan 2023 23:01:37 +0000 (00:01 +0100)]
[libc++] Add [[clang::lifetimebound]] to min/max algorithms

Reviewed By: Mordante, #libc

Spies: libcxx-commits

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

17 months ago[libc] Add an off-by-default option to silence "skipping" messages from CMake.
Siva Chandra Reddy [Sat, 28 Jan 2023 09:26:46 +0000 (09:26 +0000)]
[libc] Add an off-by-default option to silence "skipping" messages from CMake.

Reviewed By: lntue

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

17 months ago[libc] Use a more general way to determine the compiler's target triple.
Siva Chandra Reddy [Sat, 28 Jan 2023 00:14:14 +0000 (00:14 +0000)]
[libc] Use a more general way to determine the compiler's target triple.

Reviewed By: lntue

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

17 months ago[mem2reg][debuginfo] Handle op_deref when converting dbg.declare
Felipe de Azevedo Piovezan [Thu, 19 Jan 2023 15:02:28 +0000 (12:02 -0300)]
[mem2reg][debuginfo] Handle op_deref when converting dbg.declare

The conversion of dbg.declare into dbg.values doesn't take into account
the DIExpression attached to the intrinsic. In particular, when
converting:

```
store %val, ptr %alloca
dbg.declare(ptr %alloca, !SomeVar, !DIExpression())
```

Mem2Reg will try to figure out if `%val` has the size of `!SomeVar`. If
it does, then a non-undef dbg.value is inserted:

```
dbg.value(%val, !SomeVar, !DIExpression())
```

This makes sense: the alloca is _the_ address of the variable. So a
store to the alloca is a store to the variable. However, if the
expression in the original intrinsic is a `DW_OP_deref`, this logic is
not applicable:

```
store ptr %val, ptr %alloca
dbg.declare(ptr %alloca, !SomeVar, !DIExpression(DW_OP_deref))
```

Here, the alloca is *not* the address of the variable. A store to the
alloca is *not* a store to the variable. As such, querying whether
`%val` has the same size as `!SomeVar` is meaningless.

This patch addresses the issue by:
1. Allowing the conversion when the expression is _only_ a `DW_OP_deref`
without any other expressions (see code comment).
2. Checking that the expression does not start with a `DW_OP_deref`
before applying the logic that checks whether the value being stored and
the variable have the same length.

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

17 months ago[AArch64] Replace AEK_CRYPTO with relevant features in cpu definitions
David Green [Mon, 30 Jan 2023 16:05:25 +0000 (16:05 +0000)]
[AArch64] Replace AEK_CRYPTO with relevant features in cpu definitions

This replaces AEK_CRYPTO in the AArch64TargetParser definitions,
replacing the composite Crypto features with the constituent parts.
AEK_CRYPTO is replaced with either AEK_AES | AEK_SHA2 or AEK_AES |
AEK_SHA2 | AEK_SHA3 | AEK_SHA4 depending on if the cpu is Arm-v8.4+.
This helps get the features correct in some more places like
target(cpu=..) attributes.

Otherwise this is hopefully an NFC for -mcpu options but seems like a
cleaner design.

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

17 months ago[libc++] Don't assume that string_view::const_iterator is a raw pointer
Louis Dionne [Mon, 28 Nov 2022 13:01:46 +0000 (08:01 -0500)]
[libc++] Don't assume that string_view::const_iterator is a raw pointer

Our implementation of std::format assumed that string_view's iterators
were raw pointers in various places. If we want to introduce a checked
iterator in debug mode, that won't be true anymore. This patch removes
that assumption.

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

17 months ago[mlir][llvm] Import access group metadata.
Tobias Gysi [Mon, 30 Jan 2023 14:38:28 +0000 (15:38 +0100)]
[mlir][llvm] Import access group metadata.

The revision adds support to import access group metadata from LLVM IR.
It closely follows the design of the TBAA metadata import with an
up-front conversion of the metadata nodes to operations stored in the
body of a module-level metadata operation. The revision chooses to use
only one module-level metadata operation for all kinds of metadata.
This  design ensures there is only one metadata operation that pollutes
the user namespace.

The import of loop metadata, which will use the access groups,
is left to a follow up revision.

Reviewed By: Dinistro

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

17 months ago[InstCombine] Regenerate test checks (NFC)
Nikita Popov [Mon, 30 Jan 2023 14:28:27 +0000 (15:28 +0100)]
[InstCombine] Regenerate test checks (NFC)

17 months ago[InferAddressSpaces] Regenerate test checks (NFC)
Nikita Popov [Mon, 30 Jan 2023 14:27:37 +0000 (15:27 +0100)]
[InferAddressSpaces] Regenerate test checks (NFC)

17 months ago[mlir] use getNumDimAndSymbolVars when iterate dims/symbols of FlatAffineValueConstraints
Xiang [Sun, 29 Jan 2023 23:12:47 +0000 (18:12 -0500)]
[mlir] use getNumDimAndSymbolVars when iterate dims/symbols of FlatAffineValueConstraints

Fixes #59443  https://github.com/llvm/llvm-project/issues/59443

getNumVars will add locals and cause out of bound access.

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

17 months ago[X86] Add SSE2 test coverage to vector comparison all_of/any_of tests
Simon Pilgrim [Mon, 30 Jan 2023 14:00:45 +0000 (14:00 +0000)]
[X86] Add SSE2 test coverage to vector comparison all_of/any_of tests

17 months ago[mlir] Remove Linalg fusion-on-memrefs.
Alexander Belyaev [Mon, 30 Jan 2023 13:03:38 +0000 (14:03 +0100)]
[mlir] Remove Linalg fusion-on-memrefs.

PSA: https://discourse.llvm.org/t/psa-retire-tileandfuselinalgops-method/63850

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

17 months ago[MLIR][LLVM] Generate LLVM lifetime intrinsics while inlining.
Johannes de Fine Licht [Mon, 30 Jan 2023 13:33:02 +0000 (14:33 +0100)]
[MLIR][LLVM] Generate LLVM lifetime intrinsics while inlining.

Extend `LLVMInlinerInterface` to inline lifetime intrinsics for
`LLVM::AllocaOp` operations, and to insert new lifetime intrinsics when
an alloca is moved to the entry block that restrict its scope to where
the call was before inlining.

Depends on D142436

Reviewed By: gysit

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

17 months ago[Libomptarget] Fix tests after previous patch
Joseph Huber [Mon, 30 Jan 2023 13:16:25 +0000 (07:16 -0600)]
[Libomptarget] Fix tests after previous patch

Summary:
The previous patch didn't remove these tests correctly.

17 months ago[X86] combinePredicateReduction - pull out SETCC handling for all_of(icmp_eq) reducti...
Simon Pilgrim [Mon, 30 Jan 2023 12:54:04 +0000 (12:54 +0000)]
[X86] combinePredicateReduction - pull out SETCC handling for all_of(icmp_eq) reductions. NFC.

Minor cleanup before we can handle any_of(icmp_ne) with the same code.

17 months agoFix LLVM sphinx docs, redux
Aaron Ballman [Mon, 30 Jan 2023 12:46:20 +0000 (07:46 -0500)]
Fix LLVM sphinx docs, redux

I missed a second title with too short of underlining.

17 months agoFix LLVM Sphinx build
Aaron Ballman [Mon, 30 Jan 2023 12:36:51 +0000 (07:36 -0500)]
Fix LLVM Sphinx build

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

17 months ago[Libomptarget] Remove unused test targets in libomptaget
Joseph Huber [Mon, 30 Jan 2023 12:31:10 +0000 (06:31 -0600)]
[Libomptarget] Remove unused test targets in libomptaget

Summary:
These don't need to be set.

17 months ago[DAGCombine] fp_to_sint isSaturatingMinMax
Samuel Parker [Mon, 30 Jan 2023 12:17:11 +0000 (12:17 +0000)]
[DAGCombine] fp_to_sint isSaturatingMinMax

Recommitting after fixing scalable vector crash.

Check for single smax pattern against zero when converting from a
small enough float.

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

17 months agoRevert "[ASan][libcxx] Annotating std::vector with all allocators"
Hans Wennborg [Mon, 30 Jan 2023 12:15:31 +0000 (13:15 +0100)]
Revert "[ASan][libcxx] Annotating std::vector with all allocators"

This caused false container-overflow errors when using a custom allocator that
touches the memory on deallocation: GitHub Issue #60384

> This revision is a part of a series of patches extending
> AddressSanitizer C++ container overflow detection
> capabilities by adding annotations, similar to those existing
> in std::vector, to std::string and std::deque collections.
> These changes allow ASan to detect cases when the instrumented
> program accesses memory which is internally allocated by
> the collection but is still not in-use (accesses before or
> after the stored elements for std::deque, or between the size and
> capacity bounds for std::string).
>
> The motivation for the research and those changes was a bug,
> found by Trail of Bits, in a real code where an out-of-bounds read
> could happen as two strings were compared via a std::equals function
> that took iter1_begin, iter1_end, iter2_begin iterators
> (with a custom comparison function).
> When object iter1 was longer than iter2, read out-of-bounds on iter2
> could happen. Container sanitization would detect it.
>
> In revision D132522, support for non-aligned memory buffers (sharing
> first/last granule with other objects) was added, therefore the
> check for standard allocator is not necessary anymore.
> This patch removes the check in std::vector annotation member
> function (__annotate_contiguous_container) to support
> different allocators.
>
> If you have any questions, please email:
>  - advenam.tacet@trailofbits.com
>  - disconnect3d@trailofbits.com
>
> Reviewed By: #libc, #sanitizers, philnik, vitalybuka
>
> Spies: EricWF, philnik, #sanitizers, libcxx-commits
>
> Differential Revision: https://reviews.llvm.org/D136765

This reverts commit 490555026821db47d1cf4bf08c219b3e56ec6b45.

17 months ago[flang] Fix simplify intrinsic for count not checking for rank = 0 properly
Sacha Ballantyne [Mon, 30 Jan 2023 11:50:59 +0000 (11:50 +0000)]
[flang] Fix simplify intrinsic for count not checking for rank = 0 properly

Simple fix to check for rank in the same way as other intrinsics to allow
runtime count to take over when dealing with unknown dimension arrays.

Fixes #60356

Reviewed By: Leporacanthicus

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

17 months ago[lldb] Fix TestVSCode_completions for D141828
Pavel Labath [Mon, 30 Jan 2023 12:19:10 +0000 (13:19 +0100)]
[lldb] Fix TestVSCode_completions for D141828

17 months agoRevert "Revert "[lldb] Make SBSection::GetSectionData call Section::GetSectionData.""
Muhammad Omair Javaid [Mon, 30 Jan 2023 11:43:52 +0000 (16:43 +0500)]
Revert "Revert "[lldb] Make SBSection::GetSectionData call Section::GetSectionData.""

This reverts commit e1bbe50f5a48e9b5407de9e5f4ab8197dedc85c5.

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

17 months ago[AArch64] Add atomics tests for lse2+lse128
Tomas Matheson [Fri, 27 Jan 2023 13:50:47 +0000 (13:50 +0000)]
[AArch64] Add atomics tests for lse2+lse128

FEAT_LSE128 implies FEAT_LSE but not FEAT_LSE2, so add tests showing
what happens when you have both.

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

17 months ago[clangd] Disable tests that are incompatible with Windows
Andrew Ng [Fri, 20 Jan 2023 14:58:54 +0000 (14:58 +0000)]
[clangd] Disable tests that are incompatible with Windows

These tests explicitly make use of POSIX absolute paths.

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

17 months ago[memprof] Change test output redirection to enable it to run on Windows
Andrew Ng [Fri, 20 Jan 2023 15:04:38 +0000 (15:04 +0000)]
[memprof] Change test output redirection to enable it to run on Windows

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

17 months ago[VPlan] VPPredInstPHIRecipes does not write to memory.
Florian Hahn [Mon, 30 Jan 2023 10:29:27 +0000 (10:29 +0000)]
[VPlan] VPPredInstPHIRecipes does not write to memory.

VPPredInstPHIRecipe just merges the incoming values and does not write
to memory.

17 months ago[ARM] Accept shortened forms of the T2 ADC instruction
Jirui Wu [Fri, 13 Jan 2023 10:21:09 +0000 (10:21 +0000)]
[ARM] Accept shortened forms of the T2 ADC instruction

The previous T2 ADC instruction requires three operands. This patch
supports its shortened forms.

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

17 months ago[mlir][bufferization][NFC] Rename BufferRelation::None to BufferRelation::Unknown
Matthias Springer [Mon, 30 Jan 2023 10:03:34 +0000 (11:03 +0100)]
[mlir][bufferization][NFC] Rename BufferRelation::None to BufferRelation::Unknown

The previous name was incorrect. `None` does not mean that there is no buffer relation between two buffers (seems to imply that they do not alias for sure); instead it means that there is no further information available.

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

17 months ago[mlir][nfc] Migrate standalone to new fold API
Marius Brehler [Mon, 30 Jan 2023 10:02:39 +0000 (10:02 +0000)]
[mlir][nfc] Migrate standalone to new fold API

Migrates the standalone sample/dialect to the new fold API, see
https://discourse.llvm.org/t/psa-new-improved-fold-method-signature-has-landed-please-update-your-downstream-projects/67618

17 months ago[libc] Remove warning about unused variable
Guillaume Chatelet [Mon, 23 Jan 2023 17:01:00 +0000 (17:01 +0000)]
[libc] Remove warning about unused variable

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

17 months ago[LoopVectorize] Enable integer Mul and Add as select reduction patterns
Matt Devereau [Fri, 27 Jan 2023 11:16:07 +0000 (11:16 +0000)]
[LoopVectorize] Enable integer Mul and Add as select reduction patterns

This patch vectorizes Phi node loop reductions for select's whos condition
comes from a floating-point comparison, with its operands being integers
for Add, Sub, and Mul reductions.

Example:

int foo(float *x, int n) {
    int sum = 0;
    for (int i=0; i<n; ++i) {
        float elem = x[i];
        if (elem > 0) {
            sum += 2;
        }
    }
    return sum;
}

This would previously fail to vectorize due to the integer reduction.

17 months ago[X86] pr53419.ll - add AVX512 test coverage
Simon Pilgrim [Mon, 30 Jan 2023 09:32:50 +0000 (09:32 +0000)]
[X86] pr53419.ll - add AVX512 test coverage

17 months ago[mlir][bufferization] Better handling of unranked tensors in resolveTensorOpOperandCo...
Matthias Springer [Mon, 30 Jan 2023 09:19:32 +0000 (10:19 +0100)]
[mlir][bufferization] Better handling of unranked tensors in resolveTensorOpOperandConflicts

Unranked tensors can currently not be copied. They are forced to always bufferize in-place. There is typically some other OpOperand that can bufferize out-of-place instead if needed.

Note: There is IR that cannot be bufferized with One-Shot Bufferize at the moment (see invalid test case). But it is unclear if we need to support such cases. We do not have a use case at the moment. This restriction could be loosened in the future if needed.

This change improves error handling when bufferizing IR where an unranked tensor would be copied. It also disables an optimization where an OpResult was copied instead of an OpOperand in case the OpResult is an unranked tensor (Github #60187).

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

17 months ago[mlir][bufferization][NFC] Simplify func bufferization state
Matthias Springer [Mon, 30 Jan 2023 09:12:28 +0000 (10:12 +0100)]
[mlir][bufferization][NFC] Simplify func bufferization state

The analysis previous kept track of OpOperand -> OpResult and OpResult -> OpOperand aliasing mappings. Only one mapping is needed, the other one can be inferred.

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

17 months ago[mlir][bufferization] Fix getAliasingOpOperand/OpResult for non-bufferizable ops
Matthias Springer [Mon, 30 Jan 2023 09:03:23 +0000 (10:03 +0100)]
[mlir][bufferization] Fix getAliasingOpOperand/OpResult for non-bufferizable ops

Also enable analysis of unknown ops.

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

17 months ago[clang][ASTImporter] Handle UsingType in friend declarations.
Balázs Kéri [Mon, 30 Jan 2023 08:39:55 +0000 (09:39 +0100)]
[clang][ASTImporter] Handle UsingType in friend declarations.

ASTImporterLookupTable did not handle correctly friend declarations
where the friend type is an UsingType (type of a declaration that
comes from an using-declaration). The problem is fixed by handling
it in the same way as a friend with TypedefType.

Reviewed By: steakhal

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

17 months ago[UTC] Add --version argument
Nikita Popov [Fri, 27 Jan 2023 13:53:33 +0000 (14:53 +0100)]
[UTC] Add --version argument

We have a number of pending changes to update_test_checks.py
(and friends) that are essentially blocked on test churn:
If the output of UTC for an existing flag combination changes,
then the next time a test is regenerated, it will contain many
spurious changes. This makes changes to UTC default
behavior essentially impossible.

Examples of such changes are:

* D133943/D142373 want --function-signature to also check the
  return type/attributes.
* D139006/D140212 want to make --function-signature the default
  behavior.
* D142452 wants to add wildcards for block labels.

This patch tries to resolve this issue by adding a --version
argument, which works as follows:

* When regenerating an old test, the default version is 1.
* When generating a new test, the default version is the newest.
 When an explicit version is specified, that of course wins.

This means that any currently existing tests will keep using
--version 1 format, while any new tests will automatically embed
--version N where N is the latest version, and then keep using
that test format from then on.

This patch only implements the --version flag without bumping
the default version, so it does not have any visible behavior
change by itself.

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

17 months agoRevert "[llvm] Use llvm::bit_ceil (NFC)"
Nikita Popov [Mon, 30 Jan 2023 08:37:38 +0000 (09:37 +0100)]
Revert "[llvm] Use llvm::bit_ceil (NFC)"

This reverts commit 54971c8a39e8b682e7a042eee33f94a8283d8305.

This causes a compile-time regression. bit_ceil should probably
not be used in performance-critical code.

17 months ago[mlir][bufferization][NFC] Rename: "last-write" -> "definition"
Matthias Springer [Mon, 30 Jan 2023 08:41:31 +0000 (09:41 +0100)]
[mlir][bufferization][NFC] Rename: "last-write" -> "definition"

The previous lingo was confusing. There are no writes on tensors. There are only definitions.

Also some minor cleanup and better documentation.

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

17 months agoRevert "[mlir][LLVM] Add all LLVM parameter attributes"
Christian Ulmann [Mon, 30 Jan 2023 08:34:29 +0000 (09:34 +0100)]
Revert "[mlir][LLVM] Add all LLVM parameter attributes"

This reverts commit 54941942c82f3a1640d50c0e354d29a3cf5535f6.

The commit introduced a linking error in flang.

17 months ago[libc++][ranges] Temporarily mark `ranges::join_view` as experimental.
varconst [Mon, 30 Jan 2023 08:35:55 +0000 (00:35 -0800)]
[libc++][ranges] Temporarily mark `ranges::join_view` as experimental.

This is in anticipation of https://isocpp.org/files/papers/D2770R0.html,
which is ABI-breaking for `join_view`.

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

17 months ago[mlir][bufferization] Generalize and rename isMemoryWrite
Matthias Springer [Mon, 30 Jan 2023 08:26:15 +0000 (09:26 +0100)]
[mlir][bufferization] Generalize and rename isMemoryWrite

The name of the method was confusing. It is bufferizesToMemoryWrite, but from the perspective of OpResults.

`bufferizesToMemoryWrite(OpResult)` now supports ops with regions that do not have aliasing OpOperands (such as `scf.if`). These ops no longer need to implement `isMemoryWrite`.

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

17 months ago[libc++] Fix some missed `return 0` statements in test `main` functions.
Konstantin Varlamov [Mon, 30 Jan 2023 08:29:55 +0000 (00:29 -0800)]
[libc++] Fix some missed `return 0` statements in test `main` functions.

17 months ago[mlir][NFC] GreedyPatternRewriteDriver: Remove single-op entry point
Matthias Springer [Mon, 30 Jan 2023 08:04:31 +0000 (09:04 +0100)]
[mlir][NFC] GreedyPatternRewriteDriver: Remove single-op entry point

This is to simplify the API. The multi-op entry point can be used directly. GreedyRewriteStrictness must now be specified explicitly.

Depends On: D141396

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

17 months ago[mlir][LLVM] Add all LLVM parameter attributes
Christian Ulmann [Mon, 30 Jan 2023 07:27:14 +0000 (08:27 +0100)]
[mlir][LLVM] Add all LLVM parameter attributes

This commit adds name accessors and verifiers for all LLVM parameter
attributes excluding the swift specific ones to the LLVM dialect.
Additionally, these attributes are now also imported and exported.

Reviewed By: gysit

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

17 months agoRevert "[lldb] Make SBSection::GetSectionData call Section::GetSectionData."
Muhammad Omair Javaid [Mon, 30 Jan 2023 07:32:23 +0000 (12:32 +0500)]
Revert "[lldb] Make SBSection::GetSectionData call Section::GetSectionData."

This reverts commit 805600c7d573cf88cf035d01a2ea9389fc24d435.

LLDB windows buildbots were broken by the TestSectionAPI.py test. I dont
have full context of the commit to fix it. Reverting it temporarily.

https://lab.llvm.org/buildbot/#/builders/83/builds/28617
https://lab.llvm.org/buildbot/#/builders/219/builds/180

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

17 months ago[clangd] Fix test failure in TypeHints.Decltype
Nathan Ridge [Mon, 30 Jan 2023 07:07:46 +0000 (02:07 -0500)]
[clangd] Fix test failure in TypeHints.Decltype

17 months ago[Docs] Rename -dot-postdom -> -dom-post-dom in Passes.rst. NFC
Craig Topper [Mon, 30 Jan 2023 06:50:43 +0000 (22:50 -0800)]
[Docs] Rename -dot-postdom -> -dom-post-dom in Passes.rst. NFC

Same for -dot-postdom-only.

Looks like these passes got renamed when they moved to the new
pass manager.

17 months ago[clangd] Don't show 'auto' type hint when type deduction fails
Nathan Ridge [Tue, 24 Jan 2023 09:38:35 +0000 (04:38 -0500)]
[clangd] Don't show 'auto' type hint when type deduction fails

Fixes https://github.com/clangd/clangd/issues/1475

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

17 months ago[AIX][BigArchive] Treat the archive is empty if the first child member offset is...
Kai Luo [Mon, 30 Jan 2023 05:43:50 +0000 (13:43 +0800)]
[AIX][BigArchive] Treat the archive is empty if the first child member offset is zero

If the archive contains free list and contains no member file, the buffer length doesn't equal to length of the header.

Reviewed By: Esme, DiggerLin, #powerpc

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

17 months ago[mlir] skip 0-D vector in BubbleUpBitCastForStridedSliceInsert
Xiang Li [Mon, 30 Jan 2023 01:30:36 +0000 (20:30 -0500)]
[mlir] skip 0-D vector in BubbleUpBitCastForStridedSliceInsert

InsertStridedSliceOp will not get 0-D vector result, so just skip 0-D vector in BubbleUpBitCastForStridedSliceInsert.
Fixes #60214  https://github.com/llvm/llvm-project/issues/60214

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

17 months ago[WebAssembly] Convert some tests to opaque pointers (NFC)
Sergei Barannikov [Mon, 30 Jan 2023 03:39:37 +0000 (06:39 +0300)]
[WebAssembly] Convert some tests to opaque pointers (NFC)

17 months ago[Thumb2] Convert some tests to opaque pointers (NFC)
Sergei Barannikov [Mon, 30 Jan 2023 03:10:10 +0000 (06:10 +0300)]
[Thumb2] Convert some tests to opaque pointers (NFC)

17 months ago[AVR][NFC] Remove redundant target feature PROGMEM
Ben Shi [Fri, 13 Jan 2023 09:37:00 +0000 (17:37 +0800)]
[AVR][NFC] Remove redundant target feature PROGMEM

The functionality of FeaturePROGMEM is all equivalant to FeatureLPM.

Reviewed By: Chenbing.Zheng, aykevl

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

17 months ago[RISCV] Move IsRV64 field of RISCVOperand into RegOp and ImmOp sub-structs.
Craig Topper [Mon, 30 Jan 2023 02:45:58 +0000 (18:45 -0800)]
[RISCV] Move IsRV64 field of RISCVOperand into RegOp and ImmOp sub-structs.

We don't need this field for all operand types, so sync it into the
ones that do need it. Then remove it from the create* functions that
don't need it.

17 months ago[RISCV] Correct end pointer in RISCVAsmParser::parseGPRAsFPR.
Craig Topper [Sun, 29 Jan 2023 23:54:48 +0000 (15:54 -0800)]
[RISCV] Correct end pointer in RISCVAsmParser::parseGPRAsFPR.

Instead of using start pointer - 1, use start pointer + length of
the name string.

17 months ago[RISCV] Make RISCVOperand struct final.
Craig Topper [Sun, 29 Jan 2023 23:48:14 +0000 (15:48 -0800)]
[RISCV] Make RISCVOperand struct final.

Allows the compiler to de-virtualize some calls.

17 months ago[mlir][sparse] Extend sparse_tensor.sort with a enum attribute to specify a sorting...
bixia1 [Fri, 27 Jan 2023 23:16:31 +0000 (15:16 -0800)]
[mlir][sparse] Extend sparse_tensor.sort with a enum attribute to specify a sorting implementation.

Currently, all the non-stable sorting algorithms are implemented via the
straightforward quick sort. This will be fixed in the following PR.

Reviewed By: aartbik

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

17 months ago[PowerPC] Convert more tests to opaque pointers (NFC)
Sergei Barannikov [Mon, 30 Jan 2023 01:39:36 +0000 (04:39 +0300)]
[PowerPC] Convert more tests to opaque pointers (NFC)

17 months ago[clang] Remove clang::Optional
Kazu Hirata [Mon, 30 Jan 2023 02:08:00 +0000 (18:08 -0800)]
[clang] Remove clang::Optional

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

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

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

17 months ago[mlir][sparse] Change the quick sort pivot selection.
bixia1 [Fri, 27 Jan 2023 23:24:02 +0000 (15:24 -0800)]
[mlir][sparse] Change the quick sort pivot selection.

Previously, we choose the value at (lo + hi)/2 as a pivot for partitioning the
data in [lo, hi). We now choose the median for the three values at lo, (lo +
hi)/2, and (hi-1) as a pivot to match the std::qsort implementation.

Reviewed By: aartbik

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

17 months ago[JITLink] Fixes a bug in one of the test files which was causing build failures
Kshitij Jain [Mon, 30 Jan 2023 01:26:45 +0000 (01:26 +0000)]
[JITLink] Fixes a bug in one of the test files which was causing build failures

Reviewed By: MaskRay

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

17 months ago[PowerPC] Convert more tests to opaque pointers (NFC)
Sergei Barannikov [Sun, 29 Jan 2023 23:59:37 +0000 (02:59 +0300)]
[PowerPC] Convert more tests to opaque pointers (NFC)

* Add -fast-isel=false to func-alias.ll. The test was added as a
SelectionDAG test. Without this option, FastISel successfully selects
the call that had a ConstantExpr argument.
* fast-isel-branch.ll couldn't be handled by FastISel. Now it can,
hence the change in the stack offsets.

17 months ago[JITLink] Adds support for PLT based relocations to the ELF/i386 JITLink backend
Kshitij Jain [Sun, 29 Jan 2023 17:19:41 +0000 (17:19 +0000)]
[JITLink] Adds support for PLT based relocations to the ELF/i386 JITLink backend

This commit adds support for PLT based relocations. Specifically -
1. It adds logic to create a `PLTTableManager` in the `buildTables_ELF_i386`
function, which is called as part of the post-prune JITLink passes. The `PLTTableManager`
handles creating pointer jump stubs and related GOT entries for position independent
code.

2. It also adds a pre-fixup pass to optimize away PLT based calls in position independent
code, when possible.

Reviewed By: lhames

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

17 months ago[Support] Use llvm::bit_ceil (NFC)
Kazu Hirata [Mon, 30 Jan 2023 00:07:04 +0000 (16:07 -0800)]
[Support] Use llvm::bit_ceil (NFC)

For nonzero X, NextPowerOf2(X) is equivalent to llvm::bit_ceil(X + 1).