platform/upstream/llvm.git
2 years ago[PowerPC][NFC] Split out the MMA instructions from the P10 instructions.
Stefan Pintilie [Fri, 25 Feb 2022 17:16:04 +0000 (11:16 -0600)]
[PowerPC][NFC] Split out the MMA instructions from the P10 instructions.

Currently all of the MMA instructions as well as the MMA related register info
is bundled with the Power 10 instructions. This patch just splits them out.

Reviewed By: lei

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

2 years agoAvoid comparisons between types of different widths in a loop condition to prevent...
Aakanksha [Fri, 25 Feb 2022 17:30:12 +0000 (17:30 +0000)]
Avoid comparisons between types of different widths in a loop condition to prevent the loop from behaving unexpectedly

This change fixes the code violations flagged in AMD compute CodeQL scan -
Query Description: "Comparisons between types of different widths in a loop condition can cause the loop to behave unexpectedly."

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

2 years ago[flang] Lower simple character return
Valentin Clement [Fri, 25 Feb 2022 17:21:44 +0000 (18:21 +0100)]
[flang] Lower simple character return

Handles function with character return.

Character scalar results are passed as arguments in lowering so
that an assumed length character function callee can access the result
length.

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

Reviewed By: PeteSteinfeld, schweitz

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

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: V Donaldson <vdonaldson@nvidia.com>
2 years ago[AArch64] Add scalar min/max costs. NFC
David Green [Fri, 25 Feb 2022 17:11:24 +0000 (17:11 +0000)]
[AArch64] Add scalar min/max costs. NFC

The vector costs were already added, this adds scalar variants to
complete the test coverage.

2 years ago[SVE] Add missing splat patterns for bfloat vectors.
Paul Walker [Thu, 24 Feb 2022 16:50:54 +0000 (16:50 +0000)]
[SVE] Add missing splat patterns for bfloat vectors.

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

2 years ago[MergeICmps] Don't require GEP
Nikita Popov [Fri, 25 Feb 2022 16:36:29 +0000 (17:36 +0100)]
[MergeICmps] Don't require GEP

With opaque pointers, the zero-offset load will generally not use
a GEP. Allow a direct load without GEP, which is treated the same
way as a zero-offset GEP.

2 years ago[PowerPC][NFC] Add file info and license that was missing from this file.
Stefan Pintilie [Fri, 25 Feb 2022 16:19:19 +0000 (10:19 -0600)]
[PowerPC][NFC] Add file info and license that was missing from this file.

Added the license info as well as description about how classes should be named
based on existing documentation.

Reviewed By: lei, #powerpc

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

2 years ago[Clang][Sema] Do not evaluate value-dependent immediate invocations
Evgeny Shulgin [Fri, 25 Feb 2022 15:55:08 +0000 (16:55 +0100)]
[Clang][Sema] Do not evaluate value-dependent immediate invocations

Value-dependent ConstantExprs are not meant to be evaluated.
There is an assert in Expr::EvaluateAsConstantExpr that ensures this condition.
But before this patch the method was called without prior check.

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

Reviewed By: erichkeane

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

2 years ago[NFC][SVE] Refactor SelectSVEAddSubImm to match SelectSVECpyDupImm.
Paul Walker [Thu, 24 Feb 2022 16:19:59 +0000 (16:19 +0000)]
[NFC][SVE] Refactor SelectSVEAddSubImm to match SelectSVECpyDupImm.

They're equivalent other than one is signed and the other unsigned.

2 years ago[SVE] Refactor complex immediate pattern used by CPY/DUP.
Paul Walker [Wed, 23 Feb 2022 18:46:21 +0000 (18:46 +0000)]
[SVE] Refactor complex immediate pattern used by CPY/DUP.

SelectSVE8BitLslImm didn't account for constant values that have a
larger bit width than the result vector's element type.  This only
seems to affect a single corner case when lowering fixed length
vectors but the code itself is also not consistent with how other
related complex patterns are implemented so I've taken the
opportunity to refactor the code.

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

2 years ago[libcxx] String format class marked as packed
Stefan Pintilie [Fri, 25 Feb 2022 15:26:25 +0000 (09:26 -0600)]
[libcxx] String format class marked as packed

This patch marks the class _Flags as packed because the design assumes that it
is packed and a number of tests also assume that it is packed. However on AIX
the class is not packed unless it is marked as such.

Reviewed By: hubert.reinterpretcast, #libc, Mordante, ldionne, Quuxplusone

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

2 years ago[analyzer] Don't crash if the analyzer-constraint is set to Z3, but llvm is not built...
Kristóf Umann [Tue, 22 Feb 2022 14:30:47 +0000 (15:30 +0100)]
[analyzer] Don't crash if the analyzer-constraint is set to Z3, but llvm is not built with it

Exactly what it says on the tin! We had a nasty crash with the following incovation:

$ clang --analyze -Xclang -analyzer-constraints=z3 test.c
fatal error: error in backend: LLVM was not compiled with Z3 support, rebuild with -DLLVM_ENABLE_Z3_SOLVER=ON
... <stack trace> ...

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

2 years ago[mlir][sparse][taco] Use np.array_equal to compare integer values.
Bixia Zheng [Fri, 25 Feb 2022 00:24:29 +0000 (16:24 -0800)]
[mlir][sparse][taco] Use np.array_equal to compare integer values.

Fix MLIR-PyTACO and some tests to use np.array_equal to compare integer
values.

Reviewed By: aartbik

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

2 years ago[AArch64] Add test cases where zext can be lowered to series of tbl.
Florian Hahn [Fri, 25 Feb 2022 15:36:31 +0000 (15:36 +0000)]
[AArch64] Add test cases where zext can be lowered to series of tbl.

Add a set of tests for upcoming patches that allow lowering vector zext
using AArch64 tbl instructions instead of shifts.

2 years ago[mlir][OpDSL] Split arithmetic functions.
gysit [Fri, 25 Feb 2022 15:11:52 +0000 (15:11 +0000)]
[mlir][OpDSL] Split arithmetic functions.

Split arithmetic function into unary and binary functions. The revision prepares the introduction of unary and binary function attributes that work similar to type function attributes.

Depends On D120108

Reviewed By: aartbik

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

2 years ago[clang-tidy] Fix `readability-suspicious-call-argument` crash for arguments without...
Whisperity [Fri, 25 Feb 2022 13:21:18 +0000 (14:21 +0100)]
[clang-tidy] Fix `readability-suspicious-call-argument` crash for arguments without name-like identifier

As originally reported by @steakhal in
http://github.com/llvm/llvm-project/issues/54074, the name extraction logic of
`readability-suspicious-call-argument` crashes if the argument passed to a
function was a function call to a non-trivially named entity (e.g. an operator).

Fixed this crash case by ignoring such constructs and considering them as having
no name.

Reviewed By: aaron.ballman, steakhal

Differential Revision: http://reviews.llvm.org/D120555

2 years ago[mlir][sparse][taco] Add support for scalar tensors.
Bixia Zheng [Thu, 24 Feb 2022 23:26:36 +0000 (15:26 -0800)]
[mlir][sparse][taco] Add support for scalar tensors.

This change allows the use of scalar tensors with index 0 in tensor index
expressions. In this case, the scalar value is broadcast to match the
dimensions of other tensors in the same expression.

Using scalar tensors as a destination in tensor index expressions is not
supported in the PyTACO DSL.

Add a PyTACO test to show the use of scalar tensors.

Reviewed By: aartbik

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

2 years ago[MC][WebAssembly] Fix crash when relocation addend underlows U32
Sam Clegg [Thu, 24 Feb 2022 06:23:05 +0000 (22:23 -0800)]
[MC][WebAssembly] Fix crash when relocation addend underlows U32

For the object file writer we need to allow the underflow (ar write
zero), but for the final linker output we should probably generate an
error (I've left that as a TODO for now).

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

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

2 years ago[WebAssembly] Covert llvm/test/MC/WebAssembly/reloc-code.ll to asm. NFC
Sam Clegg [Thu, 24 Feb 2022 22:37:40 +0000 (14:37 -0800)]
[WebAssembly] Covert llvm/test/MC/WebAssembly/reloc-code.ll to asm. NFC

Also increase coverage of call_indirect via explict function table
(enabled when reference types is enabled) in
llvm/test/CodeGen/WebAssembly/call-indirect.ll (I believe this
was an oversight that it was not added in https://reviews.llvm.org/D90948)

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

2 years ago[mlir][OpDSL] Refactor function handling.
gysit [Fri, 25 Feb 2022 15:04:38 +0000 (15:04 +0000)]
[mlir][OpDSL] Refactor function handling.

Prepare the OpDSL function handling to introduce more function classes. A follow up commit will split ArithFn into UnaryFn and BinaryFn. This revision prepares the split by adding a function kind enum to handle different function types using a single class on the various levels of the stack (for example, there is now one TensorFn and one ScalarFn).

Depends On D119718

Reviewed By: aartbik

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

2 years ago[libcxx] Fix the type in __estimate_column_width
Stefan Pintilie [Fri, 25 Feb 2022 14:48:58 +0000 (08:48 -0600)]
[libcxx] Fix the type in __estimate_column_width

It seems that we are using wchar_t in __estimate_column_width and assume that
it is a 32 bit type. However, on AIX 32 the size of wchar_t is only 16 bits.

Changed wchar_t to uint32_t since the variable is being passed to a function
that uses uint32_t anyway.

Reviewed By: hubert.reinterpretcast, daltenty, Mordante, #libc, Quuxplusone

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

2 years ago[gn build] Port 53dcd9efd16f
LLVM GN Syncbot [Fri, 25 Feb 2022 14:48:36 +0000 (14:48 +0000)]
[gn build] Port 53dcd9efd16f

2 years ago[clang][dataflow] Add SAT solver interface and implementation
Stanislav Gatev [Mon, 21 Feb 2022 23:43:55 +0000 (23:43 +0000)]
[clang][dataflow] Add SAT solver interface and implementation

This is part of the implementation of the dataflow analysis framework.
See "[RFC] A dataflow analysis framework for Clang AST" on cfe-dev.

Reviewed-by: ymandel, xazax.hun
Differential Revision: https://reviews.llvm.org/D120289

2 years ago[IPO] AAFunctionReachabilityFunction.updateImpl - reduce AAReachability scope. NFCI.
Simon Pilgrim [Fri, 25 Feb 2022 14:42:31 +0000 (14:42 +0000)]
[IPO] AAFunctionReachabilityFunction.updateImpl - reduce AAReachability scope. NFCI.

We already have a check for !InstQueries.empty(), so move the for-range over InstQueries inside to avoid the AAReachability uninitialized variable static analysis warnings.

2 years agoUse function prototypes when appropriate; NFC
Aaron Ballman [Fri, 25 Feb 2022 14:07:32 +0000 (09:07 -0500)]
Use function prototypes when appropriate; NFC

This prepares the clang-tools-extra project for -Wstrict-prototypes
being enabled by default.

2 years ago[MLIR][Presburger] coalesce fixups: inline comments /// -> //, i++ -> ++i (NFC)
Arjun P [Fri, 25 Feb 2022 13:48:49 +0000 (13:48 +0000)]
[MLIR][Presburger] coalesce fixups: inline comments /// -> //, i++ -> ++i (NFC)

Also use empty() instead of size() == 0.

2 years ago[X86] Regenerate x86-cmov-converter.ll checks
Simon Pilgrim [Fri, 25 Feb 2022 13:52:34 +0000 (13:52 +0000)]
[X86] Regenerate x86-cmov-converter.ll checks

2 years ago[X86] Combine ADC(ADD(X,Y),0,Carry) -> ADC(X,Y,Carry)
Pawe Bylica [Fri, 25 Feb 2022 13:17:42 +0000 (14:17 +0100)]
[X86] Combine ADC(ADD(X,Y),0,Carry) -> ADC(X,Y,Carry)

Reviewed By: RKSimon

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

2 years ago[sanitizer] Disable pc guard coverage test on PPC64/s390x
Xiaodong Liu [Fri, 25 Feb 2022 13:08:47 +0000 (21:08 +0800)]
[sanitizer] Disable pc guard coverage test on PPC64/s390x

Reviewed By: benshi001, uweigand

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

2 years agoRevert "[lldb/test] Fix TestProgressReporting.py race issue with the event listener"
Michael Forster [Fri, 25 Feb 2022 13:07:49 +0000 (13:07 +0000)]
Revert "[lldb/test] Fix TestProgressReporting.py race issue with the event listener"

This reverts commit 3e3e79a9e4c378b59f5f393f556e6a84edcd8898.

MemorySanitizer: use-of-uninitialized-value

2 years ago[MLIR][Presburger] Refactor looping strategy in coalesce
Michel Weber [Fri, 25 Feb 2022 12:22:48 +0000 (12:22 +0000)]
[MLIR][Presburger] Refactor looping strategy in coalesce

This patch refactors the looping strategy of coalesce for future patches. The new strategy works in-place and uses IneqType to organize inequalities into vectors of the same type. Future coalesce cases will pattern match on this organization. E.g. the contained case needs all inequalities and equalities to be redundant, so this case becomes checking whether the respective vectors are empty. For other cases, the patterns consider the types of all inequalities of both sets making it wasteful to only consider whether a can be coalesced with b in one step, as inequalities would need to be typed again for the opposite case. Therefore, the new strategy tries to coalesce a with b and b with a in a single step.

Reviewed By: Groverkss, arjunp

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

2 years ago[RISCV] Fix a mistake in PostprocessISelDAG
Haocong.Lu [Fri, 25 Feb 2022 12:37:07 +0000 (12:37 +0000)]
[RISCV] Fix a mistake in PostprocessISelDAG

With the condition N->use_empty(), the root node of DAG always
misses peephole optimization. So a dummy node is needed.

Reviewed By: craig.topper

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

2 years ago[gn build] Port f9e8e92cf586
LLVM GN Syncbot [Fri, 25 Feb 2022 12:21:23 +0000 (12:21 +0000)]
[gn build] Port f9e8e92cf586

2 years agoRevert "[clang][analyzer] Add modeling of 'errno'."
Aaron Ballman [Fri, 25 Feb 2022 12:15:01 +0000 (07:15 -0500)]
Revert "[clang][analyzer] Add modeling of 'errno'."

This reverts commit 29b512ba322cb6dd2c45d5e07645e20db47fad0d.

This broke several build bots:

https://lab.llvm.org/buildbot/#/builders/86/builds/30183
https://lab.llvm.org/buildbot/#/builders/216/builds/488

2 years ago[MergeICmps] Add opaque pointer test (NFC)
Nikita Popov [Fri, 25 Feb 2022 12:18:45 +0000 (13:18 +0100)]
[MergeICmps] Add opaque pointer test (NFC)

We fail to merge the icmps here, because the zero-offset access
does not go through a GEP.

2 years ago[LLDB] XFAIL TestUnambiguousTailCalls.py for Arm/Linux
Muhammad Omair Javaid [Fri, 25 Feb 2022 12:08:03 +0000 (17:08 +0500)]
[LLDB] XFAIL TestUnambiguousTailCalls.py for Arm/Linux

This patch marks TestUnambiguousTailCalls.py as XFAIL on Arm/Linux.
Test started failing after 3c4ed02698afec021c6bca80740d1e58e3ee019e.

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

2 years ago[MLIR][Presburger] Use Matrix utilities for IntegerPolyhedron
Groverkss [Fri, 25 Feb 2022 12:05:09 +0000 (17:35 +0530)]
[MLIR][Presburger] Use Matrix utilities for IntegerPolyhedron

This patch replaces various functions over inequalities/equalities in
IntegerPolyhedron with Matrix functions already implementing them or refactors
them to a Matrix function.

Reviewed By: arjunp

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

2 years ago[gn build] Port 29b512ba322c
LLVM GN Syncbot [Fri, 25 Feb 2022 11:47:20 +0000 (11:47 +0000)]
[gn build] Port 29b512ba322c

2 years ago[clang][analyzer] Add modeling of 'errno'.
Balázs Kéri [Fri, 25 Feb 2022 09:15:06 +0000 (10:15 +0100)]
[clang][analyzer] Add modeling of 'errno'.

Add a checker to maintain the system-defined value 'errno'.
The value is supposed to be set in the future by existing or
new checkers that evaluate errno-modifying function calls.

Reviewed By: NoQ, steakhal

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

2 years ago[SVE] Don't custom lower constant predicate ISD:SPLAT_VECTOR operations.
Paul Walker [Tue, 22 Feb 2022 18:06:47 +0000 (18:06 +0000)]
[SVE] Don't custom lower constant predicate ISD:SPLAT_VECTOR operations.

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

2 years ago[AArch64] Async unwind - Refactor generation of shadow call stack prologue/epilogue
Momchil Velikov [Fri, 25 Feb 2022 10:50:02 +0000 (10:50 +0000)]
[AArch64] Async unwind - Refactor generation of shadow call stack prologue/epilogue

This patch is in preparation for the async unwind CFI.

Move the emission of the shadow call stack prologue/epilogue
instructions to the `emitPrologue`/`emitEpilogue`. This greatly
simplifies especially epilogue generation and makes unnecessary some
quite fragile code, that tries to skip over those

Reviewed By: MaskRay, efriedma

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

2 years ago[IndVars] Use phis() (NFC)
Nikita Popov [Fri, 25 Feb 2022 11:07:49 +0000 (12:07 +0100)]
[IndVars] Use phis() (NFC)

2 years ago[OpenCL] opencl-c.h: Fix incorrect get_image_width guard
Sven van Haastregt [Fri, 25 Feb 2022 11:05:56 +0000 (11:05 +0000)]
[OpenCL] opencl-c.h: Fix incorrect get_image_width guard

`cl_khr_3d_image_writes` should not guard `read_only image3d_t`.

2 years ago[LLDB] Remove XFAIL from minidebuginfo-set-and-hit-breakpoint.test
Muhammad Omair Javaid [Fri, 25 Feb 2022 10:52:55 +0000 (15:52 +0500)]
[LLDB] Remove XFAIL from minidebuginfo-set-and-hit-breakpoint.test

This patch removes XFAIL from minidebuginfo-set-and-hit-breakpoint.test.
Test started passing after 3c4ed02698afec021c6bca80740d1e58e3ee019e.

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

2 years ago[MLIR][Presburger] Move Presburger/ files to presburger namespace
Groverkss [Fri, 25 Feb 2022 10:31:23 +0000 (16:01 +0530)]
[MLIR][Presburger] Move Presburger/ files to presburger namespace

This patch moves the Presburger library to a new `presburger` namespace.

This allows to shorten some names, helps to avoid polluting the mlir namespace,
and also provides some structure.

Reviewed By: arjunp

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

2 years ago[InstCombine] Remove SPF min/max canonicalization
Nikita Popov [Thu, 24 Feb 2022 12:17:55 +0000 (13:17 +0100)]
[InstCombine] Remove SPF min/max canonicalization

Now that we canonicalize SPF min/max to intrinsics, there's no
need to canonicalize the structure of the SPF min/max itself
anymore. This is conceptually NFC, but in practice does slightly
impact results due to folding order differences.

2 years ago[MLIR][Presburger][NFC] Refactor redundant code in fourierMotzkinEliminate
Groverkss [Fri, 25 Feb 2022 10:10:20 +0000 (15:40 +0530)]
[MLIR][Presburger][NFC] Refactor redundant code in fourierMotzkinEliminate

This patch removes redundant code from fourierMotzkinEliminate implementation
using existing functions in IntegerPolyhedron.

Reviewed By: arjunp

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

2 years ago[flang][driver] Add support for `--target`/`--triple`
Andrzej Warzynski [Mon, 21 Feb 2022 11:51:32 +0000 (11:51 +0000)]
[flang][driver] Add support for `--target`/`--triple`

This patch adds support for:
  * `--target` in the compiler driver (`flang-new`)
  * `--triple` in the frontend driver (`flang-new -fc1`)
The semantics of these flags are inherited from `clangDriver`, i.e.
consistent with `clang --target` and `clang -cc1 --triple`,
respectively.

A new structure is defined, `TargetOptions`, that will hold various
Frontend options related to the target. Currently, this is mostly a
placeholder that contains the target triple. In the future, it will be
used for storing e.g. the CPU to tune for or the target features to
enable.

Additionally, the following target/triple related options are enabled
[*]: `-print-effective-triple`, `-print-target-triple`. Definitions in
Options.td are updated accordingly and, to facilated testing,
`-emit-llvm` is added to the list of options available in `flang-new`
(previously it was only enabled in `flang-new -fc1`).

[*] These options were actually available before (like all other options
defined in `clangDriver`), but not included in `flang-new --help`.
Before this change, `flang-new` would just use `native` for defining the
target, so these options were of little value.

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

2 years ago[C++20][Modules][4/8] Handle generation of partition implementation CMIs.
Iain Sandoe [Sun, 7 Feb 2021 17:08:42 +0000 (17:08 +0000)]
[C++20][Modules][4/8] Handle generation of partition implementation CMIs.

Partition implementations are special, they generate a CMI, but it
does not have an 'export' line, and we cannot export anything from the
it [that is it can only make decls available to other members of the
owning module, not to importers of that].

Add initial testcases for partition handling, derived from the examples in
Section 10 of the C++20 standard, which identifies what should be accepted
and/or rejected.

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

2 years ago[NFC][AArch64][SME] Remove '#' prefix in PSEL test cases
Hsiangkai Wang [Fri, 25 Feb 2022 06:58:31 +0000 (06:58 +0000)]
[NFC][AArch64][SME] Remove '#' prefix in PSEL test cases

There is no need to prefix '#' for element index in PSEL.
This is a follow up of D111213.

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

2 years ago[SCEVExpander] Use early returns in FindValueInExprValueMap() (NFC)
Nikita Popov [Fri, 25 Feb 2022 09:09:16 +0000 (10:09 +0100)]
[SCEVExpander] Use early returns in FindValueInExprValueMap() (NFC)

2 years ago[IR] Use CallBase::getParamElementType() (NFC)
Nikita Popov [Fri, 25 Feb 2022 08:59:50 +0000 (09:59 +0100)]
[IR] Use CallBase::getParamElementType() (NFC)

As this method now exists on CallBase, use it rather than the
one on AttributeList.

2 years agoRevert rG87753cebf5f861eee418d6bce155dfa0b00f9878 "[X86] combineX86ShufflesRecursivel...
Simon Pilgrim [Fri, 25 Feb 2022 08:59:47 +0000 (08:59 +0000)]
Revert rG87753cebf5f861eee418d6bce155dfa0b00f9878 "[X86] combineX86ShufflesRecursively - don't both widening inputs before calling combineX86ShuffleChain"

Reverting while we investigate codegen regression reports

2 years agoPlatformMacOSX should be activated for lldb built to run on an iOS etc device
Jason Molenda [Fri, 25 Feb 2022 08:55:54 +0000 (00:55 -0800)]
PlatformMacOSX should be activated for lldb built to run on an iOS etc device

In the changes Jonas made in https://reviews.llvm.org/D117340 , a
small oversight was that PlatformMacOSX (despite the name) is active
for any native Darwin operating system, where lldb and the target
process are running on the same system. This patch uses compile-time
checks to return the appropriate OSType for the OS lldb is being
compiled to, so the "host" platform will correctly be selected when
lldb & the inferior are both running on that OS. And a small change
to PlatformMacOSX::GetSupportedArchitectures which adds additional
recognized triples when running on macOS but not other native Darwin
systems.

Differential Revision: https://reviews.llvm.org/D120517
rdar://89247060

2 years ago[SCEV] Return ArrayRef from getSCEVValues() (NFC)
Nikita Popov [Fri, 25 Feb 2022 08:30:28 +0000 (09:30 +0100)]
[SCEV] Return ArrayRef from getSCEVValues() (NFC)

Return a read-only view on this set. For the one internal use,
directly access ExprValueMap.

2 years ago[mlir][OpDSL] Add type function attributes.
gysit [Fri, 25 Feb 2022 08:12:34 +0000 (08:12 +0000)]
[mlir][OpDSL] Add type function attributes.

Previously, OpDSL operation used hardcoded type conversion operations (cast or cast_unsigned). Supporting signed and unsigned casts thus meant implementing two different operations. Type function attributes allow us to define a single operation that has a cast type function attribute which at operation instantiation time may be set to cast or cast_unsigned. We may for example, defina a matmul operation with a cast argument:

```
@linalg_structured_op
def matmul(A=TensorDef(T1, S.M, S.K), B=TensorDef(T2, S.K, S.N), C=TensorDef(U, S.M, S.N, output=True),
    cast=TypeFnAttrDef(default=TypeFn.cast)):
  C[D.m, D.n] += cast(U, A[D.m, D.k]) * cast(U, B[D.k, D.n])
```

When instantiating the operation the attribute may be set to the desired cast function:

```
linalg.matmul(lhs, rhs, outs=[out], cast=TypeFn.cast_unsigned)
```

The revsion introduces a enum in the Linalg dialect that maps one-by-one to the type functions defined by OpDSL.

Reviewed By: aartbik

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

2 years ago[NVPTX][AsmPrinter] Emit .attribute(.managed) for global variable declarations
Kristina Bessonova [Fri, 25 Feb 2022 08:17:40 +0000 (10:17 +0200)]
[NVPTX][AsmPrinter] Emit .attribute(.managed) for global variable declarations

Declaration and definition attributes must match,
otherwise it may cause issues on linking.

Reviewed By: tra

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

2 years ago[SCEV] Don't try to reuse expressions with offset
Nikita Popov [Tue, 22 Feb 2022 09:47:15 +0000 (10:47 +0100)]
[SCEV] Don't try to reuse expressions with offset

SCEVs ExprValueMap currently tracks not only which IR Values
correspond to a given SCEV expression, but additionally stores that
it may be expanded in the form X+Offset. In theory, this allows
reusing existing IR Values in more cases.

In practice, this doesn't seem to be particularly useful (the test
changes are rather underwhelming) and adds a good bit of complexity.
Per https://github.com/llvm/llvm-project/issues/53905, we have an
invalidation issue with these offseted expressions.

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

2 years ago[SystemZ] [z/OS] Add support for generating huge (1 MiB) stack frames in XPLINK64
Neumann Hon [Fri, 25 Feb 2022 07:37:05 +0000 (02:37 -0500)]
[SystemZ] [z/OS] Add support for generating huge (1 MiB) stack frames in XPLINK64

This patch extends support for generating huge stack frames on 64-bit XPLINK by implementing the ABI-mandated call to the stack extension routine.

Reviewed By: uweigand

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

2 years ago[MLIR][Presburger] enable copy assignment operator for Simplex
Michel Weber [Fri, 25 Feb 2022 07:32:22 +0000 (07:32 +0000)]
[MLIR][Presburger] enable copy assignment operator for Simplex

This patch removes the `const` from `usingBigM` to enable the implicit copy assignment operator for Simplex.

Reviewed By: Groverkss

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

2 years ago[clang-tidy] Fix `readability-non-const-parameter` for parameter referenced by an...
Sockke [Fri, 25 Feb 2022 06:44:26 +0000 (14:44 +0800)]
[clang-tidy] Fix `readability-non-const-parameter` for parameter referenced by an lvalue

The checker missed a check for a case when the parameter is referenced by an lvalue and this could cause build breakages.

Reviewed By: aaron.ballman

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

2 years ago[RISCV] DAG Combine vcpop and vfirst with VL=0 to li imm
Chenbing Zheng [Fri, 25 Feb 2022 06:44:25 +0000 (14:44 +0800)]
[RISCV] DAG Combine vcpop and vfirst with VL=0 to li imm

vcpop and vfirst are still useful when VL=0.
vcpop equivalents to li 0 and vfirst equivalents to li -1,
since no mask elements are active.

Reviewed By: craig.topper

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

2 years ago[RISCV] Update computeTargetABI from llc as well as clang
Zakk Chen [Fri, 25 Feb 2022 03:04:24 +0000 (19:04 -0800)]
[RISCV] Update computeTargetABI from llc as well as clang

Clang computes the default ABI if -mabi is empty
and encode it in LLVM IR module flag since D105555.
For correctness, llc need to give the same target-abi
(Options.MCOptions.ABIName) with ABI encoded in IR.
The getSubtargetImpl already has a check for them only if
Options.MCOptions.ABIName is not empty.

In order to get more robustness we could have a check for
explicit ABI, but now we have two different logic to
compute the default ABI.

The front-end ABI is defautl to the ilp32/ilp32e/lp64, and
ilp32d/lp64d when hardware support for extension D.
The backend ABI is default to the ilp32/ilp32e/lp64.

Reviewed by: asb, jrtc27

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

2 years ago[AggressiveInstCombine] Fix `TruncInstCombine` (fix f84d732f)
Anton Afanasyev [Fri, 25 Feb 2022 05:04:11 +0000 (08:04 +0300)]
[AggressiveInstCombine] Fix `TruncInstCombine` (fix f84d732f)

Erase phi-nodes from `InstInfoMap` before erasing themselves

2 years ago[AggressiveInstCombine] Add `phi` nodes support to `TruncInstCombine`
Anton Afanasyev [Wed, 15 Sep 2021 06:19:53 +0000 (09:19 +0300)]
[AggressiveInstCombine] Add `phi` nodes support to `TruncInstCombine`

Expand `TruncInstCombine` to handle loops by adding `phi` nodes
to expression graph.

Reviewed by: RKSimon, lebedev.ri

(recommit of fixed f84d732f, reverted by 8ad6d5e after sanitizer breakage)

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

2 years ago[CUDA][SPIRV] Assign global address space to CUDA kernel arguments
Shangwu Yao [Fri, 25 Feb 2022 04:51:43 +0000 (20:51 -0800)]
[CUDA][SPIRV] Assign global address space to CUDA kernel arguments

(resubmit https://reviews.llvm.org/D119207 after fixing the test for
some build settings)

This patch converts CUDA pointer kernel arguments with default address
space to CrossWorkGroup address space (__global in OpenCL). This is
because Generic or Function (OpenCL's private) is not supported as
storage class for kernel pointer types.

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

2 years ago[Driver] Support GCC detection for GCC compiled with --enable-version-specific-runtim...
Raúl Peñacoba [Fri, 25 Feb 2022 04:41:02 +0000 (04:41 +0000)]
[Driver] Support GCC detection for GCC compiled with --enable-version-specific-runtime-libs

GCC's compiled with --enable-version-specific-runtime-libs change the paths where includes and libs are found.
This patch adds support for these cases

Reviewed By: MaskRay

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

2 years ago[sanitizer] Don't collect unused info
Vitaly Buka [Fri, 25 Feb 2022 04:18:56 +0000 (20:18 -0800)]
[sanitizer] Don't collect unused info

2 years ago[ELF] Parallelize initializeLocalSymbols
Fangrui Song [Fri, 25 Feb 2022 04:05:59 +0000 (20:05 -0800)]
[ELF] Parallelize initializeLocalSymbols

ObjFile::parse combines symbol initialization and resolution. Many tasks
unrelated to symbol resolution can be postponed and parallelized. This patch
extracts local symbol initialization and parallelizes it.

Technically the new function initializeLocalSymbols can be merged into
ObjFile::postParse, but functions like getSrcMsg may access the
uninitialized (all nullptr) local part of InputFile::symbols.

Linking chrome: 1.02x as fast with glibc malloc, 1.04x as fast with mimalloc

Reviewed By: ikudrin

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

2 years ago[SLP] Fix for the min/max intrinsic cost.
Vasileios Porpodas [Thu, 24 Feb 2022 02:04:36 +0000 (18:04 -0800)]
[SLP] Fix for the min/max intrinsic cost.

The min/max intrinsic cost is currently too low because in the cost calculation
we subtract the cost of the vector compare as we will not emit it.
For the cost of the vector compare we are currently passing BAD_ICMP_PREDICATE
which returns 3, the worst case cost.
I think we should be passing VecPred instead, since we know the predicates of
the compare instr.

I think this is related to commit b3b993a7ad817 which introduced the predicate
argument to getCmpSelInstrCost().
https://reviews.llvm.org/rGb3b993a7ad817c3c5801341fa78f34332900eb83

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

2 years ago[SLP][NFC] Test for a follow-up fix of the the vector min/max instrinsic cost calcula...
Vasileios Porpodas [Thu, 24 Feb 2022 02:03:20 +0000 (18:03 -0800)]
[SLP][NFC] Test for a follow-up fix of the the vector min/max instrinsic cost calculation.

The code in this test should not have been vectorized.
It looks worse than the scalar code.

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

2 years ago[RISCV] Add schedule class for Zbt extension
lian wang [Wed, 16 Feb 2022 01:59:50 +0000 (01:59 +0000)]
[RISCV] Add schedule class for Zbt extension

Reviewed By: craig.topper

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

2 years ago[sanitizer] Enable trace pc guard coverage test on PPC64/s390x/MIPS
Xiaodong Liu [Fri, 25 Feb 2022 01:42:19 +0000 (09:42 +0800)]
[sanitizer] Enable trace pc guard coverage test on PPC64/s390x/MIPS

Reviewed By: MaskRay

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

2 years ago[AMDGPU] Extend pre-emit peephole to redundantly masked VCC
Carl Ritson [Fri, 25 Feb 2022 00:42:55 +0000 (09:42 +0900)]
[AMDGPU] Extend pre-emit peephole to redundantly masked VCC

Extend pre-emit peephole for S_CBRANCH_VCC[N]Z to eliminate
redundant S_AND operations against EXEC for V_CMP results in VCC.
These occur after after register allocation when VCC has been
selected as the comparison destination.

Reviewed By: rampitec

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

2 years ago[ADT, CSSPGO] Specify set comparer
Harald van Dijk [Fri, 25 Feb 2022 00:58:50 +0000 (00:58 +0000)]
[ADT, CSSPGO] Specify set comparer

In _GLIBCXX_DEBUG builds, potentially implicitly enabled by
LLVM_ENABLE_EXPENSIVE_CHECKS, std::set<A, B>::iterator and
std::set<A, C>::iterator are distinct types that are not
interconvertible. This change aligns the iterator types with the set
types.

Reviewed By: hoy

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

2 years ago[libc++] Make sure calls to std::move are always qualified
Corentin Jabot [Fri, 25 Feb 2022 00:54:00 +0000 (19:54 -0500)]
[libc++] Make sure calls to std::move are always qualified

This fixes instances of the newly added `-Wunqualified-std-cast-call`.

(Commit 7853371146 removed unqualified `move` from the tests,
but these unqualified `move`s remained undetected in the actual headers.)

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

2 years ago[OpaquePtr][AArch64] Use load/store value type instead of pointer type for ldnt1...
Arthur Eubanks [Fri, 25 Feb 2022 00:54:18 +0000 (16:54 -0800)]
[OpaquePtr][AArch64] Use load/store value type instead of pointer type for ldnt1/stnt1 alignment

2 years ago[Debuginfod] Add BUILD_ID syntax to llvm-symbolizer.
Daniel Thornburgh [Tue, 15 Feb 2022 22:21:14 +0000 (22:21 +0000)]
[Debuginfod] Add BUILD_ID syntax to llvm-symbolizer.

This adds a BUILD_ID prefix to the llvm-symbolizer stdin and argument
syntax. The prefix causes the given binary name to be interpreted as a
build ID instead of an object file path. The semantics are analagous to
the behavior of --obj and --build-id.

Reviewed By: jhenderson

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

2 years ago[RISCV] Change rvv version to 1.0 and remove ratify notice
Qihan Cai [Thu, 24 Feb 2022 22:13:51 +0000 (09:13 +1100)]
[RISCV] Change rvv version to 1.0 and remove ratify notice

This patch changes the version of V extension from 0.1 to 1.0 in RISCVInstrInfoVPseudos.td, RISCVInstrInfoVSDPatterns.td,  RISCVInstrInfoVVLPatterns.td, RISCVInstrInfoV.td

Reviewed By: craig.topper

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

2 years ago[Driver][test] Make linux-ld.c work with CLANG_DEFAULT_PIE_ON_LINUX=on
Fangrui Song [Fri, 25 Feb 2022 00:34:05 +0000 (00:34 +0000)]
[Driver][test] Make linux-ld.c work with CLANG_DEFAULT_PIE_ON_LINUX=on

2 years ago[Symbolize] LRU cache binaries in llvm-symbolizer.
Daniel Thornburgh [Tue, 8 Feb 2022 22:07:14 +0000 (22:07 +0000)]
[Symbolize] LRU cache binaries in llvm-symbolizer.

This change adds a simple LRU cache to the Symbolize class to put a cap
on llvm-symbolizer memory usage. Previously, the Symbolizer's virtual
memory footprint would grow without bound as additional binaries were
referenced.

I'm putting this out there early for an informal review, since there may be
a dramatically different/better way to go about this. I still need to
figure out a good default constant for the memory cap and benchmark the
implementation against a large symbolization workload. Right now I've
pegged max memory usage at zero for testing purposes, which evicts the whole
cache every time.

Unfortunately, it looks like StringRefs in the returned DI objects can
directly refer to the contents of binaries. Accordingly, the cache
pruning must be explicitly requested by the caller, as the caller must
guarantee that none of the returned objects will be used afterwards.

For llvm-symbolizer this a light burden; symbolization occurs
line-by-line, and the returned objects are discarded after each.

Implementation wise, there are a number of nested caches that depend
on one another. I've implemented a simple Evictor callback system to
allow derived caches to register eviction actions to occur when the
underlying binaries are evicted.

Reviewed By: dblaikie

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

2 years ago[clang][NFC] Move all avr CodeGen tests to avr specific directory
Ben Shi [Thu, 24 Feb 2022 11:23:05 +0000 (11:23 +0000)]
[clang][NFC] Move all avr CodeGen tests to avr specific directory

Reviewed By: MaskRay

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

2 years ago[Driver] Default CLANG_DEFAULT_PIE_ON_LINUX to ON
Fangrui Song [Fri, 25 Feb 2022 00:22:12 +0000 (00:22 +0000)]
[Driver] Default CLANG_DEFAULT_PIE_ON_LINUX to ON

Default the option introduced in D113372 to ON to match all(?) major Linux
distros. This matches GCC and improves consistency with Android and linux-musl
which always default to PIE.
Note: CLANG_DEFAULT_PIE_ON_LINUX will be removed in the future.

Reviewed By: thesamesam

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

2 years ago[asan][test] asan_prelink_test.cpp: use -fno-pie -no-pie
Fangrui Song [Fri, 25 Feb 2022 00:09:18 +0000 (16:09 -0800)]
[asan][test] asan_prelink_test.cpp: use -fno-pie -no-pie

prelink (will be removed by glibc 2.37) does not support PIE.

2 years ago[Driver][test] Remove soon irrelevant pie tests
Fangrui Song [Fri, 25 Feb 2022 00:04:07 +0000 (00:04 +0000)]
[Driver][test] Remove soon irrelevant pie tests

CLANG_DEFAULT_PIE_ON_LINUX=on will soon become the default. The purpose
of these tests has gone.

2 years ago[Driver][test] Make hexagon-toolchain-elf.c work with CLANG_DEFAULT_PIE_ON_LINUX=on
Fangrui Song [Thu, 24 Feb 2022 23:53:38 +0000 (23:53 +0000)]
[Driver][test] Make hexagon-toolchain-elf.c work with CLANG_DEFAULT_PIE_ON_LINUX=on

2 years ago.mailmap: remove stray space in comment
Nico Weber [Thu, 24 Feb 2022 23:50:08 +0000 (18:50 -0500)]
.mailmap: remove stray space in comment

2 years ago[clang][test] Make mips-vector-return.c work with CLANG_DEFAULT_PIE_ON_LINUX=on
Fangrui Song [Thu, 24 Feb 2022 23:25:35 +0000 (15:25 -0800)]
[clang][test] Make mips-vector-return.c work with CLANG_DEFAULT_PIE_ON_LINUX=on

2 years ago[RISCV] Add 'i64' to some isel so tablegen will remove them for RV32. NFC
Craig Topper [Thu, 24 Feb 2022 23:09:20 +0000 (15:09 -0800)]
[RISCV] Add 'i64' to some isel so tablegen will remove them for RV32. NFC

Saves a 100 bytes or so from the isel table.

2 years agoClang `unused-but-set-variable` warnings should not apply to `__attribute__((objc_pre...
Michael Wyman [Wed, 23 Feb 2022 18:47:16 +0000 (10:47 -0800)]
Clang `unused-but-set-variable` warnings should not apply to `__attribute__((objc_precise_lifetime))` Objective-C pointers

The `objc_precise_lifetime` attribute is applied to Objective-C pointers to ensure the optimizer does not prematurely release an object under Automatic Reference Counting (ARC). It is a common enough pattern to assign values to these variables but not reference them otherwise, and annotating them with `__unused` is not really correct as they are being used to ensure an object's lifetime.

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

2 years ago[ELF] Update comment. NFC
Fangrui Song [Thu, 24 Feb 2022 22:09:00 +0000 (14:09 -0800)]
[ELF] Update comment. NFC

2 years ago[ELF] Simplify resolveDefined and resolveCommon
Fangrui Song [Thu, 24 Feb 2022 22:08:06 +0000 (14:08 -0800)]
[ELF] Simplify resolveDefined and resolveCommon

This is NFC for valid input (COMMON symbols cannot be weak or versioned).

2 years agoRevert "Encode address offsets of basic blocks relative to the end of the previous...
Rahman Lavaee [Thu, 24 Feb 2022 20:29:08 +0000 (12:29 -0800)]
Revert "Encode address offsets of basic blocks relative to the end of the previous basic blocks."

This reverts commit 029283c1c0d8d06fbf000f5682c56b8595a1101f.
The code in `ELFFile::decodeBBAddrMap` was not changed in the submitted patch.

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

2 years ago[lld/MachO] Fix +asserts build after recent change
Reid Kleckner [Thu, 24 Feb 2022 21:12:48 +0000 (13:12 -0800)]
[lld/MachO] Fix +asserts build after recent change

2 years ago[AArch64][x86] add tests for bitwise logic + shifts; NFC
Sanjay Patel [Thu, 24 Feb 2022 20:42:30 +0000 (15:42 -0500)]
[AArch64][x86] add tests for bitwise logic + shifts; NFC

2 years ago[RISCV] Add tests for (neg (abs X)) where the abs has an additional user.
Craig Topper [Thu, 24 Feb 2022 20:36:33 +0000 (12:36 -0800)]
[RISCV] Add tests for (neg (abs X)) where the abs has an additional user.

2 years ago[ELF][test] Remove invalid weak COMMON tests
Fangrui Song [Thu, 24 Feb 2022 20:54:16 +0000 (12:54 -0800)]
[ELF][test] Remove invalid weak COMMON tests

GNU as reports `Error: symbol `foo' can not be both weak and common`,
though LLVM integrated assembler does not report an error yet.

2 years ago[clang][dataflow] Add limits to size of modeled data structures in environment.
Yitzhak Mandelbaum [Thu, 24 Feb 2022 20:02:00 +0000 (20:02 +0000)]
[clang][dataflow] Add limits to size of modeled data structures in environment.

Adds two new parameters to control the size of data structures modeled in the environment: # of values and depth of data structure.  The environment already prevents creation of recursive data structures, but that was insufficient in practice. Very large structs still ground the analysis to a halt.  These new parameters allow tuning the size more effectively.

In this patch, the parameters are set as internal constants. We leave to a future patch to make these proper model parameters.

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

2 years ago[lld-macho] Implement -why_live (without perf overhead)
Jez Ng [Thu, 24 Feb 2022 20:39:59 +0000 (15:39 -0500)]
[lld-macho] Implement -why_live (without perf overhead)

This was based off @thakis' draft in {D103517}. I employed templates to ensure
the support for `-why_live` wouldn't slow down the regular non-why-live code
path.

No stat sig perf difference on my 3.2 GHz 16-Core Intel Xeon W:

             base           diff           difference (95% CI)
  sys_time   1.195 ± 0.015  1.199 ± 0.022  [  -0.4% ..   +1.0%]
  user_time  3.716 ± 0.022  3.701 ± 0.025  [  -0.7% ..   -0.1%]
  wall_time  4.606 ± 0.034  4.597 ± 0.046  [  -0.6% ..   +0.2%]
  samples    44             37

Reviewed By: #lld-macho, thakis

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

2 years agoFix typo in file name; NFC
Aaron Ballman [Thu, 24 Feb 2022 20:41:25 +0000 (15:41 -0500)]
Fix typo in file name; NFC