platform/upstream/llvm.git
2 years ago[libc][NFC] Fix a few compiler warnings.
Siva Chandra Reddy [Tue, 9 Aug 2022 22:27:46 +0000 (22:27 +0000)]
[libc][NFC] Fix a few compiler warnings.

2 years ago[RISCV] Split check lines for fpclamptosat_vec test
Philip Reames [Tue, 9 Aug 2022 21:58:26 +0000 (14:58 -0700)]
[RISCV] Split check lines for fpclamptosat_vec test

This is currently exercising scalarization code path; with vectors enabled, we hit a different code path.  Explicitly exercise both so that both configurations have testing.

2 years ago[ARM] Do not use LOAD_STACK_GUARD with ROPI/RWPI
Pengxuan Zheng [Mon, 8 Aug 2022 19:43:30 +0000 (12:43 -0700)]
[ARM] Do not use LOAD_STACK_GUARD with ROPI/RWPI

ROPI/RWPI are not supported with LOAD_STACK_GUARD currently.

Reviewed By: nickdesaulniers, rengolin

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

2 years ago@skipIfAsan for the other long test in TestMemoryRegion.py
Jim Ingham [Tue, 9 Aug 2022 21:54:18 +0000 (14:54 -0700)]
@skipIfAsan for the other long test in TestMemoryRegion.py

These two tests were each of them too long when running under ASAN,
so we have to skip both to get a clean ASAN bot run.

2 years ago[libc] Add __cxa_atexit support to the atexit function.
Siva Chandra Reddy [Tue, 2 Aug 2022 07:14:12 +0000 (07:14 +0000)]
[libc] Add __cxa_atexit support to the atexit function.

Reviewed By: abrachet

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

2 years ago[libc] Add a utility data structure named FixedVector.
Siva Chandra Reddy [Sat, 6 Aug 2022 00:19:51 +0000 (00:19 +0000)]
[libc] Add a utility data structure named FixedVector.

This data structure uses a backing cpp::array object and supports a
vector like push_back API. In comparison with a traditional vector
data structure, it is of a fixed capacity and cannot be resized.

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

2 years ago[AArch64][LoopVectorize] Introduce trip count minimal value threshold to ignore tail...
Dinar Temirbulatov [Tue, 9 Aug 2022 21:10:17 +0000 (22:10 +0100)]
[AArch64][LoopVectorize] Introduce trip count minimal value threshold to ignore tail-folding.

After D121595 was commited, I noticed regressions assosicated with small trip
count numbersvectorisation by tail folding with scalable vectors. As a solution
for those issues I propose to introduce the minimal trip count threshold value.

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

2 years ago[flang] Revert changes (NFC)
Jeff Niu [Tue, 9 Aug 2022 20:10:21 +0000 (16:10 -0400)]
[flang] Revert changes (NFC)

2 years ago[mlir] Fix build of toyc-ch6 (NFC)
Jeff Niu [Tue, 9 Aug 2022 19:58:49 +0000 (15:58 -0400)]
[mlir] Fix build of toyc-ch6 (NFC)

2 years agoThe memory region tests have been consistently timing on the ASAN
Jim Ingham [Tue, 9 Aug 2022 19:49:43 +0000 (12:49 -0700)]
The memory region tests have been consistently timing on the ASAN
bot.  This happens because they are building a long result into
a Python string, and the asan checker is making that very slow.

The last two tests here are both slow, but the 'test_command' is the
really slow one.  I'm going to start disabling just that one and see
if that gets the ASAN bots clean.

2 years ago[pseudo] Fix a suspicious usage of `sizeof(this)`.
Haojian Wu [Tue, 9 Aug 2022 19:46:56 +0000 (21:46 +0200)]
[pseudo] Fix a suspicious usage of `sizeof(this)`.

It should be `sizeof(*this)`.

2 years ago[mlir] Cleanup DenseArrayAttrBase definition and expose raw API
Jeff Niu [Mon, 8 Aug 2022 22:04:05 +0000 (18:04 -0400)]
[mlir] Cleanup DenseArrayAttrBase definition and expose raw API

This patch cleans up the definition of `DenseArrayAttrBase` by relying
more on ODS-generated methods. It also exposes an API for using the raw
data of a dense array, similar to `DenseIntOrFPElementsAttr::getRaw`.

Reviewed By: lattner, mehdi_amini

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

2 years agofix mlgo regalloc test model generation for tflite
yundiqian [Tue, 9 Aug 2022 19:10:08 +0000 (12:10 -0700)]
fix mlgo regalloc test model generation for tflite

To move from TF C API to TFLite, we found that the argmax op in TFLite does not work for int64 inputs, so cast the int64 inputs to int32 inputs to make TFLite argmax op work

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

2 years ago[mlir][LLVMIR] (NFC) Add convenience builders for ConstantOp
Jeff Niu [Tue, 9 Aug 2022 18:40:07 +0000 (14:40 -0400)]
[mlir][LLVMIR] (NFC) Add convenience builders for ConstantOp

And clean up some of the user code

2 years ago[LLD][COFF] Identify /GL object files which are inside libraries
Pengxuan Zheng [Tue, 9 Aug 2022 00:49:08 +0000 (17:49 -0700)]
[LLD][COFF] Identify /GL object files which are inside libraries

With D26647, we can already identify input object files compiled by cl.exe with
/GL. It seems to be helpful to do the same and print an error message for those
object files compiled with /GL but are inside libraries/archives too.

Reviewed By: rnk, thieta

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

2 years ago[Flang][OpenMP] Add support for integer multiplication reduction in worksharing-loop
Dylan Fleming [Tue, 9 Aug 2022 19:22:16 +0000 (19:22 +0000)]
[Flang][OpenMP] Add support for integer multiplication reduction in worksharing-loop

Adds support for reduction of multiplcation
by extending OpenMP.cpp::genOpenMPReduction()
and altering the identity constant emitted in
OpenMP.cpp::createReductionDelc()

This patch builds D130077 and as such,
only supports reductions for interger types in
worksharping loops.

Reviewed By: awarzynski

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

2 years ago[flang] Extend characterization & checking for procedure bindings
Peter Klausler [Tue, 9 Aug 2022 16:01:50 +0000 (09:01 -0700)]
[flang] Extend characterization & checking for procedure bindings

Procedure bindings with explicit interfaces don't work when the
interface is shadowed by a generic interface of the same name,
and can produce spurious semantic error messages.  Extend the
characterization and checking code for such things, and the utility
functionns on which they depend, to dig through generics when they
occlude interface-defining subprograms.  This is done on demand in
checking code, not once during name resolution, because the
procedures in question may also be forward-referenced.

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

diff --git a/flang/include/flang/Semantics/symbol.h b/flang/include/flang/Semantics/symbol.h
index e79f8ab6503e..0b03bf06eb73 100644
--- a/flang/include/flang/Semantics/symbol.h

2 years ago[mlir][sparse] fix switch statement bug on two binary ops
Aart Bik [Tue, 9 Aug 2022 16:39:58 +0000 (09:39 -0700)]
[mlir][sparse] fix switch statement bug on two binary ops

They appeared at the wrong place in the switch, treating
them as unary op rather than binary op.

Reviewed By: bixia

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

2 years ago[mlir][sparse] update bibliography of sparse tensor dialect
Aart Bik [Tue, 9 Aug 2022 18:00:07 +0000 (11:00 -0700)]
[mlir][sparse] update bibliography of sparse tensor dialect

Reviewed By: Peiming

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

2 years ago[mlir][spirv] Use functors for default memory space mappings
Lei Zhang [Tue, 9 Aug 2022 18:32:22 +0000 (14:32 -0400)]
[mlir][spirv] Use functors for default memory space mappings

This makes it easier to use as a utility function to query the
mappings, including the reverse.

This commit also drops some storage classes that aren't needed
for now.

Reviewed By: kuhar

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

2 years ago[mlir][spirv] Detach memory space mapping from type conversion
Lei Zhang [Tue, 9 Aug 2022 18:25:38 +0000 (14:25 -0400)]
[mlir][spirv] Detach memory space mapping from type conversion

This commit moves MemRef memory space to SPIR-V storage class
conversion out of the main SPIR-V type converter. Now the mapping
should happen as a prelimiary step before performing the final
conversion to SPIR-V. Flows are expect to write their own memory
space mappings like the `MapMemRefStorageClassPass` to handle
memory space mappings according to their needs.

This is needed because SPIR-V is serving multiple client APIs,
including Vulkan and OpenCL. Different client APIs might want
to use different storage classes for buffers in a particular
memory space, e.g., `StorageBuffer` for Vulkan vs. `CrossWorkgroup`
for OpenCL when converting the default 0 memory space.  Hardcoding
a specific mapping makes that hard. While it's possible to embed
selection logic further inside the main type converter, it will
make the main type converter even complicated. So it's better to
separate the concerns, as mapping the memory space is really
concretizing the meaning of those numeric memory spaces in the
particular context of SPIR-V lowering.

Reviewed By: kuhar

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

2 years ago[RISCV] Refresh two autogened tests to avoid future whitespace diffs [nfc]
Philip Reames [Tue, 9 Aug 2022 18:23:09 +0000 (11:23 -0700)]
[RISCV] Refresh two autogened tests to avoid future whitespace diffs [nfc]

2 years ago[mlir][spirv] Make MemRef memory space mapping pass more flexible
Lei Zhang [Tue, 9 Aug 2022 18:15:55 +0000 (14:15 -0400)]
[mlir][spirv] Make MemRef memory space mapping pass more flexible

* Avoid restricting the pass to to builtin module ops. The pass
  should be able to run on any region ops.
* Avoid hardcoding func FuncOp when handling functions. Instead,
  use the function op interface.
* Assigns the default mapping in the constructor. So for cases
  where we are using the pass in a pipeline, we still have a
  meaningful default.

Along the way, dropped uncessary unrealized conversion casts and
use full conversion. The pass should be able to convert all sorts
of ops; there is really no need to have such bridages.

Reviewed By: kuhar

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

2 years ago[MLIR] Extend vector.gather to accept tensor as base
Jerry Wu [Tue, 9 Aug 2022 18:19:05 +0000 (11:19 -0700)]
[MLIR] Extend vector.gather to accept tensor as base

In addition to memref, accept ranked tensor as the base operand of vector.gather, similar to vector.trasnfer_read.

This will allow us to vectorize noncontiguous tensor.extract into vector.gather. Full discussion can be found here: https://github.com/iree-org/iree/issues/9198

Reviewed By: hanchung, dcaballe

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

2 years ago[MLIR] Support lowering n-D arith.index_cast to LLVM
Jerry Wu [Tue, 9 Aug 2022 18:12:00 +0000 (11:12 -0700)]
[MLIR] Support lowering n-D arith.index_cast to LLVM

Previously we can only lower arith.index_cast with 1-D vectors to LLVM. This change added the support for n-D vectors.

Reviewed By: ftynse, hanchung

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

2 years ago[mlir][spirv] Migrate to use specalized enum attributes
Lei Zhang [Tue, 9 Aug 2022 18:03:54 +0000 (14:03 -0400)]
[mlir][spirv] Migrate to use specalized enum attributes

Previously we are using IntegerAttr to back all SPIR-V enum
attributes. Therefore we all such attributes are showed like
IntegerAttr in IRs, which is barely readable and breaks
roundtripability of the IR. This commit changes to use
`EnumAttr` as the base directly so that we can have separate
attribute definitions and better IR printing.

Reviewed By: kuhar

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

2 years ago[mlir][sparse] improve semi-ring doc
Aart Bik [Tue, 9 Aug 2022 17:29:42 +0000 (10:29 -0700)]
[mlir][sparse] improve semi-ring doc

Spell out SparseVector instead of just using SparseVec

Reviewed By: jim22k, bixia

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

2 years ago[X86][ARM] Update tests for bitwise logic trees of shifts; NFC
Filipp Zhinkin [Tue, 9 Aug 2022 17:55:50 +0000 (20:55 +0300)]
[X86][ARM] Update tests for bitwise logic trees of shifts; NFC

Baseline tests for D131189.

2 years agoMove FormattersMatchCandidate flags to a struct.
Jorge Gorbe Moya [Tue, 9 Aug 2022 17:44:09 +0000 (10:44 -0700)]
Move FormattersMatchCandidate flags to a struct.

This removes some error-prone repetition in
FormatManager::GetPossibleMatches, where the same three boolean flags
are passed in a row multiple times as arguments to recursive calls to
GetPossibleMatches.

Instead of:
```
  // same flags, but with did_strip_typedef set to true.
  GetPossibleMatches(..., did_strip_ptr, did_strip_ref, true);
```
we can now say
```
  GetPossibleMatches(..., current_flags.WithStrippedTypedef());
```
which hopefully makes the intent clearer, and more readable in case we
add another flag.

Reviewed by: DavidSpickett, labath

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

2 years ago[docs][AArch64] Label Features with Arm ARM Names
Archibald Elliott [Mon, 8 Aug 2022 10:44:26 +0000 (11:44 +0100)]
[docs][AArch64] Label Features with Arm ARM Names

This patch adds the names of the Arm Architecture Reference Manual (ARM)
features to the corresponding Subtarget Features in the AArch64 backend
and target parser.

The aim of this is to make it clearer what architectural features a
subtarget feature might enable (so, which features a CPU must provide to
support that subtarget feature), and so make it easier to add new CPUs
in the future.

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

2 years agoLiveDebugValues: Fix another crash related to unreachable blocks
Adrian Prantl [Tue, 9 Aug 2022 17:34:57 +0000 (10:34 -0700)]
LiveDebugValues: Fix another crash related to unreachable blocks

This is a follow-up patch to D130999. In the test, the MIR contains an
unreachable MBB but the code attempts to look it up in MLocs. This
patch fixes this issue by checking for the default-constructed value.

rdar://97226240

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

2 years ago[InstCombine] fold usub.with.overflow to icmp when there's no use of the math value
Sanjay Patel [Tue, 9 Aug 2022 17:03:23 +0000 (13:03 -0400)]
[InstCombine] fold usub.with.overflow to icmp when there's no use of the math value

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

This is part of solving issue #56926.

2 years ago[RISCV] Pin a test to scalar lowering to preserve test intent [nfc]
Philip Reames [Tue, 9 Aug 2022 16:58:56 +0000 (09:58 -0700)]
[RISCV] Pin a test to scalar lowering to preserve test intent [nfc]

In an upcoming change to enable fixed length vector lowering via vector registers, the codepath exercised would change.  Pin this to the old lowering.

2 years ago[X86] Remove unnecessary _mm_undefined_pd() test from avx-intrinsics-fast-isel.ll
Simon Pilgrim [Tue, 9 Aug 2022 16:46:53 +0000 (17:46 +0100)]
[X86] Remove unnecessary _mm_undefined_pd() test from avx-intrinsics-fast-isel.ll

This is already in sse2-intrinsics-fast-isel.ll

Noticed in D104790

2 years ago[flang] Fix build warning from newer compilers
Peter Klausler [Tue, 9 Aug 2022 16:20:30 +0000 (09:20 -0700)]
[flang] Fix build warning from newer compilers

Remove a lambda capture of "[this]" in two cases where it
is no longer required.  Will be pushed without waiting for
review if CI is successful in order to resolve a sad build bot.

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

2 years ago[InstCombine] add helper function for extract of with-overflow-intrinsic; NFC
Sanjay Patel [Tue, 9 Aug 2022 16:37:47 +0000 (12:37 -0400)]
[InstCombine] add helper function for extract of with-overflow-intrinsic; NFC

We can do more with these patterns, so this block is going to grow.

2 years ago[PhaseOrdering][AArch64] add test for mul-with-overflow; NFC
Sanjay Patel [Mon, 8 Aug 2022 22:58:01 +0000 (18:58 -0400)]
[PhaseOrdering][AArch64] add test for mul-with-overflow; NFC

Reduced from issue #56403

2 years ago[llvm][ADT] Allow using structured bindings with `llvm::enumerate`
Markus Böck [Tue, 9 Aug 2022 16:07:50 +0000 (18:07 +0200)]
[llvm][ADT] Allow using structured bindings with `llvm::enumerate`

This patch adds the ability to deconstruct the `value_type` returned by `llvm::enumarate` into index and value of the wrapping range. Main use case is the common occurence of using it during loop iteration. After this patch it'd then be possible to write code such as:
```
for (auto [index, value] : enumerate(container)) {
   ...
}
```
where `index` is the current index and `value` a reference to elements in the given container.

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

2 years ago[flang] Intrinsic RANDOM_SEED calls with dynamically absent/present arguments
V Donaldson [Tue, 9 Aug 2022 02:51:15 +0000 (19:51 -0700)]
[flang] Intrinsic RANDOM_SEED calls with dynamically absent/present arguments

2 years ago[LLVM] Use range based for loop, NFC
Jun Zhang [Tue, 9 Aug 2022 15:59:05 +0000 (23:59 +0800)]
[LLVM] Use range based for loop, NFC

Signed-off-by: Jun Zhang <jun@junz.org>
2 years ago[IndVars] Eliminate redundant type cast with different sizes
zhongyunde [Tue, 9 Aug 2022 15:52:31 +0000 (23:52 +0800)]
[IndVars] Eliminate redundant type cast with different sizes

Deal with different sizes between the itofp and fptoi with
trunc or sext/zext, depend on D129756.
Fixes https://github.com/llvm/llvm-project/issues/55505.

Reviewed By: nikic

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

2 years ago[AArch64] Regenerate arm64-fmax.ll test. NFC
David Green [Tue, 9 Aug 2022 15:59:00 +0000 (16:59 +0100)]
[AArch64] Regenerate arm64-fmax.ll test. NFC

2 years ago[flang] Change names of specific procedures of generic interfaces in intrinsic modules
Peter Klausler [Wed, 3 Aug 2022 19:32:15 +0000 (12:32 -0700)]
[flang] Change names of specific procedures of generic interfaces in intrinsic modules

Intrinsic procedures in intrinsic modules that have (or better, *are*) generic interfaces
must not have specific procedures with the same name according to the Fortran
standard (17.11.1); i.e., a user program is allowed to define a procedure
of the same name as one of these generic interfaces, even when the generic is
in scope.

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

2 years ago[flang][runtime] Support internal I/O to CHARACTER(KIND/=1)
Peter Klausler [Wed, 3 Aug 2022 19:31:05 +0000 (12:31 -0700)]
[flang][runtime] Support internal I/O to CHARACTER(KIND/=1)

Allow internal I/O to support non-default kinds of CHARACTER.

The I/O runtime design anticipated this standard feature, but
this patch is somewhat larger than I thought it would be because
many code sites had to have assumptions about units (characters
vs. bytes) brought into harmony, and some encoding utilities
had to be pulled out of IoStatementState and templatized into
their own new header file so that they are available to formatted
output code without having to "thread" an IoStatementState reference
through many call chains.

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

2 years ago[flang] Don't check procedure pointer interface function result specification expressions
Peter Klausler [Thu, 28 Jul 2022 15:57:28 +0000 (08:57 -0700)]
[flang] Don't check procedure pointer interface function result specification expressions

When a procedure pointer references a function as its interface, don't
apply semantic checks to the specification expressions that appear in
the declaration of the function's result -- this can lead to bogus
error messages as those specification expressions are being examined
out of their proper context.

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

2 years ago[DAGCombine][NFC] Precommit extract-subvec-combine sext tests
Peter Waller [Tue, 9 Aug 2022 14:50:41 +0000 (14:50 +0000)]
[DAGCombine][NFC] Precommit extract-subvec-combine sext tests

2 years agoFix -Wbitfield-constant-conversion on 1-bit signed bitfield
Shawn Zhong [Tue, 9 Aug 2022 15:42:39 +0000 (11:42 -0400)]
Fix -Wbitfield-constant-conversion on 1-bit signed bitfield

A one-bit signed bit-field can only hold the values 0 and -1; this
corrects the diagnostic behavior accordingly.

Fixes #53253
Differential Revision: https://reviews.llvm.org/D131255

2 years ago[clang] fix deprecation
Thorsten Schütt [Tue, 9 Aug 2022 15:42:31 +0000 (17:42 +0200)]
[clang] fix deprecation

2 years ago[DAG] Avoid hasOneUse() calls if the cheaper !AssumeSingleUse test has already failed...
Simon Pilgrim [Tue, 9 Aug 2022 15:42:10 +0000 (16:42 +0100)]
[DAG] Avoid hasOneUse() calls if the cheaper !AssumeSingleUse test has already failed. NFC.

Very minor optimization, but every little helps..

2 years ago[lld-macho][test] Rename dtrace test (NFC)
Keith Smiley [Tue, 9 Aug 2022 00:52:18 +0000 (17:52 -0700)]
[lld-macho][test] Rename dtrace test (NFC)

This matches the convention used elsewhere

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

2 years agoChange prototype merging error into a warning for builtins
Aaron Ballman [Tue, 9 Aug 2022 15:35:37 +0000 (11:35 -0400)]
Change prototype merging error into a warning for builtins

As was observed in https://reviews.llvm.org/D123627#3707635, it's
confusing that a user can write:
```
float rintf(void) {}
```
and get a warning, but writing:
```
float rintf() {}
```
gives an error. This patch changes the behavior so that both are
warnings, so that users who have functions which conflict with a
builtin identifier can still use that identifier as they wish.

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

2 years ago[DAG] SimplifyDemandedVectorElts - and/mul(x,y) - if a demanded element of y is known...
Simon Pilgrim [Tue, 9 Aug 2022 15:23:36 +0000 (16:23 +0100)]
[DAG] SimplifyDemandedVectorElts - and/mul(x,y) - if a demanded element of y is known zero then we don't need to demand it in x

This fixes most of the remaining regressions from the fixes in rG293899c64b75

2 years ago[libc++][ranges] Sets ranges feature-test macro.
Mark de Wever [Sat, 6 Aug 2022 15:46:22 +0000 (17:46 +0200)]
[libc++][ranges] Sets ranges feature-test macro.

D131234 marked the ranges papers as complete, but it didn't set the
feature-test macro.

Reviewed By: ldionne, var-const, #libc

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

2 years ago[flang] Don't inherit ELEMENTAL attribute from intrinsics for TBP bindings
Peter Klausler [Wed, 27 Jul 2022 20:15:24 +0000 (13:15 -0700)]
[flang] Don't inherit ELEMENTAL attribute from intrinsics for TBP bindings

Type-bound procedure bindings that specify intrinsic procedures as their
interfaces should not acquire the ELEMENTAL attribute from the purposes
of compatibility checking between inherited bindings and their overrides
in extended derived types.

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

2 years agoExtend ptr32 support to be applied on typedef
Ariel Burton [Tue, 9 Aug 2022 15:06:51 +0000 (11:06 -0400)]
Extend ptr32 support to be applied on typedef

Earlier, if the QualType was sugared, then we would error out
as it was not a pointer type, for example,

typedef int *int_star;

int_star __ptr32 p;

Now, if ptr32 is given we apply it if the raw Canonical Type
(i.e., the desugared type) is a PointerType, instead of only
checking whether the sugared type is a pointer type.

As before, we still disallow ptr32 usage if the pointer is used
as a pointer to a member.

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

2 years ago[flang] Don't lose homonymous specific when copying generic
Peter Klausler [Wed, 3 Aug 2022 19:25:18 +0000 (12:25 -0700)]
[flang] Don't lose homonymous specific when copying generic

Defined generic procedure interfaces are allowed to shadow non-generic
procedures of the same name in the same scope (whether or not
that non-generic procedure is a specific procedure of the generic).
When making a copy of a generic interface symbol so that it can
be locally modified or be merged with another generic, don't forget
about the homonymous non-generic procedure that it might shadow.

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

2 years ago[flang] Ignore inaccessible components when extending types or constructing structures
Peter Klausler [Wed, 3 Aug 2022 19:24:09 +0000 (12:24 -0700)]
[flang] Ignore inaccessible components when extending types or constructing structures

Inaccessible components -- those declared PRIVATE in another module -- should
be allowed to be redeclared in extended types, and should be ignored if
they appear as keywords in structure constructors.

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

2 years ago[mlir][spirv] Clean up SPIRVOps.cpp. NFC.
Jakub Kuderski [Tue, 9 Aug 2022 14:40:16 +0000 (10:40 -0400)]
[mlir][spirv] Clean up SPIRVOps.cpp. NFC.

Resolve almost all clang tidy warnings in this file:
1. Clean up string constants.
2. Use consistent argument names across function declarations and definitions. Rename `state` - > `result`, which is consistent with the other dialects.
3. Remove misleading function parameter name comments (`argTypes`). This did not match the actual function argument (`bool enableNameShadowing`).
4. Simplify calls to `is_splat`.

Reviewed By: antiagainst

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

2 years ago[AMDGPU] Unify unreachable intrinsics
Yaxun (Sam) Liu [Thu, 4 Aug 2022 03:27:17 +0000 (23:27 -0400)]
[AMDGPU] Unify unreachable intrinsics

si-annotate-control-flow does depth first traversal of BB's of
a function to insert amdgcn if intrinsics for conditional
branches so that isel can generate correct instructions later.

si-annotate-control-flow checks whether the successor BB for the 'else'
branch of a conditional branch has been visited. If it has been
visited, si-annotate-control-flow assumes the conditional
branch has been handled and will not try to insert if intrinsic
for it.

This assumption is not correct when the IR contains multiple
unreachable BB's. Then 'if' intrinscs are not inserted and incorrect
ISA are generated.

This patch fixes the issue by let amdgpu-unify-divergent-exit-nodes
unify unreachables even if they are uniformly reached. In this way
the IR will not contain multiple exits, and structurizer is able to
structurize the IR containing one unified exit.

Reviewed by: Ruiling Song, Matt Arsenault

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

Fixes: SWDEV-343244

2 years ago[flang] Pass the pipeline config to the pass
Valentin Clement [Tue, 9 Aug 2022 14:05:15 +0000 (16:05 +0200)]
[flang] Pass the pipeline config to the pass

The newly added AlgebraicSimplification pass is triggering the
greedy pattern rewriter. Since we define a specific config in the
flang pipeline, this patch adds the ability to pass the config
to the pass directly.

Reviewed By: jeanPerier

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

2 years ago[RISCV] Add target feature to force-enable atomics
Nikita Popov [Wed, 27 Jul 2022 09:29:54 +0000 (11:29 +0200)]
[RISCV] Add target feature to force-enable atomics

This adds a +forced-atomics target feature with the same semantics
as +atomics-32 on ARM (D130480). For RISCV targets without the +a
extension, this forces LLVM to assume that lock-free atomics
(up to 32/64 bits for riscv32/64 respectively) are available.

This means that atomic load/store are lowered to a simple load/store
(and fence as necessary), as these are guaranteed to be atomic
(as long as they're aligned). Atomic RMW/CAS are lowered to __sync
(rather than __atomic) libcalls. Responsibility for providing the
__sync libcalls lies with the user (for privileged single-core code
they can be implemented by disabling interrupts). Code using
+forced-atomics and -forced-atomics are not ABI compatible if atomic
variables cross the ABI boundary.

For context, the difference between __sync and __atomic is that the
former are required to be lock-free, while the latter requires a
shared global lock provided by a shared object library. See
https://llvm.org/docs/Atomics.html#libcalls-atomic for a detailed
discussion on the topic.

This target feature will be used by Rust's riscv32i target family
to support the use of atomic load/store without atomic RMW/CAS.

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

2 years ago[AIX][tests] XFAIL atan.ll test on AIX
Jake Egan [Tue, 9 Aug 2022 13:57:33 +0000 (09:57 -0400)]
[AIX][tests] XFAIL atan.ll test on AIX

XFAIL this newly added test for now to get the AIX bot back to green.

2 years ago[X86] Regenerate statepoint-vreg.ll
Simon Pilgrim [Tue, 9 Aug 2022 13:43:09 +0000 (14:43 +0100)]
[X86] Regenerate statepoint-vreg.ll

Noticed on D131260

2 years ago[flang] Clarify CheckReductionDIM()
Peter Klausler [Wed, 3 Aug 2022 19:22:42 +0000 (12:22 -0700)]
[flang] Clarify CheckReductionDIM()

This utility routine in constant folding should return false when
a DIM= actual argument to a reduction intrinsic function has a
value that prevents folding, and true when folding can proceed.
The implementation was returning true in cases where a DIM=
argument was present but not constant.

Clarify the code and add commentary: a true result means that
there is no DIM= actual argument present, or that a DIM= argument
exists, is constant, and has a value that is in range.

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

2 years agoClang: fix AST representation of expanded template arguments.
Matheus Izvekov [Sat, 18 Jun 2022 02:21:59 +0000 (04:21 +0200)]
Clang: fix AST representation of expanded template arguments.

Extend clang's SubstTemplateTypeParm to represent the pack substitution index.

Fixes PR56099.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>
Differential Revision: https://reviews.llvm.org/D128113

2 years ago[LoongArch] Add codegen support for ISD::ROTL and ISD::ROTR
gonglingqin [Tue, 9 Aug 2022 11:19:39 +0000 (19:19 +0800)]
[LoongArch] Add codegen support for ISD::ROTL and ISD::ROTR

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

2 years ago[mlir] Use C++17 structured bindings instead of std::tie where applicable. NFCI
Benjamin Kramer [Tue, 9 Aug 2022 11:33:53 +0000 (13:33 +0200)]
[mlir] Use C++17 structured bindings instead of std::tie where applicable. NFCI

2 years ago[LoongArch] Support register-register-addressed GPR loads/stores
WANG Xuerui [Tue, 9 Aug 2022 11:04:15 +0000 (19:04 +0800)]
[LoongArch] Support register-register-addressed GPR loads/stores

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

2 years ago[AMDGPU][MC][GFX11][NFC] Rename tests
Dmitry Preobrazhensky [Tue, 9 Aug 2022 10:56:05 +0000 (13:56 +0300)]
[AMDGPU][MC][GFX11][NFC] Rename tests

Make test names more uniform.

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

2 years ago[openmp] Fix enumeration build issue for openmp library
Ron Lieberman [Tue, 9 Aug 2022 10:07:28 +0000 (10:07 +0000)]
[openmp] Fix enumeration build issue for openmp library

integer value 40962 is outside the valid range of values [0, 31] for this enumeration type [-Wenum-constexpr-conversion]` (Issue #57022)

turn on -Wno-enum-constexpr-conversion to buy some time to fix the more egregious issue in hsa_agent_into_t and hsa_amd_agent_info_t interfaces.

relates to https://reviews.llvm.org/D131307/new/

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

2 years ago[AMDGPU][MC][GFX11][NFC] Split large tests
Dmitry Preobrazhensky [Tue, 9 Aug 2022 10:12:59 +0000 (13:12 +0300)]
[AMDGPU][MC][GFX11][NFC] Split large tests

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

2 years ago[Sema] Merge variable template specializations
Ilya Biryukov [Tue, 9 Aug 2022 09:50:18 +0000 (11:50 +0200)]
[Sema] Merge variable template specializations

Clang used to produce redefinition errors, see tests for examples.

Reviewed By: ChuanqiXu

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

2 years ago[ARM] Use getSymbolPreferLocal() in GetARMGVSymbol
Alex Richardson [Tue, 9 Aug 2022 09:36:29 +0000 (09:36 +0000)]
[ARM] Use getSymbolPreferLocal() in GetARMGVSymbol

This allows relaxing some relocations to STT_SECTION symbol+offset
instead of emitting a relocation against a symbol.

Reviewed By: MaskRay

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

2 years ago[Thumb] Baseline test for incorrect relocation with -ffunction-sections
Alex Richardson [Tue, 9 Aug 2022 09:52:41 +0000 (09:52 +0000)]
[Thumb] Baseline test for incorrect relocation with -ffunction-sections

When calling a dso_local function, we end up creating a call against the
.Lfoo$local label. This might be converted to a relocation against a
section if there is such a matching one (which is a lot more likely with
-ffunction-sections) and then the LSB (Thumb flag) will be lost.

I originally noticed this with Morello LLVM (which uses the LSB to indicate
a C64 encoding mode function). The missing LSB meant that ld.lld would
insert a thunk that switches encoding mode which then resulted in errors
at runtime since functions were being entered with the wrong encoding mode.
Since the Morello backend is not upstream, I looked if any in-tree
backends could also be affected by the missing STT_FUNC flag and noticed
that Thumb is also affected (although the bug is rather difficult to
trigger - it currently requires inline assembly).

Reviewed By: MaskRay

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

2 years ago[ARM] Emit local aliases (.Lfoo$local) for functions
Alex Richardson [Tue, 9 Aug 2022 09:06:48 +0000 (09:06 +0000)]
[ARM] Emit local aliases (.Lfoo$local) for functions

ARMAsmPrinter::emitFunctionEntryLabel() was not calling the base class
function so the $local alias was not being emitted. This should not have
any function effect right now since ARM does not generate different code
for the $local symbols, but it could be improved in the future.

Reviewed By: MaskRay

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

2 years ago[ARM] Add a baseline test for D131392
Alex Richardson [Tue, 9 Aug 2022 09:17:28 +0000 (09:17 +0000)]
[ARM] Add a baseline test for D131392

We should be emitting .Lfoo$local aliases for dso_local functions.

2 years ago[ARM] Add a baseline elf-preemption test
Alex Richardson [Tue, 9 Aug 2022 09:04:47 +0000 (09:04 +0000)]
[ARM] Add a baseline elf-preemption test

This is based on the RISC-V elf-preemption.ll (converted to opaque
pointers) and is useful for test coverage for the patch series starting
with D131392.

2 years ago[Support] TaskQueue.h - replace std::result_of_t with std::invoke_result_t
Simon Pilgrim [Tue, 9 Aug 2022 09:52:39 +0000 (10:52 +0100)]
[Support] TaskQueue.h - replace std::result_of_t with std::invoke_result_t

std::result_of_t is deprecated in C++17

Fixes #57023

2 years ago[clang-pseudo] Forest.h - don't inherit from std::iterator
Simon Pilgrim [Tue, 9 Aug 2022 09:18:40 +0000 (10:18 +0100)]
[clang-pseudo] Forest.h - don't inherit from std::iterator

Now that we've updated to C++17 MSVC gives very verbose warnings about not creating classes that inherit from std::iterator - use llvm::iterator_facade_base instead

Fixes #57005

2 years ago[cmake] Fix ms-compat version in WinMsvc.cmake
Tobias Hieta [Tue, 9 Aug 2022 09:13:49 +0000 (11:13 +0200)]
[cmake] Fix ms-compat version in WinMsvc.cmake

As pointed out by @glandium here https://reviews.llvm.org/D130689#3709088
we updated the requirement of MSVC compatibility but not the flag passed when
using WinMsvc.cmake as a toolchain.

2 years ago[DAG] canCreateUndefOrPoison - add freeze(ctpop(x)) -> ctpop(freeze(x)) and freeze...
Simon Pilgrim [Tue, 9 Aug 2022 09:10:29 +0000 (10:10 +0100)]
[DAG] canCreateUndefOrPoison - add freeze(ctpop(x)) -> ctpop(freeze(x)) and freeze(parity(x)) -> parity(freeze(x)) support

Both are guaranteed not to create undef/poison

2 years agoFix MSVC "not all control paths return a value" warning. NFC.
Simon Pilgrim [Tue, 9 Aug 2022 08:55:35 +0000 (09:55 +0100)]
Fix MSVC "not all control paths return a value" warning. NFC.

2 years ago[mlir][OpenMP] omp.parallel side effects
Shraiysh Vaishay [Mon, 8 Aug 2022 15:18:55 +0000 (15:18 +0000)]
[mlir][OpenMP] omp.parallel side effects

Add `NoSideEffects` trait to omp.parallel operation.

Reviewed By: ftynse

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

2 years ago[RelLookupTableConverter] Bail on invalid pointer size (x32)
Nikita Popov [Mon, 8 Aug 2022 14:13:09 +0000 (16:13 +0200)]
[RelLookupTableConverter] Bail on invalid pointer size (x32)

The RelLookupTableConverter pass currently only supports 64-bit
pointers.  This is currently enforced using an isArch64Bit() check
on the target triple. However, we consider x32 to be a 64-bit target,
even though the pointers are 32-bit. (And independently of that
specific example, there may be address spaces with different pointer
sizes.)

As such, add an additional guard for the size of the pointers that
are actually part of the lookup table.

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

2 years ago[clang][ASTImporter] Improve import of functions with auto return type.
Balázs Kéri [Tue, 9 Aug 2022 06:40:09 +0000 (08:40 +0200)]
[clang][ASTImporter] Improve import of functions with auto return type.

ASTImporter used to crash in some cases when a function is imported with
`auto` return type and the return type has references into the function.
The handling of such cases is improved and crash should not occur any more
but it is not fully verified, there are very many different types of
cases to care for.

Reviewed By: martong

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

2 years agoLLVM_NODISCARD => [[nodiscard]]. NFC
Fangrui Song [Tue, 9 Aug 2022 07:16:34 +0000 (07:16 +0000)]
LLVM_NODISCARD => [[nodiscard]]. NFC

2 years ago[clang][clang-tools-extra] LLVM_NODISCARD => [[nodiscard]]. NFC
Fangrui Song [Tue, 9 Aug 2022 07:11:18 +0000 (07:11 +0000)]
[clang][clang-tools-extra] LLVM_NODISCARD => [[nodiscard]]. NFC

2 years ago[LoongArch] Add codegen support for not
gonglingqin [Tue, 9 Aug 2022 06:04:53 +0000 (14:04 +0800)]
[LoongArch] Add codegen support for not

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

2 years ago[LoongArch] Implement branch analysis
wanglei [Tue, 9 Aug 2022 05:53:34 +0000 (13:53 +0800)]
[LoongArch] Implement branch analysis

This allows a number of optimisation passes to work.
E.g. BranchFolding and MachineBlockPlacement.

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

2 years ago[LoongArch] Add codegen support for bswap
WANG Xuerui [Tue, 9 Aug 2022 05:41:03 +0000 (13:41 +0800)]
[LoongArch] Add codegen support for bswap

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

2 years ago[llvm] Don't rely on C++17 deduction guide for array creation
Jonas Devlieghere [Tue, 9 Aug 2022 05:11:23 +0000 (22:11 -0700)]
[llvm] Don't rely on C++17 deduction guide for array creation

Seems like at least one bot (clang-ppc64-aix) is having trouble with the
C++17 deduction guide for array creation. Specify the template arguments
explicitly.

2 years ago[globalisel] Select register bank for DBG_VALUE
Luo, Yuanke [Sat, 2 Jul 2022 08:18:43 +0000 (16:18 +0800)]
[globalisel] Select register bank for DBG_VALUE

The register operand of DBG_VALUE is not selected to a proper register
bank in both AArch64 and X86. This would cause getRegClass crash after
global ISel. After discussion, we think the MIR should assume all
vritual register should be set proper register class after global ISel,
so this patch is to fix the gap of DBG_VALUE for AArch64 and X86.

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

2 years ago[asan] Faster version of QuickCheckForUnpoisonedRegion
Vitaly Buka [Tue, 9 Aug 2022 04:38:55 +0000 (21:38 -0700)]
[asan] Faster version of QuickCheckForUnpoisonedRegion

Slightly helps with performance regression after D128146.

2 years ago[llvm] Alternative attempt at fixing the modules build with C++17
Jonas Devlieghere [Tue, 9 Aug 2022 04:56:16 +0000 (21:56 -0700)]
[llvm] Alternative attempt at fixing the modules build with C++17

My initial attempt in db008af50153 resulted in "error: no viable
constructor or deduction guide for deduction of template arguments of
'array'". Let's see if we can work around that by using an ArrayRef with
an explicit template argument.

2 years ago[Basic] Deprecate MapEntryOptionalStorage::{hasValue,getValue}
Kazu Hirata [Tue, 9 Aug 2022 04:33:09 +0000 (21:33 -0700)]
[Basic] Deprecate MapEntryOptionalStorage::{hasValue,getValue}

MapEntryOptionalStorage is an underlying storage class for
OptionalStorage<clang::DirectoryEntryRef>.

This patch deprecates:

  OptionalStorage<clang::DirectoryEntryRef>::hasValue
  OptionalStorage<clang::DirectoryEntryRef>::getValue

as there is no known users of these two methods.

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

2 years ago[NFC] fix warning
Chen Zheng [Tue, 9 Aug 2022 04:18:09 +0000 (00:18 -0400)]
[NFC] fix warning

2 years ago[MachinePipeliner] Fix Phi generation failure for large stages
Yuta Mukai [Tue, 9 Aug 2022 04:11:24 +0000 (13:11 +0900)]
[MachinePipeliner] Fix Phi generation failure for large stages

The previous code overwrites VRMap for prologue stages during Phi
generation if a register spans many stages.
As a result, the wrong register is used as the one coming from
the prologue in Phis at later stages. (A process exists to correct
this, but it does not work in all cases.)
In addition, VRMap for prologue must be preserved until addBranches().

This patch fixes them by separating the map for Phis into a different
variable (VRMapPhi).

Reviewed By: bcahoon

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

2 years agoLLVM_FALLTHROUGH => [[fallthrough]]. NFC
Fangrui Song [Tue, 9 Aug 2022 04:06:52 +0000 (04:06 +0000)]
LLVM_FALLTHROUGH => [[fallthrough]]. NFC

2 years ago[mlir] LLVM_FALLTHROUGH => [[fallthrough]]. NFC
Fangrui Song [Tue, 9 Aug 2022 03:56:05 +0000 (20:56 -0700)]
[mlir] LLVM_FALLTHROUGH => [[fallthrough]]. NFC

2 years ago[lldb] Refactor Symbols::DownloadObjectAndSymbolFile
Jonas Devlieghere [Tue, 9 Aug 2022 03:12:57 +0000 (20:12 -0700)]
[lldb] Refactor Symbols::DownloadObjectAndSymbolFile

 - Reduce indentation
 - Extract caching of the DbgShellCommand and the dsymForUUID executable
   (or equivalent)
 - Check the DBGShellCommands before falling back to
   /usr/local/bin/dsymForUUID
 - Don't check ~rc/bin/dsymForUUID
 - Improve error reporting
 - Don't cache the value of LLDB_APPLE_DSYMFORUUID_EXECUTABLE

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