platform/upstream/llvm.git
2 years ago[gn build] Port 75112133b83e
LLVM GN Syncbot [Fri, 25 Mar 2022 07:28:25 +0000 (07:28 +0000)]
[gn build] Port 75112133b83e

2 years ago[llvm-pdbutil] Move InputFile/FormatUtil/LinePrinter to PDB library.
Carlos Alberto Enciso [Thu, 24 Mar 2022 16:33:08 +0000 (16:33 +0000)]
[llvm-pdbutil] Move InputFile/FormatUtil/LinePrinter to PDB library.

At Sony we are developing llvm-dva

https://lists.llvm.org/pipermail/llvm-dev/2020-August/144174.html

For its PDB support, it requires functionality already present in
llvm-pdbutil.

We intend to move that functionaly into the PDB library to be
shared by both tools. That change will be done in 2 steps, that
will be submitted as 2 patches:

(1) Replace 'ExitOnError' with explicit error handling.
(2) Move the intended shared code to the PDB library.

Patch for step (1): https://reviews.llvm.org/D121801

This patch is for step (2).

Move InputFile.cpp[h], FormatUtil.cpp[h] and LinePrinter.cpp[h]
files to the debug PDB library.

It exposes the following functionality that can be used by tools:

- Open a PDB file.
- Get module debug stream.
- Traverse module sections.
- Traverse module subsections.

Most of the needed functionality is in InputFile, but there are
dependencies from LinePrinter and FormatUtil.

Some other functionality is in the following functions in
DumpOutputStyle.cpp file:

- iterateModuleSubsections
- getModuleDebugStream
- iterateOneModule
- iterateSymbolGroups
- iterateModuleSubsections

Only these specific functions from DumpOutputStyle are moved to
the PDB library.

Reviewed By: aganea, dblaikie, rnk

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

2 years ago[flang] Lower mvbits intrinsic
Valentin Clement [Fri, 25 Mar 2022 07:00:10 +0000 (08:00 +0100)]
[flang] Lower mvbits intrinsic

This patch adds the lowering for the `mvbits`
intrinsic.

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

Reviewed By: PeteSteinfeld

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

Co-authored-by: V Donaldson <vdonaldson@nvidia.com>
Co-authored-by: Jean Perier <jperier@nvidia.com>
2 years ago[clang] Propagate requires-clause from constructor template to implicit deduction...
Nathan Ridge [Sun, 14 Nov 2021 06:39:17 +0000 (01:39 -0500)]
[clang] Propagate requires-clause from constructor template to implicit deduction guide

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

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

2 years ago[ELF] addSectionSymbols: simplify isec->getOutputSection(). NFC
Fangrui Song [Fri, 25 Mar 2022 04:54:20 +0000 (21:54 -0700)]
[ELF] addSectionSymbols: simplify isec->getOutputSection(). NFC

2 years ago[mlir][gpu] Relax restriction on mma load/store op
Thomas Raoux [Fri, 25 Mar 2022 03:31:06 +0000 (03:31 +0000)]
[mlir][gpu] Relax restriction on mma load/store op

Those ops can support more complex layout as long as the most inner
dimension is contiguous.

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

2 years ago[AVR] Add more devices
Ben Shi [Thu, 24 Mar 2022 14:29:52 +0000 (14:29 +0000)]
[AVR] Add more devices

Synchronize device list with avr-gcc 7.3.0 and avrlibc 2.0.0.

Reviewed By: aykevl

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

2 years agoMake BLAKE3 a component library
Nico Weber [Thu, 24 Mar 2022 19:39:54 +0000 (15:39 -0400)]
Make BLAKE3 a component library

It's unusual that BLAKE3/CMakeLists.txt just defines a list of
files that it injects into its parent scope. The list should either
be defined in llvm/lib/Support/CMakeLists.txt, or
llvm/lib/Support/BLAKE3/CMakeLists.txt should define an object
library.

This does the latter. It makes llvm/lib/Support/BLAKE3/CMakeLists.txt
more self-contained.

No behavior change.

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

2 years agoFix a bug where an extended vector of __fp16 was being converted to a
Akira Hatanaka [Fri, 25 Mar 2022 00:38:48 +0000 (17:38 -0700)]
Fix a bug where an extended vector of __fp16 was being converted to a
generic vector type

rdar://86109177

2 years ago[Clang] Work with multiple pragmas weak before definition
Hubert Tong [Fri, 25 Mar 2022 00:11:54 +0000 (20:11 -0400)]
[Clang] Work with multiple pragmas weak before definition

Update `WeakUndeclaredIdentifiers` to hold a collection of weak
aliases per identifier instead of only one.

This also allows the "used" state to be removed from `WeakInfo`
because it is really only there as an alternative to removing
processed map entries, and we can represent that using an empty set
now. The serialization code is updated for the removal of the field.
Additionally, a PCH test is added for the new functionality.

The records are grouped by the "target" identifier, which was already
being used as a key for lookup purposes. We also store only one record
per alias name; combined, this means that diagnostics are grouped by
the "target" and limited to one per alias (which should be acceptable).

Fixes PR28611.
Fixes llvm/llvm-project#28985.

Reviewed By: aaron.ballman, cebowleratibm

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

Co-authored-by: Rachel Craik <rcraik@ca.ibm.com>
Co-authored-by: Jamie Schmeiser <schmeise@ca.ibm.com>
2 years ago[MLIR][Presburger] Merge PresburgerLocalSpace and PresburgerSpace
Groverkss [Thu, 24 Mar 2022 23:46:48 +0000 (05:16 +0530)]
[MLIR][Presburger] Merge PresburgerLocalSpace and PresburgerSpace

This patch is a cleanup patch that merges PresburgerLocalSpace and
PresburgerSpace. Asserting that there are no locals is shifted to the
users of PresburgerSpace themselves.

The reasoning for this patch is that PresburgerLocalSpace did not contribute
much and only introduced additional complexity as locals could still be present
in PresburgerSpace, just not writable. This could introduce problems if a
PresburgerSpace with locals was copied to PresburgerLocalSpace which expected
no locals in a PresburgerSpace.

Reviewed By: arjunp

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

2 years ago[libc++] Rename __identity to __type_identity
Nikolas Klauser [Fri, 18 Mar 2022 16:49:02 +0000 (17:49 +0100)]
[libc++] Rename __identity to __type_identity

In C++20 the type trait `type_identity` was introduced. For the same purpose there is `__identity` for pre-C++20 code. The name is confusing, because since C++20 there is also `identity`, which isn't a type trait.

Reviewed By: ldionne, Mordante, #libc

Spies: EricWF, libcxx-commits

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

2 years agoRe-commit: Driver: Don't warn on -mbranch-protection when linking
Tom Stellard [Wed, 23 Mar 2022 06:17:39 +0000 (23:17 -0700)]
Re-commit: Driver: Don't warn on -mbranch-protection when linking

This is a re-commit of 98fd3b359866f474ab1c097c22fb5c3be356b996.  The
newly added test was failing on the bots, and I've fixed the test now so
that it doesn't actually invoke the linker.

2 years ago[OpenMP] Add a semantic check for updating hidden or internal values
Joseph Huber [Thu, 24 Mar 2022 12:26:32 +0000 (08:26 -0400)]
[OpenMP] Add a semantic check for updating hidden or internal values

A previous patch removed the compiler generating offloading entries
for variables that were declared on the device but were internal or
hidden. This allowed us to compile programs but turns any attempt to run
'#pragma omp target update' on one of those variables a silent failure.
This patch adds a check in the semantic analysis for if the user is
attempting the update a variable on the device from the host that is not
externally visible.

Reviewed By: jdoerfert

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

2 years ago[mlir][linalg] Add pattern to split reduction dimension in a linalg op
Thomas Raoux [Thu, 24 Mar 2022 21:02:17 +0000 (21:02 +0000)]
[mlir][linalg] Add pattern to split reduction dimension in a linalg op

This transformation allow to break up a reduction dimension in a
parallel and a reduction dimension. This is followed by a separate
reduction op. This allows to generate tree reduction which is beneficial
on target allowing to take advantage parallelism.

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

2 years agoDon't search for sim SDK path until we know we need it
Jason Molenda [Thu, 24 Mar 2022 21:35:46 +0000 (14:35 -0700)]
Don't search for sim SDK path until we know we need it

When iterating over all Platforms looking for the best one, on a Mac the
Simulator platforms (iOS, tvOS, watchOS) will first find their SDK
directory by calling xcrun, then decide if they should activate or not.
When that SDK is absent, the call to xcrun to find it can be very slow.
This patch delays that directory search until we know we're activating
this platform, so non-simulator environments don't pay a perf cost ever
time they go through the list of platforms.

Differential Revision: https://reviews.llvm.org/D122373
rdar://87960090

2 years ago[Bazel] Add BLAKE3 files to llvm:Support
Fangrui Song [Thu, 24 Mar 2022 22:26:40 +0000 (15:26 -0700)]
[Bazel] Add BLAKE3 files to llvm:Support

Hope someone can figure out how to leverage SSE42/AVE2/Arm Neon.

2 years ago[flang] Make not yet implemented messages more consistent
Peter Steinfeld [Wed, 23 Mar 2022 22:20:56 +0000 (15:20 -0700)]
[flang] Make not yet implemented messages more consistent

To make it easier to find things that are not yet implemented, I'm changing the
messages that appear in the compiler's output to all have the string "not yet
implemented:".

These changes apply to files in the front end.  I have another set of changes
to files in the lowering code.

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

2 years ago[NFC][clang][extract-api] Rename variable
Zixu Wang [Thu, 24 Mar 2022 22:09:25 +0000 (15:09 -0700)]
[NFC][clang][extract-api] Rename variable

Rename a local variable name to avoid potential ambiguity/conflict for
some compilers.

2 years ago[libc] Improve the performance of exp2f.
Tue Ly [Wed, 23 Mar 2022 19:37:19 +0000 (15:37 -0400)]
[libc] Improve the performance of exp2f.

Reduce the range-reduction table size from 128 entries down to 64 entries, and
reduce the polynomial's degree from 6 down to 4.

Currently we use a degree-6 minimax polynomial on an interval of length 2^-7
around 0 to compute exp2f.  Based on the suggestion of @santoshn and the RLIBM
project (https://github.com/rutgers-apl/rlibm-prog/blob/main/libm/float/exp2.c)
it is possible to have a good polynomial of degree-4 on a subinterval of length
2^(-6) to approximate 2^x.

We did try to either reduce the degree of the polynomial down to 3 or increase
the interval size to 2^(-5), but in both cases the number of exceptional values
exploded.  So we settle with using a degree-4 polynomial of the interval of
size 2^(-6) around 0.

Reviewed By: michaelrj, sivachandra, zimmermann6, santoshn

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

2 years ago[NFC][clang][extract-api] Add missing virtual anchors
Zixu Wang [Thu, 24 Mar 2022 21:30:14 +0000 (14:30 -0700)]
[NFC][clang][extract-api] Add missing virtual anchors

Add missing virtual method anchors for structs in ExtractAPI/API.h

2 years ago[opt] Remove -analyze option
Arthur Eubanks [Thu, 10 Feb 2022 23:39:29 +0000 (15:39 -0800)]
[opt] Remove -analyze option

This is legacy PM-specific, which is deprecated.

Uses of this should be replaced with a corresponding `-passes='print<foo>'`.

Reviewed By: asbirlea

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

2 years ago[mlir][spirv] Add Apple into the vendor list
Lei Zhang [Thu, 24 Mar 2022 19:00:39 +0000 (15:00 -0400)]
[mlir][spirv] Add Apple into the vendor list

Reviewed By: ThomasRaoux, hanchung

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

2 years agoEliminate extra set of simd variant function attribute.
Jennifer Yu [Wed, 23 Mar 2022 14:34:28 +0000 (07:34 -0700)]
Eliminate extra set of simd variant function attribute.

Current clang generates extra set of simd variant function attribute
with extra 'v' encoding.
For example:
_ZGVbN2v__Z5add_1Pf vs _ZGVbN2vv__Z5add_1Pf
The problem is due to declaration of ParamAttrs following:
    llvm::SmallVector<ParamAttrTy, 8> ParamAttrs(ParamPositions.size());
where ParamPositions.size() is grown after following assignment:
    Pos = ParamPositions[PVD];
So the PVD is not find in ParamPositions.

The problem is ParamPositions need to set for each FD decl. To fix this

Move ParamPositions's init inside while loop for each FD.

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

2 years ago[AMDGPU] Use GenericTable to classify DGEMM
Stanislav Mekhanoshin [Wed, 23 Mar 2022 18:29:56 +0000 (11:29 -0700)]
[AMDGPU] Use GenericTable to classify DGEMM

Since there is a table introduced for MAI instructions extend it
to use for DGEMM classification.

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

2 years ago[AMDGPU] gfx940 MAI hazard recognizer
Stanislav Mekhanoshin [Wed, 23 Mar 2022 16:12:34 +0000 (09:12 -0700)]
[AMDGPU] gfx940 MAI hazard recognizer

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

2 years ago[flang][NFC] Remove unused variable
Valentin Clement [Thu, 24 Mar 2022 19:43:11 +0000 (20:43 +0100)]
[flang][NFC] Remove unused variable

2 years ago[AMDGPU] Support gfx940 smfmac instructions
Stanislav Mekhanoshin [Mon, 21 Mar 2022 19:59:33 +0000 (12:59 -0700)]
[AMDGPU] Support gfx940 smfmac instructions

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

2 years ago[ASan] Reland of D116182 to always link asan_static library.
Kirill Stoimenov [Wed, 16 Mar 2022 14:50:04 +0000 (14:50 +0000)]
[ASan] Reland of D116182 to always link asan_static library.

After landing D121813 the binary size increase introduced by this change can be minimized by using --gc-sections link options. D121813 allows each individual callbacks to be optimized out if not used.

Reviewed By: vitalybuka, MaskRay

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

2 years agoRevert "[gn build] Manually port llvm/lib/Support/BLAKE3"
Nico Weber [Thu, 24 Mar 2022 19:23:36 +0000 (15:23 -0400)]
Revert "[gn build] Manually port llvm/lib/Support/BLAKE3"

This reverts commit 8424d4f641b186f30126c33f76f6a0fb619f903e.
That approach doesn't work. I checked in something that kinda
works 30 min ago or so.

2 years ago[clang][CodeGen]Fix clang crash and add bitfield support in __builtin_dump_struct
wangyihan [Thu, 24 Mar 2022 19:09:10 +0000 (12:09 -0700)]
[clang][CodeGen]Fix clang crash and add bitfield support in __builtin_dump_struct

Fix clang crash and add bitfield support in __builtin_dump_struct.

In clang13.0.x, a struct with three or more members and a bitfield at
the same time will cause a crash. In clang15.x, as long as the struct
has one bitfield, it will cause a crash in clang.

Open issue: https://github.com/llvm/llvm-project/issues/54462

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

2 years ago[CUDA][HIP] Fix hostness check with -fopenmp
Yaxun (Sam) Liu [Wed, 16 Mar 2022 01:45:02 +0000 (21:45 -0400)]
[CUDA][HIP] Fix hostness check with -fopenmp

CUDA/HIP determines whether a function can be called based on
the device/host attributes of callee and caller. Clang assumes the
caller is CurContext. This is correct in most cases, however, it is
not correct in OpenMP parallel region when CUDA/HIP program
is compiled with -fopenmp. This causes incorrect overloading
resolution and missed diagnostics.

To get the correct caller, clang needs to chase the parent chain
of DeclContext starting from CurContext until a function decl
or a lambda decl is reached. Sema API is adapted to achieve that
and used to determine the caller in hostness check.

Reviewed by: Artem Belevich, Richard Smith

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

2 years ago[VectorCombine] Insert addrspacecast when crossing address space boundaries
Fraser Cormack [Wed, 16 Mar 2022 10:14:07 +0000 (10:14 +0000)]
[VectorCombine] Insert addrspacecast when crossing address space boundaries

We can not bitcast pointers across different address spaces. This was
previously fixed in D89577 but then in D93229 an enhancement was added
which peeks further through the ponter operand, opening up the
possibility that address-space violations could be introduced.

Instead of bailing as the previous fix did, simply insert an
addrspacecast cast instruction.

Reviewed By: lebedev.ri

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

2 years ago[AMDGPU] New gfx940 mfma instructions
Stanislav Mekhanoshin [Fri, 18 Mar 2022 19:33:21 +0000 (12:33 -0700)]
[AMDGPU] New gfx940 mfma instructions

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

2 years ago[gn build] Port
LLVM GN Syncbot [Thu, 24 Mar 2022 19:11:19 +0000 (19:11 +0000)]
[gn build] Port

2 years ago[gn build] Manually port llvm/lib/Support/BLAKE3
Fangrui Song [Thu, 24 Mar 2022 19:06:19 +0000 (12:06 -0700)]
[gn build] Manually port llvm/lib/Support/BLAKE3

2 years agoRevert "[Intrinsics] Add `nocallback` to the default intrinsic attributes"
Johannes Doerfert [Thu, 24 Mar 2022 19:04:41 +0000 (14:04 -0500)]
Revert "[Intrinsics] Add `nocallback` to the default intrinsic attributes"

This reverts commit 7aea3ea8c3b33c9bb338d5d6c0e4832be1d09ac3 as it
breaks the buildbots.

I didn't see these failures in the pre-merge checks, looking into it.

2 years ago[gn build] ugly hack to work around sync script for now
Nico Weber [Thu, 24 Mar 2022 18:56:42 +0000 (14:56 -0400)]
[gn build] ugly hack to work around sync script for now

2 years agoDebugInfo: Classify noreturn function types as non-reconstructible
David Blaikie [Thu, 24 Mar 2022 18:31:48 +0000 (18:31 +0000)]
DebugInfo: Classify noreturn function types as non-reconstructible

This information isn't preserved in the DWARF description of function
types (though probably should be - it's preserved on the function
declarations/definitions themselves through the DW_AT_noreturn attribute
- but we should move or also include that in the subroutine type itself
too - but for now, with it not being there, the DWARF is lossy and
can't be reconstructed)

2 years ago[gn build] (manually) port 9aa701984d39 (BLAKE3)
Nico Weber [Thu, 24 Mar 2022 18:44:46 +0000 (14:44 -0400)]
[gn build] (manually) port 9aa701984d39 (BLAKE3)

2 years ago[Intrinsics] Add `nocallback` to the default intrinsic attributes
Johannes Doerfert [Tue, 1 Feb 2022 07:03:06 +0000 (01:03 -0600)]
[Intrinsics] Add `nocallback` to the default intrinsic attributes

Most intrinsics, especially "default" ones, will not call back into the
IR module. `nocallback` encodes this nicely. As it was not used before,
this patch also makes use of `nocallback` in the Attributor which
results in many more `norecurse` deductions.

Tablegen part is mechanical, test updates by script.

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

2 years ago[InstCombine] add more tests for nsw propagation; NFC
Sanjay Patel [Thu, 24 Mar 2022 18:39:04 +0000 (14:39 -0400)]
[InstCombine] add more tests for nsw propagation; NFC

Follow-up as suggested with b6efd2510a1efaf2 -
show a couple of examples of general subtraction
(the earlier patch was all negations).

2 years ago[Support/BLAKE3] Temporarily disable building neon file to get builders back to green
Argyrios Kyrtzidis [Thu, 24 Mar 2022 18:40:28 +0000 (11:40 -0700)]
[Support/BLAKE3] Temporarily disable building neon file to get builders back to green

2 years ago[ELF] Implement --build-id={md5,sha1} with truncated BLAKE3
Fangrui Song [Thu, 24 Mar 2022 18:31:39 +0000 (11:31 -0700)]
[ELF] Implement --build-id={md5,sha1} with truncated BLAKE3

--build-id was introduced as "approximation of true uniqueness across all
binaries that might be used by overlapping sets of people". It does not require
the some resistance mentioned below. In practice, people just use --build-id=md5
for 16-byte build ID and --build-id=sha1 for 20-byte build ID.

BLAKE3 has 256-bit key length, which provides 128-bit security against
(second-)preimage, collision, and differentiability attacks. Its portable
implementation is fast. It additionally provides Arm Neon/AVX2/AVX-512. Just
implement --build-id={md5,sha1} with truncated BLAKE3.

Linking clang 14 RelWithDebInfo with --threads=8 on a Skylake CPU:

* 1.13x as fast with --build-id=md5
* 1.15x as fast with --build-id=sha1

--threads=4 on Apple m1:

* 1.25x as fast with --build-id=md5
* 1.17x as fast with --build-id=sha1

Reviewed By: ikudrin

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

2 years ago[Support/BLAKE3] Temporarily disable building the assembly files to get the builders...
Argyrios Kyrtzidis [Thu, 24 Mar 2022 18:28:24 +0000 (11:28 -0700)]
[Support/BLAKE3] Temporarily disable building the assembly files to get the builders back to green

2 years agoRevert "[clang][deps] NFC: De-duplicate clang-cl tests"
Gulfem Savrun Yeniceri [Thu, 24 Mar 2022 18:10:08 +0000 (18:10 +0000)]
Revert "[clang][deps] NFC: De-duplicate clang-cl tests"

This reverts commit 30cb49b44e4e2af2e0627b2aa33df0ba57ab9e55.
It caused test failures on Fuchsia Toolchain Mac builds:
https://luci-milo.appspot.com/ui/p/fuchsia/builders/toolchain.ci/clang-mac-x64/b8818888168677577537/overview

2 years ago[X86] combineSub - fold SUB(X,ADC(Y,0,W)) -> SBB(X,Y,W)
Simon Pilgrim [Thu, 24 Mar 2022 17:59:50 +0000 (17:59 +0000)]
[X86] combineSub - fold SUB(X,ADC(Y,0,W)) -> SBB(X,Y,W)

2 years ago[gn build] Manually port 0c86198b2
Arthur Eubanks [Thu, 24 Mar 2022 17:53:50 +0000 (10:53 -0700)]
[gn build] Manually port 0c86198b2

2 years ago[clang][extract-api] Stop allocating APIRecords via BumpPtrAllocator
Daniel Grumberg [Wed, 23 Mar 2022 15:03:02 +0000 (15:03 +0000)]
[clang][extract-api] Stop allocating APIRecords via BumpPtrAllocator

Using a BumpPtrAllocator introduced memory leaks for APIRecords as they
contain a std::vector. This meant that we needed to always keep a
reference to the records in APISet and arrange for their destructor to
get called appropriately. This was further complicated by the need for
records to own sub-records as these subrecords would still need to be
allocated via the BumpPtrAllocator and the owning record would now need
to arrange for the destructor of its subrecords to be called
appropriately.

Since APIRecords contain a std::vector so whenever elements get added to
that there is an associated heap allocation regardless. Since
performance isn't currently our main priority it makes sense to use
regular unique_ptr to keep track of APIRecords, this way we don't need
to arrange for destructors to get called.

The BumpPtrAllocator is still used for strings such as USRs so that we
can easily de-duplicate them as necessary.

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

2 years agoFix unused variable warning by embedding inside assertion
Simon Pilgrim [Thu, 24 Mar 2022 17:41:24 +0000 (17:41 +0000)]
Fix unused variable warning by embedding inside assertion

2 years ago[Support/BLAKE3] LLVM-specific changes over the original BLAKE3 C implementation
Argyrios Kyrtzidis [Thu, 24 Mar 2022 01:16:56 +0000 (18:16 -0700)]
[Support/BLAKE3] LLVM-specific changes over the original BLAKE3 C implementation

Changes from original BLAKE3 sources:

* `blake.h`:
    * Changes to avoid conflicts if a client also links with its own BLAKE3 version:
        * Renamed the header macro guard with `LLVM_C_` prefix
        * Renamed the C symbols to add the `llvm_` prefix
    * Added a top header comment that references the CC0 license and points to the `LICENSE` file in the repo.
* `blake3_impl.h`: Added `#define`s to remove some of `llvm_` prefixes for the rest of the internal implementation.
* Implementation files:
    * Added a top header comment for `blake.c`
    * Used `llvm_` prefix for the C public API functions
    * Used `LLVM_LIBRARY_VISIBILITY` for internal implementation functions
    * Added `.private_extern`/`.hidden` in assembly files to reduce visibility of the internal implementation functions
* `README.md`:
    * added a note about where the sources originated from
    * Used the C++ BLAKE3 class and `llvm_` prefixed C API in place of examples and API documentation.
    * Removed instructions about how to build the files.

2 years ago[Support] Introduce the BLAKE3 hashing function implementation
Argyrios Kyrtzidis [Sat, 12 Mar 2022 01:32:27 +0000 (17:32 -0800)]
[Support] Introduce the BLAKE3 hashing function implementation

BLAKE3 is a cryptographic hash function that is secure and very performant.
The C implementation originates from https://github.com/BLAKE3-team/BLAKE3/tree/1.3.1/c
License is at https://github.com/BLAKE3-team/BLAKE3/blob/1.3.1/LICENSE

This patch adds:

* `llvm/include/llvm-c/blake3.h`: The BLAKE3 C API
* `llvm/include/llvm/Support/BLAKE3.h`: C++ wrapper of the C API
* `llvm/lib/Support/BLAKE3`: Directory containing the BLAKE3 C implementation files, including the `LICENSE` file
* `llvm/unittests/Support/BLAKE3Test.cpp`: unit tests for the BLAKE3 C++ wrapper

This initial patch contains the pristine BLAKE3 sources, a follow-up patch will introduce
LLVM-specific prefixes to avoid conflicts if a client also links with its own BLAKE3 version.

And here's some timings comparing BLAKE3 with LLVM's SHA1/SHA256/MD5.
Timings include `AVX512`, `AVX2`, `neon`, and the generic/portable implementations.
The table shows the speed-up multiplier of BLAKE3 for hashing 100 MBs:

|        Processor        | SHA1  | SHA256 |  MD5 |
|-------------------------|-------|--------|------|
| Intel Xeon W (AVX512)   | 10.4x |   27x  | 9.4x |
| Intel Xeon W (AVX2)     | 6.5x  |   17x  | 5.9x |
| Intel Xeon W (portable) | 1.3x  |  3.3x  | 1.1x |
|      M1Pro (neon)       | 2.1x  |  4.7x  | 2.8x |
|      M1Pro (portable)   | 1.1x  |  2.4x  | 1.5x |

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

2 years ago[mlir][OpenMP][IRBuilder] Add support for nowait on single construct
Shraiysh Vaishay [Thu, 24 Mar 2022 16:46:43 +0000 (22:16 +0530)]
[mlir][OpenMP][IRBuilder] Add support for nowait on single construct

This patch adds the nowait parameter to `createSingle` in
OpenMPIRBuilder and handling for IR generation from OpenMP Dialect.

Also added tests for the same.

Reviewed By: ftynse

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

2 years ago[X86] Add additional 'add/sub single bit' patterns
Simon Pilgrim [Thu, 24 Mar 2022 17:16:46 +0000 (17:16 +0000)]
[X86] Add additional 'add/sub single bit' patterns

InstCombine can convert some cases to 'splat bit' sra(shl(x,y),bw-1) patterns which we need to handle as well

2 years ago[libc][obvious] only test FILE on working platforms
Michael Jones [Thu, 24 Mar 2022 00:00:45 +0000 (17:00 -0700)]
[libc][obvious] only test FILE on working platforms

The main code for the FILE struct is only enabled on platforms that it
works on, but before this patch the tests were included unconditionally.

Reviewed By: sivachandra, lntue

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

2 years ago[libc++] Audit all uses of _LIBCPP_ASSERT and _LIBCPP_DEBUG_ASSERT
Louis Dionne [Thu, 24 Mar 2022 13:03:56 +0000 (09:03 -0400)]
[libc++] Audit all uses of _LIBCPP_ASSERT and _LIBCPP_DEBUG_ASSERT

I audited all uses of _LIBCPP_ASSERT to make sure that we only used it
for "basic assertions", i.e. assertions with constant-time conditions.
I also audited all uses of _LIBCPP_DEBUG_ASSERT to make sure we used it
only for debug-mode assertions, and in one case had to change for
_LIBCPP_ASSERT instead.

As a fly-by, I also changed a couple of tests against nullptr or 0 to
be more explicit.

After this patch, all uses of _LIBCPP_ASSERT should be with constant-time
conditions, and all uses of _LIBCPP_DEBUG_ASSERT should be with conditions
that we only want to check when the debug mode is enabled.

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

2 years ago[LLDB] Cleanup for Fixing DWARFExpression handling of ValueType::FileAddress case...
Shafik Yaghmour [Thu, 24 Mar 2022 16:58:58 +0000 (09:58 -0700)]
[LLDB] Cleanup for Fixing DWARFExpression handling of ValueType::FileAddress case for DW_OP_deref_size

Late review on https://reviews.llvm.org/D121408 spotted some nice quick clean-ups on this code.

2 years ago[polly] Remove last instances of -analyze
Arthur Eubanks [Tue, 22 Mar 2022 00:41:06 +0000 (17:41 -0700)]
[polly] Remove last instances of -analyze

As mentioned in D120782, the loop block order can be different depending
on if LoopInfo is incrementally updated or freshly computed.

Reviewed By: Meinersbur

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

2 years ago[TSan] Add a runtime flag to print full thread creation stacks up to the main thread
Dmitry Vyukov [Thu, 24 Mar 2022 16:07:32 +0000 (17:07 +0100)]
[TSan] Add a runtime flag to print full thread creation stacks up to the main thread

Currently, we only print how threads involved in data race are created from their parent threads.
Add a runtime flag 'print_full_thread_history' to print thread creation stacks for the threads involved in the data race and their ancestors up to the main thread.

Reviewed By: dvyukov

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

2 years ago[OpenMP] Initial parsing/sema for the 'omp target parallel loop' construct
Mike Rice [Wed, 23 Mar 2022 22:37:06 +0000 (15:37 -0700)]
[OpenMP] Initial parsing/sema for the 'omp target parallel loop' construct

 Adds basic parsing/sema/serialization support for the
 #pragma omp target parallel loop directive.

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

2 years ago[AArch64] Async unwind - function prologues
Momchil Velikov [Thu, 24 Mar 2022 15:27:04 +0000 (15:27 +0000)]
[AArch64] Async unwind - function prologues

Re-commit of 32e8b550e5439c7e4aafa73894faffd5f25d0d05

This patch rearranges emission of CFI instructions, so the resulting
DWARF and `.eh_frame` information is precise at every instruction.

The current state is that the unwind info is emitted only after the
function prologue. This is fine for synchronous (e.g. C++) exceptions,
but the information is generally incorrect when the program counter is
at an instruction in the prologue or the epilogue, for example:

```
stp x29, x30, [sp, #-16]!           // 16-byte Folded Spill
mov x29, sp
.cfi_def_cfa w29, 16
...
```

after the `stp` is executed the (initial) rule for the CFA still says
the CFA is in the `sp`, even though it's already offset by 16 bytes

A correct unwind info could look like:
```
stp x29, x30, [sp, #-16]!           // 16-byte Folded Spill
.cfi_def_cfa_offset 16
mov x29, sp
.cfi_def_cfa w29, 16
...
```

Having this information precise up to an instruction is useful for
sampling profilers that would like to get a stack backtrace. The end
goal (towards this patch is just a step) is to have fully working
`-fasynchronous-unwind-tables`.

Reviewed By: danielkiss, MaskRay

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

2 years ago[flang[OpenACC] Lower wait directive
Valentin Clement [Thu, 24 Mar 2022 16:15:00 +0000 (17:15 +0100)]
[flang[OpenACC] Lower wait directive

This patch adds lowering for the `!$acc wait` directive
from the PFT to OpenACC dialect.

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

Reviewed By: PeteSteinfeld

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

2 years ago[SelectionDAG] Add AssertAlign to AddNodeIDCustom so that it will CSE properly.
Craig Topper [Thu, 24 Mar 2022 15:59:00 +0000 (08:59 -0700)]
[SelectionDAG] Add AssertAlign to AddNodeIDCustom so that it will CSE properly.

The alignment needs to be part of the folding set hash. This is
handled by getAssertAlign when nodes are created, but needs to repeated here.

No test case as I found it as part of a very early experimental patch.

Reviewed By: spatel

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

2 years ago[llvm] Initialize and move UseUpRegs outside of `union` MemOp struct.
Alexander Belyaev [Thu, 24 Mar 2022 15:29:21 +0000 (16:29 +0100)]
[llvm] Initialize and move UseUpRegs outside of `union` MemOp struct.

Asan complained about uninitialized bool

`invalid-bool-load`
llvm/lib/Target/X86/AsmParser/X86Operand.h:389:12: runtime error: load
of value 171, which is not a valid value for type 'bool'

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

2 years agoDiagnose use of a naked attribute on a member function in ms-mode
Aaron Ballman [Thu, 24 Mar 2022 15:51:31 +0000 (11:51 -0400)]
Diagnose use of a naked attribute on a member function in ms-mode

This matches the behavior of cl.exe.

2 years agoReland "[ELF] Enable new passmanager plugin support for LTO"
Jakob Koschel [Thu, 24 Mar 2022 06:52:16 +0000 (07:52 +0100)]
Reland "[ELF] Enable new passmanager plugin support for LTO"

This is the orignal patch + a check that LLVM_BUILD_EXAMPLES is enabled before
adding a dependency on the 'Bye' example pass.

Original summary:

Add cli options for new passmanager plugin support to lld.

Currently it is not possible to load dynamic NewPM plugins with lld. This is an
incremental update to D76866. While that patch only added cli options for
llvm-lto2, this adds them for lld as well. This is especially useful for running
dynamic plugins on the linux kernel with LTO.

Reviewed By: MaskRay

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

2 years ago[VPlan] Add VPWidenPointerInductionRecipe.
Florian Hahn [Thu, 24 Mar 2022 14:58:23 +0000 (14:58 +0000)]
[VPlan] Add VPWidenPointerInductionRecipe.

This patch moves pointer induction handling from VPWidenPHIRecipe to its
own recipe. In the process, it adds all information required to generate
code for pointer inductions without relying on Legal to access the list
of induction phis.

Alternatively VPWidenPHIRecipe could also take an optional pointer to InductionDescriptor.

Reviewed By: Ayal

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

2 years agoFix a crash with variably-modified parameter types in a naked function
Aaron Ballman [Thu, 24 Mar 2022 14:38:37 +0000 (10:38 -0400)]
Fix a crash with variably-modified parameter types in a naked function

Naked functions have no prolog, so it's not valid to emit prolog code
to evaluate the variably-modified type. This fixes Issue 50541.

2 years ago[flang[OpenACC] Lower data directive
Valentin Clement [Thu, 24 Mar 2022 14:29:59 +0000 (15:29 +0100)]
[flang[OpenACC] Lower data directive

This patch adds lowering for the `!$acc data`
from the PFT to OpenACC dialect.

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

Depends on D122384

Reviewed By: PeteSteinfeld

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

2 years ago[InstCombine] merge shuffled vector negate and multiply
Sanjay Patel [Thu, 24 Mar 2022 14:01:41 +0000 (10:01 -0400)]
[InstCombine] merge shuffled vector negate and multiply

Add the "(0 - X) --> (X * -1)" reverse identity to the list of alternate form binops.

We need a little hack to make the existing logic work because it does not expect to
move constants from op0 to op1, but the code comment hopefully makes that clear.
I don't think there are any other identities like that.

Fixes #54364

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

2 years ago[libc++][NFC] Refactor the ABI changelog
Louis Dionne [Thu, 24 Mar 2022 14:00:23 +0000 (10:00 -0400)]
[libc++][NFC] Refactor the ABI changelog

Add missing commit SHAs in a few cases, and use "All Platforms" when
the change affected all platforms instead of explicitly listing the
platforms, since there's too many to list exhaustively.

2 years ago[clangd] Retain main file fixes attached to diags from preamble
Kadir Cetinkaya [Wed, 23 Mar 2022 14:22:47 +0000 (15:22 +0100)]
[clangd] Retain main file fixes attached to diags from preamble

Clangd ignores fixits if the diagnsotics is outside the main file (e.g.
a note on a declaration from a header), but the fix might still be inside the
main file (e.g. change the function call).

This patch changes the logic to retain fixes that touch main file, if the
diagnostic owning them is still inside main file, even if they are attached to a
note outside the main file.

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

2 years ago[flang][OpenACC] Lower update directive
Valentin Clement [Thu, 24 Mar 2022 14:18:29 +0000 (15:18 +0100)]
[flang][OpenACC] Lower update directive

This patch adds lowering for the `!$acc update`
from the PFT to OpenACC dialect.

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

Depends on D122387

Reviewed By: PeteSteinfeld

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

2 years ago[flang][OpenACC] Lower init/shutdown directive
Valentin Clement [Thu, 24 Mar 2022 14:16:46 +0000 (15:16 +0100)]
[flang][OpenACC] Lower init/shutdown directive

This patch adds lowering for the `!$acc init` and `!$acc shutdown`
from the PFT to OpenACC dialect.

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

Depends on D122384

Reviewed By: PeteSteinfeld

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

2 years ago[flang][OpenACC] Lower exit data directive
Valentin Clement [Thu, 24 Mar 2022 14:15:40 +0000 (15:15 +0100)]
[flang][OpenACC] Lower exit data directive

This patch adds lowering for the `!$acc exit data` directive
from the PFT to OpenACC dialect.

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

Depends on D122384

Reviewed By: PeteSteinfeld

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

2 years ago[flang][OpenACC] Lower enter data directive
Valentin Clement [Thu, 24 Mar 2022 14:00:52 +0000 (15:00 +0100)]
[flang][OpenACC] Lower enter data directive

This patch adds lowering for the `!$acc enter data` directive
from the PFT to OpenACC dialect.

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

Reviewed By: PeteSteinfeld

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

2 years ago[flang][NFC] Add lowering test for array expression
Valentin Clement [Thu, 24 Mar 2022 13:58:27 +0000 (14:58 +0100)]
[flang][NFC] Add lowering test for array expression

This patches adds lowering tests for some array
expressions use cases.

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

Reviewed By: PeteSteinfeld

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2 years ago[libc++][NFC] Update ABI changelog to account for new assertion handler
Louis Dionne [Thu, 24 Mar 2022 13:57:28 +0000 (09:57 -0400)]
[libc++][NFC] Update ABI changelog to account for new assertion handler

2 years ago[OpenCL] opencl-c.h: remove x/y/z arg names
Sven van Haastregt [Thu, 24 Mar 2022 13:55:41 +0000 (13:55 +0000)]
[OpenCL] opencl-c.h: remove x/y/z arg names

This simplifies completeness comparisons against OpenCLBuiltins.td and
also makes the header no longer "claim" the identifiers "x", "y" and
"z".

Continues the direction set out in D119560.

2 years ago[gn build] Port 62d5f254ccd0
LLVM GN Syncbot [Thu, 24 Mar 2022 13:50:02 +0000 (13:50 +0000)]
[gn build] Port 62d5f254ccd0

2 years ago[pseudo] Introduce parse forest.
Haojian Wu [Mon, 21 Mar 2022 14:32:15 +0000 (15:32 +0100)]
[pseudo] Introduce parse forest.

Parse forest is the output of the GLR parser, it is a tree-like DAG
which presents all possible parse trees without duplicating subparse structures.

This is a patch split from https://reviews.llvm.org/D121150.

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

2 years agoNFC: [LICM] Update some stale comments
Djordje Todorovic [Wed, 23 Mar 2022 15:00:03 +0000 (16:00 +0100)]
NFC: [LICM] Update some stale comments

After removing the MaybePromotable, some comments
became stale. This improves them.

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

2 years ago[pseudo] Sort nonterminals based on their reduction order.
Haojian Wu [Wed, 23 Mar 2022 10:38:49 +0000 (11:38 +0100)]
[pseudo] Sort nonterminals based on their reduction order.

Reductions need to be performed in a careful order in GLR parser, to
make sure we gather all alternatives before creating an ambigous forest
node.

This patch encodes the nonterminal order into the rule id, so that we
can efficiently to determinal ordering of reductions in GLR parser.

This patch also abstracts to a TestGrammar, which is shared among tests.

This is a part of the GLR parser, https://reviews.llvm.org/D121368,
https://reviews.llvm.org/D121150

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

2 years ago[NFC] Format and uglify PowerPC intrinsics headers
Qiu Chaofan [Thu, 24 Mar 2022 12:46:35 +0000 (20:46 +0800)]
[NFC] Format and uglify PowerPC intrinsics headers

This change formats PowerPC intrinsics wrapper headers into LLVM style,
and add extra prefix '__' to all variables to prevent conflict with user
code.

2 years ago[gn build] remove a "from __future__" import not needed after 0ff3cc2087b9
Nico Weber [Thu, 24 Mar 2022 13:07:46 +0000 (09:07 -0400)]
[gn build] remove a "from __future__" import not needed after 0ff3cc2087b9

2 years ago[SLP][NFC]Fix param name in comments, NFC.
Alexey Bataev [Thu, 24 Mar 2022 12:48:35 +0000 (05:48 -0700)]
[SLP][NFC]Fix param name in comments, NFC.

2 years ago[clang] Reformat
Nathan Sidwell [Wed, 23 Mar 2022 14:27:43 +0000 (07:27 -0700)]
[clang] Reformat

Reformat some misindentation that is coincidentally close to a piece
being worked on.

Reviewed By: dblaikie

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

2 years agoTypo fix in the documentation; NFC
Aaron Ballman [Thu, 24 Mar 2022 12:55:43 +0000 (08:55 -0400)]
Typo fix in the documentation; NFC

2 years ago[compiler-rt] [cmake] Fix a typo in a variable name
Martin Storsjö [Thu, 24 Mar 2022 11:05:30 +0000 (13:05 +0200)]
[compiler-rt] [cmake] Fix a typo in a variable name

There's no other references to this variable name, but other files
refer to the same with the same name but with double Fs.

2 years ago[trace][intelpt] Server side changes for TSC to wall time conversion
Jakob Johnson [Tue, 22 Mar 2022 13:15:56 +0000 (06:15 -0700)]
[trace][intelpt] Server side changes for TSC to wall time conversion

Update the response schema of the TraceGetState packet and add
Intel PT specific response structure that contains the TSC conversion,
if it exists. The IntelPTCollector loads the TSC conversion and caches
it to prevent unnecessary calls to perf_event_open. Move the TSC conversion
calculation from Perf.h to TraceIntelPTGDBRemotePackets.h to remove
dependency on Linux specific headers.

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

2 years ago[gn build] Port 406bde9a1513
LLVM GN Syncbot [Thu, 24 Mar 2022 12:12:11 +0000 (12:12 +0000)]
[gn build] Port 406bde9a1513

2 years ago[lldb] Avoid pointer element type accesses
Nikita Popov [Thu, 24 Mar 2022 12:07:24 +0000 (13:07 +0100)]
[lldb] Avoid pointer element type accesses

2 years ago[PowerPC] [Clang] Add SSE4 and BMI intrinsics implementation
Qiu Chaofan [Thu, 24 Mar 2022 12:03:08 +0000 (20:03 +0800)]
[PowerPC] [Clang] Add SSE4 and BMI intrinsics implementation

Reviewed By: jsji

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

2 years ago[lldb] Use byval type
Nikita Popov [Thu, 24 Mar 2022 11:55:42 +0000 (12:55 +0100)]
[lldb] Use byval type

Query byval type instead of pointer element type.

2 years ago[lldb] Remove unused Module argument (NFC)
Nikita Popov [Thu, 24 Mar 2022 11:53:02 +0000 (12:53 +0100)]
[lldb] Remove unused Module argument (NFC)

2 years ago[Docs] Update opaque pointers transition state (NFC)
Nikita Popov [Thu, 24 Mar 2022 10:51:04 +0000 (11:51 +0100)]
[Docs] Update opaque pointers transition state (NFC)

Opaque pointer support in Clang is now complete.

2 years ago[X86][NFC] Remove unused variable introduce by D121785
Shengchen Kan [Thu, 24 Mar 2022 10:46:59 +0000 (18:46 +0800)]
[X86][NFC] Remove unused variable introduce by D121785

2 years ago[mlir][linalg] Support padding LinalgOps in use-def chain.
gysit [Thu, 24 Mar 2022 10:28:20 +0000 (10:28 +0000)]
[mlir][linalg] Support padding LinalgOps in use-def chain.

Previously, only LinalgOps whose operands are defined by an ExtractSliceOp could be padded. The revision supports walking a use-def chain of LinalgOps to find an ExtractSliceOp.

Reviewed By: hanchung

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

2 years ago[NFC] Mark derived destructors as `override`
Antonio Frighetto [Thu, 24 Mar 2022 10:42:47 +0000 (11:42 +0100)]
[NFC] Mark derived destructors as `override`

Derived destructors can be marked as override, in order to prevent
possible compilation failures of projects depending on those
headers (when compiled with flags -Wall, -Wsuggest-destructor-override,
-Winconsistent-missing-destructor-override).

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

2 years ago[mlir][linalg] Do not fuse shape-only producers.
gysit [Thu, 24 Mar 2022 10:22:28 +0000 (10:22 +0000)]
[mlir][linalg] Do not fuse shape-only producers.

This revision introduces a heuristic to stop fusion for shape-only tensors. A shape-only tensor only defines the shape of the consumer computation while the data is not used. Pure producer consumer fusion thus shall not fuse the producer of a shape-only tensor. In particular, since the shape-only tensor will have other uses that actually consume the data.

The revision enables fusion for consumers that have two uses of the same tensor. One as input operand and one as shape-only output operand. In these cases, we want to fuse only the input operand and avoid output fusion via iteration argument.

Reviewed By: hanchung

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