platform/upstream/llvm.git
2 years ago[OpenMP] libomp: Fix crash if application send us negative thread_limit value
AndreyChurbanov [Wed, 8 Dec 2021 16:02:57 +0000 (19:02 +0300)]
[OpenMP] libomp: Fix crash if application send us negative thread_limit value

Regardless that specification requires thread_limit to be positive,
it is better to warn user instead of crash in case the value is negative.

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

2 years ago[dexter] Fix source-root-dir unittests on Windows
Tom Weaver [Wed, 8 Dec 2021 15:35:48 +0000 (15:35 +0000)]
[dexter] Fix source-root-dir unittests on Windows

These tests were spuriously failing on Windows due to path separators getting
flipped from `/` to `\\`  in various parts of dexter:

test_add_breakpoint_with_source_root_dir
test_get_step_info
test_get_step_info_no_source_root_dir

Tested on Windows and Linux.

Patch written by @TWeaver.

Reviewed By: jmorse

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

2 years ago[ARM] Peek through And 1 in IsCMPZCSINC
David Green [Wed, 8 Dec 2021 15:40:23 +0000 (15:40 +0000)]
[ARM] Peek through And 1 in IsCMPZCSINC

We can be in situations where And 1 zext nodes will not have been yet,
preventing us from detecting removable cmpz/csinc patterns. This peeks
through those nodes allowing us to simplify more code.

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

2 years ago[InstCombine] try to fold div with constant dividend and select-of-constants divisor
Sanjay Patel [Wed, 8 Dec 2021 15:03:52 +0000 (10:03 -0500)]
[InstCombine] try to fold div with constant dividend and select-of-constants divisor

We avoid this fold in the more general cases where we use FoldOpIntoSelect.
That's because -- unlike most binary opcodes -- 'div' can't usually be
speculated with a variable divisor since it can have immediate UB. But in
the case where both arms of the select are constants, we can safely evaluate
both sides and eliminate 'div' completely.

This is a follow-up to the equivalent fold for 'rem' opcodes:
D115173 / f65be726ab50

2 years ago[clangd] Add fixes for clang "include <foo.h>" diagnostics
Sam McCall [Sat, 27 Nov 2021 23:33:11 +0000 (00:33 +0100)]
[clangd] Add fixes for clang "include <foo.h>" diagnostics

Clang doesn't offer these fixes I guess for a couple of reasons:
 - where to insert includes is a formatting concern, and clang shouldn't
   depend on clang-format
 - the way clang prints diagnostics, we'd show a bunch of basically irrelevant
   context of "this is where we'd want to insert the include"

Maybe it's possible to hack around 1, but 2 is still a concern.
Meanwhile, bolting this onto include-fixer gets the job done.

Fixes https://github.com/clangd/clangd/issues/355
Fixes https://github.com/clangd/clangd/issues/937

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

2 years ago[DWARF] Fix consistency and AIX compatibility of checks in DWARF test
Jake Egan [Wed, 8 Dec 2021 15:10:30 +0000 (10:10 -0500)]
[DWARF] Fix consistency and AIX compatibility of checks in DWARF test

This patch removes the white space and trailing bracket to make the checks consistent and verbose direct/indirect string agnostic for AIX compatibility.

Reviewed By: dblaikie

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

2 years ago[LAA] Use type sizes when determining dependence.
Jolanta Jensen [Mon, 6 Dec 2021 11:44:03 +0000 (11:44 +0000)]
[LAA] Use type sizes when determining dependence.

In the isDependence function the code does not try hard enough
to determine the dependence between types. If the types are
different it simply gives up, whereas in fact what we really
care about are the type sizes. I've changed the code to compare
sizes instead of types.

Reviewed By: fhahn, sdesmalen

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

2 years ago[lldb/qemu] Sort entries in QEMU_(UN)SET_ENV
Pavel Labath [Wed, 8 Dec 2021 14:51:31 +0000 (15:51 +0100)]
[lldb/qemu] Sort entries in QEMU_(UN)SET_ENV

The test for this functionality was failing on the darwin bot, because
the entries came out in opposite order. While this does not impact
functionality, and the algorithm that produces it is technically
deterministic (the nondeterminism comes from the contents of the host
environment), it seems like it would be more user-friendly if the
entries came out in a more predictible order.

Therefore I am adding the sort call to the actual code instead of
relaxing test expectations.

2 years ago[clangd] Record IWYU pragma keep in the IncludeStructure
Kirill Bobyrev [Wed, 8 Dec 2021 14:55:39 +0000 (15:55 +0100)]
[clangd] Record IWYU pragma keep in the IncludeStructure

This will allow the IncludeCleaner to suppress warnings on the lines with "IWYU
pragma: keep".

Clang APIs are not very convinient, so the code has to navigate around it.

Reviewed By: kadircet

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

2 years ago[mlir][linalg][bufferize] Add dialect filter to BufferizationOptions
Matthias Springer [Wed, 8 Dec 2021 14:26:22 +0000 (23:26 +0900)]
[mlir][linalg][bufferize] Add dialect filter to BufferizationOptions

This adds a new option `dialectFilter` to BufferizationOptions. Only ops from dialects that are allow-listed in the filter are bufferized. Other ops are left unbufferized. Note: This option requires `allowUnknownOps = true`.

To make use of `dialectFilter`, BufferizationOptions or BufferizationState must be passed to various helper functions.

The purpose of this change is to provide a better infrastructure for partial bufferization, which will be fully activated in a subsequent change.

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

2 years agoRemove Colours array in -print-changed=dot-cfg
Jamie Schmeiser [Wed, 8 Dec 2021 14:50:07 +0000 (09:50 -0500)]
Remove Colours array in -print-changed=dot-cfg

Summary:
The Colours array is apparently the source of TSAN errors. It is
unnecessary and was there to ease readability of the code. Remove it to
clean up the TSAN errors.

Author: Jamie Schmeiser <schmeise@ca.ibm.com>
Reviewed By: aeubanks (Arthur Eubanks)
Differential Revision: https://reviews.llvm.org/D115175

2 years ago[LTO] Remove default_triple requirement from tests that specify the triple
Jake Egan [Wed, 8 Dec 2021 14:16:58 +0000 (09:16 -0500)]
[LTO] Remove default_triple requirement from tests that specify the triple

The `default_triple` requirement is redundant if the test specifies the triple, so this patch removes it.

Reviewed By: hubert.reinterpretcast

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

2 years ago[libc] Fix two missing cases in 1c92911e9e1d503c0dfc4367da7f15d0dff50587
Haojian Wu [Wed, 8 Dec 2021 14:12:32 +0000 (15:12 +0100)]
[libc] Fix two missing cases in 1c92911e9e1d503c0dfc4367da7f15d0dff50587

Fix the broken build.

2 years ago[libc++] Bump Dockerfile
Louis Dionne [Wed, 8 Dec 2021 13:57:19 +0000 (08:57 -0500)]
[libc++] Bump Dockerfile

2 years ago[InstCombine][InstSimplify] Add baseline tests for icmp bool with not on LHS; NFC
Hasyimi Bahrudin [Wed, 8 Dec 2021 13:21:44 +0000 (08:21 -0500)]
[InstCombine][InstSimplify] Add baseline tests for icmp bool with not on LHS; NFC

See D114666 for proposed code change to instsimplify.

The difference between the CHECK result of these 2 tests
highlights missed folds in instsimplify
(e.g. (icmp eq (xor X, true), false) -> X) that are
already being handled by instcombine.

The tests are based on:
llvm/test/Transforms/InstSimplify/icmp-bool-constant.ll

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

2 years ago[gn build] Port 81eda008e952
LLVM GN Syncbot [Wed, 8 Dec 2021 13:42:16 +0000 (13:42 +0000)]
[gn build] Port 81eda008e952

2 years agoRemoving some unused parameters from this test; NFC
Aaron Ballman [Wed, 8 Dec 2021 13:34:38 +0000 (08:34 -0500)]
Removing some unused parameters from this test; NFC

2 years ago[libc++] Extract __clamp_to_integral to its own header
Louis Dionne [Tue, 7 Dec 2021 21:34:13 +0000 (16:34 -0500)]
[libc++] Extract __clamp_to_integral to its own header

In addition to being more consistent with our approach for helpers, this
solves an actual issue where <cmath> was using numeric_limits but never
including the <limits> header directly. In a normal setup, this is not
an issue because the <math.h> header included by <cmath> does include
<limits>. However, I did stumble upon some code where that didn't work,
most likely because they were placing their own <math.h> header in front
of ours. I didn't bother investigating further.

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

2 years agoAdd __builtin_elementwise_ceil
Jun Zhang [Wed, 8 Dec 2021 13:29:33 +0000 (08:29 -0500)]
Add __builtin_elementwise_ceil

This patch implements one of the missing builtin functions specified
in https://reviews.llvm.org/D111529.

2 years ago[lldb] Fix TestDataFormatterGenericList
Pavel Labath [Wed, 8 Dec 2021 12:38:35 +0000 (13:38 +0100)]
[lldb] Fix TestDataFormatterGenericList

Test is using "next" commands to make progress in the process. D115137
added an additional statement to the program, without adding a command
to step over it. This only seemed to matter for the libc++ flavour of
the test, possibly because libstdc++ list is "empty" in its
uninitialized state.

Since moving with step commands is a treacherous, this patch adds a
run-to-breakpoint command to the test. It only does this for the
affected step, but one may consider doing it elsewhere too.

2 years ago[lldb] Unify two versions of TestMemoryRead
Pavel Labath [Wed, 8 Dec 2021 12:25:30 +0000 (13:25 +0100)]
[lldb] Unify two versions of TestMemoryRead

Our test infrastructure does not like two tests with the same name, but
it makes sense to do it regardless, as they are testing the same
command.

2 years ago[HIPSPV] Convert HIP kernels to SPIR-V kernels
Henry Linjamäki [Wed, 8 Dec 2021 07:47:25 +0000 (10:47 +0300)]
[HIPSPV] Convert HIP kernels to SPIR-V kernels

This patch translates HIP kernels to SPIR-V kernels when the HIP
compilation mode is targeting SPIR-S. This involves:

* Setting Cuda calling convention to CC_OpenCLKernel (which maps to
  SPIR_KERNEL in LLVM IR later on).

* Coercing pointer arguments with default address space (AS) qualifier
  to CrossWorkGroup AS (__global in OpenCL). HIPSPV's device code is
  ultimately SPIR-V for OpenCL execution environment (as
  starter/default) where Generic or Function (OpenCL's private) is not
  supported as storage class for kernel pointer types. This leaves the
  CrossWorkGroup to be the only reasonable choice for HIP buffers.

Reviewed By: yaxunl

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

2 years ago[lldb/qemu] Separate host and target environments
Pavel Labath [Mon, 29 Nov 2021 10:30:23 +0000 (11:30 +0100)]
[lldb/qemu] Separate host and target environments

Qemu normally forwards its (host) environment variables to the emulated
process. While this works fine for most variables, there are some (few, but
fairly important) variables where this is not possible. LD_LIBRARY_PATH
is the probably the most important of those -- we don't want the library
search path for the emulated libraries to interfere with the libraries
that the emulator itself needs.

For this reason, qemu provides a mechanism (QEMU_SET_ENV,
QEMU_UNSET_ENV) to set variables only for the emulated process. This
patch makes use of that functionality to pass any user-provided
variables to the emulated process. Since we're piggy-backing on the
normal lldb environment-handling mechanism, all the usual mechanism to
provide environment (target.env-vars setting, SBLaunchInfo, etc.) work
out-of-the-box, and the only thing we need to do is to properly
construct the qemu environment variables.

This patch also adds a new setting -- target-env-vars, which represents
environment variables which are added (on top of the host environment)
to the default launch environments of all (qemu) targets. The reason for
its existence is to enable the configuration (e.g., from a startup
script) of the default launch environment, before any target is created.
The idea is that this would contain the variables (like the
aforementioned LD_LIBRARY_PATH) common to all targets being debugged on
the given system. The user is, of course, free to customize the
environment for a particular target in the usual manner.

The reason I do not want to use/recommend the "global" version of the
target.env-vars setting for this purpose is that the setting would apply
to all targets, whereas the settings (their values) I have mentioned
would be specific to the given platform.

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

2 years ago[VE] Change error handling of data references
Kazushi (Jam) Marukawa [Sun, 5 Dec 2021 17:25:44 +0000 (02:25 +0900)]
[VE] Change error handling of data references

Change to use Ctx.reportError() instead of llvm_unreachable for
better error handling.  Also correct evaluateAsRelocatableImpl().

Reviewed By: simoll

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

2 years ago[X86] LowerRotate - split 512-bit integers on non 512-bit BWI targets.
Simon Pilgrim [Wed, 8 Dec 2021 11:54:43 +0000 (11:54 +0000)]
[X86] LowerRotate - split 512-bit integers on non 512-bit BWI targets.

2 years ago[lldb] Add missing space in C string format memory read warning
David Spickett [Wed, 1 Dec 2021 14:56:18 +0000 (14:56 +0000)]
[lldb] Add missing space in C string format memory read warning

Also add tests to check that we print the warning in the right
circumstances.

Reviewed By: labath

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

2 years ago[SVE][InstCombine] Support more cases where ld1/st1 can be lowered to load/store...
Paul Walker [Fri, 3 Dec 2021 14:36:54 +0000 (14:36 +0000)]
[SVE][InstCombine] Support more cases where ld1/st1 can be lowered to load/store instructions.

This patch extends the "is all active predicate" check to cover
cases where the predicate is casted but in a way that doesn't
change its "all active" status.

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

2 years ago[llvm] Remove out-of-date fixme from SmallVectorMemoryBuffer
Jan Svoboda [Wed, 8 Dec 2021 10:43:43 +0000 (11:43 +0100)]
[llvm] Remove out-of-date fixme from SmallVectorMemoryBuffer

This fixme first appeared in the codebase with the introduction of `ObjectMemoryBuffer` in rG93de2a12a36feaf1e6d8ff28c76db9b6cda4e844, but the constructor appears to never have been templated.

Reviewed By: dexonsmith

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

2 years ago[clang][deps] Reset some benign codegen options
Jan Svoboda [Wed, 8 Dec 2021 10:00:15 +0000 (11:00 +0100)]
[clang][deps] Reset some benign codegen options

Some command-line codegen arguments are likely to differ between identical modules discovered from different translation units. This patch removes them to make builds deterministic and/or reduce the number of built modules.

Reviewed By: Bigcheese

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

2 years agoAdd note about inlining dllimport functions to the attribute docs
Hans Wennborg [Tue, 7 Dec 2021 16:09:44 +0000 (17:09 +0100)]
Add note about inlining dllimport functions to the attribute docs

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

2 years ago[SDAG] Refine MMO size when converting masked load/store to normal load/store
David Green [Wed, 8 Dec 2021 10:13:25 +0000 (10:13 +0000)]
[SDAG] Refine MMO size when converting masked load/store to normal load/store

After D113888 / 32b6c17b29079e7d the MMO size of a masked loads/store is
unknown. When we are converting back to a standard load/store because
the mask is known all ones, we can refine that to the correct size from
the size of the vector being loaded/stored.

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

2 years ago[ARM][libunwind] add PACBTI-M support for libunwind
Ties Stuij [Wed, 8 Dec 2021 09:44:45 +0000 (09:44 +0000)]
[ARM][libunwind] add PACBTI-M support for libunwind

This patch implements the following:

- Emit PACBTI-M build attributes in libunwind asm files

- Authenticate LR in DWARF32 using PACBTI

Use Armv8.1-M.Main PACBTI extension to authenticate the return address
(stored in the LR register) before moving it to the PC (IP) register.

The AUTG instruction is used with the candidate return address, the CFA,
and the authentication code that is retrieved from the saved
pseudo-register RA_AUTH_CODE.

- Authenticate LR in EHABI using PACBTI

Authenticate the contents of the LR register using Armv8.1-M.Main PACBTI
extension.

A new frame unwinding instruction is introduced (0xb4). This
instruction pops out of the stack the return address authentication
code, which is then used in conjunction with the SP and the next-to-be
instruction pointer to perform authentication.

This authentication code is popped into a new register,
UNW_ARM_PSEUDO_PAC, which is a pseudo-register.

This patch is part of a series that adds support for the PACBTI-M extension of
the Armv8.1-M architecture, as detailed here:

https://community.arm.com/arm-community-blogs/b/architectures-and-processors-blog/posts/armv8-1-m-pointer-authentication-and-branch-target-identification-extension

The PACBTI-M specification can be found in the Armv8-M Architecture Reference
Manual:

https://developer.arm.com/documentation/ddi0553/latest

The following people contributed to this patch:

- Momchil Velikov
- Victor Campos
- Ties Stuij

Reviewed By: #libunwind, danielkiss, mstorsjo

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

2 years ago[NFC] Only attach a declaration to global module fragment if it appears in a module
Chuanqi Xu [Wed, 8 Dec 2021 09:11:40 +0000 (17:11 +0800)]
[NFC] Only attach a declaration to global module fragment if it appears in a module

2 years agoRevert "[OpenMP][AMDGPU] Switch host-device memory copy to asynchronous version"
Jon Chesterfield [Wed, 8 Dec 2021 08:23:12 +0000 (08:23 +0000)]
Revert "[OpenMP][AMDGPU] Switch host-device memory copy to asynchronous version"

This reverts commit 6de698bf10996b532632bb9dfa9fd420c5af62af.
It didn't build in the dynamic_hsa configuration

2 years agoAllow DataLayout to support arbitrary pointer sizes
Stephen Neuendorffer [Fri, 19 Nov 2021 05:54:47 +0000 (21:54 -0800)]
Allow DataLayout to support arbitrary pointer sizes

Currently, it is impossible to specify a DataLayout with pointer
size and index size that is not a whole number of bytes.
This patch modifies
the DataLayout class to accept arbitrary pointer sizes and to
store the size as a number of bits, rather than as a number of bytes.
Generally speaking, the external interface of the class as used
by in-tree architectures remains the same and shouldn't affect the
behavior of architecures with pointer sizes equal to a whole number
of bytes.

Note the interface of setPointerAlignment has changed and takes
a pointer and index size that is a number of bits, rather than a number
of bytes.

Patch originally by Ajit Kumar Agarwal

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

2 years ago[CMake] Specify byproducts for custom libcxx builds
Petr Hosek [Wed, 8 Dec 2021 07:06:12 +0000 (23:06 -0800)]
[CMake] Specify byproducts for custom libcxx builds

These were removed in bda3f2dd763b06427dd2713aa062e356c9d7bdc6 but
are needed as it turned out for the MSan tests.

2 years ago[C++20] [Modules] [Concepts] Recognize same concepts more precisely in Serialization
Chuanqi Xu [Wed, 8 Dec 2021 06:58:44 +0000 (14:58 +0800)]
[C++20] [Modules] [Concepts] Recognize same concepts more precisely in Serialization

The compiler would judge two concepts is same by their addresses.
However, when we use modules, the addresses wouldn't be the same all the
time since one is parsed in their TU and another is imported in another
TU.
This patch fixes this by using isSameEntity to judge the two concepts.

Reviewed By: rsmith

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

2 years ago[lsan] Replace atomic_store/atomic_load with atomic_fetch_add
Vitaly Buka [Wed, 8 Dec 2021 06:39:12 +0000 (22:39 -0800)]
[lsan] Replace atomic_store/atomic_load with atomic_fetch_add

2 years ago[NFC][asan] Remove -std=c++20 from test
Vitaly Buka [Wed, 8 Dec 2021 06:35:39 +0000 (22:35 -0800)]
[NFC][asan] Remove -std=c++20 from test

Fails after D110215
with errors like
/usr/include/x86_64-linux-gnu/sys/types.h:33:9: error: unknown type name '__u_char'
typedef __u_char u_char;

2 years ago[NFC] Fix C++20 module test in PPC and warning
Chuanqi Xu [Wed, 8 Dec 2021 06:25:42 +0000 (14:25 +0800)]
[NFC] Fix C++20 module test in PPC and warning

2 years ago[clangd] Make a.k.a printing configurable.
lh123 [Wed, 8 Dec 2021 05:52:15 +0000 (13:52 +0800)]
[clangd] Make a.k.a printing configurable.

Currently, a.k.a printing is closed by default.

Reviewed By: sammccall, kadircet

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

2 years agoAdjust "end namespace" comment in MLIR to match new agree'd coding style
Mehdi Amini [Tue, 7 Dec 2021 18:27:58 +0000 (18:27 +0000)]
Adjust "end namespace" comment in MLIR to match new agree'd coding style

See D115115 and this mailing list discussion:
https://lists.llvm.org/pipermail/llvm-dev/2021-December/154199.html

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

2 years agoBuild MLIR with -Werror=mismatched-tags (NFC)
Mehdi Amini [Wed, 8 Dec 2021 05:14:01 +0000 (05:14 +0000)]
Build MLIR with -Werror=mismatched-tags (NFC)

This is a defensive action to catch at build time on Linux failures that
may happen only on Windows otherwise.

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

2 years ago[C++20] [Modules] Namespace Declaration shouldn't have module linkage
Chuanqi Xu [Wed, 8 Dec 2021 05:49:02 +0000 (13:49 +0800)]
[C++20] [Modules] Namespace Declaration shouldn't have module linkage

According to [basic.namespace.general]/p2, a namespace declaration
shouldn't have a module linkage.
> A namespace is never attached to a named module and never has a name
> with module linkage.

Without this patch, the compiler would crash for the test in assertion
enabled build due to inconsistent linkage for redeclaration for
namespaces.

Reviewed by: rsmith

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

2 years ago[NFC][lsan] Move method implementation up
Vitaly Buka [Wed, 8 Dec 2021 05:34:57 +0000 (21:34 -0800)]
[NFC][lsan] Move method implementation up

2 years ago[NFC][lsan] Clang-format lsan_common.cpp
Vitaly Buka [Wed, 8 Dec 2021 05:34:06 +0000 (21:34 -0800)]
[NFC][lsan] Clang-format lsan_common.cpp

2 years ago[C++20] [Module] Support extern C/C++ semantics
Chuanqi Xu [Wed, 8 Dec 2021 03:34:18 +0000 (11:34 +0800)]
[C++20] [Module] Support extern C/C++ semantics

According to [module.unit]p7.2.3, a declaration within a linkage-specification
should be attached to the global module.
This let user to forward declare types across modules.

Reviewed by: rsmith, aaron.ballman

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

2 years ago[clangd] Add desugared type to hover
lh123 [Wed, 8 Dec 2021 04:31:00 +0000 (12:31 +0800)]
[clangd] Add desugared type to hover

Add desugared type to hover when the desugared type and the pretty-printed type are different.

```c++
template<typename T>
struct TestHover {
  using Type = T;
};

int main() {
  TestHover<int>::Type a;
}
```

```
variable a

Type: TestHover<int>::Type (aka int)
```

Reviewed By: sammccall

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

2 years agoFix flang tests after MLIR changes on the handling of declarative assembly
Mehdi Amini [Wed, 8 Dec 2021 04:30:43 +0000 (04:30 +0000)]
Fix flang tests after MLIR changes on the handling of declarative assembly

2 years ago[NFC][lsan] Use kIgnored in MarkInvalidPCCb
Vitaly Buka [Wed, 8 Dec 2021 03:49:44 +0000 (19:49 -0800)]
[NFC][lsan] Use kIgnored in MarkInvalidPCCb

kIgnored didn't exist when the code was added, but it should be
equivalent to kReachable.
The goal is to refactor MarkInvalidPCCb to avoid StackDepotGet
in StopTheWorld.

2 years ago[CostModel][X86] Add i64 mul cost for avx512 as 1cy
Haohai Wen [Tue, 7 Dec 2021 02:15:38 +0000 (10:15 +0800)]
[CostModel][X86] Add i64 mul cost for avx512 as 1cy

i64 mul cost is 1cy for all cpu that support avx512. Currently
all X86 cpu uses i64 mul cost in X64 cost table which is not
true for cpu that support avx512 (skx, icx).

Reviewed By: pengfei, RKSimon

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

2 years ago[ORC] Add a MaterializationUnit::Interface struct.
Lang Hames [Tue, 7 Dec 2021 21:10:41 +0000 (08:10 +1100)]
[ORC] Add a MaterializationUnit::Interface struct.

MaterializationUnit::Interface holds the values that make up the interface
(for ORC's purposes) of a materialization unit: the symbol flags map and
initializer symbol.

Having a type for this will make functions that build materializer interfaces
more readable and maintainable.

2 years ago[Powerpc] testcases for D111485; nfc
Chen Zheng [Sat, 9 Oct 2021 08:52:27 +0000 (08:52 +0000)]
[Powerpc] testcases for D111485; nfc

2 years ago[macho] add support for emitting macho files with two build version load commands
Alex Lorenz [Wed, 8 Dec 2021 01:51:44 +0000 (17:51 -0800)]
[macho] add support for emitting macho files with two build version load commands

This patch extends LLVM IR to add metadata that can be used to emit macho files with two build version load commands.
It utilizes "darwin.target_variant.triple" and "darwin.target_variant.SDK Version" metadata names for that,
which will be set by a future patch in clang.

MachO uses two build version load commands to represent an object file / binary that is targeting both the macOS target,
and the Mac Catalyst target. At runtime, a dynamic library that supports both targets can be loaded from either a native
macOS or a Mac Catalyst app on a macOS system. We want to add support to this to upstream to LLVM to be able to build
compiler-rt for both targets, to finish the complete support for the Mac Catalyst platform, which is right now targetable
by upstream clang, but the compiler-rt bits aren't supported because of the lack of this multiple build version support.

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

2 years ago[sanitizer] Restore __thumb__ workaround
Vitaly Buka [Wed, 8 Dec 2021 01:59:39 +0000 (17:59 -0800)]
[sanitizer] Restore __thumb__ workaround

It was removed in D114934 and failed clang-thumbv7-full-2stage.

2 years agoChange the printing/parsing behavior for Attributes used in declarative assembly...
Mehdi Amini [Wed, 8 Dec 2021 01:24:51 +0000 (01:24 +0000)]
Change the printing/parsing behavior for Attributes used in declarative assembly format

The new form of printing attribute in the declarative assembly is eliding the `#dialect.mnemonic` prefix to only keep the `<....>` part.

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

2 years ago[PowerPC] use lvx + splat directly for aligned splat load
Chen Zheng [Tue, 16 Nov 2021 07:46:08 +0000 (07:46 +0000)]
[PowerPC] use lvx + splat directly for aligned splat load

Reviewed By: nemanjai

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

2 years agoReland "[gn build] (manually) port 1ee32055ea1d (benchmark move)"
Nico Weber [Wed, 8 Dec 2021 01:50:39 +0000 (20:50 -0500)]
Reland "[gn build] (manually) port 1ee32055ea1d (benchmark move)"

This reverts commit bbccf4992219222c5b905e9965ec26b35e2c6af8.
1ee32055ea1d relanded in 5dda2efde57.

2 years ago[X86][clang] Emit diagnostic for float and double when we have features -x87 and...
Phoebe Wang [Wed, 8 Dec 2021 00:26:38 +0000 (08:26 +0800)]
[X86][clang] Emit diagnostic for float and double when we have features -x87 and -sse on 64-bits

A follow up of D114162.

Reviewed By: asavonic

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

2 years agoRe-Reland "[benchmarks] Move libcxx's fork of google/benchmark and llvm/utils'"
Mircea Trofin [Wed, 8 Dec 2021 00:46:55 +0000 (16:46 -0800)]
Re-Reland "[benchmarks] Move libcxx's fork of google/benchmark and llvm/utils'"

This reverts commit b2fbd45d2395f1f6ef39db72b7156724fc101e40. D114922
fixed the reason of the 2nd revert.

This patch also re-applies 39e9f5d3685f3cfca0df072928ad96d973704dff.

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

2 years ago[ASan] Missed some SHADOW_XYZ uses on non-Linux platforms.
Kirill Stoimenov [Wed, 8 Dec 2021 00:36:09 +0000 (00:36 +0000)]
[ASan] Missed some SHADOW_XYZ uses on non-Linux platforms.

Reviewed By: kstoimenov

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

2 years ago[ASan] Renamed SHADOW_XYZ to ASAN_SHADOW_XYZ.
Kirill Stoimenov [Tue, 7 Dec 2021 23:18:04 +0000 (23:18 +0000)]
[ASan] Renamed SHADOW_XYZ to ASAN_SHADOW_XYZ.

Follow up from D115271.

Reviewed By: vitalybuka

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

2 years ago[lld-macho] Include archive name in bitcode files
Jez Ng [Wed, 8 Dec 2021 00:11:06 +0000 (19:11 -0500)]
[lld-macho] Include archive name in bitcode files

Reviewed By: MaskRay

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

2 years ago[libc][obvious] fix missed rename
Michael Jones [Wed, 8 Dec 2021 00:07:24 +0000 (16:07 -0800)]
[libc][obvious] fix missed rename

In https://reviews.llvm.org/D114302 I renamed ForLoopCopy to
for_loop_copy, but these got missed.

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

2 years ago[compiler-rt] Use the runtimes build for custom libc++
Petr Hosek [Wed, 1 Dec 2021 09:07:14 +0000 (01:07 -0800)]
[compiler-rt] Use the runtimes build for custom libc++

Some of the compiler-rt runtimes use custom instrumented libc++ build.
Use the runtimes build for building this custom libc++.

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

2 years ago[libc] fix the .yaml files not being tracked
Michael Jones [Tue, 7 Dec 2021 22:48:28 +0000 (14:48 -0800)]
[libc] fix the .yaml files not being tracked

adds the .yaml files clang-tidy generates as byproducts, which means
that they will be updated properly and cleaned by `ninja -t clean`

Reviewed By: lntue

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

2 years ago[mlir][sparse] add a few more sparse output tests (for generated IR)
Aart Bik [Tue, 7 Dec 2021 22:33:39 +0000 (14:33 -0800)]
[mlir][sparse] add a few more sparse output tests (for generated IR)

also fixes two typos in IR doc

Reviewed By: bixia

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

2 years agoRevert "Revert "Use VersionTuple for parsing versions in Triple, fixing issues that...
James Farrell [Mon, 6 Dec 2021 17:41:26 +0000 (17:41 +0000)]
Revert "Revert "Use VersionTuple for parsing versions in Triple, fixing issues that caused the original change to be reverted. This makes it possible to distinguish between "16" and "16.0" after parsing, which previously was not possible.""

This reverts commit 63a6348cad6caccf285c1661bc60d8ba5a40c972.

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

2 years agoRevert "[RISCV] Add target specific loop unrolling and peeling preferences"
Michael Berg [Tue, 7 Dec 2021 23:13:42 +0000 (15:13 -0800)]
Revert "[RISCV] Add target specific loop unrolling and peeling preferences"

This reverts commit 8487981a7249f7c080d5395ebee0e8b969c6f47c.

2 years ago[CUDA][HIP] Add pre-defined macro `__CLANG_RDC__`
Yaxun (Sam) Liu [Tue, 30 Nov 2021 19:45:16 +0000 (14:45 -0500)]
[CUDA][HIP] Add pre-defined macro `__CLANG_RDC__`

nvcc defines __CUDACC_RDC__ for both host and
device compilation when -rdc=true is specified
(https://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html#nvcc-identification-macro)

This patch defines __CLANG_RDC__ when -fgpu-rdc
is specified for CUDA/HIP.

Reviewed by: Artem Belevich

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

2 years agoFix error reporting for "process load" and add a test for it.
Jim Ingham [Tue, 7 Dec 2021 19:56:36 +0000 (11:56 -0800)]
Fix error reporting for "process load" and add a test for it.

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

2 years ago[RISCV] Add target specific loop unrolling and peeling preferences
Michael Berg [Tue, 7 Dec 2021 23:06:24 +0000 (15:06 -0800)]
[RISCV] Add target specific loop unrolling and peeling preferences

Both these preference helper functions have initial support with
this change. The loop unrolling preferences are set with initial
settings to control thresholds, size and attributes of loops to
unroll with some tuning done.  The peeling preferences may need
some tuning as well as the initial support looks much like what
other architectures utilize.

Reviewed By: craig.topper

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

2 years ago[OpenMP][AMDGPU] Switch host-device memory copy to asynchronous version
Carlo Bertolli [Tue, 7 Dec 2021 23:04:50 +0000 (23:04 +0000)]
[OpenMP][AMDGPU] Switch host-device memory copy to asynchronous version

Prepare amdgpu plugin for asynchronous implementation. This patch switches to using HSA API for asynchronous memory copy.
Moving away from hsa_memory_copy means that plugin is responsible for locking/unlocking host memory pointers.

Reviewed By: JonChesterfield

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

2 years agoConvert fir.allocmem and fir.freemem operations to calls to malloc and free, respectively
AlexisPerry [Tue, 2 Nov 2021 21:46:21 +0000 (15:46 -0600)]
Convert fir.allocmem and fir.freemem operations to calls to malloc and free, respectively

This patch is part of the upstreaming effort from the fir-dev branch.

Address review comments
- move CHECK blocks to after the mlir code in the test file
- fix style with respect to anonymous namespaces: only include class definitions in the namespace and make functions static and outside the namespace
- fix a few nits
- remove TODO in favor of notifyMatchFailure
- removed unnecessary CHECK line from convert-to-llvm.fir
- rebase on main - add TODO back in
- get successfull test of TODO in AllocMemOp converion of derived type with LEN params
- clearer comments and reduced use of auto
- move defintion of computeDerivedTypeSize to fix build error

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: Jean Perier <jperier@nvidia.com>
Reviewed By: awarzynski, clementval, kiranchandramohan, schweitz

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

2 years ago[ASan] Removed ASAN_SHADOW_SCALE.
Kirill Stoimenov [Tue, 7 Dec 2021 22:28:22 +0000 (22:28 +0000)]
[ASan] Removed ASAN_SHADOW_SCALE.

This is additional cleanup as follow-up of D104279.

Reviewed By: vitalybuka

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

2 years agoReapply [runtimes] Fix building initial libunwind+libcxxabi+libcxx with compiler...
Martin Storsjö [Sat, 23 Oct 2021 22:11:20 +0000 (01:11 +0300)]
Reapply [runtimes] Fix building initial libunwind+libcxxabi+libcxx with compiler implied -lunwind

This does mostly the same as D112126, but for the runtimes cmake files.
Most of that is straightforward, but the interdependency between
libcxx and libunwind is tricky:

Libunwind is built at the same time as libcxx, but libunwind is not
installed yet. LIBCXXABI_USE_LLVM_UNWINDER makes libcxx link directly
against the just-built libunwind, but the compiler implicit -lunwind
isn't found. This patch avoids that by adding --unwindlib=none if
supported, if we are going to link explicitly against a newly built
unwinder anyway.

Reapplying this after
db32c4f45625dddc2c5cb683adf3d9cab7a9732f, which should fix the issues
that were reported last time this was applied.

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

2 years ago[Flang] Upstream conversion of the XRebox Op
Kiran Chandramohan [Tue, 7 Dec 2021 13:01:28 +0000 (13:01 +0000)]
[Flang] Upstream conversion of the XRebox Op

The XRebox Op is formed by the codegen rewrite which makes it easier to
convert the operation to LLVM. The XRebox op includes the information
from the rebox op and the associated slice, shift, and shape ops.

During the conversion process a new descriptor is created for reboxing.

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: Val Donaldson <vdonaldson@nvidia.com>
Reviewed By: clementval

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

2 years agoRevert "[ASan] Removed ASAN_SHADOW_SCALE."
Kirill Stoimenov [Tue, 7 Dec 2021 22:17:58 +0000 (22:17 +0000)]
Revert "[ASan] Removed ASAN_SHADOW_SCALE."

This reverts commit e4800fc099ad204f88c432276e6488772042bffc.

Reviewed By: kstoimenov

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

2 years ago[ASan] Removed ASAN_SHADOW_SCALE.
Kirill Stoimenov [Tue, 7 Dec 2021 19:08:52 +0000 (19:08 +0000)]
[ASan] Removed ASAN_SHADOW_SCALE.

This is additional cleanup as follow-up of D104279.

Reviewed By: vitalybuka

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

2 years ago[libc++] Remove _LIBCPP_DEFAULT
Nikolas Klauser [Tue, 7 Dec 2021 19:29:35 +0000 (20:29 +0100)]
[libc++] Remove _LIBCPP_DEFAULT

clang has `= default` as an extension in c++03, so just use it.

Reviewed By: ldionne, Quuxplusone, #libc

Spies: libcxx-commits

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

2 years ago[gn build] Port 02940d6d2202
LLVM GN Syncbot [Tue, 7 Dec 2021 21:08:05 +0000 (21:08 +0000)]
[gn build] Port 02940d6d2202

2 years agoRevert "CycleInfo: Introduce cycles as a generalization of loops"
Jonas Devlieghere [Tue, 7 Dec 2021 18:50:08 +0000 (10:50 -0800)]
Revert "CycleInfo: Introduce cycles as a generalization of loops"

This reverts commit 0fe61ecc2cef333250a152cd90d80d0b802b27db because it
breaks the modules build.

https://green.lab.llvm.org/green/job/clang-stage2-rthinlto/4858/
https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/39112/

2 years ago[NFC][OpenMP] Prepare amdgpu plugin for asynchronous implementation of target region...
Carlo Bertolli [Tue, 7 Dec 2021 21:00:11 +0000 (21:00 +0000)]
[NFC][OpenMP] Prepare amdgpu plugin for asynchronous implementation of target region launch

At present, amdgpu plugin merges both asynchronous and synchronous kernel launch implementations into a single synchronous version.
This patch prepares the plugin for asynchronous implementation by:
- Privatizing actual kernel launch code (valid in both cases) into an anonymous namespace base function

Actual separation of kernel launch code (async vs sync) is a following patch.

Reviewed By: JonChesterfield

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

2 years ago[InstCombine] try to fold rem with constant dividend and select-of-constants divisor
Sanjay Patel [Tue, 7 Dec 2021 20:48:45 +0000 (15:48 -0500)]
[InstCombine] try to fold rem with constant dividend and select-of-constants divisor

We avoid this fold in the more general cases where we use `FoldOpIntoSelect`.
That's because -- unlike most binary opcodes -- 'rem' can't usually be
speculated with a variable divisor since it can have immediate UB. But in
the case where both arms of the select are constants, we can safely evaluate
both sides and eliminate 'rem' completely.

This should fix:
https://llvm.org/PR52102

The same optimization for 'div' is planned as a follow-up patch.

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

2 years ago[InstCombine] add tests for div/rem with 0 select arm; NFC
Sanjay Patel [Tue, 7 Dec 2021 20:28:42 +0000 (15:28 -0500)]
[InstCombine] add tests for div/rem with 0 select arm; NFC

More coverage for D115173 and its div sibling. These are
existing transforms handled by simplifyDivRemOfSelectWithZeroOp().

2 years ago[InstCombine] add tests for div with select-of-constants divisor; NFC
Sanjay Patel [Tue, 7 Dec 2021 16:28:23 +0000 (11:28 -0500)]
[InstCombine] add tests for div with select-of-constants divisor; NFC

Similar patterns as tests for:
D115173
(and we might want to make a single patch for all of these).

2 years ago[OpenMP] Disable libomptarget profiling by default if built via the "runtimes" setup
Martin Storsjö [Wed, 17 Nov 2021 13:06:15 +0000 (15:06 +0200)]
[OpenMP] Disable libomptarget profiling by default if built via the "runtimes" setup

In the "runtimes" setup, the runtime (e.g. OpenMP) can be built for
a target entirely different from the current host build (where LLVM
and Clang are built). If profiling is enabled, libomptarget links
against LLVMSupport (which only has been built for the host).

Thus, don't enable profiling by default in this setup.

This should allow relanding D113253.

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

2 years ago[flang][runtime] Add ragged array runtime functions
Valentin Clement [Tue, 7 Dec 2021 20:19:34 +0000 (21:19 +0100)]
[flang][runtime] Add ragged array runtime functions

This patch adds the runtime function to allocate and
deallocate ragged arrays.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: klausler

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

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2 years agoFix buildbots after https://reviews.llvm.org/D115073.
Greg Clayton [Tue, 7 Dec 2021 20:19:00 +0000 (12:19 -0800)]
Fix buildbots after https://reviews.llvm.org/D115073.

2 years agoFix buildbot after https://reviews.llvm.org/D115073.
Greg Clayton [Tue, 7 Dec 2021 20:03:45 +0000 (12:03 -0800)]
Fix buildbot after https://reviews.llvm.org/D115073.

2 years ago[Analysis] Ignore casts and unary ops for uninitialized values
Bill Wendling [Tue, 7 Dec 2021 07:14:19 +0000 (23:14 -0800)]
[Analysis] Ignore casts and unary ops for uninitialized values

A series of unary operators and casts may obscure the variable we're
trying to analyze. Ignore them for the uninitialized value analysis.
Other checks determine if the unary operators result in a valid l-value.

Link: https://github.com/ClangBuiltLinux/linux/issues/1521
Reviewed By: nickdesaulniers

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

2 years ago[ASan] Replaced constants for SHADOW_OFFSET with defines.
Kirill Stoimenov [Tue, 7 Dec 2021 02:47:11 +0000 (02:47 +0000)]
[ASan] Replaced constants for SHADOW_OFFSET with defines.

Reviewed By: vitalybuka

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

2 years ago[VP] Cost model for VPMemory operations on PowerPC.
Bardia Mahjour [Mon, 6 Dec 2021 16:33:42 +0000 (11:33 -0500)]
[VP] Cost model for VPMemory operations on PowerPC.

PPC Implementation of getVPMemoryOpCost and hasActiveVectorLength.

Reviewed By: Roland Froese

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

2 years ago[sanitizer] Lock/Unlock stack store on fork
Vitaly Buka [Tue, 7 Dec 2021 01:58:52 +0000 (17:58 -0800)]
[sanitizer] Lock/Unlock stack store on fork

Reviewed By: dvyukov

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

2 years ago[mlir][sparse] fix broken build
Aart Bik [Tue, 7 Dec 2021 19:05:45 +0000 (11:05 -0800)]
[mlir][sparse] fix broken build

rebase and commit crossed the getFunc change

Reviewed By: Chia-hungDuan

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

2 years ago[libc++] [test] Rationalize the nodiscard tests for range adaptors.
Arthur O'Dwyer [Mon, 6 Dec 2021 22:16:34 +0000 (17:16 -0500)]
[libc++] [test] Rationalize the nodiscard tests for range adaptors.

Reviewed as part of D115177.

2 years ago[libc++] [ranges] SFINAE-friendly "write it three times" in views::counted.
Arthur O'Dwyer [Mon, 6 Dec 2021 20:39:08 +0000 (15:39 -0500)]
[libc++] [ranges] SFINAE-friendly "write it three times" in views::counted.

Before this patch, the new test's `CountedInvocable<int*, int*>`
would hard-error instead of SFINAEing and cleanly returning false.

Notice that views::counted specifically does NOT work with pipes;
`counted(42)` is ill-formed. This is because `counted`'s first argument
is supposed to be an iterator, not a range.

Also, mark `views::counted(it, n)` as [[nodiscard]], and test that.
(We have a general policy now that range adaptors are consistently
marked [[nodiscard]], so that people don't accidentally think that
they have side effects. This matters mostly for `reverse` and
`transform`, arguably `drop`, and just generally let's be consistent.)

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

2 years ago[libc++] Remove unneeded `std::` qualifications from <compare>. NFCI.
Arthur O'Dwyer [Mon, 6 Dec 2021 18:28:33 +0000 (13:28 -0500)]
[libc++] Remove unneeded `std::` qualifications from <compare>. NFCI.

Reviewed as part of D115177.

2 years ago[libc++] std::move should be _VSTD::move in one place. NFCI.
Arthur O'Dwyer [Mon, 6 Dec 2021 18:25:27 +0000 (13:25 -0500)]
[libc++] std::move should be _VSTD::move in one place. NFCI.

Reviewed as part of D115177.

2 years ago[mlir][sparse] finalize sparse output in the presence of reductions
Aart Bik [Sat, 4 Dec 2021 00:55:43 +0000 (16:55 -0800)]
[mlir][sparse] finalize sparse output in the presence of reductions

This revision implements sparse outputs (from scratch) in all cases where
the loops can be reordered with all but one parallel loops outer. If the
inner parallel loop appears inside one or more reductions loops, then an
access pattern expansion is required (aka. workspaces in TACO speak).

Reviewed By: bixia

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