platform/upstream/llvm.git
2 years ago[SLP] Explicit track required stacksave/alloca dependency (try 3)
Philip Reames [Fri, 25 Mar 2022 16:09:02 +0000 (09:09 -0700)]
[SLP] Explicit track required stacksave/alloca dependency (try 3)

This is an extension of commit b7806c to handle one last case noticed in test changes for D118538.  Again, this is thought to be a latent bug in the existing code, though this time I have not managed to reduce tests for the original algoritthm.

The prior attempt had failed to account for this case:
  %a = alloca i8
  stacksave
  stackrestore
  store i8 0, i8* %a

If we allow '%a' to reorder into the stacksave/restore region, then the alloca will be deallocated before the use.  We will have taken a well defined program, and introduced a use-after-free bug.

There's also an inverse case where the alloca originally follows the stackrestore, and we need to prevent the reordering it above the restore.

Compile time wise, we potentially do an extra scan of the block for each alloca seen in a bundle.  This is significantly more expensive than the stacksave rooted version and is why I'd tried to avoid this in the initial patch.  There is room to optimize this (by essentially caching a "has stacksave" bit per block), but I'm leaving that to future work if it actually shows up in practice.  Since allocas in bundles should be rare in practice, I suspect we can defer the complexity for a long while.

2 years ago[InstrProfiling] No runtime hook for unused funcs
Gulfem Savrun Yeniceri [Wed, 23 Mar 2022 16:22:32 +0000 (16:22 +0000)]
[InstrProfiling] No runtime hook for unused funcs

CoverageMappingModuleGen generates a coverage mapping record
even for unused functions with internal linkage, e.g.
static int foo() { return 100; }
Clang frontend eliminates such functions, but InstrProfiling pass
still pulls in profile runtime since there is a coverage record.
Fuchsia uses runtime counter relocation, and pulling in profile
runtime for unused functions causes a linker error:
undefined hidden symbol: __llvm_profile_counter_bias.
Since 389dc94d4be7, we do not hook profile runtime for the binaries
that none of its translation units have been instrumented in Fuchsia.
This patch extends that for the instrumented binaries that
consist of only unused functions.

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

2 years ago[Support/BLAKE3] Do manual instrumentation of `llvm_blake3_hasher_finalize` for memor...
Argyrios Kyrtzidis [Fri, 25 Mar 2022 16:47:41 +0000 (09:47 -0700)]
[Support/BLAKE3] Do manual instrumentation of `llvm_blake3_hasher_finalize` for memory sanitizer

This is to avoid false positives when using the uninstrumented assembly code implementation.

2 years ago[LV] Use getVectorLoopRegion to retrieve header. (NFC)
Florian Hahn [Fri, 25 Mar 2022 16:57:12 +0000 (16:57 +0000)]
[LV] Use getVectorLoopRegion to retrieve header. (NFC)

Update all places that currently assume the entry block to the plan is
also the vector loop header to use getVectorLoopRegion instead.

getVectorLoopRegion will keep doing the right thing when the pre-header
is modeled explicitly (and becomes the new entry block in the plan).

2 years ago[lldb] Conditionalize target_link_libraries on the target
Jonas Devlieghere [Fri, 25 Mar 2022 16:47:08 +0000 (09:47 -0700)]
[lldb] Conditionalize target_link_libraries on the target

Fixes "Cannot specify link libraries for target "lldb-target-fuzzer"
which is not built by this project." Normally that's taken care of by
add_llvm_fuzzer but we need target_link_libraries for liblldb and our
utility library.

2 years ago[mlir][tosa] : adding folder and canonicalizer for select
lipracer [Fri, 25 Mar 2022 16:49:14 +0000 (16:49 +0000)]
[mlir][tosa] : adding folder and canonicalizer for select

define canonicalizer and folder for tosa::select

Reviewed By: mehdi_amini, Mogball

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

2 years ago[flang] Fix cycle-catcher in procedure characterization
Peter Klausler [Mon, 21 Mar 2022 23:18:03 +0000 (16:18 -0700)]
[flang] Fix cycle-catcher in procedure characterization

The "seenProcs" sets passed as arguments to the procedure and dummy
procedure characterization routines need to be passed by value so that
local updates to those sets do not become permanent.  They are
presently passed by reference and that has led to bogus errors about
recursively defined procedures in testing.

(It might be faster to pass the sets by reference and undo those local
updates in these functions, but that's error-prone, and the performance
difference is not expected to be detectable in practice.)

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

2 years ago[clang][dataflow] Add support for disabling warnings on smart pointers.
Yitzhak Mandelbaum [Mon, 21 Mar 2022 15:03:52 +0000 (15:03 +0000)]
[clang][dataflow] Add support for disabling warnings on smart pointers.

This patch provides the user with the ability to disable all checked of accesses
to optionals that are the pointees of smart pointers. Since smart pointers are
not modeled (yet), the system cannot distinguish safe from unsafe accesses to
optionals through smart pointers. This results in false positives whenever
optionals are used through smart pointers. The patch gives the user the choice
of ignoring all positivess in these cases.

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

2 years ago[OpenMP][FIX] Ensure exclusive access to the HDTT map
Johannes Doerfert [Sat, 5 Mar 2022 21:14:20 +0000 (15:14 -0600)]
[OpenMP][FIX] Ensure exclusive access to the HDTT map

This patch solves two problems with the `HostDataToTargetMap` (HDTT
map) which caused races and crashes before:

1) Any access to the HDTT map needs to be exclusive access. This was not
   the case for the "dump table" traversals that could collide with
   updates by other threads. The new `Accessor` and `ProtectedObject`
   wrappers will ensure we have a hard time introducing similar races in
   the future. Note that we could allow multiple concurrent
   read-accesses but that feature can be added to the `Accessor` API
   later.
2) The elements of the HDTT map were `HostDataToTargetTy` objects which
   meant that they could be copied/moved/deleted as the map was changed.
   However, we sometimes kept pointers to these elements around after we
   gave up the map lock which caused potential races again. The new
   indirection through `HostDataToTargetMapKeyTy` will allows us to
   modify the map while keeping the (interesting part of the) entries
   valid. To offset potential cost we duplicate the ordering key of the
   entry which avoids an additional indirect lookup.

We should replace more objects with "protected objects" as we go.

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

2 years ago[lldb] Add a fuzzer for target creation
Jonas Devlieghere [Fri, 25 Mar 2022 16:03:52 +0000 (09:03 -0700)]
[lldb] Add a fuzzer for target creation

This patch adds a generic fuzzer that interprets inputs as object files
and uses them to create a target in lldb. It is very similar to the
llvm-dwarfdump fuzzer which found a bunch of issues in libObject.

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

2 years ago[libc] Improve the performance of expf.
Tue Ly [Thu, 24 Mar 2022 22:07:46 +0000 (18:07 -0400)]
[libc] Improve the performance of expf.

Reduce the polynomial's degree from 7 down to 4.

Currently we use a degree-7 minimax polynomial on an interval of length 2^-7
around 0 to compute `expf`. Based on the suggestion of @santoshn and the RLIBM
project (https://github.com/rutgers-apl/rlibm-all/blob/main/source/float/exp.c)
and the improvement we made with `exp2f` in https://reviews.llvm.org/D122346,
it is possible to have a good polynomial of degree-4 on a subinterval of length
2^(-7) to approximate e^x.

We did try to either reduce the degree of the polynomial down to 3 or increase
the interval size to 2^(-6), 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^(-7) around 0.

Reviewed By: sivachandra, zimmermann6, santoshn

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

2 years ago[NFCI] Fix set-but-unused warning in DenseMap.h in some configurations
Dávid Bolvanský [Fri, 25 Mar 2022 16:12:53 +0000 (17:12 +0100)]
[NFCI] Fix set-but-unused warning in DenseMap.h in some configurations

2 years ago[NFCI] Fix set-but-unused warning in AArch64AsmParser.cpp
Dávid Bolvanský [Fri, 25 Mar 2022 16:10:25 +0000 (17:10 +0100)]
[NFCI] Fix set-but-unused warning in AArch64AsmParser.cpp

2 years ago[CSSPGO] Turn on profi and ext-tsp when using probe-based profile.
Hongtao Yu [Thu, 24 Mar 2022 23:30:20 +0000 (16:30 -0700)]
[CSSPGO] Turn on profi and ext-tsp when using probe-based profile.

Probe-based profile leads to a better performance when combined with profi and ext-tsp block layout. I'm turning them on by default.

Reviewed By: wenlei

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

2 years ago[slp] Factor out a lambda to avoid uplicating code a third time in upcoming patch...
Philip Reames [Fri, 25 Mar 2022 16:02:23 +0000 (09:02 -0700)]
[slp] Factor out a lambda to avoid uplicating code a third time in upcoming patch [nfc]

2 years ago[AVR][NFC] Fix incorrect register states in expanding pseudo instructions
Ben Shi [Thu, 27 Jan 2022 12:51:52 +0000 (12:51 +0000)]
[AVR][NFC] Fix incorrect register states in expanding pseudo instructions

Reviewed By: aykevl

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

2 years ago[gn build] Port 39b80c8380c8
LLVM GN Syncbot [Fri, 25 Mar 2022 15:50:53 +0000 (15:50 +0000)]
[gn build] Port 39b80c8380c8

2 years ago[test,slp] Add another stacksave related dependence test
Philip Reames [Fri, 25 Mar 2022 15:48:08 +0000 (08:48 -0700)]
[test,slp] Add another stacksave related dependence test

2 years ago[clang-tidy] Add modernize-macro-to-enum check
Richard [Mon, 3 Jan 2022 16:24:12 +0000 (09:24 -0700)]
[clang-tidy] Add modernize-macro-to-enum check

This check performs basic analysis of macros and replaces them
with an anonymous unscoped enum.  Using an unscoped anonymous enum
ensures that everywhere the macro token was used previously, the
enumerator name may be safely used.

Potential macros for replacement must meet the following constraints:
- Macros must expand only to integral literal tokens.  The unary
  operators plus, minus and tilde are recognized to allow for positive,
  negative and bitwise negated integers.
- Macros must be defined on sequential source file lines, or with
  only comment lines in between macro definitions.
- Macros must all be defined in the same source file.
- Macros must not be defined within a conditional compilation block.
- Macros must not be defined adjacent to other preprocessor directives.
- Macros must not be used in preprocessor conditions

Each cluster of macros meeting the above constraints is presumed to
be a set of values suitable for replacement by an anonymous enum.
From there, a developer can give the anonymous enum a name and
continue refactoring to a scoped enum if desired.  Comments on the
same line as a macro definition or between subsequent macro definitions
are preserved in the output.  No formatting is assumed in the provided
replacements.

The check cppcoreguidelines-macro-to-enum is an alias for this check.

Fixes #27408

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

2 years ago[InstCombine] SimplifyDemandedUseBits - remove ashr node if we only demand known...
Simon Pilgrim [Fri, 25 Mar 2022 15:39:08 +0000 (15:39 +0000)]
[InstCombine] SimplifyDemandedUseBits - remove ashr node if we only demand known sign bits

We already do this for SelectionDAG, but we're missing it here.

Noticed while re-triaging PR21929

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

2 years ago[OpenMP] Replace device kernel linkage with weak_odr
Joseph Huber [Thu, 24 Mar 2022 23:32:05 +0000 (19:32 -0400)]
[OpenMP] Replace device kernel linkage with weak_odr

Currently the device kernels all have weak linkage to prevent linkage
errors on multiple defintions. However, this prevents some optimizations
from adequately analyzing them because of the nature of weak linkage.
This patch replaces the weak linkage with weak_odr linkage so we can
statically assert that multiple declarations of the same kernel will
have the same definition.

Reviewed By: jdoerfert

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

2 years ago[AMDGPU][DOC][NFC] Added GFX1030 assembler syntax description
Dmitry Preobrazhensky [Fri, 25 Mar 2022 14:52:13 +0000 (17:52 +0300)]
[AMDGPU][DOC][NFC] Added GFX1030 assembler syntax description

2 years ago[C++20][Modules] Correct an assert for modules-ts.
Iain Sandoe [Thu, 24 Mar 2022 13:10:38 +0000 (13:10 +0000)]
[C++20][Modules] Correct an assert for modules-ts.

When adding the support for modules partitions we added an assert that the
actual status of Global Module Fragments matches the state machine that is
driven by the module; keyword.

That does not apply to the modules-ts case, where there is an implicit GMF.

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

2 years ago[clang] Do not crash on arrow operator on dependent type.
Adam Czachorowski [Wed, 16 Mar 2022 13:27:27 +0000 (14:27 +0100)]
[clang] Do not crash on arrow operator on dependent type.

There seems to be more than one way to get to that state. I included to
example cases in the test, both were noticed recently.

There is room for improvement, for example by creating RecoveryExpr in
place of the bad initializer, but for now let's stop the crashes.

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

2 years agoReapply "[Intrinsics] Add `nocallback` to the default intrinsic attributes"
Johannes Doerfert [Thu, 24 Mar 2022 20:08:53 +0000 (15:08 -0500)]
Reapply "[Intrinsics] Add `nocallback` to the default intrinsic attributes"

This reverts commit c5f789050daab25aad6770790987e2b7c0395936 and
reapplies 7aea3ea8c3b33c9bb338d5d6c0e4832be1d09ac3 with additional test
changes.

2 years ago[Flang] Lower achar intrinsic
Kiran Chandramohan [Fri, 25 Mar 2022 14:22:49 +0000 (14:22 +0000)]
[Flang] Lower achar intrinsic

The intrinsic returns the character located at the position requested
in the ASCII sequence. The intrinsic is lowered to inline FIR code.

This is part of the upstreaming effort from the fir-dev branch in [1].
[1] https://github.com/flang-compiler/f18-llvm-project

Reviewed By: clementval

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

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2 years ago[AMDGPU] Move VOP3 classes into VOPInstructions.td. NFC.
Jay Foad [Fri, 25 Mar 2022 09:57:28 +0000 (09:57 +0000)]
[AMDGPU] Move VOP3 classes into VOPInstructions.td. NFC.

These classes are also used by VOP1/2/C instructions.

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

2 years ago[X86] Add test showing failure to fold multiple constant args in ADC
Simon Pilgrim [Fri, 25 Mar 2022 13:41:59 +0000 (13:41 +0000)]
[X86] Add test showing failure to fold multiple constant args in ADC

As noticed on Issue #35256

2 years ago[mlir][Vector] Add integration tests for ArmSVE
Javier Setoain [Thu, 3 Jun 2021 09:34:44 +0000 (10:34 +0100)]
[mlir][Vector] Add integration tests for ArmSVE

In order to run these integration tests, it is required access to an
SVE-enabled CPU or and emulator with SVE support. In case of using
an emulator, aarch64 versions of lli and the MLIR C Runner Utils Library
are also required.

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

2 years ago[pseudo] Use box-drawing chars to prettify debug dumps. NFC
Sam McCall [Fri, 25 Mar 2022 13:17:31 +0000 (14:17 +0100)]
[pseudo] Use box-drawing chars to prettify debug dumps. NFC

2 years ago[SimplifyCFG] `FoldBranchToCommonDest()`: allow branch-on-select
Roman Lebedev [Fri, 25 Mar 2022 12:11:49 +0000 (15:11 +0300)]
[SimplifyCFG] `FoldBranchToCommonDest()`: allow branch-on-select

This whole check is bogus, it's some kind of a profitability check.
For now, simply extend it to not only allow branch-on-binary-ops,
but also on poison-safe logic ops.

Refs. https://github.com/llvm/llvm-project/issues/53861
Refs. https://github.com/llvm/llvm-project/issues/54553

2 years ago[NFC][SimplifyCFG] Add test from https://github.com/llvm/llvm-project/issues/53861
Roman Lebedev [Fri, 25 Mar 2022 12:09:50 +0000 (15:09 +0300)]
[NFC][SimplifyCFG] Add test from https://github.com/llvm/llvm-project/issues/53861

2 years ago[X86] combineADC - pull out repeated dyn_cast<ConstantSDNode> calls. NFC.
Simon Pilgrim [Fri, 25 Mar 2022 12:52:53 +0000 (12:52 +0000)]
[X86] combineADC - pull out repeated dyn_cast<ConstantSDNode> calls. NFC.

2 years ago[libc++] Remove the _LIBCPP_BOOL_CONSTANT macro
Louis Dionne [Wed, 23 Mar 2022 21:02:07 +0000 (17:02 -0400)]
[libc++] Remove the _LIBCPP_BOOL_CONSTANT macro

I suspect this is a remnant of the times when we were not comfortable
using Clang's C++11/14 extensions everywhere, but now we do, so we can
use _BoolConstant instead and get rid of the macro.

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

2 years agoUpdated MLIR type stubs to work with pytype
Sergei Lebedev [Fri, 25 Mar 2022 12:38:13 +0000 (13:38 +0100)]
Updated MLIR type stubs to work with pytype

The diff is big, but there are in fact only three kinds of changes

* ir.py had a synax error -- underminated [
* forward references are unnecessary in .pyi files (see https://github.com/python/typeshed/blob/9a76b13127ffa8365431dcc105fc111cdd267e7e/CONTRIBUTING.md?plain=1#L450-L454)
* methods defined via .def_static() are now decorated with @staticmethod

Reviewed By: ftynse

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

2 years agoPrevent comparison with wider type in loop condition
Aakanksha [Fri, 25 Mar 2022 11:33:25 +0000 (11:33 +0000)]
Prevent comparison with wider type in loop condition

This change fixes the code violations flagged in AMD compute CodeQL scan - "comparison-with-wider-type"

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

2 years agoFix clang Sphinx build bot
Aaron Ballman [Fri, 25 Mar 2022 11:13:26 +0000 (07:13 -0400)]
Fix clang Sphinx build bot

2 years ago[SDAG] enable binop identity constant folds for multiplies
Simon Pilgrim [Fri, 25 Mar 2022 11:06:41 +0000 (11:06 +0000)]
[SDAG] enable binop identity constant folds for multiplies

Add mul to the list of ops that we canonicalize with a select to expose an identity merge

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

2 years ago[bazel] Add missing dependency after a75a46db89
Benjamin Kramer [Fri, 25 Mar 2022 11:04:43 +0000 (12:04 +0100)]
[bazel] Add missing dependency after a75a46db89

2 years ago[bazel] Add missing dependency after a75a46db89
Benjamin Kramer [Fri, 25 Mar 2022 11:02:36 +0000 (12:02 +0100)]
[bazel] Add missing dependency after a75a46db89

2 years ago[mlir][Sparse] Add option for VLA sparsification
Javier Setoain [Thu, 2 Dec 2021 15:09:33 +0000 (15:09 +0000)]
[mlir][Sparse] Add option for VLA sparsification

Use "enable-vla-vectorization=vla" to generate a vector length agnostic
loops during vectorization. This option works for vectorization strategy 2.

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

2 years ago[X86] combineAdd - fold ADD(ADC(Y,0,W),X) -> ADC(X,Y,W)
Simon Pilgrim [Fri, 25 Mar 2022 10:49:04 +0000 (10:49 +0000)]
[X86] combineAdd - fold ADD(ADC(Y,0,W),X) -> ADC(X,Y,W)

This also exposed a missed ADC canonicalization of constant ops to the RHS

2 years ago[mlir][Vector] Enable create_mask for scalable vectors
Javier Setoain [Wed, 26 Jan 2022 15:01:39 +0000 (15:01 +0000)]
[mlir][Vector] Enable create_mask for scalable vectors

The way vector.create_mask is currently lowered is
vector-length-dependent, and therefore incompatible with scalable vector
types. This patch adds an alternative lowering path for create_mask
operations that return a scalable vector mask.

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

2 years ago[AMDGPU] Improve v_cmpx usage on GFX10.3.
Thomas Symalla [Tue, 1 Feb 2022 09:28:18 +0000 (10:28 +0100)]
[AMDGPU] Improve v_cmpx usage on GFX10.3.

On GFX10.3 targets, the following instruction sequence

v_cmp_* SGPR, ...
s_and_saveexec ..., SGPR

leads to a fairly long stall caused by a VALU write to a SGPR and having the
following SALU wait for the SGPR.

An equivalent sequence is to save the exec mask manually instead of letting
s_and_saveexec do the work and use a v_cmpx instruction instead to do the
comparison.

This patch modifies the SIOptimizeExecMasking pass as this is the last position
where s_and_saveexec instructions are inserted. It does the transformation by
trying to find the pattern, extracting the operands and generating the new
instruction sequence.

It also changes some existing lit tests and introduces a few new tests to show
the changed behavior on GFX10.3 targets.

Same as D119696 including a buildbot and MIR test fix.

Reviewed By: critson

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

2 years ago[AArch64] isProfitableToHoist - remove nullptr test
Simon Pilgrim [Fri, 25 Mar 2022 10:27:16 +0000 (10:27 +0000)]
[AArch64] isProfitableToHoist - remove nullptr test

User is dereferenced on the main codepath so the null test is likely superfluous

2 years ago[Utils] stripDebugifyMetadata - use cast<> instead of dyn_cast_or_null<> to avoid...
Simon Pilgrim [Fri, 25 Mar 2022 10:25:04 +0000 (10:25 +0000)]
[Utils] stripDebugifyMetadata - use cast<> instead of dyn_cast_or_null<> to avoid dereference of nullptr

The pointer is dereferenced immediately, so assert the cast is correct instead of returning nullptr

2 years ago[AsmPrinter] AIXException::endFunction - use cast<> instead of dyn_cast<> to avoid...
Simon Pilgrim [Fri, 25 Mar 2022 10:23:22 +0000 (10:23 +0000)]
[AsmPrinter] AIXException::endFunction - use cast<> instead of dyn_cast<> to avoid dereference of nullptr

The pointer is used immediately inside the getSymbol() call, so assert the cast is correct instead of returning nullptr

2 years ago[clang] CheckSizelessVectorOperands - use castAs<> instead of getAs<> to avoid derefe...
Simon Pilgrim [Fri, 25 Mar 2022 10:22:05 +0000 (10:22 +0000)]
[clang] CheckSizelessVectorOperands - use castAs<> instead of getAs<> to avoid dereference of nullptr

Move the only uses of the cast to where they are dereferenced.

2 years ago[X86] Add test showing failure to fold add(adc(x,0,carry),c) -> adc(x,c,carry)
Simon Pilgrim [Fri, 25 Mar 2022 10:14:11 +0000 (10:14 +0000)]
[X86] Add test showing failure to fold add(adc(x,0,carry),c) -> adc(x,c,carry)

2 years agoRevert "[AArch64] Lower 3 and 4 sources buildvectors to TBL"
David Green [Fri, 25 Mar 2022 10:03:10 +0000 (10:03 +0000)]
Revert "[AArch64] Lower 3 and 4 sources buildvectors to TBL"

This reverts commit ec93b28909749619dbe58b092a13da9d1ff1eb1e as problems
with it have been reported.

2 years ago[clang-format] Clean up DefinitionBlockSeparatorTest. NFC.
Marek Kurdej [Fri, 25 Mar 2022 09:44:36 +0000 (10:44 +0100)]
[clang-format] Clean up DefinitionBlockSeparatorTest. NFC.

2 years ago[PowerPC] Add test for failing lowering llvm.ppc.cfence on i128. NFC.
Kai Luo [Fri, 25 Mar 2022 09:54:34 +0000 (17:54 +0800)]
[PowerPC] Add test for failing lowering llvm.ppc.cfence on i128. NFC.

2 years ago[Clang] Added release note for improved -Wunused-but-set-variable warning
Dávid Bolvanský [Fri, 25 Mar 2022 09:45:08 +0000 (10:45 +0100)]
[Clang] Added release note for improved -Wunused-but-set-variable warning

2 years ago[NVPTX] Remove code duplication in LowerCall
Daniil Kovalev [Fri, 25 Mar 2022 09:36:20 +0000 (12:36 +0300)]
[NVPTX] Remove code duplication in LowerCall

In D120129 we enhanced vectorization options of byval parameters. This patch
removes code duplication when handling byval and non-byval cases.

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

2 years ago[C++20][Modules][HU 1/5] Introduce header units as a module type.
Iain Sandoe [Sun, 20 Sep 2020 08:29:14 +0000 (09:29 +0100)]
[C++20][Modules][HU 1/5] Introduce header units as a module type.

This is the first in a series of patches that introduce C++20 importable
header units.

These differ from clang header modules in that:
 (a) they are identifiable by an internal name
 (b) they represent the top level source for a single header - although
     that might include or import other headers.

We name importable header units with the path by which they are specified
(although that need not be the absolute path for the file).

So "foo/bar.h" would have a name "foo/bar.h".  Header units are made a
separate module type so that we can deal with diagnosing places where they
are permitted but a named module is not.

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

2 years ago[BPF] Don't fetch alignment of llvm.preserve.union.access.index argument
Nikita Popov [Thu, 24 Mar 2022 10:24:40 +0000 (11:24 +0100)]
[BPF] Don't fetch alignment of llvm.preserve.union.access.index argument

The way the alignment is determined here is not compatible with
opaque pointers -- we'd have to thread it through using either
align or elementtype attributes.

However, as far as I can tell this alignment is actually never
used for this particular intrinsic, so I've dropped the assignment
entirely and converted RecordAlignment to MaybeAlign, so we get an
assertion failure if it does end up being used.

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

2 years ago[flang][NFC] fix comment typo in SetLowerBound description
Jean Perier [Fri, 25 Mar 2022 08:18:09 +0000 (01:18 -0700)]
[flang][NFC] fix comment typo in SetLowerBound description

2 years ago[flang][codegen] ensure descriptor lower bounds are LBOUND compliant
Jean Perier [Fri, 25 Mar 2022 08:02:48 +0000 (09:02 +0100)]
[flang][codegen] ensure descriptor lower bounds are LBOUND compliant

Follow-up of https://reviews.llvm.org/D121488 to ensure all descriptors
created inline complies with LBOUND requirement that the lower bound is
`1` when the related dimension extent is zero.

Both fir.xrebox and fir.xembox codegen is updated to enforce this
constraint.

Also upstream the "normalized lower bound" attribute that was added in fir-dev
since embox codegen was upstreamed, it is conflicting with this patch
otherwise.

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

2 years ago[flang] Fix LBOUND rewrite on descriptor components
Jean Perier [Fri, 25 Mar 2022 08:00:23 +0000 (09:00 +0100)]
[flang] Fix LBOUND rewrite on descriptor components

GetLowerBoundHelper rewrite in https://reviews.llvm.org/D121488 was
incorrect with POINTER/ALLOCATABLE components. The rewrite created a
descriptor inquiry to the component symbol only instead of the whole
named entity. The base information was lost, and not retrievable.
LBOUND(a(10)%p) became LBOUND(p).

Fix this regression, and also update DescriptorInquiry unparsing to
carry the kind information. DescriptorInquiries are KIND 8 expressions,
while LBOUND/SIZE/RANK, %LEN are default kind expressions.
This caused `print *,lbound(x,kind=8)` to unparse as `print*,lbound(x)` which is not
semantically the same (this unparsing issue was not an issue for
lowering, but I noticed it while writing my regression test).

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

2 years agoRelease Workflow: Remove cherry-pick-failed label when pull request is created
Tom Stellard [Fri, 25 Mar 2022 07:45:25 +0000 (00:45 -0700)]
Release Workflow: Remove cherry-pick-failed label when pull request is created

Reviewed By: nikic

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

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)