platform/upstream/llvm.git
2 years ago[mlir][Linalg] Add pattern for folding reshape by collapsing.
Mahesh Ravishankar [Mon, 7 Feb 2022 03:43:52 +0000 (03:43 +0000)]
[mlir][Linalg] Add pattern for folding reshape by collapsing.

Fusion of `linalg.generic` with
`tensor.expand_shape/tensor.collapse_shape` currently handles fusion
with reshape by expanding the dimensionality of the `linalg.generic`
operation. This helps fuse elementwise operations better since they
are fused at the highest dimensionality while keeping all indexing
maps involved projected permutations. The intent of these is to push
the reshape to the boundaries of functions.

The presence of named ops (or other ops across which the reshape
cannot be propagated) stops the propagation to the edges of the
function. At this stage, the converse patterns that fold the reshapes
with generic ops by collapsing the dimensions of the generic op can
push the reshape towards edges. In particular it helps the case where
reshapes exist in between named ops and generic ops.

`linalg.named_op` -> `tensor.expand_shape` -> `linalg.generic`

Pushing the reshape down will help fusion of `linalg.named_op` ->
`linalg.generic` using tile + fuse transformations.

This pattern is intended to replace the following patterns

1) FoldReshapeByLinearization : These patterns create indexing maps
that are not projected permutations that affect future
transformations. They are only useful for folding unit-dimensions.
2) PushReshapeByExpansion : This pattern has the same functionality
but has some restrictions
    a) It tries to avoid creating new reshapes that limits its
    applicability. The pattern added here can achieve the same
    functionality through use of the `controlFn` that allows clients
    of the pattern freedom to make this decision.
    b) It does not work for ops with indexing semantics.

These patterns will be deprecated in a future patch.

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

2 years ago[libc++] Granularize algorithm includes
Nikolas Klauser [Tue, 15 Feb 2022 17:18:08 +0000 (18:18 +0100)]
[libc++] Granularize algorithm includes

Reviewed By: Mordante, ldionne, Quuxplusone, #libc, #libc_abi

Spies: #libc_vendors, libcxx-commits, miyuki

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

2 years agoRevert "Add support for floating-point option `ffp-eval-method` and for"
Nico Weber [Wed, 16 Feb 2022 03:02:25 +0000 (22:02 -0500)]
Revert "Add support for floating-point option `ffp-eval-method` and for"

This reverts commit 4bafe65c2b2f1ce745894a509a6d80c87fb1c335.
Breaks at least Misc/warning-flags.c, see comments on
https://reviews.llvm.org/D109239

2 years ago[NFC] Update new warning to test
Chuanqi Xu [Wed, 16 Feb 2022 02:44:20 +0000 (10:44 +0800)]
[NFC] Update new warning  to test

This tries to fix the broke test introduced in
4bafe65c2b2f1ce745894a509a6.

2 years ago[FuncSpec] Save compilation time by caching uses for propagation
Bin Cheng [Tue, 15 Feb 2022 08:51:04 +0000 (16:51 +0800)]
[FuncSpec] Save compilation time by caching uses for propagation

We only need to do propagation on use instructions of the original
value, rather than the replacing const value which might have lots
of irrelavant uses.  This is done by caching uses before replacing.

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

2 years ago[RISCV] Add the passthru operand for RVV nomask binary intrinsics.
Zakk Chen [Mon, 14 Feb 2022 01:28:44 +0000 (17:28 -0800)]
[RISCV] Add the passthru operand for RVV nomask binary intrinsics.

The goal is support tail and mask policy in RVV builtins.
We focus on IR part first.
If the passthru operand is undef, we use tail agnostic, otherwise
use tail undisturbed.

Add passthru operand for VSLIDE1UP_VL and VSLIDE1DOWN_VL to support
i64 scalar in rv32.

The masked VSLIDE1 would only emit mask undisturbed policy regardless
of giving mask agnostic policy until InsertVSETVLI supports mask agnostic.

Reviewed by: craig.topper, rogfer01

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

2 years ago[lld-macho][nfc] Clean up trailing spaces and tabs
Jez Ng [Wed, 16 Feb 2022 02:28:18 +0000 (21:28 -0500)]
[lld-macho][nfc] Clean up trailing spaces and tabs

2 years agoAMDGPU: Use subtarget in class instead of querying function
Matt Arsenault [Tue, 15 Feb 2022 22:18:32 +0000 (17:18 -0500)]
AMDGPU: Use subtarget in class instead of querying function

2 years ago[lld-macho][nfc] Factor out callgraph parsing code
Jez Ng [Wed, 16 Feb 2022 02:13:41 +0000 (21:13 -0500)]
[lld-macho][nfc] Factor out callgraph parsing code

`parseSections()` is a getting a bit large unwieldy, let's factor out
logic where we can.

Other minor changes in this diff:
* `"__cg_profile"` is now a global constexpr
* We now use `checkError()` instead of `fatal()`-ing without handling
  the Error
* Check for `callGraphProfileSort` before checking the section name,
  since the boolean comparison is likely cheaper

Reviewed By: #lld-macho, lgrey, oontvoo

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

2 years ago[BOLT][DWARF] Add ability to insert new entries in to DIE
Alexander Yermolovich [Wed, 16 Feb 2022 02:06:03 +0000 (18:06 -0800)]
[BOLT][DWARF] Add ability to insert new entries in to DIE

Added ability to append new entries to DIE. This is useful to standadize DWARF4
Split Dwarf, and simplify implementation of DWARF5.
Multiple DIEs can share an abbrev. So currently limitation is that only unique
Attributes can be added.

Reviewed By: maksfb

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

2 years agoFix crash when deserializing a lambda expression in a decltype.
Richard Smith [Wed, 16 Feb 2022 01:55:35 +0000 (17:55 -0800)]
Fix crash when deserializing a lambda expression in a decltype.

2 years ago[ELF][test] Improve LTO duplicate symbol test
Fangrui Song [Wed, 16 Feb 2022 01:54:38 +0000 (17:54 -0800)]
[ELF][test] Improve LTO duplicate symbol test

2 years ago[DAGCombiner][AArch64] Enhance to fold CSNEG into CSINC instruction
zhongyunde [Wed, 16 Feb 2022 01:35:15 +0000 (09:35 +0800)]
[DAGCombiner][AArch64] Enhance to fold CSNEG into CSINC instruction

Perform the scalar expression combine in the form of:
  CSNEG(1, c, cc) + b  =>  cc  ? b+1 : b-c => CSINC(b-c, b, !cc)
  CSNEG(c, -1, cc) + b =>  cc  ? b+c : b+1 => CSINC(b+c, b, cc)

Fix https://github.com/llvm/llvm-project/issues/53071

Reviewed By: dmgreen

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

2 years ago[mlir] Expose printer flags in AsmState
Sergei Grechanik [Wed, 16 Feb 2022 01:09:08 +0000 (17:09 -0800)]
[mlir] Expose printer flags in AsmState

This change exposes printer flags in AsmState and AsmStateImpl. All functions
receiving AsmState as a parameter now use the flags from the AsmState instead of
taking an additional OpPrintingFlags parameter.

Reviewed By: rriddle

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

2 years ago[lld][WebAssembly] Don't force the export symbols assiged internal/dummy GOT entries
Sam Clegg [Tue, 15 Feb 2022 23:33:42 +0000 (15:33 -0800)]
[lld][WebAssembly] Don't force the export symbols assiged internal/dummy GOT entries

Symbols with regular GOT entries do need to be exported, but those that
are internalized (and have dymmy/internal GOT entries) need not be
exported.

This happens to fix the failures on the emscripten waterfall where extra
symbols were being exported by the linker (and then later removed by
wasm-opt).

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

2 years ago[Bitstream] Improve error propagation from ReadVBR
Jan Korous [Tue, 15 Feb 2022 02:22:18 +0000 (18:22 -0800)]
[Bitstream] Improve error propagation from ReadVBR

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

2 years ago[Bitstream] Add assert to ReadVBR and ReadVBR64
Jan Korous [Tue, 15 Feb 2022 02:21:00 +0000 (18:21 -0800)]
[Bitstream] Add assert to ReadVBR and ReadVBR64

We want to prevent UB potentially caused by left-shifting by type bit-width.

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

2 years ago[ELF] --exclude-libs: skip local symbols for ET_REL. NFC
Fangrui Song [Wed, 16 Feb 2022 01:02:55 +0000 (17:02 -0800)]
[ELF] --exclude-libs: skip local symbols for ET_REL. NFC

Beside the optimization, this will avoid accessing nullptr entries with my
planned change to parallelize initializeLocalSymbols.

2 years ago[libc++][ranges] Implement Ranges changes to `istream{,buf}_iterator`.
Konstantin Varlamov [Wed, 16 Feb 2022 00:59:16 +0000 (16:59 -0800)]
[libc++][ranges] Implement Ranges changes to `istream{,buf}_iterator`.

The changes from the One Ranges Proposal amount to adding:
- a constructor that takes a `default_sentinel_t` and is equivalent to
  the default constructor;
- an `operator==` that compares the iterator to `default_sentinel_t`.

The original proposal defined two overloads for `operator==` (different
argument order) as well as `operator!=`. This has been removed by
[P1614](https://wg21.link/p1614).

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

2 years ago[X86] Add test for interaction between pushf/popf and redzones
Reid Kleckner [Fri, 11 Feb 2022 18:58:34 +0000 (10:58 -0800)]
[X86] Add test for interaction between pushf/popf and redzones

As requested on D92695

2 years ago[libc] change ASAN condition to generator expression
Michael Jones [Mon, 14 Feb 2022 23:15:22 +0000 (15:15 -0800)]
[libc] change ASAN condition to generator expression

Previously, building LLVM-libc with GWP ASAN was conditioned on the flag
COMPILER_RT_BUILD_GWP_ASAN, which caused issues do to the default value
of the flag being set in the compiler-rt cmake, which is seperate. Now
GWP ASAN is included based on if it exists as a target, which is more
consistent.

Reviewed By: sivachandra

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

2 years ago[mlir][sparse][taco] Handle tensor copy and trivial reduction expression.
Bixia Zheng [Tue, 15 Feb 2022 18:17:51 +0000 (10:17 -0800)]
[mlir][sparse][taco] Handle tensor copy and trivial reduction expression.

Handle tensor copy, such as A[i, j] = B[i, j]. Also, handle trivial
reduction expression, such as A[i] = B[i, j].

Add unit tests.

Reviewed By: aartbik

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

2 years ago[WebAssembly] Add TLS FileCheck lines to Wasm SjLj test
Heejin Ahn [Tue, 15 Feb 2022 02:04:48 +0000 (18:04 -0800)]
[WebAssembly] Add TLS FileCheck lines to Wasm SjLj test

Reviewed By: sbc100

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

2 years ago[libc++][test] Run clang-tidy during CI
Nikolas Klauser [Tue, 15 Feb 2022 19:00:34 +0000 (20:00 +0100)]
[libc++][test] Run clang-tidy during CI

I'm trying to get libc++ to the point of being able to run clang-tidy. This is a PR to see if clang-tidy is happy with all the CI configs.

Reviewed By: Quuxplusone, ldionne, #libc

Spies: mgorny, aheejin, libcxx-commits, arichardson

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

2 years ago[SystemZ][z/OS] Fix f32 variadic argument assertion
Mubariz Afzal [Tue, 15 Feb 2022 23:11:50 +0000 (18:11 -0500)]
[SystemZ][z/OS] Fix f32 variadic argument assertion

The tablegen lines that specify the XPLINK64 calling convention for promoting an f32 vararg to an f64 are effectively overwritten by the following tablegen line which bitcast an f64 vararg to an i64 (so that it can be used in the GPRs). It becomes a bitcast from f32 to i64.

Since we don't handle a bitcast for f32s this caused an assertion.

2 years ago[lld][WebAssemlby] Warn on unknown -z flags
Sam Clegg [Tue, 15 Feb 2022 21:04:13 +0000 (13:04 -0800)]
[lld][WebAssemlby] Warn on unknown -z flags

This code mirrors that in lld/ELF/Driver.cpp, as does the new test code.

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

2 years agoAdd support for floating-point option `ffp-eval-method` and for
Zahira Ammarguellat [Tue, 19 Oct 2021 16:12:57 +0000 (09:12 -0700)]
Add support for floating-point option `ffp-eval-method` and for
`pragma clang fp eval_method`.

2 years ago[lldb] Check max_size before resizing DataBufferHeap
Jonas Devlieghere [Tue, 15 Feb 2022 21:53:19 +0000 (13:53 -0800)]
[lldb] Check max_size before resizing DataBufferHeap

Don't resize DataBufferHeap if the newly requested size exceeds the
capacity of the underlying data structure, i.e. std::vector<uint8_t>.
This matches the existing check in the DataBufferHeap constructor.

2 years agoFix typo in llvm-config.h.cmake
Muhammad Omair Javaid [Tue, 15 Feb 2022 21:32:19 +0000 (02:32 +0500)]
Fix typo in llvm-config.h.cmake

This patch fixes a typo in https://reviews.llvm.org/rGa1862d78eb45 where
parenthesis was placed by in place of curly braces which was strangely
building with 3.17.

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

2 years ago[libc++] [test] Qualify `distance` as `std::distance` in a lot of tests. NFCI.
Arthur O'Dwyer [Sun, 13 Feb 2022 19:46:29 +0000 (14:46 -0500)]
[libc++] [test] Qualify `distance` as `std::distance` in a lot of tests. NFCI.

We shouldn't be calling `distance` via ADL -- and neither should anybody
in the wild be calling it via ADL, so it's not like we need to test
this ADL ability of `distance` in particular.

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

2 years ago[libc++] Mark test as unsupported with apple-clang
Louis Dionne [Tue, 15 Feb 2022 21:12:08 +0000 (16:12 -0500)]
[libc++] Mark test as unsupported with apple-clang

This is to avoid spurious test failures in case apple-clang-14 doesn't
support _BitInt.

2 years ago[libc++] Take more knobs into account when generating ABI lists
Louis Dionne [Mon, 14 Feb 2022 19:39:17 +0000 (14:39 -0500)]
[libc++] Take more knobs into account when generating ABI lists

This change will make it possible to track exported symbols in more
configurations, notably the Apple system one, where we disable incomplete
features and the debug mode. Also, as a fly-by fix, shorten the name for
whether new is in libc++ or not.

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

2 years ago[NFC] [MTE] only do one pass over allocas for stack tagging.
Florian Mayer [Tue, 15 Feb 2022 02:12:32 +0000 (18:12 -0800)]
[NFC] [MTE] only do one pass over allocas for stack tagging.

Reviewed By: eugenis

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

2 years agoUse functions with prototypes when appropriate; NFC
Aaron Ballman [Tue, 15 Feb 2022 21:06:01 +0000 (16:06 -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 eleventh batch of tests being updated (there are a
significant number of other tests left to be updated).

2 years ago[AMDGPU] Do not define GET_INSTRINFO_SCHED_ENUM
Stanislav Mekhanoshin [Tue, 15 Feb 2022 19:17:13 +0000 (11:17 -0800)]
[AMDGPU] Do not define GET_INSTRINFO_SCHED_ENUM

Autogenerated names are too long and break compilation on Windows,
while we do not need this enum at all.

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

2 years ago[ELF][PPC64] Fix assertion failure for branches to hidden undefined weak for -no-pie
Fangrui Song [Tue, 15 Feb 2022 20:57:27 +0000 (12:57 -0800)]
[ELF][PPC64] Fix assertion failure for branches to hidden undefined weak for -no-pie

Reported by Stefan Pintilie in D119773.

For a branch to a hidden undefined weak symbol, there is an
`assert(sym->getVA());` failure in PPC64LongBranchTargetSection::writeTo for a
-no-pie link. The root cause is that we unnecessarily create the thunk for the
-no-pie link.

Fix this by changing the condition to just `s.isUndefined()`. See the inline
comment.

Rename ppc64-weak-undef-call.s to ppc64-undefined-weak.s to be consistent with
other architectures.

Reviewed By: sfertile, stefanp

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

2 years ago[libc++] Temporarily silence failing debug mode test
Louis Dionne [Tue, 15 Feb 2022 20:47:45 +0000 (15:47 -0500)]
[libc++] Temporarily silence failing debug mode test

Also, fix the actual code so that the test would pass if we fixed the
issue that the method is instantiated in the dylib, and hence the debug
assertion will never fire except if the debug mode is enabled when the
dylib is being compiled.

2 years ago[mlir][scf] Add callback to annotate ops during pipelining
Thomas Raoux [Tue, 15 Feb 2022 20:23:57 +0000 (12:23 -0800)]
[mlir][scf] Add callback to annotate ops during pipelining

This allow user to register a callback that can annotate operations
during software pipelining. This allows user potential annotate op to
know what part of the pipeline they correspond to.

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

2 years ago[clang-format][NFC] Give State.Stack.back() a meaningful name
Björn Schäpers [Fri, 3 Dec 2021 08:19:11 +0000 (09:19 +0100)]
[clang-format][NFC] Give State.Stack.back() a meaningful name

Without that debugging was a hell for me.

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

2 years ago[clang-format] Extend SpaceBeforeParens for requires
Björn Schäpers [Sun, 7 Nov 2021 21:02:34 +0000 (22:02 +0100)]
[clang-format] Extend SpaceBeforeParens for requires

We can now configure the space between requires and the following paren,
seperate for clauses and expressions.

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

2 years ago[clang-format] Further improve support for requires expressions
Björn Schäpers [Mon, 7 Feb 2022 14:46:46 +0000 (15:46 +0100)]
[clang-format] Further improve support for requires expressions

Detect requires expressions in more unusable contexts. This is far from
perfect, but currently we have no good metric to decide between a
requires expression and a trailing requires clause.

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

2 years ago[SLP] Add assert that entities are scheduled as expected
Philip Reames [Tue, 15 Feb 2022 20:20:33 +0000 (12:20 -0800)]
[SLP] Add assert that entities are scheduled as expected

Requested in D118538

2 years ago[mlir][ods] Allow type attribute/operand for 0 result ops prefixed
Jacques Pienaar [Tue, 15 Feb 2022 20:20:07 +0000 (12:20 -0800)]
[mlir][ods] Allow type attribute/operand for 0 result ops prefixed

Without results, there is no getType injected and so generating one in prefixed form doesn't result in any failures during C++ compilation.

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

2 years ago[CUDA][HIP] Do not promote constexpr var with non-constant initializer
Yaxun (Sam) Liu [Sat, 12 Feb 2022 04:07:46 +0000 (23:07 -0500)]
[CUDA][HIP] Do not promote constexpr var with non-constant initializer

constexpr var may be initialized with address of non-const variable.
In this case the initializer is not constant in device compilation.
This has been handled for const vars but not for constexpr vars.

This patch makes handling of const var and constexpr var
consistent.

Reviewed by: Artem Belevich

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

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

2 years ago[libc++] Add missing UNSUPPORTED for the has-no-incomplete-ranges test
Louis Dionne [Tue, 15 Feb 2022 20:10:27 +0000 (15:10 -0500)]
[libc++] Add missing UNSUPPORTED for the has-no-incomplete-ranges test

This wasn't caught because we don't test the combination of no-filesystem
and no-experimental-features in the CI.

2 years ago[libc++][ci] Pin apple-system to arm64 to relieve pressure on x86_64 hosts
Louis Dionne [Tue, 15 Feb 2022 20:07:47 +0000 (15:07 -0500)]
[libc++][ci] Pin apple-system to arm64 to relieve pressure on x86_64 hosts

2 years ago[Libomptarget] Run CPU offloading tests using the new driver
Joseph Huber [Mon, 14 Feb 2022 18:03:36 +0000 (13:03 -0500)]
[Libomptarget] Run CPU offloading tests using the new driver

This patch adds a new target to the OpenMP CPU offloading tests. This
tests the usage of the new driver for CPU offloading. If this all works
then we can move to transition to the new driver as the default.

Depends on D119613

Reviewed By: jdoerfert

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

2 years ago[OpenMP] Add support for CPU offloading in new driver
Joseph Huber [Sat, 12 Feb 2022 02:58:15 +0000 (21:58 -0500)]
[OpenMP] Add support for CPU offloading in new driver

This patch adds support for linking CPU offloading applications in the
linker wrapper. We generate the necessary linking job using the host
linker's path and library arguments. This may not be true for more
complex offloading schemes, but this is sufficient for now.

Reviewed By: jdoerfert

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

2 years agoDebugInfo: Disable simplified template names for -gmlt and below
David Blaikie [Tue, 15 Feb 2022 19:26:15 +0000 (11:26 -0800)]
DebugInfo: Disable simplified template names for -gmlt and below

Since -gmlt doesn't carry any type information necessary to rebuild
template names.

2 years agoDebugInfo: Don't simplify template names using _BitInt(N)
David Blaikie [Fri, 11 Feb 2022 05:14:02 +0000 (21:14 -0800)]
DebugInfo: Don't simplify template names using _BitInt(N)

_BitInt(N) only encodes the byte size in DWARF, not the bit size, so
can't be reconstituted.

2 years ago[mlir][sparse] sparse transpose operation
Aart Bik [Tue, 15 Feb 2022 18:07:50 +0000 (10:07 -0800)]
[mlir][sparse] sparse transpose operation

This test shows that when access patterns do not match (e.g. transposing
a row-wise sparse matrix into another row-wise sparse matrix), a conversion
operation in between can enable codegen (i.e. avoid cycle in iteration graph).

Reviewed By: bixia

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

2 years ago[mlir][ods] NFC fix compilation error on clang-8
Mogball [Tue, 15 Feb 2022 19:41:01 +0000 (19:41 +0000)]
[mlir][ods] NFC fix compilation error on clang-8

2 years ago[HWASan] remove replacement of DbgVariableIntrinsics.
Florian Mayer [Tue, 15 Feb 2022 02:25:45 +0000 (18:25 -0800)]
[HWASan] remove replacement of DbgVariableIntrinsics.

This code was dead because we AI->replaceUsesWithIf above. I verified
this doesn't actually get run by applying
https://gist.github.com/fmayer/aea7cbb4700cfe2c9d932591ae1073c3 to the
Android toolchain and building AOSP, without any crash.

Reviewed By: eugenis

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

2 years ago[gn build] Port c62eefb8863e
LLVM GN Syncbot [Tue, 15 Feb 2022 19:28:46 +0000 (19:28 +0000)]
[gn build] Port c62eefb8863e

2 years ago[nfc][codegen] Move RegisterBank[Info].cpp under CodeGen
Mircea Trofin [Sat, 5 Feb 2022 04:29:53 +0000 (20:29 -0800)]
[nfc][codegen] Move RegisterBank[Info].cpp under CodeGen

Layering-wise, it seems RegisterBank stuff fits under CodeGen, like
other target abstraction.
In particular, TargetSubtargetInfo has a getRegBankInfo member, but
using that object requires making sure GlobalISel is linked, which is
not always the case (e.g. llvm-jitlink doesn't).

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

2 years ago[flang] Make source location more accurate for actual arguments
Peter Klausler [Sat, 12 Feb 2022 00:58:01 +0000 (16:58 -0800)]
[flang] Make source location more accurate for actual arguments

Track source location information when available for actual arguments
to procedure references, and use this information when checking constraints
on calls so that error messages refer to specific actual arguments
rather than to the entire call.

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

2 years ago[ELF] reportDuplicate: change Symbol * to const Symbol &. NFC
Fangrui Song [Tue, 15 Feb 2022 19:18:31 +0000 (11:18 -0800)]
[ELF] reportDuplicate: change Symbol * to const Symbol &. NFC

2 years ago[mlir][ods] Default-valued parameters in attribute or type defs
Mogball [Tue, 15 Feb 2022 19:00:12 +0000 (19:00 +0000)]
[mlir][ods] Default-valued parameters in attribute or type defs

Optional parameters with `defaultValue` set will be populated with that value if they aren't encountered during parsing. Moreover, parameters equal to their default values are elided when printing.

Depends on D118210

Reviewed By: rriddle

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

2 years ago[ProfData] Change type of options from int to uint64_t.
minglotus-6 [Tue, 15 Feb 2022 07:18:18 +0000 (23:18 -0800)]
[ProfData] Change type of options from int to uint64_t.

- Reader uses option values to override uint64_t values.

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

2 years ago[polly][NFC] removes using-directives to fix modules build
Christopher Di Bella [Tue, 15 Feb 2022 06:55:09 +0000 (06:55 +0000)]
[polly][NFC] removes using-directives to fix modules build

When compiling with Clang modules enabled, polly's use of using-directives
caused the global object `Target` in RegisterPasses.cpp to clash with
`llvm::Target`. By eliminating the using-directives, we're able to get
polly to play nicely with a modules build.

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

2 years ago[flang] Handle CALL C_F_POINTER(without SHAPE=)
Peter Klausler [Wed, 9 Feb 2022 18:33:20 +0000 (10:33 -0800)]
[flang] Handle CALL C_F_POINTER(without SHAPE=)

Calls to C_F_POINTER() without the optional SHAPE= third argument
were failing to be recognized as proper calls to the intrinsic,
but the failure was not generating any error message.  This led to
a crash in lowering, which rightfully expects a typed expression
to be associated with the call.

So (1) catch silent failures to convert CALL statements as internal
errors, as is done for expressions and assignment statements; and
(2) clean up C_F_POINTER intrinsic handling to cope with only two
arguments and to emit an error for a FPTR= argument with no type.

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

2 years ago[MLIR] Add support for alloca() of non-zero address spaces
Krzysztof Drewniak [Tue, 15 Feb 2022 16:55:22 +0000 (16:55 +0000)]
[MLIR] Add support for alloca() of non-zero address spaces

This change is needed when lowering alloca()-using code on targets
such as ROCDL that represent private scratch space as a separate
address space.

Reviewed By: ftynse

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

2 years ago[gn build] Port 987c7f407d14
LLVM GN Syncbot [Tue, 15 Feb 2022 18:33:42 +0000 (18:33 +0000)]
[gn build] Port 987c7f407d14

2 years ago[gn build] (manually) port 9c30bafd59bf1
Nico Weber [Tue, 15 Feb 2022 18:31:46 +0000 (13:31 -0500)]
[gn build] (manually) port 9c30bafd59bf1

This is needed after b432eb5c8412c to keep std::unexpected_handler
around (which libcxxabi uses from libcxx).

2 years ago[PowerPC] Fix __builtin_pdepd and __builtin_pextd to be 64-bit and P10 only.
Amy Kwan [Tue, 15 Feb 2022 16:47:55 +0000 (10:47 -0600)]
[PowerPC] Fix __builtin_pdepd and __builtin_pextd to be 64-bit and P10 only.

The `__builtin_pdepd` and `__builtin_pextd` are P10 builtins that are meant to
be used under 64-bit only. For instance, when the builtins are compiled under
32-bit mode:
```
$ cat t.c
unsigned long long foo(unsigned long long a, unsigned long long b) {
  return __builtin_pextd(a,b);
}

$ clang -c t.c -mcpu=pwr10 -m32
ExpandIntegerResult #0: t31: i64 = llvm.ppc.pextd TargetConstant:i32<6928>, t28, t29

fatal error: error in backend: Do not know how to expand the result of this operator!
```
This patch adds sema checking for these builtins to compile under 64-bit
mode only and on P10. The builtins will emit a diagnostic when they are compiled on
non-P10 compilations and on 32-bit mode.

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

2 years ago[flang] Allow extension cases of EQUIVALENCE with optional warnings
Peter Klausler [Thu, 10 Feb 2022 00:32:58 +0000 (16:32 -0800)]
[flang] Allow extension cases of EQUIVALENCE with optional warnings

EQUIVALENCE storage association of objects whose types are not
both default-kind numeric storage sequences, or not both default-kind
character storage sequences, are not standard conformant.
However, most Fortran compilers admit such usage, with warnings
in strict conformance mode.  This patch allos EQUIVALENCE of objects
that have sequence types that are either identical, both numeric
sequences (of default kind or not), or both character sequences.
Non-sequence types, and sequences types that are not homogeneously
numeric or character, remain errors.

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

2 years ago[libc++] Replace `#include ""` with `<>` in libcxx/src/. NFCI.
Arthur O'Dwyer [Fri, 11 Feb 2022 18:00:39 +0000 (13:00 -0500)]
[libc++] Replace `#include ""` with `<>` in libcxx/src/. NFCI.

Our best guess is that the two syntaxes should have exactly equivalent
effects, so, let's be consistent with what we do in libcxx/include/.

I've left `#include "include/x.h"` and `#include "../y.h"` alone
because I'm less sure that they're interchangeable, and they aren't
inconsistent with libcxx/include/ because libcxx/include/ never
does that kind of thing.

Also, use the `_LIBCPP_PUSH_MACROS/POP_MACROS` dance for `<__undef_macros>`,
even though it's technically unnecessary in a standalone .cpp file,
just so we have consistently one way to do it.

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

2 years ago[libc++] Revert <stdatomic.h> changes
Louis Dionne [Tue, 15 Feb 2022 17:57:12 +0000 (12:57 -0500)]
[libc++] Revert <stdatomic.h> changes

This reverts commits a30a7948d and 5d1c1a243, which broke the LLDB
data formatters tests because they build with modules in C++11 mode.

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

2 years ago[VE] Fix breakage after D118981
Simon Moll [Tue, 15 Feb 2022 17:55:08 +0000 (18:55 +0100)]
[VE] Fix breakage after D118981

VE backend code expected all VP SDNode to have a mask parameter.  This
is not the case with vp.select|merge after D118981.

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