platform/upstream/llvm.git
23 months agoAMDGPU: Fixup tests
Nicolai Hähnle [Wed, 30 Nov 2022 11:29:37 +0000 (12:29 +0100)]
AMDGPU: Fixup tests

23 months ago[FLANG] Fix MSVC + clang-cl build
Muhammad Omair Javaid [Wed, 30 Nov 2022 11:28:13 +0000 (16:28 +0500)]
[FLANG] Fix MSVC + clang-cl build

Flang build on windows with MSVC environment and clang-cl compiler
requires clang_rt.builtin.${target} library. This patch allows us to
locate and include this link library. This is mostly needed for flang
runtime and associated unittests as it requires the uint128 division
builtin function __udivti3.

Reviewed By: DavidTruby

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

23 months ago[MSAN] add interceptor for stpncpy
Gabor Buella [Sun, 20 Nov 2022 21:15:24 +0000 (22:15 +0100)]
[MSAN] add interceptor for stpncpy

Reviewed By: vitalybuka

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

23 months agoRevert "[OpenMP] [OMPD] Enable OMPD Tests"
Vignesh Balasubramanian [Wed, 30 Nov 2022 11:07:01 +0000 (16:37 +0530)]
Revert "[OpenMP] [OMPD] Enable OMPD Tests"

This reverts commit 451c017a32695ee62c0ae6de6401d89cd9bd9555.

23 months ago[flang] fix unused variables
Tom Eccles [Wed, 30 Nov 2022 10:33:22 +0000 (10:33 +0000)]
[flang] fix unused variables

23 months agoAMDGPU: Remove ImagePSV and move images to addrspace 7
Nicolai Hähnle [Tue, 29 Nov 2022 21:36:15 +0000 (22:36 +0100)]
AMDGPU: Remove ImagePSV and move images to addrspace 7

Following up on the removal of BufferPSV in commit 43b86bf992 ("AMDGPU:
Remove BufferPseudoSourceValue")

It is unclear what exactly the right address space for images should be.
They seem morally closest to buffers, so that's what I went with. In
practical terms, address space 7 is better than address space 0 because
it can't alias with LDS.

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

23 months ago[Clang] Remove conflict markers from ReleaseNotes
Corentin Jabot [Wed, 30 Nov 2022 10:27:16 +0000 (11:27 +0100)]
[Clang] Remove conflict markers from ReleaseNotes

23 months agoImplement CWG2631
Corentin Jabot [Sun, 23 Oct 2022 15:32:58 +0000 (17:32 +0200)]
Implement CWG2631

Implement https://cplusplus.github.io/CWG/issues/2631.html.

Immediate calls in default arguments and defaults members
are not evaluated.

Instead, we evaluate them when constructing a
`CXXDefaultArgExpr`/`BuildCXXDefaultInitExpr`.

The immediate calls are executed by doing a
transform on the initializing expression.

Note that lambdas are not considering subexpressions so
we do not need to transform them.

As a result of this patch, unused default member
initializers are not considered odr-used, and
errors about members binding to local variables
in an outer scope only surface at the point
where a constructor is defined.

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

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

23 months ago[OpenMP] [OMPD] Enable OMPD Tests
Vignesh Balasubramanian [Wed, 30 Nov 2022 08:48:29 +0000 (14:18 +0530)]
[OpenMP] [OMPD] Enable OMPD Tests

It was disabled due to different failures it different llvm bots.

Reviewed By: ye-luo
Differential Revision: https://reviews.llvm.org/D138411

23 months ago[LoongArch] Add codegen support for atomicrmw min/max operation on LA64
gonglingqin [Wed, 30 Nov 2022 09:04:25 +0000 (17:04 +0800)]
[LoongArch] Add codegen support for atomicrmw min/max operation on LA64

This patch is required by OpenMP. After applying this patch, OpenMP regression
test passed. To reduce review difficulty caused by too large patches,
atomicrmw min/max operations on LA32 will be added later.

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

23 months ago[clang][Interp] Explicitly handle RVO Pointer
Timm Bäder [Fri, 4 Nov 2022 06:43:34 +0000 (07:43 +0100)]
[clang][Interp] Explicitly handle RVO Pointer

The calling convention is:

[RVO pointer]
[instance pointer]
[... args ...]

We handle the instance pointer ourselves, BUT for the RVO pointer, we
just assumed in visitReturnStmt() that it is on top of the stack. Which
isn't true if there are other args present (and a this pointer, maybe).

Fix this by recording the RVO pointer explicitly when creating an
InterpFrame, just like we do with the instance/This pointer.

There is already a "RVOAndParams()" test in test/AST/Inter/records.cpp,
that was supposed to test this, however, it didn't trigger any
problematic behavior because the parameter and the return value have the
same type.

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

23 months agotsan: fix epoll_pwait2 interceptor
Dmitry Vyukov [Tue, 29 Nov 2022 15:51:48 +0000 (16:51 +0100)]
tsan: fix epoll_pwait2 interceptor

epoll_pwait2 is new and may not be present in libc and/or kernel.
Since we effectively add it to libc (as will be probed by the program
using dlsym or a weak function pointer) we need to handle the case
when it's not present in the actual libc.

Reviewed By: melver

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

23 months ago[clang][Interp] Use placement new to construct opcode args into vector
Timm Bäder [Wed, 23 Nov 2022 09:48:45 +0000 (10:48 +0100)]
[clang][Interp] Use placement new to construct opcode args into vector

This way we're invoking the copy constructor, which might be necessary
if the argument is not trivially constructible.

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

23 months ago[clang][Interp] Handle undefined functions better
Timm Bäder [Fri, 28 Oct 2022 08:31:47 +0000 (10:31 +0200)]
[clang][Interp] Handle undefined functions better

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

23 months ago[clang][Interp] Array initialization via CXXConstructExpr
Timm Bäder [Sun, 30 Oct 2022 06:08:45 +0000 (07:08 +0100)]
[clang][Interp] Array initialization via CXXConstructExpr

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

23 months ago[flang] Handle polymorphic value when creating temporary
Valentin Clement [Wed, 30 Nov 2022 08:58:27 +0000 (09:58 +0100)]
[flang] Handle polymorphic value when creating temporary

Reviewed By: PeteSteinfeld

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

23 months agoRevert "Use-after-return sanitizer binary metadata"
Dmitry Vyukov [Wed, 30 Nov 2022 08:35:30 +0000 (09:35 +0100)]
Revert "Use-after-return sanitizer binary metadata"

This reverts commit e6aea4a5db09c845276ece92737a6aac97794100.

Broke tests:
https://lab.llvm.org/buildbot/#/builders/16/builds/38992

23 months ago[mlir][bufferize] Improve error message when returning allocs
Matthias Springer [Wed, 30 Nov 2022 08:11:50 +0000 (09:11 +0100)]
[mlir][bufferize] Improve error message when returning allocs

The previous error message was confusing. Also improve code documentation and some minor code cleanups.

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

23 months ago[clang][Interp] Fix discarding non-primitive function call return values
Timm Bäder [Fri, 21 Oct 2022 15:32:39 +0000 (17:32 +0200)]
[clang][Interp] Fix discarding non-primitive function call return values

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

23 months ago[RISCV] Remove lmuls argument in Sched class
wangpc [Wed, 30 Nov 2022 08:01:12 +0000 (16:01 +0800)]
[RISCV] Remove lmuls argument in Sched class

The original intention is adding a list of SchedWrites (which is a
default argument of ReadAdvance) to LMULReadAdvance, but it may not
be practical that there are two default arguments in one class. So
we add variants that are intended for widening and narrowing
instructions with postfix "W" and remove lmuls argument.

Reviewed By: michaelmaitland

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

23 months agoUse-after-return sanitizer binary metadata
Dmitry Vyukov [Mon, 17 Oct 2022 13:13:56 +0000 (15:13 +0200)]
Use-after-return sanitizer binary metadata

Currently per-function metadata consists of:
(start-pc, size, features)

This adds a new UAR feature and if it's set an additional element:
(start-pc, size, features, stack-args-size)

Reviewed By: melver

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

23 months ago[AMDGPU] Remove AMDGPUISelDAGToDAG::isKnownNeverNaN
Thomas Symalla [Tue, 29 Nov 2022 19:15:40 +0000 (20:15 +0100)]
[AMDGPU] Remove AMDGPUISelDAGToDAG::isKnownNeverNaN

This function removes the mentioned function, as it only does two
checks which are already implemented as part of
SelectionDAG::isKnownNeverNaN - which is called there.

Reviewed By: arsenm

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

23 months ago[llvm-profdata] Use flattening sample profile in profile supplementation
Rong Xu [Wed, 30 Nov 2022 06:23:47 +0000 (22:23 -0800)]
[llvm-profdata] Use flattening sample profile in profile supplementation

We need to flatten the SampleFDO profile in profile supplementation
because the InstrFDO profile does not have inlined callsite counters.
Without flattening profile, FDO optimizations are not stable:
we will not supplement the second generation profile when the modified
functions are all inlined.

This patch fixes this issue: we will flatten the profile for functions
that appears in FDO profile.

Note that we only need to find the hot/warm functions in SampleFDO
profile, so we will not perform a full flatten. We will use
a DFS traversal to compute the accumulated entry count and max bodycount.
This is much cheaper than full flattening.

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

23 months ago[CMake] Support injecting extra dependencies for perf-training
Petr Hosek [Wed, 30 Nov 2022 03:02:58 +0000 (03:02 +0000)]
[CMake] Support injecting extra dependencies for perf-training

It may be necessary to build additional targets before running
perf-training, the typical use case would be builtins and runtimes.

This change allows users to specify those dependencies as:

  set(CLANG_PERF_TRAINING_DEPS builtins runtimes CACHE STRING "")

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

23 months ago[X86] combine-and.ll - add test coverage for scalar broadcast
Evgenii Kudriashov [Wed, 30 Nov 2022 05:22:33 +0000 (13:22 +0800)]
[X86] combine-and.ll - add test coverage for scalar broadcast

Reviewed By: RKSimon, pengfei

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

23 months agoFix obvious typo
Gabriel F. T. Gomes [Wed, 30 Nov 2022 05:21:33 +0000 (13:21 +0800)]
Fix obvious typo

The -fcf-protection option takes an optional argument, which allows the
requesting of control-flow protection on returns, or on indirect jumps
and calls, or both. One of the comments in the code applies to returns,
yet it mentions branches (for indirect calls and jumps). This patch
fixes this obvious typo.

Reviewed By: pengfei

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

23 months ago[perf-training] Support additional test suffixes
Petr Hosek [Wed, 30 Nov 2022 03:10:07 +0000 (03:10 +0000)]
[perf-training] Support additional test suffixes

.cc and .test are commonly used and supported by other lit test suites.

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

23 months ago[IR][NFC] Adds Instruction::insertAt() for inserting at a specific point in the instr...
Vasileios Porpodas [Mon, 28 Nov 2022 22:38:38 +0000 (14:38 -0800)]
[IR][NFC] Adds Instruction::insertAt() for inserting at a specific point in the instr list.

Currently the only way to do this is to work with the instruction list directly.
This is part of a series of cleanup patches towards making BasicBlock::getInstList() private.

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

23 months ago[mlir][linalg] Changing the positions of introduced parallel loop in SplitReduction...
Murali Vijayaraghavan [Wed, 30 Nov 2022 03:50:58 +0000 (03:50 +0000)]
[mlir][linalg] Changing the positions of introduced parallel loop in SplitReduction to be consistent with IREE's downstream passes

IREE's passes depend on the behavior of SplitReduction's introduced
parallel loop being the same as the introduced dimension in the
intermediate tensor (the order of loops was changed in
https://reviews.llvm.org/D137478).

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

23 months ago[X86] include cmpccxaddintrin.h from immintrin.h to x86gprintrin.h
Freddy Ye [Wed, 30 Nov 2022 02:40:01 +0000 (10:40 +0800)]
[X86] include cmpccxaddintrin.h from immintrin.h to x86gprintrin.h

Reviewed By: LuoYuanke, pengfei

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

23 months ago[scudo] Do not consider releasing unallocated pages
Petr Hosek [Wed, 30 Nov 2022 02:34:46 +0000 (02:34 +0000)]
[scudo] Do not consider releasing unallocated pages

We already know that there are no free blocks above Region->AllocatedUser.
This results in a smaller RegionPageMap and faster releaseFreeMemoryToOS.

Patch By: fabio-d
Differential Revision: https://reviews.llvm.org/D138794

23 months ago[clang-doc] Fix warnings about lock_guard
Petr Hosek [Wed, 30 Nov 2022 02:30:40 +0000 (02:30 +0000)]
[clang-doc] Fix warnings about lock_guard

Fixes a warning about a potentially unsupported template argument
deduction by explicitly specifying the template type in std::lock_guard.

Patch By: brettw
Differential Revision: https://reviews.llvm.org/D138961

23 months ago[InstSimplify] Fold (X || Y) ? X : Y --> X
chenglin.bi [Wed, 30 Nov 2022 02:10:45 +0000 (10:10 +0800)]
[InstSimplify] Fold (X || Y) ? X : Y --> X

(X || Y) ? X : Y --> X
https://alive2.llvm.org/ce/z/oRQJee

Reviewed By: spatel

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

23 months ago[RISCV] Preserve chain output when selecting splat as x0 strided load.
Craig Topper [Tue, 29 Nov 2022 23:18:35 +0000 (15:18 -0800)]
[RISCV] Preserve chain output when selecting splat as x0 strided load.

We need the vlse node to have a chain output and it should replace
the chain output of the original load.

23 months ago[NFC] Removed call to getInstList() from range loops on BBs.
Vasileios Porpodas [Wed, 23 Nov 2022 21:30:03 +0000 (13:30 -0800)]
[NFC] Removed call to getInstList() from range loops on BBs.

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

23 months ago[ADT] Add `zip_equal` for iteratees of equal lengths
Jakub Kuderski [Wed, 30 Nov 2022 00:56:23 +0000 (19:56 -0500)]
[ADT] Add `zip_equal` for iteratees of equal lengths

Add a new version of `zip` that assumes that all iteratees have equal
lengths. The difference compared to `zip_first` is that `zip_equal`
checks this assumption in builds with assertions enabled.

This will allow us to clearly express the intent when working with
equally-sized ranges without having to write this assertion manually.

This is similar to Python's `zip(..., equal=True)` [1] or
`more_itertools.zip_equal` [2].

I saw this first suggested by @benvanik.

[1] https://peps.python.org/pep-0618/
[2] https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.zip_equal

Reviewed By: dblaikie

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

23 months ago[ADT] Clarify `zip` behavior with iteratees of different lengths
Jakub Kuderski [Wed, 30 Nov 2022 00:50:15 +0000 (19:50 -0500)]
[ADT] Clarify `zip` behavior with iteratees of different lengths

Update the documentation comment and add a new test case.

Add an assertion in `zip_first` checking the iteratee length precondition.

Reviewed By: dblaikie

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

23 months ago[RISCV][CodeGen] Account for LMUL for Vector Fixed-Point Arithmetic Instructions
Michael Maitland [Thu, 3 Nov 2022 16:37:00 +0000 (09:37 -0700)]
[RISCV][CodeGen] Account for LMUL for Vector Fixed-Point Arithmetic Instructions

It is likley that subtargets act differently for vector fixed-point arithmetic instructions based on the LMUL.
This patch creates seperate SchedRead, SchedWrite, WriteRes, ReadAdvance for each relevant LMUL.

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

23 months ago[FuzzMutate] SinkInstructionStrategy
Peter Rong [Tue, 29 Nov 2022 21:41:02 +0000 (13:41 -0800)]
[FuzzMutate] SinkInstructionStrategy

Randomlly select an instruction and try to use it in the future by replacing it with another instruction's operand.

Reviewed By: arsenm

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

23 months agoAMDGPU: Convert some cast tests to opaque pointers
Matt Arsenault [Tue, 29 Nov 2022 23:41:50 +0000 (18:41 -0500)]
AMDGPU: Convert some cast tests to opaque pointers

23 months ago[libc++][math.h] move #undefs to the top and guard explicitly against MSVCRT instead
Nikolas Klauser [Fri, 4 Nov 2022 19:19:20 +0000 (20:19 +0100)]
[libc++][math.h] move #undefs to the top and guard explicitly against MSVCRT instead

Reviewed By: ldionne, #libc

Spies: #libc_vendors, EricWF, libcxx-commits

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

23 months ago[libc++][math.h] Use builtins for all the functions
Nikolas Klauser [Thu, 20 Oct 2022 23:41:22 +0000 (01:41 +0200)]
[libc++][math.h] Use builtins for all the functions

This allows compiling libc++, even when the C library doesn't support floating point math.

Reviewed By: ldionne, #libc

Spies: daltenty, xingxue, libcxx-commits, michaelplatings

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

23 months ago[libc++] Install llvm-dev in the docker image
Nikolas Klauser [Fri, 25 Nov 2022 17:25:05 +0000 (18:25 +0100)]
[libc++] Install llvm-dev in the docker image

This is required to compile custom clang-tidy checks

Reviewed By: Mordante, #libc

Spies: libcxx-commits, arichardson

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

23 months ago[mlir][tensor] Enhance the verifier of pack and unpack op.
Hanhan Wang [Tue, 29 Nov 2022 19:38:15 +0000 (11:38 -0800)]
[mlir][tensor] Enhance the verifier of pack and unpack op.

The outer_dims_perm must be a permutation or empty.

Reviewed By: chelini

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

23 months agoAMDGPU: Convert some bit operation tests to opaque pointers
Matt Arsenault [Tue, 29 Nov 2022 23:26:06 +0000 (18:26 -0500)]
AMDGPU: Convert some bit operation tests to opaque pointers

23 months agoAMDGPU: Fix creating illegal f16 fp_class
Matt Arsenault [Tue, 29 Nov 2022 01:18:10 +0000 (20:18 -0500)]
AMDGPU: Fix creating illegal f16 fp_class

We were missing legality checks. The device library build was broken
for targets without f16 support. Technically the first pattern isn't
tested by this patch; it only triggers with the isBeforeLegalize check
in performAndCombine removed. I'm not sure how to trick this into
appearing post-legalization.

23 months agoAMDGPU: Bulk update some call tests to use opaque pointers
Matt Arsenault [Tue, 29 Nov 2022 23:10:38 +0000 (18:10 -0500)]
AMDGPU: Bulk update some call tests to use opaque pointers

23 months agoAMDGPU: Bulk update some generic intrinsic tests to opaque pointers
Matt Arsenault [Fri, 25 Nov 2022 03:53:12 +0000 (22:53 -0500)]
AMDGPU: Bulk update some generic intrinsic tests to opaque pointers

Done purely with the script.

23 months agoAMDGPU: Convert amdgpu-alias-analysis.ll to opaque pointers
Matt Arsenault [Tue, 29 Nov 2022 22:54:34 +0000 (17:54 -0500)]
AMDGPU: Convert amdgpu-alias-analysis.ll to opaque pointers

This one was slightly tricky. The AA debug printing usually, but not
always, uses the old pointer syntax. Also, we need to stop folding out
0 index GEPs in a few of these cases.

23 months agoAMDGPU: Convert some fp op tests to opaque issues
Matt Arsenault [Tue, 29 Nov 2022 22:49:58 +0000 (17:49 -0500)]
AMDGPU: Convert some fp op tests to opaque issues

fmax_legacy.ll had one test that produced "ptraddrspace(1)", since
somehow "i1addrspace(1)*" used to parse.

23 months ago[Hexagon] Fix unused variable warning in Release builds. NFC
Benjamin Kramer [Tue, 29 Nov 2022 23:00:43 +0000 (00:00 +0100)]
[Hexagon] Fix unused variable warning in Release builds. NFC

23 months ago[clang-doc] Move file layout to the generators.
Brett Wilson [Tue, 29 Nov 2022 20:35:58 +0000 (12:35 -0800)]
[clang-doc] Move file layout to the generators.

Previously file naming and directory layout was handled on a per Info
object basis by ClangDocMain and the generators blindly wrote to the
files given. This means all generators must use the same file layout and
caused problems where multiple objects mapped to the same file. The
object collision problem happens most easily with template
specializations because the template parameters are not part of the
"name".

This patch moves the responsibility for output file organization to the
generators. Currently HTML and MD use the same structure as before. But
they now collect all objects that map to a given file and combine them,
avoiding the corruption problems.

Converts the YAML generator to naming files based on USR in one
directory. This is easier for downstream tools to manage and avoids the
naming problems with template specializations. Since this change
requires backward-incompatible output changes to referenced files anyway
(since each one is now an array), this is a good time to introduce this
change.

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

23 months ago[libc++][ranges][NFC] Revamp the Ranges status page
varconst [Tue, 29 Nov 2022 22:07:44 +0000 (14:07 -0800)]
[libc++][ranges][NFC] Revamp the Ranges status page

Focus on the not-yet-implemented features: remove most details about the
already-implemented C++20 stuff, list out the major C++23 additions.

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

23 months ago[clang][darwin] Use consistent version define stringifying logic for different Darwin...
Alex Lorenz [Tue, 29 Nov 2022 22:13:39 +0000 (14:13 -0800)]
[clang][darwin] Use consistent version define stringifying logic for different Darwin OSes

23 months ago[Hexagon] Further improve code generation for shuffles
Krzysztof Parzyszek [Thu, 24 Nov 2022 15:05:10 +0000 (07:05 -0800)]
[Hexagon] Further improve code generation for shuffles

* Concatenate partial shuffles into longer ones whenever possible:
In selection DAG, shuffle's operands and return type must all agree. This
is not the case in LLVM IR, and non-conforming IR-level shuffles will be
rewritten to match DAG's requirements. This can also make a shuffle that
can be matched to a single HVX instruction become shuffles that require
more complex handling. Example: anything that takes two single vectors
and returns a pair (e.g. V6_vshuffvdd).
This is avoided by concatenating such shuffles into ones that take a vector
pair, and an undef pair, and produce a vector pair.

* Recognize perfect shuffles when masks contain `undef` values.

* Use funnel shifts for contracting shuffles.

* Recognize rotations as a separate step.

These changes go into a single commit, because each one on their own
introduced some regressions.

23 months ago[AIX][LTO] Properly respect LDR_CNTRL and set MAXDATA32 to 0xA0000000@DSA.
Wael Yehia [Tue, 29 Nov 2022 20:43:04 +0000 (20:43 +0000)]
[AIX][LTO] Properly respect LDR_CNTRL and set MAXDATA32 to 0xA0000000@DSA.

Reviewed By: rzurob

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

23 months agoupdate_test_checks: fix typos
Nicolai Hähnle [Tue, 29 Nov 2022 22:08:47 +0000 (23:08 +0100)]
update_test_checks: fix typos

Found by our downstream CI.

23 months ago[libc++] Add a missing include to `swap_allocator.h`.
Konstantin Varlamov [Tue, 29 Nov 2022 21:54:20 +0000 (13:54 -0800)]
[libc++] Add a missing include to `swap_allocator.h`.

Also add tests for the file.

Reviewed By: #libc, ldionne

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

23 months ago[InstCombine] Revert D125845
William Huang [Tue, 29 Nov 2022 21:49:44 +0000 (21:49 +0000)]
[InstCombine] Revert D125845

Reverting D125845 `[InstCombine] Canonicalize GEP of GEP by swapping constant-indexed GEP to the back` because multiple users reported performance regression

Reviewed By: davidxl

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

23 months ago[clang] [test] Fix recently pushed mingw tests in some environments
Martin Storsjö [Tue, 29 Nov 2022 21:56:50 +0000 (23:56 +0200)]
[clang] [test] Fix recently pushed mingw tests in some environments

Account for backslashes in paths in mingw.cpp.

Testing clang with the <triple>-clang form seems to require the
x86 target to be enabled, when the triple is an x86 triple. Just
skip that aspect of the test, since the "clang --target=<triple>"
form should give enough test coverage here.

23 months agoAMDGPU: Remove unused variables. NFC
Benjamin Kramer [Tue, 29 Nov 2022 21:57:00 +0000 (22:57 +0100)]
AMDGPU: Remove unused variables. NFC

23 months ago[PowerPC] Fix vperm codegen
Maryam Moghadas [Fri, 25 Nov 2022 21:58:00 +0000 (15:58 -0600)]
[PowerPC] Fix vperm codegen

Commit rG934d5fa2b8672695c335deed0e19d0e777c98403 changed the vperm codegen
for cases that vperm is not replaced by xxperm, this patch is to revert that.

Reviewed By: stefanp

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

23 months agoRevert "enable code-object-version=5"
Ron Lieberman [Tue, 29 Nov 2022 21:21:09 +0000 (15:21 -0600)]
Revert "enable code-object-version=5"

very sorry wrong repo.

This reverts commit d882ba7aeac4b496dccd1b10cb58bd691786b691.

23 months agoRevert "Add mean_anyway to hpc config"
Ron Lieberman [Tue, 29 Nov 2022 21:19:44 +0000 (15:19 -0600)]
Revert "Add mean_anyway to hpc config"

my bad, wrong repo ,so sorry.

This reverts commit 0b9350f3da7daf1d740bbbfab79d01613fcd29f4.

23 months ago[clang][driver][darwin] Enforce consistent major version limit for any Darwin OS
Alex Lorenz [Tue, 29 Nov 2022 21:12:22 +0000 (13:12 -0800)]
[clang][driver][darwin] Enforce consistent major version limit for any Darwin OS

Limit can also be bumped up to 999 to allow OS versions over 100

23 months ago[openmp] [test] Use stdint.h instead of manual code defining kmp_int*. NFC.
Martin Storsjö [Mon, 28 Nov 2022 15:08:05 +0000 (17:08 +0200)]
[openmp] [test] Use stdint.h instead of manual code defining kmp_int*. NFC.

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

23 months agoReapply [openmp] [test] XFAIL many-microtask-args.c on ARM
Martin Storsjö [Fri, 25 Nov 2022 14:26:50 +0000 (16:26 +0200)]
Reapply [openmp] [test] XFAIL many-microtask-args.c on ARM

On ARM, a C fallback version of __kmp_invoke_microtask is used,
which only handles up to a fixed number of arguments - while
many-microtask-args.c tests that the function can handle an
arbitrarily large number of arguments (the testcase produces 17
arguments).

On the CMake level, we can't add ${LIBOMP_ARCH} directly to
OPENMP_TEST_COMPILER_FEATURES in OpenMPTesting.cmake, since
that file is parsed before LIBOMP_ARCH is set. Instead
convert the feature list into a proper CMake list, and append
${LIBOMP_ARCH} into it before serializing it to an Python array.

Reapply: Make sure OPENMP_TEST_COMPILER_FEATURES is defined
properly in all other test subdirectories other than
runtime/test too.

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

23 months ago[clang] [MinGW] Improve detection of libstdc++ headers on Fedora
Martin Storsjö [Tue, 22 Nov 2022 12:39:39 +0000 (14:39 +0200)]
[clang] [MinGW] Improve detection of libstdc++ headers on Fedora

There's some variation in where different toolchain distributions
(and linux distributions) package the mingw sysroots - this is
so far handled by adding specific known subdirectory paths
to the include and lib directory lists.

There are multiple degrees of combinatorics involved here though;
the distros may use different locations such as
/usr/x86_64-w64-mingw32/include or
/usr/x86_64-w64-mingw32/sys-root/mingw/include.

So far, this setup has been treated as base=/usr, subdir=x86_64-w64-mingw32,
and the driver tries to add further subdirectories such as
<base>/<subdir>/include, <base>/<subdir>/sys-root/mingw/include.

When it comes to libstdc++ (and libc++), each of these come with
a large number of potential subdirectories. Instead of further
exploding the combinatorics another step by adding all combinations
of all paths, check whether <base>/<subdir>/sys-root/mingw/include
exists, and if it does, append that subpath into the subdir variable.

This allows finding libstdc++ headers in e.g.
/usr/x86_64-w64-mingw32/sys-root/mingw/include/c++/x86_64-w64-mingw32
on Fedora.

The same logic (where everything belonging to this target fits
under one expanded <subdir> path, with just /include and /lib
under it) doesn't seem to apply on Gentoo, where the includes
are found in <base>/<subdir>/usr/include while the libraries
are in <base>/<subdir>/mingw/lib (see
8e218026f8d5eabfdef9141ae5e26aa91d1933e6). But apparently
the libstdc++ headers aren't installed under
<base>/<subdir>/usr/include, so that path hierarchy quirk doesn't
need to be taken into account in AddClangCXXStdlibIncludeArgs.

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

23 months ago[clang] [MinGW] Improve/extend the gcc/sysroot detection logic
Martin Storsjö [Tue, 22 Nov 2022 12:38:54 +0000 (14:38 +0200)]
[clang] [MinGW] Improve/extend the gcc/sysroot detection logic

There are three functions that try to detect the right implicit
sysroot and libgcc directory setup to use
- One which looks for mingw sysroots located in
  <clangbin>/../<sysrootname>
- One which looks for a mingw-targeting gcc executables in the PATH
- One which looks in the <gccroot>/lib/gcc directory to find the
  right one to use, and the right specific triple used for arch
  specific directories in the gcc/libstdc++ install

These have mostly tried to look for executables named
"<arch>-w64-mingw32-gcc" or "mingw32-gcc" or subdirectories
named "<arch>-w64-mingw32" or "mingw32".

In the case of findClangRelativeSysroot, it also has looked
for directories with the name of the actual triple. This
was added in deff7536278d355977171726124f83aa4bb95419,
with the intent of looking for a directory matching exactly
the user provided literal triple - however the triple here
is the normalized one, not the one provided by the user on
the command line.

Improve and unify this logic somewhat:
- Always first look for things based on the literal triple
  provided by the user.
- Secondly look for things based on the normalized triple
  (which usually ends up as e.g. x86_64-w64-windows-gnu),
  accessed via the Triple which is passed to the constructor
- Then look for the common triple form <arch>-w64-mingw32

The literal triple provided by the user is available via
Driver::getTargetTriple(), but computeTargetTriple() may
change e.g. the architecture of it, so we need to
reapply the effective architecture on the literal triple
spelling from Driver::getTargetTriple().

Do this consistently for all of findGcc, findClangRelativeSysroot
and findGccLibDir (while keeping the existing plain "mingw32"
cases in findGcc and findGccLibDir too).

Fedora 37 started shipping mingw sysroots targeting UCRT,
in addition to the traditional msvcrt.dll, and these use
triples in the form <arch>-w64-mingw32ucrt - see
https://fedoraproject.org/wiki/Changes/F37MingwUCRT.

Thus, in addition to the existing default tested triples,
try looking for triples in the form <arch>-w64-mingw32ucrt,
to automatically find the UCRT sysroots on Fedora 37.
By explicitly setting a specific target on the Clang command
line, the user can be more explicit with which flavour is
to be preferred.

This should fix the main issue in
https://github.com/llvm/llvm-project/issues/59001.

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

23 months agoAMDGPU: Remove BufferPseudoSourceValue
Nicolai Hähnle [Fri, 25 Nov 2022 06:21:54 +0000 (07:21 +0100)]
AMDGPU: Remove BufferPseudoSourceValue

The use of a PSV for buffer intrinsics is misleading because it may be
misinterpreted as all buffer intrinsics accessing the same address in
memory, which is clearly not true.

Instead, build MachineMemOperands without a pointer value but with an
address space, so that address space-based alias analysis can still
work.

There is a lot of test churn because previously address space 4
(constant address space) was used as an address space for buffer
intrinsics. This doesn't make much sense and seems to have been an
accident -- see the change in
AMDGPUTargetMachine::getAddressSpaceForPseudoSourceKind.

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

23 months agoAdd mean_anyway to hpc config
Ron Lieberman [Tue, 29 Nov 2022 21:11:48 +0000 (15:11 -0600)]
Add mean_anyway to hpc config

23 months agoenable code-object-version=5
Ron Lieberman [Tue, 29 Nov 2022 20:12:05 +0000 (14:12 -0600)]
enable code-object-version=5

23 months ago[FuzzMutate] Fix a bug in `connectToSink` which might invalidate the whole module.
Peter Rong [Tue, 29 Nov 2022 03:50:59 +0000 (19:50 -0800)]
[FuzzMutate] Fix a bug in `connectToSink` which might invalidate the whole module.

`connectToSink` uses a value by putting it in a future instruction.
It will replace the operand of a future instruction with the current value.

However, if current value is an `Instruction` and put into a switch case, the module is invalid.
We fix that by only connecting to Br/Switch's condition, and don't touch other operands.

Will have other strategies to mutate other Br/Switch operands to be patched once this patch is passed

Reviewed By: arsenm

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

23 months ago[libc] Fix test not including 'free'
Joseph Huber [Tue, 29 Nov 2022 21:03:00 +0000 (15:03 -0600)]
[libc] Fix test not including 'free'

Summary:
A previous change removed a transient inclusion of `stdlib.h` from the
`string_utils.h` file which this test depended on. Include it directly
here.

23 months ago[msan] Increase size of app/shadow/origin mappings on aarch64
Thurston Dang [Tue, 8 Nov 2022 20:53:20 +0000 (20:53 +0000)]
[msan] Increase size of app/shadow/origin mappings on aarch64

msan's app memory mappings for aarch64 are constrained by
the MEM_TO_SHADOW constant to 64GB or less, and some app
memory mappings (in kMemoryLayout) are even smaller in
practice. This will lead to a crash with the error message
"MemorySanitizer can not mmap the shadow memory" if the
executable's memory mappings (e.g., libraries) extend
beyond msan's app memory mappings.

This patch makes the app/shadow/origin memory mappings
considerably larger, along with corresponding changes to
the MEM_TO_SHADOW and SHADOW_TO_ORIGIN constants.

Note that this deprecates compatibility with 39- and 42-bit
VMAs.

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

23 months ago[libc][docs] Add documentation for the new GPU mode
Joseph Huber [Mon, 28 Nov 2022 20:54:30 +0000 (14:54 -0600)]
[libc][docs] Add documentation for the new GPU mode

This patch introduces documentation for the new GPU mode added in
D138608. The documentation includes instructions for building and using
the library, along with a description of the supported functions and
headers.

Reviewed By: sivachandra, lntue, michaelrj

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

23 months ago[libc] Add initial support for a libc implementation for the GPU
Joseph Huber [Tue, 22 Nov 2022 20:45:38 +0000 (14:45 -0600)]
[libc] Add initial support for a libc implementation for the GPU

This patch contains the initial support for building LLVM's libc as a
target for the GPU. Currently this only supports a handful of very basic
functions that can be implemented without an operating system. The GPU
code is build using the existing OpenMP toolchain. This allows us to
minimally change the existing codebase and get a functioning static
library. This patch allows users to create a static library called
`libcgpu.a` that contains fat binaries containing device IR.

Current limitations are the lack of test support and the fact that only
one target OS can be built at a time. That is, the user cannot get a
`libc` for Linux and one for the GPU simultaneously.

This introduces two new CMake variables to control the behavior
`LLVM_LIBC_TARET_OS` is exported so the user can now specify it to equal
`"gpu"`. `LLVM_LIBC_GPU_ARCHITECTURES` is also used to configure how
many targets to build for at once.

Depends on D138607

Reviewed By: sivachandra

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

23 months ago[libc] Move strdup implementation to a new header
Joseph Huber [Tue, 22 Nov 2022 20:59:13 +0000 (14:59 -0600)]
[libc] Move strdup implementation to a new header

The `strdup` family of functions rely on `malloc` to be implemented.
Its presence in the `string_utils.h` header meant that compiling many of
the string functions relied on `malloc` being implementated as well.
This patch simply moves the implementation into a new file to avoid
including `stdlib.h` from the other string functions. This was a barrier
for compiling string functions for the GPU where there is no malloc
currently.

Reviewed By: sivachandra

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

23 months ago[gn build] Port 185d4964a158
LLVM GN Syncbot [Tue, 29 Nov 2022 20:47:01 +0000 (20:47 +0000)]
[gn build] Port 185d4964a158

23 months ago[lldb] Introduce dwim-print command
Dave Lee [Fri, 18 Nov 2022 01:11:30 +0000 (17:11 -0800)]
[lldb] Introduce dwim-print command

Implements `dwim-print`, a printing command that chooses the most direct,
efficient, and resilient means of printing a given expression.

DWIM is an acronym for Do What I Mean. From Wikipedia, DWIM is described as:

  > attempt to anticipate what users intend to do, correcting trivial errors
  > automatically rather than blindly executing users' explicit but
  > potentially incorrect input

The `dwim-print` command serves as a single print command for users who don't
yet know, or prefer not to know, the various lldb commands that can be used to
print, and when to use them.

This initial implementation is the base foundation for `dwim-print`. It accepts
no flags, only an expression. If the expression is the name of a variable in
the frame, then effectively `frame variable` is used to get, and print, its
value. Otherwise, printing falls back to using `expression` evaluation. In this
initial version, frame variable paths will be handled with `expression`.

Following this, there are a number of improvements that can be made. Some
improvements include supporting `frame variable` expressions or registers.

To provide transparency, especially as the `dwim-print` command evolves, a new
setting is also introduced: `dwim-print-verbosity`. This setting instructs
`dwim-print` to optionally print a message showing the effective command being
run. For example `dwim-print var.meth()` can print a message such as: "note:
ran `expression var.meth()`".

See https://discourse.llvm.org/t/dwim-print-command/66078 for the proposal and
discussion.

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

23 months ago[mlir][sparse] Improve concatenate operator rewrite for annotated all dense dimension...
bixia1 [Tue, 29 Nov 2022 17:19:24 +0000 (09:19 -0800)]
[mlir][sparse] Improve concatenate operator rewrite for annotated all dense dimensions results.

Reviewed By: aartbik

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

23 months ago[Windows] Convert llvm/test/ExecutionEngine/MCJIT/remote tests to check 'target=...
Paul Robinson [Tue, 29 Nov 2022 20:18:38 +0000 (12:18 -0800)]
[Windows] Convert llvm/test/ExecutionEngine/MCJIT/remote tests to check 'target=<triple>'

Part of the project to eliminate special handling for triples in lit
expressions.

23 months ago[Hexagon] Simplify logic for generating code for contracting shuffles
Krzysztof Parzyszek [Tue, 29 Nov 2022 16:32:03 +0000 (08:32 -0800)]
[Hexagon] Simplify logic for generating code for contracting shuffles

Add functions that generate masks for the HVX instructions we were
targeting. This is both simpler than analyzing the masks, and these
functions may also be used in other places.

23 months ago[Windows] Convert clang/test/Modules tests to check 'target=<triple>'
Paul Robinson [Tue, 29 Nov 2022 20:14:10 +0000 (12:14 -0800)]
[Windows] Convert clang/test/Modules tests to check 'target=<triple>'

Part of the project to eliminate special handling for triples in lit
expressions.

23 months agoRevert "[SystemZ] change test to mir to better isolate miscompile; NFC"
Sanjay Patel [Tue, 29 Nov 2022 20:05:46 +0000 (15:05 -0500)]
Revert "[SystemZ] change test to mir to better isolate miscompile; NFC"

This reverts commit 8076c70d6a2a21d18713458996732f5231d61f43.
After discussion in D137791, a test that shows a miscompile
is better than the more isolated test for a transform (that
may not be wrong in all cases).

23 months ago[RISCV] Add test coverage for vector constant materialization costs on arithmetic...
Philip Reames [Tue, 29 Nov 2022 19:54:09 +0000 (11:54 -0800)]
[RISCV] Add test coverage for vector constant materialization costs on arithmetic instructions

23 months ago[clang] Fix buildbot failure in delayed-template-with-pragma.cpp
Mike Rice [Tue, 29 Nov 2022 19:41:09 +0000 (11:41 -0800)]
[clang] Fix buildbot failure in delayed-template-with-pragma.cpp

Use captured values to match loop metadata.

23 months ago[RISCV] Add cost model coverage for vector arithmetic
Philip Reames [Tue, 29 Nov 2022 19:46:06 +0000 (11:46 -0800)]
[RISCV] Add cost model coverage for vector arithmetic

23 months ago[flang] Use BaseBoxType in component by component assignment
Valentin Clement [Tue, 29 Nov 2022 19:44:42 +0000 (20:44 +0100)]
[flang] Use BaseBoxType in component by component assignment

Use BaseBoxType in `genComponentByComponentAssignment`
so the component by component assignment involving polymorphic entities
does not fall back to scalar assignment.

Reviewed By: PeteSteinfeld

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

23 months agoAdd test coverage for more C DRs
Aaron Ballman [Tue, 29 Nov 2022 19:43:45 +0000 (14:43 -0500)]
Add test coverage for more C DRs

This completes the initial pass over all of the C DRs.

23 months ago[AMDGPU] Unify uniform return and divergent unreachable blocks
Brendon Cahoon [Thu, 27 Oct 2022 21:27:50 +0000 (16:27 -0500)]
[AMDGPU] Unify uniform return and divergent unreachable blocks

This patch fixes a "failed to annotate CFG" error in
SIAnnotateControlFlow. The problem occurs when there are
divergent and uniform unreachable/return blocks in the same
region. In this case, AMDGPUUnifyDivergentExitNodes does not
create a unified block so the region contains multiple exits.

StructurizeCFG does not work properly when there are multiple
exits, so the neccessary CFG transformations do not occur along
divergent control flow. Subsequently, SIAnnotateControlFlow
processes the path to the divergent exit block, but may only
partially process blocks along a unform control flow path to
another exit block.

This patch fixes the bug by creating a single exit block when
there is a divergent exit block in the function.

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

23 months ago[OpenMP][OMPIRBuilder] Migrate target outlined function registration to OMPIRBuilder...
Jan Sjodin [Mon, 7 Nov 2022 20:27:50 +0000 (15:27 -0500)]
[OpenMP][OMPIRBuilder] Migrate target outlined function registration to OMPIRBuilder from clang

This patch moves the outlined function registration, function attribute
configuration and function ID creation to the OpenMPIRBuilder. This will later
be used by flag as well.

Reviewed By: jdoerfert

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

23 months ago[lld-macho] Reject -no_pie for unsupported archs
Keith Smiley [Tue, 29 Nov 2022 01:44:53 +0000 (17:44 -0800)]
[lld-macho] Reject -no_pie for unsupported archs

ld64 rejects `-no_pie` when targeting arm64, this mirrors that behavior.
Newer versions of ld64 also reject it based on minimum OS versions, but
that logic isn't in an open source dump yet so it isn't implemented
here.

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

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

23 months ago[flang][doc] Remove DCMPLX intrinsic from the Intrinsic Procedures Lacking Support...
Kelvin Li [Mon, 28 Nov 2022 19:45:10 +0000 (14:45 -0500)]
[flang][doc] Remove DCMPLX intrinsic from the Intrinsic Procedures Lacking Support list

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

23 months ago[WebAssembly] Move debug tests into DebugInfo
Heejin Ahn [Mon, 28 Nov 2022 23:28:14 +0000 (15:28 -0800)]
[WebAssembly] Move debug tests into DebugInfo

This moves debug info tests in `test/CodeGen/WebAssembly` into
`test/DebugInfo/WebAssembly`, to gather all wasm debug info related
tests there.

Reviewed By: dschuff

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

23 months ago[BOLT] Fix unused function warnings
Kazu Hirata [Tue, 29 Nov 2022 19:13:14 +0000 (11:13 -0800)]
[BOLT] Fix unused function warnings

This patch fixes:

  bolt/lib/Passes/CallGraph.cpp:27:15: error: unused function
  'hash_int64_fallback' [-Werror,-Wunused-function]

  bolt/lib/Passes/CallGraph.cpp:40:15: error: unused function
  'hash_int64' [-Werror,-Wunused-function]

23 months ago[libc++abi][LIT][AIX] Use Vector instructions available on Power7 in vec_reg_restore...
Xing Xue [Tue, 29 Nov 2022 19:08:03 +0000 (14:08 -0500)]
[libc++abi][LIT][AIX] Use Vector instructions available on Power7 in vec_reg_restore.pass.cpp

Summary:
libc++abi LIT test case vec_reg_restore.pass.cpp for AIX uses instructions mtvsrd and mfvsrd that are only available on Power8 CPU and higher, and therefore, fails on Power7 which is supported by the current AIX Clang. This patch replaces mtvsrd/mfvsrd with vector instructions available on Power7.

Reviewed by: nemanjai

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

23 months ago[RISCV] Separate out helper for checking if vector splat supported for operand [nfc]
Philip Reames [Tue, 29 Nov 2022 19:05:04 +0000 (11:05 -0800)]
[RISCV] Separate out helper for checking if vector splat supported for operand [nfc]

23 months ago[flang] Add support for LSHIFT and RSHIFT intrinsics
Kelvin Li [Mon, 28 Nov 2022 19:02:16 +0000 (14:02 -0500)]
[flang] Add support for LSHIFT and RSHIFT intrinsics

The functionality of LSHIFT and RSHIFT intrinsics is the same as the
standard SHIFTL and SHIFTA intrinsics respectively. The patch is to
alias the two intrinsics to the standardized ones.

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

23 months ago[NFC][asan] Simplify parameters check
Vitaly Buka [Mon, 28 Nov 2022 00:24:05 +0000 (16:24 -0800)]
[NFC][asan] Simplify parameters check