platform/upstream/llvm.git
2 years ago[NFC][sanitizer] Remove SetSoftRssLimitExceededCallback
Vitaly Buka [Thu, 2 Dec 2021 20:44:38 +0000 (12:44 -0800)]
[NFC][sanitizer] Remove SetSoftRssLimitExceededCallback

According comments on D44404, something like that was the goal.

Reviewed By: morehouse, kstoimenov

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

2 years ago[NFC][sanitizer] Reorder functions in cpp file
Vitaly Buka [Thu, 2 Dec 2021 21:27:11 +0000 (13:27 -0800)]
[NFC][sanitizer] Reorder functions in cpp file

2 years agolibcxx pretty printers: remove non-lazy_string fallback
David Blaikie [Thu, 2 Dec 2021 20:16:10 +0000 (12:16 -0800)]
libcxx pretty printers: remove non-lazy_string fallback

This has been supported on gdb for something like ~10 years, so doesn't
seem necessary to carry a fallback.

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

2 years ago[TLI checker] Follow good practice with -COUNT directives
Paul Robinson [Thu, 2 Dec 2021 22:28:07 +0000 (14:28 -0800)]
[TLI checker] Follow good practice with -COUNT directives

FileCheck's -COUNT suffix doesn't fail if there are more matches
than you asked for, so it's good practice to put a -NOT after.

2 years ago[clang-tidy] Allow disabling support for NOLINTBEGIN/NOLINTEND blocks.
Yitzhak Mandelbaum [Thu, 2 Dec 2021 19:52:47 +0000 (19:52 +0000)]
[clang-tidy] Allow disabling support for NOLINTBEGIN/NOLINTEND blocks.

This patch parameterizes the clang-tidy diagnostic consumer with a boolean that
controls whether to honor NOLINTBEGIN/NOLINTEND blocks. The current support for
scanning these blocks is very costly -- O(n*m) in the size of files (n) and
number of diagnostics found (m), with a large constant factor.  So, the patch
allows clients to disable it.

Future patches should make the feature more efficient, but this will mitigate in
the interim.

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

2 years ago[MLIR][FlatAffineConstraints] Remove duplicate divisions while merging local ids
Groverkss [Thu, 2 Dec 2021 22:14:36 +0000 (03:44 +0530)]
[MLIR][FlatAffineConstraints] Remove duplicate divisions while merging local ids

This patch implements detecting duplicate local identifiers by extracting their
division representation while merging local identifiers.

For example, given the FACs A, B:

```
A: (x, y)[s0] : (exists d0 = [x / 4], d1 = [y / 4]: d0 <= s0, d1 <= s0, x + y >= 2)
B: (x, y)[s0] : (exists d0 = [x / 4], d1 = [y / 4]: d0 <= s0, d1 <= s0, x + y >= 5)
```

The intersection of A and B without this patch would lead to the following FAC:

```
(x, y)[s0] : (exists d0 = [x / 4], d1 = [y / 4], d2 = [x / 4], d3 = [x / 4]: d0 <= s0, d1 <= s0, d2 <= s0, d3 <= s0, x + y >= 2, x + y >= 5)
```

after this patch, merging of local ids will detect that `d0 = d2` and `d1 = d3`,
and the intersection of these two FACs will be (after removing duplicate constraints):

```
(x, y)[s0] : (exists d0 = [x / 4], d1 = [y / 4] : d0 <= s0, d1 <= s0, x + y >= 2, x + y >= 5)
```

This reduces the number of constraints by 2 (constraints) + 4 (2 constraints for each extra division) for this case.

This is used to reduce the output size representation of operations like
PresburgerSet::subtract, PresburgerSet::intersect which require merging local
variables.

Reviewed By: arjunp, bondhugula

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

2 years agoRevert changes that should have been sent as a patch
Groverkss [Thu, 2 Dec 2021 22:08:00 +0000 (03:38 +0530)]
Revert changes that should have been sent as a patch

Revert changes that were meant to be sent as a single commit with
summary for the differential review, but were accidently sent directly.

This reverts commit 3bc5353fc6f291d6ac12c256600b5b05d7de8f74.

2 years ago[OPENMP]Fix PR50733: unexpected final value of list-item in linear clause in loop...
Alexey Bataev [Tue, 29 Jun 2021 20:56:00 +0000 (13:56 -0700)]
[OPENMP]Fix PR50733: unexpected final value of list-item in linear clause in loop construct.

Currently the last value of linear is calculated as var = init + num_iters * step.
Replaced it with var = var_priv, i.e. original variable gets the value
of the last private copy.

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

2 years ago[PowerPC] Fix load/store selection infrastructure when load/store intrinsics are...
Amy Kwan [Thu, 2 Dec 2021 21:24:06 +0000 (15:24 -0600)]
[PowerPC] Fix load/store selection infrastructure when load/store intrinsics are used on P10.

The load/store infrastructure previously made an incorrect assumption that
whenever it is used with a load/store intrinsic on Power10 - those intrinsics
would automatically be the lxvp/stxvp intrinsics introduced in Power10.

However, this is obviously not the case as there are multiple instances of
pre-P10 intrinsics that use the refactored load/store implementation.
This patch corrects this assumption, and produces the expected intrinsic on pre-P10.

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

2 years agoAddress bondhugula's comments
Groverkss [Thu, 2 Dec 2021 21:39:19 +0000 (03:09 +0530)]
Address bondhugula's comments

2 years agoAddressed comments
Groverkss [Thu, 18 Nov 2021 17:04:36 +0000 (22:34 +0530)]
Addressed comments

2 years agoFix doc comment for mergeLocalIds.
Groverkss [Thu, 18 Nov 2021 15:34:00 +0000 (21:04 +0530)]
Fix doc comment for mergeLocalIds.

2 years agoAddress more comments.
Groverkss [Thu, 18 Nov 2021 14:51:46 +0000 (20:21 +0530)]
Address more comments.

2 years agoAddressed more comments
Groverkss [Fri, 12 Nov 2021 22:57:37 +0000 (04:27 +0530)]
Addressed more comments

2 years agoFix asserts as suggested by Arjun
Groverkss [Thu, 11 Nov 2021 17:12:04 +0000 (22:42 +0530)]
Fix asserts as suggested by Arjun

2 years agoFix clang-format errors
Groverkss [Wed, 10 Nov 2021 10:18:48 +0000 (15:48 +0530)]
Fix clang-format errors

2 years agoUpdate docs
Groverkss [Mon, 8 Nov 2021 22:02:40 +0000 (03:32 +0530)]
Update docs

2 years agoUpdate tests for mergeLocalIds
Groverkss [Mon, 8 Nov 2021 21:43:43 +0000 (03:13 +0530)]
Update tests for mergeLocalIds

2 years agoAddress arjun's comments
Groverkss [Mon, 8 Nov 2021 21:43:25 +0000 (03:13 +0530)]
Address arjun's comments

2 years agoMove division representation to a common function
Groverkss [Sun, 7 Nov 2021 05:15:20 +0000 (10:45 +0530)]
Move division representation to a common function

2 years agoUpdate mergeLocalIds docs
Groverkss [Sat, 6 Nov 2021 10:45:51 +0000 (16:15 +0530)]
Update mergeLocalIds docs

2 years agoUpdate docs for mergeLocalIds
Groverkss [Sun, 31 Oct 2021 21:34:08 +0000 (03:04 +0530)]
Update docs for mergeLocalIds

2 years agoImplement division merging
Groverkss [Sat, 30 Oct 2021 12:12:47 +0000 (17:42 +0530)]
Implement division merging

2 years ago[LTO] Specify triple to address unknown binary format assertion
Jake Egan [Thu, 2 Dec 2021 21:39:52 +0000 (16:39 -0500)]
[LTO] Specify triple to address unknown binary format assertion

On AIX, this test generates an XCOFF file and hits "unknown binary format" assertion in llvm-nm. This patch specifies the triple to mitigate this issue.

Reviewed By: steven_wu

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

2 years ago[OPENMP]Fix PR51327: Range based for loop not working if range's type is a template.
Alexey Bataev [Wed, 24 Nov 2021 19:21:10 +0000 (11:21 -0800)]
[OPENMP]Fix PR51327: Range based for loop not working if range's type is a template.

Need to postpone anlysis of the ranged for loops till the actual
instantiation to avoid erroneous emission of error messages.

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

2 years ago[mlir][ods] fix defgen on empty files
Mogball [Thu, 2 Dec 2021 21:25:04 +0000 (21:25 +0000)]
[mlir][ods] fix defgen on empty files

2 years ago[funcattrs] Infer writeonly argument attribute
Philip Reames [Thu, 2 Dec 2021 20:56:09 +0000 (12:56 -0800)]
[funcattrs] Infer writeonly argument attribute

This change extends the current logic for inferring readonly and readnone argument attributes to also infer writeonly.

This change is deliberately minimal; there's a couple of areas for follow up.
* I left out all call handling and thus any benefit from the SCC walk. When examining the test changes, I realized the existing code is imprecise, and am going to fix that in it's own revision before adding in the writeonly handling. (Mostly because updating the tests is hard when I, the human, can't figure out whether the result is correct.)
* I left out handling for storing a value (as opposed to storing to a pointer). This should benefit readonly/readnone as well, and applies to a bunch of other instructions. Seemed worth having as a separate review.

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

2 years ago[OPENMP]Fix error emission for dependent expressions in iterators for depend clauses.
Alexey Bataev [Fri, 26 Nov 2021 15:36:25 +0000 (07:36 -0800)]
[OPENMP]Fix error emission for dependent expressions in iterators for depend clauses.

Need to postpone analysis for addressable lvalue in a depend clause with
iterators, otherwise the incorrect error message is emitted.

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

2 years agoRestric xfail on openmp/libomptarget/test/mapping/reduction_implicit_map.cpp to amdgc...
Ron Lieberman [Thu, 2 Dec 2021 20:58:19 +0000 (20:58 +0000)]
Restric xfail on openmp/libomptarget/test/mapping/reduction_implicit_map.cpp to amdgcn-amd-amdhsa

2 years ago[NFC][sanitizer] Rename RssLimitExceeded -> IsRssLimitExceeded
Vitaly Buka [Thu, 2 Dec 2021 20:47:47 +0000 (12:47 -0800)]
[NFC][sanitizer] Rename RssLimitExceeded -> IsRssLimitExceeded

2 years ago[gn build] (manually) port e0b259f22c003ffe9
Nico Weber [Thu, 2 Dec 2021 20:50:56 +0000 (15:50 -0500)]
[gn build] (manually) port e0b259f22c003ffe9

2 years agoxfail: libomptarget reduction_implicit_map.cpp after reapply of Start calling setTarg...
Ron Lieberman [Thu, 2 Dec 2021 20:32:06 +0000 (20:32 +0000)]
xfail: libomptarget reduction_implicit_map.cpp after reapply of Start calling setTargetAttributes

2 years ago[llvm] [Support] Add CURL HTTP Client.
Noah Shutty [Thu, 2 Dec 2021 19:33:04 +0000 (19:33 +0000)]
[llvm] [Support] Add CURL HTTP Client.

Provides an implementation of `HTTPClient` that wraps libcurl.

Reviewed By: dblaikie

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

2 years agoRevert "xfail: reduction_implicit_map.cpp after reapply of Start calling setTargetAtt...
Ron Lieberman [Thu, 2 Dec 2021 20:29:30 +0000 (20:29 +0000)]
Revert "xfail: reduction_implicit_map.cpp after reapply of Start calling setTargetAttributes"

This reverts commit 8b646f212e9ccc8e0fbf1a84603d0a40bfca1338.

2 years ago[ASan] Fixed asan_mapping.h format.
Kirill Stoimenov [Thu, 2 Dec 2021 20:19:29 +0000 (20:19 +0000)]
[ASan] Fixed asan_mapping.h format.

Reviewed By: kstoimenov

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

2 years agoxfail: reduction_implicit_map.cpp after reapply of Start calling setTargetAttributes
Ron Lieberman [Thu, 2 Dec 2021 20:22:11 +0000 (20:22 +0000)]
xfail: reduction_implicit_map.cpp after reapply of Start calling setTargetAttributes

2 years ago[libc++][NFC] Update namespace comments in include/
Nikolas Klauser [Thu, 2 Dec 2021 13:12:51 +0000 (14:12 +0100)]
[libc++][NFC] Update namespace comments in include/

update the namspace comments in include/

Reviewed By: ldionne, #libc

Spies: smeenai, libcxx-commits

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

2 years agoprofi - a flow-based profile inference algorithm: Part III (out of 3)
spupyrev [Thu, 2 Dec 2021 19:59:33 +0000 (11:59 -0800)]
profi - a flow-based profile inference algorithm: Part III (out of 3)

This is a continuation of D109860 and D109903.

An important challenge for profile inference is caused by the fact that the
sample profile is collected on a fully optimized binary, while the block and
edge frequencies are consumed on an early stage of the compilation that operates
with a non-optimized IR. As a result, some of the basic blocks may not have
associated sample counts, and it is up to the algorithm to deduce missing
frequencies. The problem is illustrated in the figure where three basic
blocks are not present in the optimized binary and hence, receive no samples
during profiling.

We found that it is beneficial to treat all such blocks equally. Otherwise the
compiler may decide that some blocks are “cold” and apply undesirable
optimizations (e.g., hot-cold splitting) regressing the performance. Therefore,
we want to distribute the counts evenly along the blocks with missing samples.
This is achieved by a post-processing step that identifies "dangling" subgraphs
consisting of basic blocks with no sampled counts; once the subgraphs are
found, we rebalance the flow so as every branch probability is 50:50 within the
subgraphs.

Our experiments indicate up to 1% performance win using the optimization on
some binaries and a significant improvement in the quality of profile counts
(when compared to ground-truth instrumentation-based counts)

{F19093045}

Reviewed By: hoy

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

2 years ago[gn build] (manually) port 9e3552523ebd (no more old mach-o lld)
Nico Weber [Thu, 2 Dec 2021 20:00:40 +0000 (15:00 -0500)]
[gn build] (manually) port 9e3552523ebd (no more old mach-o lld)

2 years ago[ELF] Hint -z nostart-stop-gc for __start_ undefined references
Fangrui Song [Thu, 2 Dec 2021 19:58:25 +0000 (11:58 -0800)]
[ELF] Hint -z nostart-stop-gc for __start_ undefined references

Make users aware what to do with ld.lld 13.0.0 / GNU ld<2015-10 --gc-sections
behavior.

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

2 years agoReapply "OpenMP: Start calling setTargetAttributes for generated kernels"
Matt Arsenault [Mon, 29 Nov 2021 20:47:42 +0000 (15:47 -0500)]
Reapply "OpenMP: Start calling setTargetAttributes for generated kernels"

This reverts commit 25eb7fa01d7ebbe67648ea03841cda55b4239ab2.

Previous buildbot failures appear to have been a fluke from a dirty
build.

2 years ago[NFC][sanitizer] Use more bytes of sanitizer_stack_store_test pointers
Vitaly Buka [Thu, 2 Dec 2021 02:41:54 +0000 (18:41 -0800)]
[NFC][sanitizer] Use more bytes of sanitizer_stack_store_test pointers

2 years ago[compiler-rt] Fix incorrect variable names used
Leonard Chan [Thu, 2 Dec 2021 19:45:41 +0000 (11:45 -0800)]
[compiler-rt] Fix incorrect variable names used

2 years ago[sanitizer] Start background thread once
Vitaly Buka [Thu, 2 Dec 2021 08:41:41 +0000 (00:41 -0800)]
[sanitizer] Start background thread once

Reviewed By: morehouse

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

2 years ago[Bazel] Remove old macho lld port
Keith Smiley [Thu, 2 Dec 2021 19:24:08 +0000 (11:24 -0800)]
[Bazel] Remove old macho lld port

This code and cmake was removed in https://reviews.llvm.org/D114842

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

2 years ago[asan] Remove confusing workaround
Vitaly Buka [Thu, 2 Dec 2021 08:53:02 +0000 (00:53 -0800)]
[asan] Remove confusing workaround

The goal is to identify the bot and try to fix it.

SetSoftRssLimitExceededCallback is AsanInitInternal as I assume
that only MaybeStartBackgroudThread needs to be delayed to constructors.
Later I want to move MaybeStartBackgroudThread call into sanitizer_common.

If it needs to be reverted please provide to more info, like bot, or details about setup.

Reviewed By: kstoimenov

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

2 years agoSimplify the libcxx std::string_view gdb pretty printer
David Blaikie [Fri, 5 Nov 2021 05:45:55 +0000 (22:45 -0700)]
Simplify the libcxx std::string_view gdb pretty printer

Seems better to rely on the existing formatting, makes the output
smaller/simpler - this is consistent with libstdc++'s std::string_view
pretty printing too.

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

2 years ago[Bazel] Remove old MachO LLD from the Bazel build
Reid Kleckner [Thu, 2 Dec 2021 19:30:26 +0000 (11:30 -0800)]
[Bazel] Remove old MachO LLD from the Bazel build

Updates Bazel files for 9e3552523ebd3385487e01e3e7af37b8c0efaf57

2 years ago[lld-macho] Remove old macho darwin lld
Keith Smiley [Wed, 1 Dec 2021 06:01:07 +0000 (22:01 -0800)]
[lld-macho] Remove old macho darwin lld

During the llvm round table it was generally agreed that the newer macho
lld implementation is feature complete enough to replace the old
implementation entirely. This will reduce confusion for new users who
aren't aware of the history.

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

2 years agoprofi - a flow-based profile inference algorithm: Part II (out of 3)
spupyrev [Thu, 2 Dec 2021 18:19:32 +0000 (10:19 -0800)]
profi - a flow-based profile inference algorithm: Part II (out of 3)

This is a continuation of D109860.

Traditional flow-based algorithms cannot guarantee that the resulting edge
frequencies correspond to a *connected* flow in the control-flow graph. For
example, for an instance in the attached figure, a flow-based (or any other)
inference algorithm may produce an output in which the hot loop is disconnected
from the entry block (refer to the rightmost graph in the figure). Furthermore,
creating a connected minimum-cost maximum flow is a computationally NP-hard
problem. Hence, we apply a post-processing adjustments to the computed flow
by connecting all isolated flow components ("islands").

This feature helps to keep all blocks with sample counts connected and results
in significant performance wins for some binaries.
{F19077343}

Reviewed By: hoy

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

2 years ago[mlir][bufferization] fixed typo in to_memref doc
Aart Bik [Tue, 30 Nov 2021 23:34:23 +0000 (15:34 -0800)]
[mlir][bufferization] fixed typo in to_memref doc

Reviewed By: pifon2a

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

2 years ago[SLP]Fix reused extracts cost.
Alexey Bataev [Thu, 2 Dec 2021 12:22:55 +0000 (04:22 -0800)]
[SLP]Fix reused extracts cost.

If the extractelement instruction is used multiple times in the
different tree entries (either vectorized, or gathered), need to
compensate the scalar cost of such instructions. They are completely
removed if all users are part of the tree but we need to compensate the
cost only once for each instruction.

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

2 years ago[sanitizer] Add delta compression stack depot
Vitaly Buka [Mon, 22 Nov 2021 05:54:08 +0000 (21:54 -0800)]
[sanitizer] Add delta compression stack depot

Compress by factor 4x, takes about 10ms per 8 MiB block.

Depends on D114498.

Reviewed By: morehouse

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

2 years ago[sanitizer] Add compress_stack_depot flag
Vitaly Buka [Wed, 24 Nov 2021 00:31:26 +0000 (16:31 -0800)]
[sanitizer] Add compress_stack_depot flag

Depends on D114494.

Reviewed By: morehouse

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

2 years ago[ELF] Fix driver.test after 8c3641d0 when cwd is readonly
Reid Kleckner [Thu, 2 Dec 2021 18:19:54 +0000 (10:19 -0800)]
[ELF] Fix driver.test after 8c3641d0 when cwd is readonly

2 years ago[sanitizer] DEFINE_REAL_PTHREAD_FUNCTIONS for hwasan, lsan, msan
Vitaly Buka [Thu, 2 Dec 2021 07:52:31 +0000 (23:52 -0800)]
[sanitizer] DEFINE_REAL_PTHREAD_FUNCTIONS for hwasan, lsan, msan

It should be NFC, as they already intercept pthread_create.

This will let us to fix BackgroundThread for these sanitizerts.
In in followup patches I will fix MaybeStartBackgroudThread for them
and corresponding tests.

Reviewed By: kstoimenov

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

2 years ago[lldb] Skip two lldb tests on Windows because they are flaky
Stella Stamenova [Thu, 2 Dec 2021 17:53:28 +0000 (09:53 -0800)]
[lldb] Skip two lldb tests on Windows because they are flaky

These tests work fine with VS2017, but become more flaky with VS2019 and the buildbot is about to get upgraded.

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

2 years ago[bazel][mlgo] Remove the mlgo-related build excludes
Mircea Trofin [Thu, 2 Dec 2021 17:50:09 +0000 (09:50 -0800)]
[bazel][mlgo] Remove the mlgo-related build excludes

They aren't needed anymore, we handle conditional compilation in those
files.

Reviewed By: GMNGeoffrey

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

2 years ago[BasicAA] Add tests for strcat/strncat/strcpy.
Florian Hahn [Thu, 2 Dec 2021 17:38:07 +0000 (17:38 +0000)]
[BasicAA] Add tests for strcat/strncat/strcpy.

2 years ago[DSE] Read after strcpy test.
Florian Hahn [Thu, 2 Dec 2021 17:37:59 +0000 (17:37 +0000)]
[DSE] Read after strcpy test.

2 years ago[OpenMP] Remove the new runtime default for AMDGPU
Joseph Huber [Thu, 2 Dec 2021 17:28:21 +0000 (12:28 -0500)]
[OpenMP] Remove the new runtime default for AMDGPU

The new runtime is currently broken for AMD offloading. This patch makes
the default the old runtime only for the AMD target.

Reviewed By: ronlieb

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

2 years ago[llvm] Use range-based for loops (NFC)
Kazu Hirata [Thu, 2 Dec 2021 17:27:47 +0000 (09:27 -0800)]
[llvm] Use range-based for loops (NFC)

2 years ago[llvm] Fix "unused variable" warnings
Kazu Hirata [Thu, 2 Dec 2021 17:20:17 +0000 (09:20 -0800)]
[llvm] Fix "unused variable" warnings

2 years ago[SLP]Outline and fix code for finding common insertelement vectors.
Alexey Bataev [Wed, 1 Dec 2021 18:01:56 +0000 (10:01 -0800)]
[SLP]Outline and fix code for finding common insertelement vectors.

Need to outline the code for finding common vectors in insertelement
instructions into a separate function for future patches. It also
improves the process by adding some extra checks for early exit and
fixes a bug where it always finds the match because of erroneous compare
of the same values.

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

2 years ago[ARM] Introduce i8neg and i8pos addressing modes
David Green [Thu, 2 Dec 2021 17:10:26 +0000 (17:10 +0000)]
[ARM] Introduce i8neg and i8pos addressing modes

Some instructions with i8 immediate ranges can only hold negative values
(like t2LDRHi8), only hold positive values (like t2STRT) or hold +/-
depending on the U bit (like the pre/post inc instructions. e.g
t2LDRH_POST). This patch splits the AddrModeT2_i8 into AddrModeT2_i8,
AddrModeT2_i8pos and AddrModeT2_i8neg to make this clear.

This allows us to get the offset ranges of t2LDRHi8 correct in the
load/store optimizer, fixing issues where we could end up creating
instructions with positive offsets (which may then be encoded as ldrht).

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

2 years ago[clang-cl] Define _MSVC_LANG for -std=c++2b
Nico Weber [Thu, 2 Dec 2021 14:12:50 +0000 (09:12 -0500)]
[clang-cl] Define _MSVC_LANG for -std=c++2b

This matches the value that msvc v19.29 VS16.11 uses for
_MSVC_LANG with /std:c++latest.

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

2 years agoReapply "[TLI checker] Add more tests"
Paul Robinson [Thu, 2 Dec 2021 16:34:16 +0000 (08:34 -0800)]
Reapply "[TLI checker] Add more tests"

This reverts commit 8cd61aac0030b8add686a98b8902ea49ec9c1deb.
I had missed one place in a test that needed updating; it passed on my
dirty build tree but not on a clean one.

Original commit message:

D114478 identified testing gaps; this patch fills them.

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

2 years agotsan: tolerate munmap with invalid arguments
Dmitry Vyukov [Thu, 2 Dec 2021 12:35:04 +0000 (13:35 +0100)]
tsan: tolerate munmap with invalid arguments

We call UnmapShadow before the actual munmap, at that point we don't yet
know if the provided address/size are sane. We can't call UnmapShadow
after the actual munmap becuase at that point the memory range can
already be reused for something else, so we can't rely on the munmap
return value to understand is the values are sane.
While calling munmap with insane values (non-canonical address, negative
size, etc) is an error, the kernel won't crash. We must also try to not
crash as the failure mode is very confusing (paging fault inside of the
runtime on some derived shadow address).

Such invalid arguments are observed on Chromium tests:
https://bugs.chromium.org/p/chromium/issues/detail?id=1275581

Reviewed By: melver

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

2 years ago[SLP]Improve registering and merging of compatible shuffles.
Alexey Bataev [Mon, 15 Nov 2021 17:18:27 +0000 (09:18 -0800)]
[SLP]Improve registering and merging of compatible shuffles.

If several shuffle instructions are emitted, some of them might
same/compatible (less defined) with the previously emitted ones. Such
shuffles can be removed safely, improving the total cost of the
vectorized code.

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

2 years agotsan: fix false positives in dynamic libs with static tls
Dmitry Vyukov [Thu, 2 Dec 2021 14:15:14 +0000 (15:15 +0100)]
tsan: fix false positives in dynamic libs with static tls

The added test demonstrates  loading a dynamic library with static TLS.
Such static TLS is a hack that allows a dynamic library to have faster TLS,
but it can be loaded only iff all threads happened to allocate some excess
of static TLS space for whatever reason. If it's not the case loading fails with:

dlopen: cannot load any more object with static TLS

We used to produce a false positive because dlopen will write into TLS
of all existing threads to initialize/zero TLS region for the loaded library.
And this appears to be racing with initialization of TLS in the thread
since we model a write into the whole static TLS region (we don't what part
of it is currently unused):

WARNING: ThreadSanitizer: data race (pid=2317365)
  Write of size 1 at 0x7f1fa9bfcdd7 by main thread:
    0 memset
    1 init_one_static_tls
    2 __pthread_init_static_tls
    [[ this is where main calls dlopen ]]
    3 main
  Previous write of size 8 at 0x7f1fa9bfcdd0 by thread T1:
    0 __tsan_tls_initialization

Fix this by ignoring accesses during dlopen.

Reviewed By: melver

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

2 years ago[lld][WebAssembly] Fix for debug relocations against undefined function symbols
Sam Clegg [Thu, 2 Dec 2021 02:10:37 +0000 (18:10 -0800)]
[lld][WebAssembly] Fix for debug relocations against undefined function symbols

This is very similar to https://reviews.llvm.org/D103557 but applies to
symbols which are undefined at link time rather than compile time.

We already have code that handles symbols which were defined at link
time but dead stripped by `--gc-sections` (See
`test/wasm/debug-removed-fn.ll`). In that case the symbols are not live
(!isLive()).  However, we can also have live symbols (which are
references by the program) but which are undefined at link time and are
imported by the linker.

In the test case here the symbol `undef` is used but is not defined
in the program but is imported by the linker due to the
`--import-undefined` flag.

Fixes: https://github.com/emscripten-core/emscripten/issues/15528

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

2 years agoRevert "[TLI checker] Add more tests"
Paul Robinson [Thu, 2 Dec 2021 16:30:47 +0000 (08:30 -0800)]
Revert "[TLI checker] Add more tests"

This reverts commit 2778554971dada8ef7df9ee6954c52a753d90c22.

Some bots are failing on the updated tests.

2 years ago[clang] Do not duplicate "EnableSplitLTOUnit" module flag
David Greene [Wed, 6 Oct 2021 19:10:08 +0000 (12:10 -0700)]
[clang] Do not duplicate "EnableSplitLTOUnit" module flag

If clang's output is set to bitcode and LTO is enabled, clang would
unconditionally add the flag to the module.  Unfortunately, if the input were a
bitcode or IR file and had the flag set, this would result in two copies of the
flag, which is illegal IR.  Guard the setting of the flag by checking whether it
already exists.  This follows existing practice for the related "ThinLTO" module
flag.

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

2 years ago[TLI checker] Add more tests
Paul Robinson [Wed, 1 Dec 2021 22:56:00 +0000 (14:56 -0800)]
[TLI checker] Add more tests

D114478 identified testing gaps; this patch fills them.

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

2 years ago[OpenMP] Make the new device runtime the default
Joseph Huber [Wed, 1 Dec 2021 18:14:40 +0000 (13:14 -0500)]
[OpenMP] Make the new device runtime the default

This patch changes the `-fopenmp-target-new-runtime` option which controls if
the new or old device runtime is used to be true by default.  Disabling this to
use the old runtime now requires using `-fno-openmp-target-new-runtime`.

Reviewed By: JonChesterfield, tianshilei1992, gregrodgers, ronlieb

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

2 years ago[InstCombine] add tests for icmp with mul op; NFC
Sanjay Patel [Thu, 2 Dec 2021 15:30:06 +0000 (10:30 -0500)]
[InstCombine] add tests for icmp with mul op; NFC

2 years ago[clangd] cleanup of header guard names
Christian Kühnel [Thu, 2 Dec 2021 13:43:13 +0000 (13:43 +0000)]
[clangd] cleanup of header guard names

Renaming header guards to match the LLVM convention.
This patch was created by automatically applying the fixes from
clang-tidy.

I've removed the [NFC]  tag from the title, as we're adding header guards in some files and thus might trigger behavior changes.

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

2 years ago[Clang] Fix LTO pipeline test after 770a50b28c00211f9a.
Florian Hahn [Thu, 2 Dec 2021 15:41:31 +0000 (15:41 +0000)]
[Clang] Fix LTO pipeline test after 770a50b28c00211f9a.

2 years ago[AnnotationRemarks] Support generating annotation remarks with -O0.
Florian Hahn [Thu, 2 Dec 2021 14:50:14 +0000 (14:50 +0000)]
[AnnotationRemarks] Support generating annotation remarks with -O0.

This matches the legacy pass manager behavior. If remarks are not
enabled the pass is effectively a no-op.

2 years ago[clang-tidy] Fix build broken by commit 6a9487df73e917c4faf5e060f2bb33c6ade3f967...
Yitzhak Mandelbaum [Thu, 2 Dec 2021 14:41:00 +0000 (14:41 +0000)]
[clang-tidy] Fix build broken by commit 6a9487df73e917c4faf5e060f2bb33c6ade3f967 (D113148)

2 years ago[SLP][NFC]Add a test for extractelements with many uses vectorization, NFC.
Alexey Bataev [Thu, 2 Dec 2021 14:29:27 +0000 (06:29 -0800)]
[SLP][NFC]Add a test for extractelements with many uses vectorization, NFC.

2 years ago[AMDGPU] Add support for in-order bvh in waitcnt pass
David Stuttard [Tue, 30 Nov 2021 09:29:14 +0000 (09:29 +0000)]
[AMDGPU] Add support for in-order bvh in waitcnt pass

bvh should be handled separately from vmem and vmem with sampler instructions
for waitcnt handling.

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

2 years ago[AMDGPU] Test for in-order waitcnt insertion for bvh instructions
David Stuttard [Tue, 30 Nov 2021 09:29:14 +0000 (09:29 +0000)]
[AMDGPU] Test for in-order waitcnt insertion for bvh instructions

In-order bvh instructions don't require a waitcnt as order is
guaranteed.

However, waitcnt IS required for other image instruction types vs
bvh.

Pre-commit test for new functionality in https://reviews.llvm.org/D114794

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

2 years ago[VE][NFC] Cleanup redundant namespace wrapper
Simon Moll [Thu, 2 Dec 2021 12:59:24 +0000 (13:59 +0100)]
[VE][NFC] Cleanup redundant namespace wrapper

2 years ago[MemoryLocation] Support strncpy in getForArgument.
Florian Hahn [Thu, 2 Dec 2021 14:18:04 +0000 (14:18 +0000)]
[MemoryLocation] Support strncpy in getForArgument.

The size argument of strncpy can be used as bound for the size of
its pointer arguments.

strncpy is guaranteed to write N bytes and reads up to N bytes.

Reviewed By: xbolva00

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

2 years ago[libc] Fix a bug in MPFRUtils making ULP values off by 2^(-mantissaWidth).
Tue Ly [Wed, 1 Dec 2021 15:24:57 +0000 (10:24 -0500)]
[libc] Fix a bug in MPFRUtils making ULP values off by 2^(-mantissaWidth).

Fix a bug in MPFRUtils making ULP values off by 2^(-mantissaWidth) and incorrect eps for denormal numbers.

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

2 years ago[PatternMatch] create and use matcher for 'not' that excludes undef elements
Sanjay Patel [Wed, 1 Dec 2021 22:21:19 +0000 (17:21 -0500)]
[PatternMatch] create and use matcher for 'not' that excludes undef elements

We needed a stricter version of m_Not for D114462, but I wasn't
sure if that was going to be required anywhere else, so I didn't bother
to make that reusable.

It turns out we have one more existing simplification that needs
this (currently miscompiles):
https://alive2.llvm.org/ce/z/9-nTKi

And there's at least one more fold in that family that we could add.

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

2 years ago[MemoryLocation] Support memset_chk in getForArgument.
Florian Hahn [Thu, 2 Dec 2021 13:45:58 +0000 (13:45 +0000)]
[MemoryLocation] Support memset_chk in getForArgument.

The size argument for memset_chk is an upper bound for the size of the
pointer argument. memset_chk may write less than the specified length,
if it exceeds the specified max size and aborts.

Reviewed By: nikic

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

2 years ago[gn build] Port 6a9487df73e9
LLVM GN Syncbot [Thu, 2 Dec 2021 13:40:22 +0000 (13:40 +0000)]
[gn build] Port 6a9487df73e9

2 years ago[flang] GettingInvolved: update LLVM Alias Analysis Technical Call info
Jeroen Dobbelaere [Thu, 2 Dec 2021 13:36:11 +0000 (14:36 +0100)]
[flang] GettingInvolved: update LLVM Alias Analysis Technical Call info

The google doc was changed and the calls are now using teams.

Reviewed By: sameeranjoshi

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

2 years ago[HIPSPV] Add CUDA->SPIR-V address space mapping
Anastasia Stulova [Thu, 2 Dec 2021 13:30:05 +0000 (13:30 +0000)]
[HIPSPV] Add CUDA->SPIR-V address space mapping

Add mapping for CUDA address spaces for HIP to SPIR-V
translation. This change allows HIP device code to be
emitted as valid SPIR-V by mapping unqualified pointers
to generic address space and by mapping __device__ and
__shared__ AS to their equivalent AS in SPIR-V
(CrossWorkgroup and Workgroup, respectively).

Cuda's __constant__ AS is handled specially. In HIP
unqualified pointers (aka "flat" pointers) can point to
__constant__ objects. Mapping this AS to ConstantMemory
would produce to illegal address space casts to
generic AS. Therefore, __constant__ AS is mapped to
CrossWorkgroup.

Patch by linjamaki (Henry Linjamäki)!

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

2 years agoFix documentation for `forEachLambdaCapture` and `hasAnyCapture`
James King [Thu, 2 Dec 2021 13:27:33 +0000 (13:27 +0000)]
Fix documentation for `forEachLambdaCapture` and `hasAnyCapture`

Updates the return types of these matchers' definitions to use
`internal::Matcher<LambdaCapture>` instead of `LambdaCaptureMatcher`. This
ensures that they are categorized as traversal matchers, instead of narrowing
matchers.

Reviewed By: ymandel, tdl-g, aaron.ballman

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

2 years agoAdd new clang-tidy check for string_view(nullptr)
CJ Johnson [Thu, 2 Dec 2021 13:17:12 +0000 (13:17 +0000)]
Add new clang-tidy check for string_view(nullptr)

Checks for various ways that the `const CharT*` constructor of `std::basic_string_view` can be passed a null argument and replaces them with the default constructor in most cases. For the comparison operators, braced initializer list does not compile so instead a call to `.empty()` or the empty string literal are used, where appropriate.

This prevents code from invoking behavior which is unconditionally undefined. The single-argument `const CharT*` constructor does not check for the null case before dereferencing its input. The standard is slated to add an explicitly-deleted overload to catch some of these cases: wg21.link/p2166

https://reviews.llvm.org/D114823 is a companion change to prevent duplicate warnings from the `bugprone-string-constructor` check.

Reviewed By: ymandel

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

2 years ago[fir] Declare test function inline
Valentin Clement [Thu, 2 Dec 2021 13:17:28 +0000 (14:17 +0100)]
[fir] Declare test function inline

Declare functions checkCallOp and checkCallOpFromResultBox inline due to buildbot failure flang-aarch64-latest-clang

2 years agoExpand testing of necessary features for print-changed=dot-cfg.
Jamie Schmeiser [Thu, 2 Dec 2021 13:16:18 +0000 (08:16 -0500)]
Expand testing of necessary features for print-changed=dot-cfg.

Summary:
Expand the testing for whether the lit tests for print-changed=dot-cfg
are supported to include checking whether dot supports pdf output.

Author: Jamie Schmeiser <schmeise@ca.ibm.com>
Reviewed By: hvdijk (Harald van Dijk)
Differential Revision: https://reviews.llvm.org/D113187

2 years ago[AArch64][SVE] Enable bf16 vector.insert
Matt Devereau [Tue, 30 Nov 2021 15:10:06 +0000 (15:10 +0000)]
[AArch64][SVE] Enable bf16 vector.insert

Allow passthrough bf16 registers for vector.insert

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

2 years ago[VE][Clang][NFC] Disable VE toolchain tests on Windows
Simon Moll [Thu, 2 Dec 2021 12:33:46 +0000 (13:33 +0100)]
[VE][Clang][NFC] Disable VE toolchain tests on Windows

VE hardware is unsupported under Windows. Disable the clang VE toolchain
tests here. Tests breaking because of non-POSIX path separators.

2 years agoReland "[LICM] Hoist LOAD without sinking the STORE"
Djordje Todorovic [Thu, 2 Dec 2021 11:40:00 +0000 (03:40 -0800)]
Reland "[LICM] Hoist LOAD without sinking the STORE"

When doing load/store promotion within LICM, if we
cannot prove that it is safe to sink the store we won't
hoist the load, even though we can prove the load could
be dereferenced and moved outside the loop. This patch
implements the load promotion by moving it in the loop
preheader by inserting proper PHI in the loop. The store
is kept as is in the loop. By doing this, we avoid doing
the load from a memory location in each iteration.

Please consider this small example:

loop {
  var = *ptr;
  if (var) break;
  *ptr= var + 1;
}
After this patch, it will be:

var0 = *ptr;
loop {
  var1 = phi (var0, var2);
  if (var1) break;
  var2 = var1 + 1;
  *ptr = var2;
}
This addresses some problems from [0].

[0] https://bugs.llvm.org/show_bug.cgi?id=51193

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

2 years ago[BasicAA] Add tests for memset_pattern{4,8,16}.
Florian Hahn [Thu, 2 Dec 2021 11:50:32 +0000 (11:50 +0000)]
[BasicAA] Add tests for memset_pattern{4,8,16}.

This also removes the existing memset_pattern.ll test, which was relying
on GVN. It is also covered by the new test directly.

2 years ago[DAG][PowerPC] Enable initial ISD::BITCAST SimplifyDemandedBits/SimplifyMultipleUseDe...
Simon Pilgrim [Thu, 2 Dec 2021 11:47:43 +0000 (11:47 +0000)]
[DAG][PowerPC] Enable initial ISD::BITCAST SimplifyDemandedBits/SimplifyMultipleUseDemandedBits big-endian handling

This patch begins extending handling for peeking through bitcast nodes to big-endian targets as well as the existing little-endian case.

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