platform/upstream/llvm.git
2 years ago[mlir] Flipping vector dialect to both prefixed form.
Jacques Pienaar [Tue, 15 Feb 2022 17:48:51 +0000 (09:48 -0800)]
[mlir] Flipping vector dialect to both prefixed form.

Following
https://discourse.llvm.org/t/psa-ods-generated-accessors-will-change-to-have-a-get-prefix-update-you-apis/4476

Mostly mechanical, avoiding function name conflicts.

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

2 years ago[clangd][NFC] includes missing headers
Christopher Di Bella [Tue, 15 Feb 2022 04:44:51 +0000 (04:44 +0000)]
[clangd][NFC] includes missing headers

`Shutdown.h` was transitively depending on two headers, but this isn't
allowed under a modules build, so they're now explicitly included.

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

2 years ago[libc++][ranges][NFC] Small formatting fixes to the Ranges algorithms' status.
Konstantin Varlamov [Tue, 15 Feb 2022 17:42:48 +0000 (09:42 -0800)]
[libc++][ranges][NFC] Small formatting fixes to the Ranges algorithms' status.

2 years ago[lldb] Fix uninitialized variable in EvaluateExpressionOptions
Jonas Devlieghere [Tue, 15 Feb 2022 17:39:33 +0000 (09:39 -0800)]
[lldb] Fix uninitialized variable in EvaluateExpressionOptions

Initialize m_pound_line_line to 0.

2 years ago[flang] Accept pointer assignment w/ remapping to function result
Peter Klausler [Tue, 8 Feb 2022 21:49:40 +0000 (13:49 -0800)]
[flang] Accept pointer assignment w/ remapping to function result

When a pointer assignment with bounds remapping has a function
reference as its right-hand side, don't check for array conformance.

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

2 years ago[ELF] Parse archives as --start-lib object files
Fangrui Song [Tue, 15 Feb 2022 17:38:00 +0000 (09:38 -0800)]
[ELF] Parse archives as --start-lib object files

https://maskray.me/blog/2022-01-16-archives-and-start-lib

For every definition in an extracted archive member, we intern the symbol twice,
once for the archive index entry, once for the .o symbol table after extraction.
This is inefficient.

Symbols in a --start-lib ObjFile/BitcodeFile are only interned once because the
result is cached in symbols[i].

Just handle an archive using the --start-lib code path. We can therefore remove
ArchiveFile and LazyArchive. For many projects, archive member extraction ratio
is high and it is a net performance win. Linking a Release build of clang is
1.01x as fast.

Note: --start-lib scans symbols in the same order that llvm-ar adds them to the
index, so in the common case the semantics should be identical. If the archive
symbol table was created in a different order, or is incomplete, this strategy
may have different semantics. Such cases are considered user error.

The `is neither ET_REL nor LLVM bitcode` error is changed to a warning.
Previously an archive may have such members without a diagnostic. Using a
warning prevents breakage.

* For some tests, the diagnostics get improved where we did not consider
  the archive member name: `b.a:` => `b.a(b.o):`.
* `no-obj.s`: the link is now allowed, matching GNU ld
* `archive-no-index.s`: the `is neither ET_REL nor LLVM bitcode` diagnostic is
  demoted to a warning.
* `incompatible.s`: even when an archive is unextracted, we may report an
  "incompatible with" error.

---

I recently decreased sizeof(SymbolUnion) by 8 and decreased memory usage quite a
bit, so retaining `symbols` for un-extracted archive members should not cause a
memory usage problem.

Reviewed By: peter.smith

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

2 years ago[gn build] (manually) port 3b625060fc915 (-std=c++20) more
Nico Weber [Tue, 15 Feb 2022 17:34:39 +0000 (12:34 -0500)]
[gn build] (manually) port 3b625060fc915 (-std=c++20) more

8c54583b2e ported this only for libcxx, not libcxxabi.
As of 05337a756c6, it's needed for libcxxabi too.

2 years ago[mlir][Arith] Disallow casting between scalable and fixed-length vectors
Javier Setoain [Fri, 11 Feb 2022 19:00:16 +0000 (19:00 +0000)]
[mlir][Arith] Disallow casting between scalable and fixed-length vectors

Casting between scalable vectors and fixed-length vectors doesn't make
sense. If one of the operands is scalable, the other has to be scalable
to be able to guarantee they have the same shape at runtime.

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

2 years ago[flang][nfc] Update D119555 comments and use getVoidPtr
Jean Perier [Tue, 15 Feb 2022 17:23:15 +0000 (18:23 +0100)]
[flang][nfc] Update D119555 comments and use getVoidPtr

Minor comment updates and use getVoidPtr helper instead of
builiding `i8*` type manually in codegen.

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

2 years ago[VP] Condition in vp.select|merge not a VP mask
Simon Moll [Tue, 15 Feb 2022 17:17:54 +0000 (18:17 +0100)]
[VP] Condition in vp.select|merge not a VP mask

vp.select|merge both select lanes based on a condition mask.  Unlike
other VP intrinsics the lanes are defined where the condition mask is
false. Hence, the condition mask in vp.select|mask is not a mask in the
sense of VP intrinsics.  By doing not treating the condition mask
specially, vp.select becomes the canonical VP translation of the select
instruction.

Reviewed By: frasercrmck

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

2 years ago[VP] vp.fptosi cast intrinsic and docs
Simon Moll [Tue, 15 Feb 2022 16:04:47 +0000 (17:04 +0100)]
[VP] vp.fptosi cast intrinsic and docs

Reviewed By: craig.topper

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

2 years ago[MLIR][GPU] Add missing include to SerilazeToHsaco
Krzysztof Drewniak [Tue, 15 Feb 2022 16:43:31 +0000 (16:43 +0000)]
[MLIR][GPU] Add missing include to SerilazeToHsaco

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

2 years ago[clang-format] Honour PointerAlignment in statements with initializers.
Marek Kurdej [Tue, 15 Feb 2022 08:52:33 +0000 (09:52 +0100)]
[clang-format] Honour PointerAlignment in statements with initializers.

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

Reviewed By: HazardyKnusperkeks, owenpan

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

2 years ago[libc] Improve performance of generic hypot when the exponent difference is sufficien...
Tue Ly [Tue, 15 Feb 2022 15:04:47 +0000 (10:04 -0500)]
[libc] Improve performance of generic hypot when the exponent difference is sufficiently large.

Simplify the logic when the exponent difference is at least MantissaLength + 2, while still maintaining correct rounding for all rounding modes.

Reviewed By: sivachandra

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

2 years ago[libc++][nfc] Add TEST_HAS_NO_FGETPOS_FSETPOS.
Mark de Wever [Fri, 11 Feb 2022 18:33:16 +0000 (19:33 +0100)]
[libc++][nfc] Add TEST_HAS_NO_FGETPOS_FSETPOS.

This avoids using an libc++ internal macro in our tests.

Reviewed By: #libc, philnik, ldionne

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

2 years ago[RISCV] Match vwmulsu_vx with scalar splat input.
Craig Topper [Tue, 15 Feb 2022 16:45:21 +0000 (08:45 -0800)]
[RISCV] Match vwmulsu_vx with scalar splat input.

This is a more generic version of D119110 that uses MaskedValueIsZero
to do the matching and SimplifyDemandedBits to remove any unneeded
AND instructions.

Tests were taken from D119110.

Reviewed By: Chenbing.Zheng

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

2 years ago[RISCV] Replace llvm_unreachable with report_fatal_error.
Craig Topper [Mon, 14 Feb 2022 20:06:38 +0000 (12:06 -0800)]
[RISCV] Replace llvm_unreachable with report_fatal_error.

Parsing errors aren't handled earlier in all cases. A simple
example is llc -mtriple=riscv64 -mattr=+zve32f. If F or Finx is
not also specified, this will hit a parse error.

Use a fatal_error so that the error is conveyed to the user.

2 years ago[libTooling] Change Tranformer's consumer to take multiple changes
Eric Li [Tue, 15 Feb 2022 15:48:51 +0000 (15:48 +0000)]
[libTooling] Change Tranformer's consumer to take multiple changes

Previously, Transformer would invoke the consumer once per file modified per
match, in addition to any errors encountered. The consumer is not aware of which
AtomicChanges come from any particular match. It is unclear which sets of edits
may be related or whether an error invalidates any previously emitted changes.

Modify the signature of the consumer to accept a set of changes. This keeps
related changes (i.e. all edits from a single match) together, and clarifies
that errors don't produce partial changes.

Reviewed By: ymandel

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

2 years ago[libc++] Allow backdeployment CI to run on newer macOS
Louis Dionne [Tue, 15 Feb 2022 14:34:04 +0000 (09:34 -0500)]
[libc++] Allow backdeployment CI to run on newer macOS

This should work now that we are using a matching libunwind.dylib when
we run the tests in back-deployment scenarios. The only restriction we
have now is to run on macOS x86_64, since that's what the old dylibs
were compiled for. This should allow us to move to newer AppleClangs
in the CI.

As a fly-by, fix missing availability annotations on optional's
monadic operations.

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

2 years ago[libc++] [test] Improve test coverage for std::{c,}{begin,end}.
Arthur O'Dwyer [Sun, 13 Feb 2022 20:39:14 +0000 (15:39 -0500)]
[libc++] [test] Improve test coverage for std::{c,}{begin,end}.

Incidentally, this removes some unqualified ADL calls to `begin` and `end`.

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

2 years ago[MLIR] Link SerializeToHsaco dependencies to correct MLIR library
Krzysztof Drewniak [Mon, 14 Feb 2022 21:22:35 +0000 (21:22 +0000)]
[MLIR] Link SerializeToHsaco dependencies to correct MLIR library

Reviewed By: mehdi_amini

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

2 years ago[SLP][NFC]Add a test for miscompilation of alternate cmp instructions,
Alexey Bataev [Tue, 15 Feb 2022 16:28:40 +0000 (08:28 -0800)]
[SLP][NFC]Add a test for miscompilation of alternate cmp instructions,
NFC.

2 years ago[libc++] Remove conditional noexcepts from view_interface.
Arthur O'Dwyer [Wed, 9 Feb 2022 19:31:21 +0000 (14:31 -0500)]
[libc++] Remove conditional noexcepts from view_interface.

As suggested in D117966.
These conditional noexcepts are *permitted* by the Standard (as long
as there were no mistakes in them, I guess); but not *mandated*.
The Standard doesn't put any noexcept-specifications on these member functions.
The same logic would apply to `transform_view::iterator::operator*`
and `transform_view::iterator::operator[]`, but the Standard mandates
conditional noexcept on `iter_move(transform_view::iterator)`, and
I think it doesn't make much sense to say "moving from this iterator
is conditionally noexcept but not-moving from it is noexcept(false),"
so I'm leaving transform_view alone for now.

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

2 years ago[NFC][PhaseOrdering] Add some tests from D119839
Andrew Wei [Tue, 15 Feb 2022 15:50:50 +0000 (18:50 +0300)]
[NFC][PhaseOrdering] Add some tests from D119839

Based on original tests from D119839.

See https://github.com/llvm/llvm-project/issues/53853

2 years ago[Analysis] propagate poison through add/sub saturate intrinsics
Sanjay Patel [Tue, 15 Feb 2022 15:17:45 +0000 (10:17 -0500)]
[Analysis] propagate poison through add/sub saturate intrinsics

A more general enhancement needs to add tests and make sure
that intrinsics that return structs are correct. There are also
target-specific intrinsics, and I'm not sure what behavior is
expected for those.

2 years ago[Analysis] propagate poison through integer min/max intrinsics
Sanjay Patel [Tue, 15 Feb 2022 15:09:36 +0000 (10:09 -0500)]
[Analysis] propagate poison through integer min/max intrinsics

A more general enhancement needs to add tests and make sure
that intrinsics that return structs are correct. There are also
target-specific intrinsics, and I'm not sure what behavior is
expected for those.

2 years ago[ConstProp] add tests for intrinsics with poison ops; NFC
Sanjay Patel [Tue, 15 Feb 2022 14:55:28 +0000 (09:55 -0500)]
[ConstProp] add tests for intrinsics with poison ops; NFC

2 years ago[libc++] Rename *SAFE_STATIC to *CONSTINIT, and normalize its uses.
Arthur O'Dwyer [Tue, 8 Feb 2022 18:08:59 +0000 (13:08 -0500)]
[libc++] Rename *SAFE_STATIC to *CONSTINIT, and normalize its uses.

In src/, most files can use `constinit` directly because they're always
compiled with C++20. But some files, like "libcxxabi/src/fallback_malloc.cpp",
can't, because they're `#include`d directly from test cases in libcxxabi/test/
and therefore must (currently) compile as C++03. We might consider refactoring
those offending tests, or at least marking them `UNSUPPORTED: c++03`.

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

2 years ago[libc++] [test] Split "UNSUPPORTED: libcpp-no-concepts, libcpp-has-no-incomplete...
Arthur O'Dwyer [Tue, 15 Feb 2022 15:36:29 +0000 (10:36 -0500)]
[libc++] [test] Split "UNSUPPORTED: libcpp-no-concepts, libcpp-has-no-incomplete-ranges" onto two lines. NFC.

2 years ago[libc++] Guard much of std::ranges under _LIBCPP_HAS_NO_INCOMPLETE_RANGES.
Arthur O'Dwyer [Tue, 1 Feb 2022 21:52:02 +0000 (16:52 -0500)]
[libc++] Guard much of std::ranges under _LIBCPP_HAS_NO_INCOMPLETE_RANGES.

The logic here is that we are disabling *only* things in `std::ranges::`.
Everything in `std::` is permitted, including `default_sentinel`, `contiguous_iterator`,
`common_iterator`, `projected`, `swappable`, and so on. Then, we include
anything from `std::ranges::` that is required in order to make those things
work: `ranges::swap`, `ranges::swap_ranges`, `input_range`, `ranges::begin`,
`ranges::iter_move`, and so on. But then that's all. Everything else (including
notably all of the "views" and the `std::views` namespace itself) is still
locked up behind `_LIBCPP_HAS_NO_INCOMPLETE_RANGES`.

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

2 years ago[flang][mlir][NFC] Replace uses of raw accessors with prefixed accessors
Shraiysh Vaishay [Tue, 15 Feb 2022 15:05:46 +0000 (20:35 +0530)]
[flang][mlir][NFC] Replace uses of raw accessors with prefixed accessors

`kEmitAccessorPrefix_Raw ` is being removed, and so updating the
accessors to `kEmitAccessorPrefix_Prefixed`.

Reviewed By: clementval

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

2 years ago[AArch64] Suggest b.nfrst if the user tries b.nfirst.
Matt Devereau [Thu, 10 Feb 2022 16:37:50 +0000 (16:37 +0000)]
[AArch64] Suggest b.nfrst if the user tries b.nfirst.

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

Co-authored-by: George Steed <george.steed@arm.com>
2 years ago[flang] Handle lowering of ranked array
Valentin Clement [Tue, 15 Feb 2022 15:00:28 +0000 (16:00 +0100)]
[flang] Handle lowering of ranked array

This patch adds lowering of ranked array as function return.

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

Reviewed By: PeteSteinfeld

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
2 years ago[NFC] Introduce option to switch off compatible invokes merge
Max Kazantsev [Tue, 15 Feb 2022 14:34:55 +0000 (21:34 +0700)]
[NFC] Introduce option to switch off compatible invokes merge

Does not affect default behavior (transform is on).

2 years ago[PowerPC] Add default handling for single element vectors, and split/promote vNi1...
Amy Kwan [Fri, 11 Feb 2022 18:45:07 +0000 (12:45 -0600)]
[PowerPC] Add default handling for single element vectors, and split/promote vNi1 vectors.

This patch updates the handling of vectors in getPreferredVectorAction():

For single-element and scalable vectors, fall back to default vector legalization
handling. For vNi1 vectors, add handling to either split or promote them in
order to prevent the production of wide v256i1/v512i1 types.

The following assertion is fixed by this patch, as we ended up producing the
wide vector types (that are used for MMA) in the backend prior to this fix.

```
Assertion failed: VT.getSizeInBits() == Operand.getValueSizeInBits() &&
"Cannot BITCAST between types of different sizes!"
```

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

2 years ago[llvm-nm] add a new option -X to specify the type of object file llvm-nm should examine
zhijian [Tue, 15 Feb 2022 14:43:31 +0000 (09:43 -0500)]
[llvm-nm] add a new option -X to specify the type of object file llvm-nm should examine
Summary:
Added a new option "-X" to specify, which type of object file should be examine.

For example:

1. "llvm-nm -X64 archive.a" only deal with the 64bit object files in the archive.a ,ignore the all 32bit object files in the archive.a
2. "llvm-nm -X32 xcoffobj32.o xcoffobj64.o " only deal with the 32bit object file "xcoffobj32.o" , 64bit object file "xcoffobj64.o" will be ignored

Reviewers: James Henderson,Fangrui Song
Differential Revision: https://reviews.llvm.org/D118193

2 years agoUse functions with prototypes when appropriate; NFC
Aaron Ballman [Tue, 15 Feb 2022 14:27:12 +0000 (09:27 -0500)]
Use functions with prototypes when appropriate; NFC

A significant number of our tests in C accidentally use functions
without prototypes. This patch converts the function signatures to have
a prototype for the situations where the test is not specific to K&R C
declarations. e.g.,

  void func();

becomes

  void func(void);

This is the tenth batch of tests being updated (there are a
significant number of other tests left to be updated).

2 years ago[libc++] Fix broken stdatomic test on GCC
Louis Dionne [Tue, 15 Feb 2022 14:25:29 +0000 (09:25 -0500)]
[libc++] Fix broken stdatomic test on GCC

The test would trigger -Wtautological-compare. I think that the little
we gain from comparing addresses isn't worth the added complexity to
work around the warning.

2 years ago[X86] LowerVSETCC - always split 512-bit vectors before lowering to PCMPEQ/GT (PR53842)
Simon Pilgrim [Tue, 15 Feb 2022 14:17:00 +0000 (14:17 +0000)]
[X86] LowerVSETCC - always split 512-bit vectors before lowering to PCMPEQ/GT (PR53842)

Extend the existing split where we already do this for v32i16/v64i8

We can end up trying to use PCMPEQ/GT if the result needs to be sign-extended (typically due to the DAGCombiner::foldSextSetcc fold).

Fixes #53842

2 years ago[mlir][Math] Fix NaN handling in Exp approximation
Adrian Kuegel [Tue, 15 Feb 2022 12:49:30 +0000 (13:49 +0100)]
[mlir][Math] Fix NaN handling in Exp approximation

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

2 years ago[mlir][gpu] Make header parse standalone. NFC.
Benjamin Kramer [Tue, 15 Feb 2022 14:09:39 +0000 (15:09 +0100)]
[mlir][gpu] Make header parse standalone. NFC.

2 years agoRevert "[asan] Add support for disable_sanitizer_instrumentation attribute"
Alexander Potapenko [Tue, 15 Feb 2022 13:57:28 +0000 (14:57 +0100)]
Revert "[asan] Add support for disable_sanitizer_instrumentation attribute"

This reverts commit dd145f953db3dafbc019f1d3783bb4f09a28af92.

https://reviews.llvm.org/D119726, like https://reviews.llvm.org/D114421,
still causes TSan to fail, see https://lab.llvm.org/buildbot/#/builders/70/builds/18020

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

2 years ago[mlir][gpu] sinkOperationsIntoLaunchOp: Add user hook for isSinkingBeneficiary
Ivan Butygin [Sat, 12 Feb 2022 16:13:43 +0000 (19:13 +0300)]
[mlir][gpu] sinkOperationsIntoLaunchOp: Add user hook for isSinkingBeneficiary

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

2 years ago[libc++][AIX] Remove "pragma priority" from locale.cpp
Xing Xue [Tue, 15 Feb 2022 13:36:29 +0000 (08:36 -0500)]
[libc++][AIX] Remove "pragma priority" from locale.cpp

Summary:
The pragma priority guarded for AIX in locale.cpp is no longer useful and is ignored by the current AIX build compilers. This patch removes it from the source.

Reviewed by: ldionne, hubert.reinterpretcast, libc++

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

2 years ago[InstCombine] reassociate min/max intrinsics with constant operands
Sanjay Patel [Tue, 15 Feb 2022 13:18:11 +0000 (08:18 -0500)]
[InstCombine] reassociate min/max intrinsics with constant operands

Integer min/max operations are associative:
  max (max X, C0), C1 --> max X, (max C0, C1) --> max X, NewC

https://alive2.llvm.org/ce/z/wW5HVM

This would avoid a regression when we canonicalize to min/max intrinsics
(see D98152 ).

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

2 years ago[Test] Add test demonstating how deopt bundle constants may be merged into instruction
Max Kazantsev [Tue, 15 Feb 2022 13:12:52 +0000 (20:12 +0700)]
[Test] Add test demonstating how deopt bundle constants may be merged into instruction

2 years ago[InstCombine] Fold sub(Y,and(lshr(X,C),1)) --> add(ashr(shl(X,(BW-1)-C),BW-1),Y)...
Simon Pilgrim [Tue, 15 Feb 2022 13:24:20 +0000 (13:24 +0000)]
[InstCombine] Fold sub(Y,and(lshr(X,C),1)) --> add(ashr(shl(X,(BW-1)-C),BW-1),Y) (PR53610)

As noted on PR53610, we can fold a 'bit splat' negation of a shifted bitmask pattern into a pair of shifts.

https://alive2.llvm.org/ce/z/eGrsoN

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

2 years ago[SLP] Don't try to vectorize pair with insertelement
Anton Afanasyev [Sun, 13 Feb 2022 13:07:45 +0000 (16:07 +0300)]
[SLP] Don't try to vectorize pair with insertelement

Particularly this breaks vectorization of insertelements where some of
intermediate (i.e. not last) insertelements are used externally.

Fixes PR52275
Fixes #51617

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

2 years ago[Test][SLP] Add tests for PR52275
Anton Afanasyev [Thu, 10 Feb 2022 19:02:47 +0000 (22:02 +0300)]
[Test][SLP] Add tests for PR52275

2 years ago[asan] Add support for disable_sanitizer_instrumentation attribute
Alexander Potapenko [Tue, 23 Nov 2021 09:32:35 +0000 (10:32 +0100)]
[asan] Add support for disable_sanitizer_instrumentation attribute

For ASan this will effectively serve as a synonym for
__attribute__((no_sanitize("address")))

This is a reland of https://reviews.llvm.org/D114421

Reviewed By: melver, eugenis

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

2 years ago[mlir][OpenMP] NFC: Remove unused variable
Adrian Kuegel [Tue, 15 Feb 2022 13:01:12 +0000 (14:01 +0100)]
[mlir][OpenMP] NFC: Remove unused variable

2 years ago[InstCombine] add tests for min/max intrinsics; NFC
Sanjay Patel [Mon, 14 Feb 2022 21:46:42 +0000 (16:46 -0500)]
[InstCombine] add tests for min/max intrinsics; NFC

2 years ago[clang][NFC] Remove IgnoreLinkageSpecDecls
Nathan Sidwell [Mon, 14 Feb 2022 18:19:04 +0000 (10:19 -0800)]
[clang][NFC] Remove IgnoreLinkageSpecDecls

The Itanium mangler uses IgnoreLinkageSpecDecls to strip linkage spec
contexts.  It doesn't do this consistently, but there is no need for
it to do it at all.  getEffectiveDeclContext never returns a linkage
spec, as it either recurses, uses getRedeclContext (which itself
removes the specs), or gets the decl context of non-namespace entities.

This patch removes the function and all calls to it.  For safety I add
a couple of asserts to make sure we never get them.

Reviewed By: ChuanqiXu

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

2 years ago[mlir][OpenMP] Change omp.atomic.update to have generic updates
Shraiysh Vaishay [Tue, 15 Feb 2022 12:01:31 +0000 (17:31 +0530)]
[mlir][OpenMP] Change omp.atomic.update to have generic updates

This patch changes the syntax of omp.atomic.update to allow the other
dialects to modify the variable with appropriate operations in the
region.

Reviewed By: ftynse

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

2 years ago[mlir][bufferize] Add vector-bufferize pass and remove obsolete patterns from Linalg...
Matthias Springer [Tue, 15 Feb 2022 12:16:50 +0000 (21:16 +0900)]
[mlir][bufferize] Add vector-bufferize pass and remove obsolete patterns from Linalg Bufferize

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

2 years ago[InstCombine] Add shift+trunc+mask tests requested for D119715
Simon Pilgrim [Tue, 15 Feb 2022 12:16:54 +0000 (12:16 +0000)]
[InstCombine] Add shift+trunc+mask tests requested for D119715

2 years ago[OpenCL] opencl-c.h: fix atomic_fetch_max with addrspace
Sven van Haastregt [Tue, 15 Feb 2022 12:12:03 +0000 (12:12 +0000)]
[OpenCL] opencl-c.h: fix atomic_fetch_max with addrspace

Commit 3c7d2f1b67d1 ("[OpenCL] opencl-c.h: add CL 3.0 non-generic
address space atomics", 2021-07-30) added some atomic_fetch_add/sub
overloads with uintptr_t arguments twice.  Instead, they should have
been atomic_fetch_max overloads with non-generic address spaces.

2 years ago[DSE] Extract a common PDT check (NFC)
Nikita Popov [Tue, 15 Feb 2022 12:04:52 +0000 (13:04 +0100)]
[DSE] Extract a common PDT check (NFC)

2 years ago[VE] v256i1 broadcast isel and tests
Simon Moll [Tue, 15 Feb 2022 09:55:14 +0000 (10:55 +0100)]
[VE] v256i1 broadcast isel and tests

Reviewed By: kaz7

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

2 years ago[clang][lex] Remove misleading comment
Jan Svoboda [Tue, 15 Feb 2022 11:39:20 +0000 (12:39 +0100)]
[clang][lex] Remove misleading comment

The resiliency to `HeaderSearch::Add{,System}SearchPath` is implemented in later patch (D116750).

2 years ago[lldb] Remove memory region non-address change from release notes
David Spickett [Tue, 15 Feb 2022 11:36:55 +0000 (11:36 +0000)]
[lldb] Remove memory region non-address change from release notes

This is now on 14.x as af19ae529271f9ae96927662d7d876489115fb26
so it is not new to 15.

2 years ago[AMDGPU] Reenable some disabled RUN lines
Jay Foad [Tue, 15 Feb 2022 11:06:44 +0000 (11:06 +0000)]
[AMDGPU] Reenable some disabled RUN lines

These look like they were temporarily disabled to placate
update_mir_test_checks and then committed by mistake.

2 years ago[clang] Remove a duplicate action kind table entry.
iains [Tue, 15 Feb 2022 09:55:22 +0000 (09:55 +0000)]
[clang] Remove a duplicate action kind table entry.

We have two entries for OPT_emit_codegen_only in the frontend action kind
table, delete one.

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

2 years ago[X86][Win64] Avoid statepoints in trailing call position
Markus Böck [Sun, 13 Feb 2022 10:07:36 +0000 (11:07 +0100)]
[X86][Win64] Avoid statepoints in trailing call position

The "avoid trailing call pass" makes sure that no function ends with a call instruction for the purpose of the unwinder.
It starts of by skipping over any non real instruction, which is approximated via the Pseudo and Meta property. This sadly leads to issues when the last machine instruction is a STATEPOINT, as it is skipped despite it lowering to a call.

This patch fixes the use of a statepoint in the trailing call position by making sure call instructions are not skipped.

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

2 years ago[llvm][doc] Update comments and documentation of custom stackmap formats in GC
Markus Böck [Sun, 13 Feb 2022 19:34:00 +0000 (20:34 +0100)]
[llvm][doc] Update comments and documentation of custom stackmap formats in GC

Since https://reviews.llvm.org/D53892 it is possible to emit a custom stackmap by overwriting the emitStackMaps method of GCMetadataPrinter. That way even AOT compilers can generate a more efficient and more suitable format for their needs.

This patch updates documentation and stale comments in source code. In particular it removes the issue from the issue list in the Statepoints documentation and adjusts comments in GCStrategy.

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

2 years ago[mlir][Math] Fix NaN handling in ExpM1 approximation.
Adrian Kuegel [Tue, 15 Feb 2022 10:14:20 +0000 (11:14 +0100)]
[mlir][Math] Fix NaN handling in ExpM1 approximation.

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

2 years ago[InstSimplify] Strip offsets once in computePointerICmp()
Nikita Popov [Tue, 15 Feb 2022 11:00:47 +0000 (12:00 +0100)]
[InstSimplify] Strip offsets once in computePointerICmp()

Instead of doing an inbounds strip first and another non-inbounds
strip afterward for equality comparisons, directly do a single
inbounds or non-inbounds strip based on whether we have an equality
predicate or not.

This is NFC-ish in that the alloca equality codepath is the only
part that sees additional non-inbounds offsets now, and for that
codepath it doesn't matter whether or not the GEP is inbounds, as
it does a stronger check itself. InstCombine would infer inbounds
for such GEPs.

2 years ago[BOLT] Fix aarch64 dwarf test
Vladislav Khmelevsky [Tue, 15 Feb 2022 10:23:31 +0000 (13:23 +0300)]
[BOLT] Fix aarch64 dwarf test

After "Remove caching of ranges/abbrevs" patch the dwarf offsets are a
bit changed and the subprograms high pc is replaced with AT_RANGES.

Reviewed By: rafauler

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

2 years ago[mlir][bufferize] Support tensor.expand_shape and tensor.collapse_shape
Matthias Springer [Tue, 15 Feb 2022 10:44:31 +0000 (19:44 +0900)]
[mlir][bufferize] Support tensor.expand_shape and tensor.collapse_shape

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

2 years ago[AMDGPU] Divergence-driven instruction selection for bfm patterns
Jay Foad [Mon, 14 Feb 2022 10:49:12 +0000 (10:49 +0000)]
[AMDGPU] Divergence-driven instruction selection for bfm patterns

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

2 years agoAdd verifier for gpu.alloc op
Akshay Baviskar [Mon, 14 Feb 2022 16:54:59 +0000 (22:24 +0530)]
Add verifier for gpu.alloc op

Add verifier for gpu.alloc op to verify if the dimension operand counts
and symbol operand counts are same as their memref counterparts.

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

2 years ago[mlir][bufferize] Generalize filtering mechanism in BufferizationOptions
Matthias Springer [Tue, 15 Feb 2022 10:05:26 +0000 (19:05 +0900)]
[mlir][bufferize] Generalize filtering mechanism in BufferizationOptions

Support ALLOW filters and DENY filters. This is needed for compatibility with existing code that specifies more complex op filters.

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

2 years ago[DAGCombine] Move AVG combine to SimplifyDemandBits
David Green [Tue, 15 Feb 2022 10:17:02 +0000 (10:17 +0000)]
[DAGCombine] Move AVG combine to SimplifyDemandBits

This moves the matching of AVGFloor and AVGCeil into a place where
demand bit are available, so that it can detect more cases for more
folds. It changes the transform to start from a shift, not from a
truncate. We match the pattern shr(add(ext(A), ext(B)), 1), transforming
to ext(hadd(A, B)).

For signed values, because only the bottom bits are demanded llvm will
transform the above to use a lshr too, as opposed to ashr. In order to
correctly detect the hadd we need to know the demanded bits to turn it
back. Depending on whether the shift is signed (ashr) or logical (lshr),
and the extensions are signed or unsigned we can create different nodes.
If the shift is signed:
  Needs >= 2 sign bits. https://alive2.llvm.org/ce/z/h4gQAW generating signed rhadd.
  Needs >= 2 zero bits. https://alive2.llvm.org/ce/z/B64DUA generating unsigned rhadd.
If the shift is unsigned:
  Needs >= 1 zero bits. https://alive2.llvm.org/ce/z/ByD8sj generating unsigned rhadd.
  Needs 1 demanded bit zero and >= 2 sign bits https://alive2.llvm.org/ce/z/hvPGxX and
    https://alive2.llvm.org/ce/z/32P5n1 generating signed rhadd.

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

2 years ago[clang][lex] Use `SearchDirIterator` types in for loops
Jan Svoboda [Tue, 15 Feb 2022 09:40:05 +0000 (10:40 +0100)]
[clang][lex] Use `SearchDirIterator` types in for loops

This patch replaces a lot of index-based loops with iterators and ranges.

Depends on D117566.

Reviewed By: ahoppen

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

2 years ago[clang][lex] Use `ConstSearchDirIterator` in lookup cache
Jan Svoboda [Tue, 15 Feb 2022 09:37:36 +0000 (10:37 +0100)]
[clang][lex] Use `ConstSearchDirIterator` in lookup cache

This patch starts using the new iterator type in `LookupFileCacheInfo`.

Depends on D117566.

Reviewed By: ahoppen

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

2 years ago[clang][lex] Introduce `ConstSearchDirIterator`
Jan Svoboda [Tue, 15 Feb 2022 09:11:00 +0000 (10:11 +0100)]
[clang][lex] Introduce `ConstSearchDirIterator`

The `const DirectoryLookup *` out-parameter of `{HeaderSearch,Preprocessor}::LookupFile()` is assigned the most recently used search directory, which callers use to implement `#include_next`.

From the function signature it's not obvious the `const DirectoryLookup *` is being used as an iterator. This patch introduces `ConstSearchDirIterator` to make that affordance obvious. This would've prevented a bug that occurred after initially landing D116750.

Reviewed By: ahoppen

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

2 years ago[AMDGPU] Honor !invariant.load metadata on load-like intrinsics
Jay Foad [Mon, 14 Feb 2022 17:50:21 +0000 (17:50 +0000)]
[AMDGPU] Honor !invariant.load metadata on load-like intrinsics

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

2 years ago[AMDGPU] Precommit test for !invariant.load metadata on load-like intrinsics
Jay Foad [Mon, 14 Feb 2022 17:52:38 +0000 (17:52 +0000)]
[AMDGPU] Precommit test for !invariant.load metadata on load-like intrinsics

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

2 years ago[BitcodeReader] Change order of assignValue() arguments (NFC)
Nikita Popov [Tue, 15 Feb 2022 09:09:48 +0000 (10:09 +0100)]
[BitcodeReader] Change order of assignValue() arguments (NFC)

Other methods in ValueList generally pass Idx first, and it is
more convention for assignment methods to have the target on the
LHS rather than RHS.

2 years ago[clang][lex] NFC: De-duplicate some #include_next logic
Jan Svoboda [Tue, 15 Feb 2022 08:52:38 +0000 (09:52 +0100)]
[clang][lex] NFC: De-duplicate some #include_next logic

This patch addresses a FIXME and de-duplicates some `#include_next` logic

Depends on D119714.

Reviewed By: ahoppen

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

2 years ago[clang][deps] Disable global module index
Jan Svoboda [Tue, 15 Feb 2022 08:51:17 +0000 (09:51 +0100)]
[clang][deps] Disable global module index

While scanning dependencies of a TU that depends on a PCH, the scanner basically performs mixed implicit/explicit modular compilation. (Explicit modules come from the PCH.) This seems to trip up the global module index.

This patch disables global module index in the dependency scanner.

Reviewed By: Bigcheese

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

2 years ago[clang][lex][minimizer] Avoid treating path separators as comments
Jan Svoboda [Tue, 15 Feb 2022 08:49:16 +0000 (09:49 +0100)]
[clang][lex][minimizer] Avoid treating path separators as comments

The minimizer strips out single-line comments (introduced by `//`). This sequence of characters can also appear in `#include` or `#import` directives where they play the role of path separators. We already avoid stripping this character sequence for `#include` but not for `#import` (which has the same semantics). This patch makes it so `#import <A//A.h>` is not affected by minimization. Previously, we would incorrectly reduce it into `#import <A`.

Reviewed By: arphaman

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

2 years ago[clang][lex][minimizer] Ensure whitespace between squashed lines
Jan Svoboda [Tue, 15 Feb 2022 08:49:00 +0000 (09:49 +0100)]
[clang][lex][minimizer] Ensure whitespace between squashed lines

The minimizer tries to squash multi-line macro definitions into single line. For that to work, contents of each line need to be separated by a space. Since we always strip leading whitespace on lines of a macro definition, the code currently tries to preserve exactly one space that appeared before the backslash.

This means the following code:

```
#define FOO(BAR) \
  #BAR           \
  baz
```

gets minimized into:

```
#define FOO(BAR) #BAR baz
```

However, if there are no spaces before the backslash on line 2:

```
#define FOO(BAR) \
  #BAR\
  baz
```

no space can be preserved, leading to (most likely) malformed macro definition:

```
#define FOO(BAR) #BARbaz
```

This patch makes sure we always put exactly one space at the end of line ending with a backslash.

Reviewed By: arphaman

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

2 years ago[clang][lex] Remove `Preprocessor::GetCurDirLookup()`
Jan Svoboda [Tue, 15 Feb 2022 08:18:35 +0000 (09:18 +0100)]
[clang][lex] Remove `Preprocessor::GetCurDirLookup()`

`Preprocessor` exposes the search directory iterator via `GetCurDirLookup()` getter, which is only used in two static functions.

To simplify reasoning about search directory iterators/references and to simplify the `Preprocessor` API, this patch makes the two static functions private member functions and removes the getter entirely.

Depends D119708.

Reviewed By: ahoppen, dexonsmith

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

2 years ago[clang][lex] Remove `PPCallbacks::FileNotFound()`
Jan Svoboda [Tue, 15 Feb 2022 08:17:22 +0000 (09:17 +0100)]
[clang][lex] Remove `PPCallbacks::FileNotFound()`

The purpose of the `FileNotFound` preprocessor callback was to add the ability to recover from failed header lookups. This was to support downstream project.

However, injecting additional search path while performing header search can invalidate currently used iterators/references to `DirectoryLookup` in `Preprocessor` and `HeaderSearch`.

The downstream project ended up maintaining a separate patch to further tweak the functionality. Since we don't have any upstream users nor open source downstream users, I'd like to remove this callback for good to prevent future misuse. I doubt there are any actual downstream users, since the functionality is definitely broken at the moment.

Reviewed By: ahoppen

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

2 years ago[Support] Fix build on illumos
Nikita Popov [Sun, 13 Feb 2022 13:13:16 +0000 (14:13 +0100)]
[Support] Fix build on illumos

D116366 added a call to madvise() in Path.inc. Unfortunately,
Illumos does not declare this function if _XOPEN_SOURCE is defined
(which it is by default) and we need to provide the declaration
manually. This is the same workaround used in sanitizers:
https://github.com/llvm/llvm-project/blob/ee423d93ead39e94c2970b3cc7ef6e6faa75d10b/compiler-rt/lib/sanitizer_common/sanitizer_solaris.cpp#L77-L85

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

2 years ago[Bitcode] Improve support for opaque-pointer bitcode upgrade
Nikita Popov [Wed, 9 Feb 2022 13:44:20 +0000 (14:44 +0100)]
[Bitcode] Improve support for opaque-pointer bitcode upgrade

This is step two of supporting autoupgrade of old bitcode to opaque
pointers. Rather than tracking the element type ID of pointers in
particular, track all type IDs that a type contains. This allows us
to recover the element type in more complex situations, e.g. when
we need to determine the pointer element type of a vector element
or function type parameter.

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

2 years ago[mlir][spirv] Add OpenCL fma op and lowering
Ivan Butygin [Sun, 13 Feb 2022 20:25:19 +0000 (23:25 +0300)]
[mlir][spirv] Add OpenCL fma op and lowering

Also, it seems Khronos has changed html spec format so small adjustment to script was needed.
Base op parsing is also probably broken.

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

2 years agoCleanup LLVMDWARFDebugInfo
serge-sans-paille [Mon, 14 Feb 2022 15:27:04 +0000 (16:27 +0100)]
Cleanup LLVMDWARFDebugInfo

As usual with that header cleanup series, some implicit dependencies now need to
be explicit:

llvm/DebugInfo/DWARF/DWARFContext.h no longer includes:
- "llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h"
- "llvm/DebugInfo/DWARF/DWARFCompileUnit.h"
- "llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h"
- "llvm/DebugInfo/DWARF/DWARFDebugAranges.h"
- "llvm/DebugInfo/DWARF/DWARFDebugFrame.h"
- "llvm/DebugInfo/DWARF/DWARFDebugLoc.h"
- "llvm/DebugInfo/DWARF/DWARFDebugMacro.h"
- "llvm/DebugInfo/DWARF/DWARFGdbIndex.h"
- "llvm/DebugInfo/DWARF/DWARFSection.h"
- "llvm/DebugInfo/DWARF/DWARFTypeUnit.h"
- "llvm/DebugInfo/DWARF/DWARFUnitIndex.h"

Plus llvm/Support/Errc.h not included by a bunch of llvm/DebugInfo/DWARF/DWARF*.h files

Preprocessed lines to build llvm on my setup:
after: 1065629059
before: 1066621848

Which is a great diff!

Discourse thread: https://discourse.llvm.org/t/include-what-you-use-include-cleanup
Differential Revision: https://reviews.llvm.org/D119723

2 years agoInsert a blurb about the -fzero-call-used-regs feature
Bill Wendling [Tue, 15 Feb 2022 08:06:01 +0000 (00:06 -0800)]
Insert a blurb about the -fzero-call-used-regs feature

Reviewed By: nickdesaulniers

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

2 years ago[lldb] Fix thread syncrhonization TestThreadBacktraceRepeat
Pavel Labath [Tue, 15 Feb 2022 07:41:44 +0000 (08:41 +0100)]
[lldb] Fix thread syncrhonization TestThreadBacktraceRepeat

lldb reports (and lldbutil.continue_to_breakpoint returns) a stop reason
even for suspended threads. Fix the test to expect that.

This was making the test flaky, as most of the time, the two threads
stop simultaneously, and the synchronization code is not executed.

2 years ago[flang] Enable complex type in function lowering
Valentin Clement [Tue, 15 Feb 2022 07:24:48 +0000 (08:24 +0100)]
[flang] Enable complex type in function lowering

This patch enables complex type in lowering.
It is tested on function return types.

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

Depends on D119698

Reviewed By: kiranchandramohan

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
2 years ago[flang] Enable scalar real type in lowering
Valentin Clement [Tue, 15 Feb 2022 07:23:00 +0000 (08:23 +0100)]
[flang] Enable scalar real type in lowering

This patch enables scalar real type in lowering.
It is tested on function return types.

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

Depends on D119698

Reviewed By: kiranchandramohan

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
2 years ago[flang][mlir][NFC] Remove deprecated parser/printer/verifier utilities
Shraiysh Vaishay [Tue, 15 Feb 2022 05:56:49 +0000 (11:26 +0530)]
[flang][mlir][NFC] Remove deprecated parser/printer/verifier utilities

These have been replaced by `hasCustomAssemblyFormat` and `hasVerifier`
fields and aren't needed anymore.

Ops deriving from `fir_IntegralSwitchTerminatorOp` and `region_Op` are
not handled in this patch for ease of review.

Reviewed By: rriddle

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

2 years ago[libc] Add a platform independent buffered file IO data structure.
Siva Chandra Reddy [Tue, 25 Jan 2022 19:50:00 +0000 (19:50 +0000)]
[libc] Add a platform independent buffered file IO data structure.

Reviewed By: lntue

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

2 years ago[lldb] Determine the main binary in JSON crashlogs
Jonas Devlieghere [Tue, 15 Feb 2022 05:21:07 +0000 (21:21 -0800)]
[lldb] Determine the main binary in JSON crashlogs

The symbolicator assumes that the first image in the image list is the
main image. That isn't always the case. For JSON crashlogs we can use
the procName to move the main image to the front of the list.

rdar://83907760

2 years ago[Safepoint Verifier] Add a missed comment to previous commit.
Serguei Katkov [Tue, 15 Feb 2022 05:21:33 +0000 (12:21 +0700)]
[Safepoint Verifier] Add a missed comment to previous commit.

2 years ago[Safepoint Verifier] gc.relocate does not change the constant property.
Serguei Katkov [Mon, 14 Feb 2022 12:22:47 +0000 (19:22 +0700)]
[Safepoint Verifier] gc.relocate does not change the constant property.

Add traverse through gc.relocate in determining whether base is
isExclusivelyDerivedFromNull OR ExclusivelyNull.

Reviewers: reames, anna
Reviewed By: reames, anna
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D119712

2 years ago[TableGen] Add a new `encoder` directive into VarLenCodeEmitterGen
Min-Yih Hsu [Tue, 14 Dec 2021 12:59:22 +0000 (20:59 +0800)]
[TableGen] Add a new `encoder` directive into VarLenCodeEmitterGen

The new encoder directive can be used to specify custom encoder for a
single operand or slice. This is different from the EncoderMethod field
within an Operand, which affects every operands in the target.

In addition, this patch also changes the function signature of the
encoder method -- a new argument, InsertPost, is added to both the
default one (i.e. getMachineValue) and the custom one. This argument
provides the bit position where the operand will eventually be inserted.

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

2 years ago[Driver][NetBSD] -r: imply -nostdlib like GCC
Brad Smith [Tue, 15 Feb 2022 04:29:13 +0000 (23:29 -0500)]
[Driver][NetBSD] -r: imply -nostdlib like GCC

Similar to D116843 for Gnu.cpp

Reviewed By: MaskRay

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