platform/upstream/llvm.git
2 years agoReland "[llvm-pdbutil] Add options to only dump symbol record at specified offset...
Zequan Wu [Fri, 29 Apr 2022 23:38:56 +0000 (16:38 -0700)]
Reland "[llvm-pdbutil] Add options to only dump symbol record at specified offset and its parents or children with spcified depth."

This reverts commit cfb4e782520ce59602a34732386ebbdf58136cfb.

2 years ago[lldb] Fix an unused function warning
Kazu Hirata [Wed, 25 May 2022 16:49:05 +0000 (09:49 -0700)]
[lldb] Fix an unused function warning

This patch fixes:

  .../llvm-project/lldb/source/Host/common/PseudoTerminal.cpp:106:20:
  error: unused function 'use_ptsname' [-Werror,-Wunused-function]

2 years ago[mlir] Fix Tensor_InsertSliceOp description
Logan Chien [Tue, 24 May 2022 01:04:30 +0000 (18:04 -0700)]
[mlir] Fix Tensor_InsertSliceOp description

This commit fixes `Tensor_InsertSliceOp` `sizes` inputs/attributes
description.

Before this commit, the description says the `sizes` inputs/attributes
denote the size of the return type. But according to the
`InsertSliceOpConstantArgumentFolder` in
`lib/Dialect/Tensor/IR/TensorOps.cpp`, the `sizes` inputs/attributes
actually denote the size of the source type.

I had an off-line discussion with the authors of `TensorOps.td` and
`TensorOps.cpp`. We concluded that it was a typo in the Op description.

This commit updates the Op description to match the actual usage.

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

2 years agoAMDGPU/GISel: Factor out AMDGPURegisterBankInfo::buildReadFirstLane
Nicolai Hähnle [Tue, 10 May 2022 15:10:36 +0000 (10:10 -0500)]
AMDGPU/GISel: Factor out AMDGPURegisterBankInfo::buildReadFirstLane

A later change will add a 3rd user, so factoring out the common code
seems useful.

Reorganizing the executeInWaterfallLoop causes some more COPYs to be
generated, but those all fold away during instruction selection.
Generating the comparisons uses generic instructions over machine
instructions now which admittedly shouldn't make a difference
(though it should make it easier to move the waterfall loop generation
to another place).

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

2 years agoAllow pointer types for atomicrmw xchg
Takafumi Arakaki [Wed, 25 May 2022 16:12:11 +0000 (16:12 +0000)]
Allow pointer types for atomicrmw xchg

This adds support for pointer types for `atomic xchg` and let us write
instructions such as `atomicrmw xchg i64** %0, i64* %1 seq_cst`. This
is similar to the patch for allowing atomicrmw xchg on floating point
types: https://reviews.llvm.org/D52416.

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

2 years ago[RISCV] Preserve fast math flags in lowerVPOp.
Craig Topper [Wed, 25 May 2022 16:16:07 +0000 (09:16 -0700)]
[RISCV] Preserve fast math flags in lowerVPOp.

Update test to check MIR after finalize-isel instead of debug output.

This is of course not the only place we should preserve FMF, but
it's the most obvious one.

Reviewed By: frasercrmck

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

2 years ago[X86] Add isSimple check to the load combine in combineExtractVectorElt.
Craig Topper [Wed, 25 May 2022 16:11:11 +0000 (09:11 -0700)]
[X86] Add isSimple check to the load combine in combineExtractVectorElt.

I think we need to be sure the load isn't volatile before we
duplicate and shrink it.

Reviewed By: spatel

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

2 years ago[llvm-objcopy][ObjectYAML][mips] Add MIPS specific ELF section indexes
Anubhab Ghosh [Wed, 25 May 2022 16:01:12 +0000 (09:01 -0700)]
[llvm-objcopy][ObjectYAML][mips] Add MIPS specific ELF section indexes

This fixes https://github.com/llvm/llvm-project/issues/53998
and displays correct information in obj2yaml for SHN_MIPS_*
sections according to
https://refspecs.linuxfoundation.org/elf/mipsabi.pdf

Reviewed By: jhenderson, MaskRay

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

2 years ago[clang] Don't parse MS attributes in `ParseExportDeclaration()`.
Martin Boehme [Fri, 20 May 2022 12:04:44 +0000 (14:04 +0200)]
[clang] Don't parse MS attributes in `ParseExportDeclaration()`.

As @rsmith commented on https://reviews.llvm.org/D111548: "That looks like it's
simply a bug as far as I can tell, and that call can be removed. MS attributes
will be parsed as part of the decl specifier sequence as needed and don't need
to be parsed as declaration attributes."

Reviewed By: aaron.ballman

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

2 years ago[RISCV] Hoist VSETVLI vlmax, vtype out of scalable loops
Philip Reames [Wed, 25 May 2022 15:00:27 +0000 (08:00 -0700)]
[RISCV] Hoist VSETVLI vlmax, vtype out of scalable loops

This is a straight forward extension of the PRE transform introduced in D124869 to handle the VLMAX case.

The test changes here look quite positive. This surprised me until I realized that all the tests are using @llvm.vscale to figure out the VLMAX, not the llvm.riscv.vsetvlmax intrinsic. If they'd used the later, these would have been full redundancy cases and fully handled by the data flow. I'm not really sure if use of vscale here is representative or not. If it is, we should probably look at using VSETVLI to lower vscale rather than a raw read of vlenb and some math.

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

2 years ago[RISCV] Restructure comment and add clarifying assert to getFrameIndexReference ...
Philip Reames [Wed, 25 May 2022 14:58:11 +0000 (07:58 -0700)]
[RISCV] Restructure comment and add clarifying assert to getFrameIndexReference [NFC]

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

2 years ago[mlir][spirv] Fix capability check for 64-bit element types
Lei Zhang [Wed, 25 May 2022 14:53:35 +0000 (10:53 -0400)]
[mlir][spirv] Fix capability check for 64-bit element types

Using 64-bit integer/float type in interface storage classes would
require Int64/Float64 capability, per the Vulkan spec:

```
shaderInt64 specifies whether 64-bit integers (signed and unsigned) are
supported in shader code. If this feature is not enabled, 64-bit integer
types must not be used in shader code. This also specifies whether
shader modules can declare the Int64 capability. Declaring and using
64-bit integers is enabled for all storage classes that SPIR-V allows
with the Int64 capability.
```

This is different from, say, 16-bit element types, where:

```
shaderInt16 specifies whether 16-bit integers (signed and unsigned) are
supported in shader code. If this feature is not enabled, 16-bit integer
types must not be used in shader code. This also specifies whether
shader modules can declare the Int16 capability. However, this only
enables a subset of the storage classes that SPIR-V allows for the Int16
SPIR-V capability: Declaring and using 16-bit integers in the Private,
Workgroup (for non-Block variables), and Function storage classes is
enabled, while declaring them in the interface storage classes (e.g.,
UniformConstant, Uniform, StorageBuffer, Input, Output, and
PushConstant) is not enabled.
```

Reviewed By: hanchung

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

2 years ago[mlir][scf] Retain existing attributes in scf.for transforms
Lei Zhang [Wed, 25 May 2022 14:45:26 +0000 (10:45 -0400)]
[mlir][scf] Retain existing attributes in scf.for transforms

These attributes can carry useful information, e.g., pipelines
might use them to organize and chain patterns.

Reviewed By: hanchung

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

2 years ago[libc++][test] Verify std::ranges::rbegin, crbegin, rend, crend are CPOs
Joe Loser [Tue, 24 May 2022 20:40:08 +0000 (14:40 -0600)]
[libc++][test] Verify std::ranges::rbegin, crbegin, rend, crend are CPOs

Uncomment the tests to ensure `std::ranges::rbegin` and friends are indeed
customization points objects.

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

2 years ago[riscv] Add coverage for fixed length vector loops using LMUL
Philip Reames [Wed, 25 May 2022 14:41:45 +0000 (07:41 -0700)]
[riscv] Add coverage for fixed length vector loops using LMUL

2 years ago[TableGen] Undeprecate 'field' when used with the CodeEmitterGen backend.
Ivan Kosarev [Wed, 25 May 2022 14:15:06 +0000 (15:15 +0100)]
[TableGen] Undeprecate 'field' when used with the CodeEmitterGen backend.

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

2 years ago[llvm-rc] Avoid which(1) dependency in windres-prefix.test
Michał Górny [Wed, 25 May 2022 11:04:44 +0000 (13:04 +0200)]
[llvm-rc] Avoid which(1) dependency in windres-prefix.test

Rely on lit substitution to provide the path to llvm-windres instead
of redundantly calling which(1) with the subtituted absolute path.
This fixes test failure on the happy systems without which(1) installed.

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

2 years ago[MLIR][Presburger] Add inverse to IntegerRelation
Groverkss [Wed, 25 May 2022 14:06:35 +0000 (19:36 +0530)]
[MLIR][Presburger] Add inverse to IntegerRelation

This patch adds support for obtaining inverse of a relation.

Reviewed By: ftynse

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

2 years ago[PhaseOrdering] Add test for unprofitable loop load PRE backedge splitting (NFC)
Nikita Popov [Wed, 25 May 2022 14:05:11 +0000 (16:05 +0200)]
[PhaseOrdering] Add test for unprofitable loop load PRE backedge splitting (NFC)

2 years ago[MLIR][Presburger] Add getDomainSet, getRangeSet to IntegerRelation
Groverkss [Wed, 25 May 2022 14:02:21 +0000 (19:32 +0530)]
[MLIR][Presburger] Add getDomainSet, getRangeSet to IntegerRelation

This patch adds support for obtaining a set corresponding to the domain/range
of the relation.

Reviewed By: ftynse

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

2 years ago[libc++] Remove conditional include
Louis Dionne [Wed, 25 May 2022 14:04:47 +0000 (10:04 -0400)]
[libc++] Remove conditional include

2 years ago[VP][fix] Don't discard masks in reductions
Simon Moll [Wed, 25 May 2022 13:08:31 +0000 (15:08 +0200)]
[VP][fix] Don't discard masks in reductions

When expanding VP reductions to non VP-code, the reduction pass was
ignoring the mask before. Fix this by keeping the mask and selecting
neutral elements where the mask is zero.

Reviewed By: frasercrmck

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

2 years ago[PS5] Default to -fno-rtti
Paul Robinson [Wed, 25 May 2022 13:46:12 +0000 (06:46 -0700)]
[PS5] Default to -fno-rtti

2 years ago[libc++] Use Python subprocess instead of libc++'s own utilities
Louis Dionne [Tue, 24 May 2022 15:14:23 +0000 (11:14 -0400)]
[libc++] Use Python subprocess instead of libc++'s own utilities

Once we move off entirely from the legacy testing framework, this will
allow removing a bunch of code.

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

2 years agoFix unused-variable warning, NFC.
Haojian Wu [Wed, 25 May 2022 13:25:03 +0000 (15:25 +0200)]
Fix unused-variable warning, NFC.

2 years ago[AST] Dont invalidate a ref-type var decl if it has no initializer.
Haojian Wu [Wed, 25 May 2022 12:58:28 +0000 (14:58 +0200)]
[AST] Dont invalidate a ref-type var decl if it has no initializer.

This would allow more AST nodes being preserved for broken code, and
have a more consistent valid bit for ref-type var decl (currently, a
ref-type var decl with a broken initializer is valid).

Per https://reviews.llvm.org/D76831#1973053, the initializer of a variable
should play no part in its "invalid" bit.

Reviewed By: sammccall

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

2 years ago[pseudo-gen] Add -o flag, make --grammar required
Nico Weber [Wed, 25 May 2022 12:45:41 +0000 (08:45 -0400)]
[pseudo-gen] Add -o flag, make --grammar required

Virtually all LLVM tools accept a `-o` flag, so add one. This will make it
possible to possibly add a --write-if-changed flag later. It also makes it
so that the file isn't partially written if the tool oesn't run successfully.

Marking --grammar as `Required` allows removing some manual
verification code for it.

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

2 years ago[MLIR][NFC] Fix the Conversion/MemRefToSPIRV/alloc.mlir test.
Ivan Kosarev [Wed, 25 May 2022 12:57:52 +0000 (13:57 +0100)]
[MLIR][NFC] Fix the Conversion/MemRefToSPIRV/alloc.mlir test.

Caught with D125604.

Reviewed By: antiagainst

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

2 years ago[tests] precommit tests for D126040
zhongyunde [Wed, 25 May 2022 12:37:32 +0000 (20:37 +0800)]
[tests] precommit tests for D126040

Reviewed By: spatel

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

2 years ago[lld-macho] Support -non_global_symbols_strip_list, -non_global_symbols_no_strip_lis...
Vy Nguyen [Fri, 20 May 2022 07:45:26 +0000 (14:45 +0700)]
[lld-macho] Support  -non_global_symbols_strip_list, -non_global_symbols_no_strip_list, -x

PR/55600

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

2 years ago[x86] add test with volatile load; NFC
Sanjay Patel [Wed, 25 May 2022 12:13:43 +0000 (08:13 -0400)]
[x86] add test with volatile load; NFC

Test for D126353

2 years agoTest C DR conformance (part three of many)
Aaron Ballman [Wed, 25 May 2022 12:17:10 +0000 (08:17 -0400)]
Test C DR conformance (part three of many)

This adds more of the tests for the first 100 DRs in C and updates
their status on the status page.

2 years ago[clang-tidy] Update docs for SimplifyDeMorganRelaxed
Nathan James [Wed, 25 May 2022 12:12:20 +0000 (13:12 +0100)]
[clang-tidy] Update docs for SimplifyDeMorganRelaxed

Forgot to add this to f3c1d281767

2 years ago[clang-tidy] Extend SimplifyBooleanExpr demorgan support.
Nathan James [Wed, 25 May 2022 12:09:00 +0000 (13:09 +0100)]
[clang-tidy] Extend SimplifyBooleanExpr demorgan support.

Adds an option SimplifyDemorganRelaxed which, when enabled, will transform negated conjunctions or disjunctions when neither operand is a negation.
Default value is `false`.

Reviewed By: LegalizeAdulthood

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

2 years ago[MLIR][Linalg] Adjust documentation (NFC)
lorenzo chelini [Wed, 25 May 2022 10:59:20 +0000 (12:59 +0200)]
[MLIR][Linalg] Adjust documentation (NFC)

Adjust docs for tensor.pad, tensor.collapse_shape and tensor.expand_shape.

Reviewed By: ftynse

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

2 years ago[mlir][openmp] Add check for types of operands in omp.atomic.write
Shraiysh Vaishay [Wed, 25 May 2022 11:49:09 +0000 (17:19 +0530)]
[mlir][openmp] Add check for types of operands in omp.atomic.write

This patch makes sure that the address dereferences to value in
omp.atomic.write operation.

Reviewed By: kiranchandramohan, peixin

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

2 years ago[gn build] (manually) port some of cd2292ef8245
Nico Weber [Wed, 25 May 2022 11:16:50 +0000 (07:16 -0400)]
[gn build] (manually) port some of cd2292ef8245

2 years ago[ARM] Fix vcvtb/t.f16 input liveness
David Green [Wed, 25 May 2022 11:16:26 +0000 (12:16 +0100)]
[ARM] Fix vcvtb/t.f16 input liveness

The `vcvtb.f16.f32 Sd, Sn` (and vcvtt.f16.f32) instruction convert a f32
into a f16, writing either the top or bottom halves of the register.
That means that half of the input register Sd is used in the output.
This wasn't being modelled in the instructions, leading later analyses
to believe that the registers were dead where they were not, generating
invalid scheduling

Fix that be specifying the input Sda register for the instructions too,
allowing them to be set for cases like vector inserts. Most of the
changes are plumbing through the constraint string, cstr.

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

2 years ago[Clang] Added options for integrated backend.
Anastasia Stulova [Wed, 25 May 2022 11:01:42 +0000 (12:01 +0100)]
[Clang] Added options for integrated backend.

Following the new flow for external object code emission,
provide flags to switch between integrated and external
backend similar to the integrated assembler options.

SPIR-V target is the only user of this functionality at
this point.

This patch also updated SPIR-V documentation to clarify
that integrated object code emission for SPIR-V is an
experimental feature.

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

2 years ago[LoopVectorize] Fix assertion failure in fixReduction when tail-folding
David Sherwood [Tue, 24 May 2022 12:24:20 +0000 (13:24 +0100)]
[LoopVectorize] Fix assertion failure in fixReduction when tail-folding

When compiling the attached new test in scalable-reductions-tf.ll we
were hitting this assertion in fixReduction:

  Assertion `isa<PHINode>(U) && "Reduction exit must feed Phi's or select"

The loop contains a reduction and an intermediate store of the reduction
value. When vectorising with tail-folding the contains of 'U' in the
assertion above happened to be a scatter_store. It turns out that we
were still creating a widen recipe for the invariant store, despite
knowing that we can actually sink it. The simplest fix is to change
buildVPlanWithVPRecipes so that we look for invariant stores before
attempting to widen it.

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

2 years ago[pseudo] Add missing dependency, fix shared library build.
Haojian Wu [Wed, 25 May 2022 10:38:23 +0000 (12:38 +0200)]
[pseudo] Add missing dependency, fix shared library build.

2 years ago[VPlan] Exit earlier when trying to widen with scalar VFs.
Florian Hahn [Wed, 25 May 2022 10:05:23 +0000 (11:05 +0100)]
[VPlan] Exit earlier when trying to widen with scalar VFs.

This simplifies the code a bit, suggested in D124718.

Reviewed By: Ayal

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

2 years ago[pseudo] A basic implementation of compiling cxx grammar at build time.
Haojian Wu [Tue, 24 May 2022 18:21:45 +0000 (20:21 +0200)]
[pseudo] A basic implementation of compiling cxx grammar at build time.

The main idea is to compile the cxx grammar at build time, and construct
the core pieces (Grammar, LRTable) of the pseudoparse based on the compiled
data sources.

This is a tiny implementation, which is good for start:

- defines how the public API should look like;
- integrates the cxx grammar compilation workflow with the cmake system.
- onlynonterminal symbols of the C++ grammar are compiled, anything
  else are still doing the real compilation work at runtime, we can opt-in more
  bits in the future;
- splits the monolithic clangPsuedo library for better layering;

Reviewed By: sammccall

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

2 years ago[mlir] Fix warning `missing base in copy ctor`
Javed Absar [Mon, 23 May 2022 13:48:57 +0000 (14:48 +0100)]
[mlir] Fix warning `missing base in copy ctor`

This suppresse annoying warning when building mlir.
```
 warning: base class ‘class mlir::PassWrapper<{anonymous}::TestStatisticPass,
  mlir::OperationPass<void> >’ should be explicitly initialized in the copy constructor [-Wextra]
```

Reviewed By: rriddle

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

2 years ago[XCORE][CodeGen][NFC] Revert: Use ArrayRef in TargetLowering functions
Nigel Perks [Wed, 25 May 2022 09:09:59 +0000 (10:09 +0100)]
[XCORE][CodeGen][NFC] Revert: Use ArrayRef in TargetLowering functions

Revert 6365bde6585651b7813010dc63df7984a5b8ad41

Restore more readable version in line with other targets,
which did not apply the change.

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

2 years ago[OpenCL] Remove argument names from async copy builtins
Sven van Haastregt [Wed, 25 May 2022 09:05:25 +0000 (10:05 +0100)]
[OpenCL] Remove argument names from async copy builtins

This simplifies completeness comparisons against OpenCLBuiltins.td and
also makes the header no longer "claim" the argument name identifiers.

Continues the direction set out in D119560.

2 years ago[analyzer] Fix symbol simplification assertion failure
Gabor Marton [Tue, 24 May 2022 08:01:18 +0000 (10:01 +0200)]
[analyzer] Fix symbol simplification assertion failure

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

The assertion mentioned in the issue is triggered because an
inconsistency is formed in the Sym->Class and Class->Sym relations. A
simpler but similar inconsistency is demonstrated here:
https://reviews.llvm.org/D114887 .

Previously in `removeMember`, we didn't remove the old symbol's
Sym->Class relation. Back then, we explained it with the following two
bullet points:
> 1) This way constraints for the old symbol can still be found via it's
> equivalence class that it used to be the member of.
> 2) Performance and resource reasons. We can spare one removal and thus one
> additional tree in the forest of `ClassMap`.

This patch do remove the old symbol's Sym->Class relation in order to
keep the Sym->Class relation consistent with the Class->Sym relations.
Point 2) above has negligible performance impact, empirical measurements
do not show any noticeable difference in the run-time. Point 1) above
seems to be a not well justified statement. This is because we cannot
create a new symbol that would be equal to the old symbol after the
simplification had happened. The reason for this is that the SValBuilder
uses the available constant constraints for each sub-symbol.

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

2 years ago[gn build] Port 7af89a379cce
LLVM GN Syncbot [Wed, 25 May 2022 08:31:45 +0000 (08:31 +0000)]
[gn build] Port 7af89a379cce

2 years ago[gn build] Port 29a5a7c6d47a
LLVM GN Syncbot [Wed, 25 May 2022 08:31:44 +0000 (08:31 +0000)]
[gn build] Port 29a5a7c6d47a

2 years ago[VPlan] Use MapVector for LiveOuts for deterministic iteration.
Florian Hahn [Wed, 25 May 2022 08:29:52 +0000 (09:29 +0100)]
[VPlan] Use MapVector for LiveOuts for deterministic iteration.

During code-gen, we iterate over the LiveOuts and the differences in
iteration order can cause slightly different outputs.

2 years ago[libc++] Implement ranges::fill{, _n}
Nikolas Klauser [Sat, 21 May 2022 16:26:29 +0000 (18:26 +0200)]
[libc++] Implement ranges::fill{, _n}

Reviewed By: var-const, #libc

Spies: libcxx-commits, mgorny

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

2 years ago[RISCV] Add pre-emit pass to make more instructions compressible
Lewis Revill [Mon, 25 Apr 2022 11:24:09 +0000 (12:24 +0100)]
[RISCV] Add pre-emit pass to make more instructions compressible

When optimizing for size, this pass searches for instructions that are
prevented from being compressed by one of the following:

1. The use of a single uncompressed register.
2. A base register + offset where the offset is too large to be
   compressed and the base register may or may not already be compressed.

In the first case, if there is a compressed register available, then the
uncompressed register is copied to the compressed register and its uses
replaced. This is only done if there are enough uses that code size
would be improved.

In the second case, if a compressed register is available, then the
original base register is copied and adjusted such that:

new_base_register = base_register + adjustment
base_register + large_offset = new_base_register + small_offset

and the uses of the base register are replaced with the new base
register. Again this is only done if there are enough uses for code size
to be improved.

This pass was authored by Lewis Revill, with large offset optimization
added by Craig Blackmore.

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

2 years ago[mlir] Add `complex.atan2` operation.
Alexander Belyaev [Wed, 25 May 2022 07:58:00 +0000 (09:58 +0200)]
[mlir] Add `complex.atan2` operation.

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

2 years ago[ValueTracking] Loads with !dereferenceable metadata cannot be undef/poison
Nikita Popov [Tue, 24 May 2022 13:20:01 +0000 (15:20 +0200)]
[ValueTracking] Loads with !dereferenceable metadata cannot be undef/poison

A load with !dereferenceable or !dereferenceable_or_null metadata
must return a well-defined (non-undef/poison) value. Effectively
they imply !noundef. This is the same as we do for the
dereferenceable(N) attribute.

This should fix https://github.com/llvm/llvm-project/issues/55672,
or at least the specific case discussed there.

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

2 years ago[libc++] Make sure that all headers can be included with modules enabled
Louis Dionne [Tue, 10 May 2022 19:27:52 +0000 (15:27 -0400)]
[libc++] Make sure that all headers can be included with modules enabled

This commit ensures that we can include all libc++ headers with modules
enabled. It adds a test to ensure that this doesn't regress, which is
necessary because our modules CI job does not build in all Standard modes.

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

2 years agoFix warning by handling OMPC_fail in switch statement.
Adrian Kuegel [Wed, 25 May 2022 07:33:41 +0000 (09:33 +0200)]
Fix warning by handling OMPC_fail in switch statement.

2 years ago[Clang][OpenMP] Support for omp nothing
Sunil Kuravinakop [Wed, 25 May 2022 04:59:19 +0000 (23:59 -0500)]
[Clang][OpenMP] Support for omp nothing

Patch to support "#pragma omp nothing"

Reviewed By: tianshilei1992

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

2 years ago[OpenMP] atomic compare fail : Parser & AST support
Sunil Kuravinakop [Wed, 25 May 2022 04:55:08 +0000 (23:55 -0500)]
[OpenMP] atomic compare fail : Parser & AST support

This is a support for " #pragma omp atomic compare fail ". It has Parser & AST support for now.

Reviewed By: tianshilei1992

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

2 years ago[RISCV] Fix vnsrl/vnsra isel patterns that are dropping VL.
Craig Topper [Wed, 25 May 2022 02:10:40 +0000 (19:10 -0700)]
[RISCV] Fix vnsrl/vnsra isel patterns that are dropping VL.

We were incorrectly using VLMax instead of the passed VL.

Reviewed By: khchen, reames

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

2 years ago[flang][MSVC] Fix building with `/permissive-` flag
Mehdi Chinoune [Mon, 23 May 2022 21:25:41 +0000 (16:25 -0500)]
[flang][MSVC] Fix building with `/permissive-` flag

CLOCK_REALTIME is POSIX defined and never available with MSVC, even without /permissive-.
The difference is that the template is never instantiated and the compiler ignores the undefined identifier.

Reviewed By: Meinersbur

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

2 years ago[RISCV] Replace untested code with assert
Fraser Cormack [Tue, 24 May 2022 06:20:55 +0000 (07:20 +0100)]
[RISCV] Replace untested code with assert

We found untested code where negative frame indices were ostensibly
handled despite it being in a block guarded by !MFI.isFixedObjectIndex.

While the implementation of MachineFrameInfo::isFixedObjectIndex
suggests this is possible (i.e., if a frame index was more negative - less than the
number of fixed objects), I couldn't find any test in tree -- for any
target -- where a negative frame index wasn't also a fixed object
offset. I couldn't find a way of creating such a object with the
public MachineFrameInfo creation APIs. Even
MachineFrameInfo::getObjectIndexBegin starts counting at the negative
number of fixed objects, so such frame indices wouldn't be covered by
loops using the provided begin/end methods.

Given all this, an assert that any object encountered in the block is
non-negative seems reasonable.

Reviewed By: StephenFan, kito-cheng

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

2 years agoMove GCC-compatible pod-packing change to v15/old behavior available at v14 and below
David Blaikie [Tue, 24 May 2022 22:14:56 +0000 (22:14 +0000)]
Move GCC-compatible pod-packing change to v15/old behavior available at v14 and below

Since this didn't make it into the v14 release - anyone requesting the
v14 ABI shouldn't get this GCC-compatible change that isn't backwards
compatible with v14 Clang.

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

2 years ago[libc++][NFC] Add more tests to `move_{iterator,sentinel}`.
Konstantin Varlamov [Wed, 25 May 2022 02:56:02 +0000 (19:56 -0700)]
[libc++][NFC] Add more tests to `move_{iterator,sentinel}`.

More test coverage for the parts added by the One Ranges Proposal.

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

2 years agoRevert "[MachineSink] replace MachineLoop with MachineCycle"
Chen Zheng [Wed, 25 May 2022 02:43:37 +0000 (22:43 -0400)]
Revert "[MachineSink] replace MachineLoop with MachineCycle"

This reverts commit 62a9b36fcf728b104ea87e6eb84c0be69b779df7.
Cause build failure on lldb incremental buildbot:
https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/43994/changes

2 years ago[C++20] [Coroutines] Conform the updates for CWG issue 2585
Chuanqi Xu [Wed, 25 May 2022 02:30:32 +0000 (10:30 +0800)]
[C++20] [Coroutines] Conform the updates for CWG issue 2585

According to the updates in CWG issue 2585
https://cplusplus.github.io/CWG/issues/2585.html, we shouldn't find an
allocation function with (size, p0, …, pn) in global scope.

Reviewed By: erichkeane

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

2 years ago[InstCombine] [NFC] Move transforms for truncated shifts into narrowBinOp
Chenbing Zheng [Wed, 25 May 2022 02:21:39 +0000 (10:21 +0800)]
[InstCombine] [NFC] Move transforms for truncated shifts into narrowBinOp

Reviewed By: spatel

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

2 years ago[InstCombine] add test for trunc-shl-trunc ; NFC
Chenbing Zheng [Wed, 25 May 2022 02:09:58 +0000 (10:09 +0800)]
[InstCombine] add test for trunc-shl-trunc ; NFC

2 years ago[clang-format][NFC] Insert/remove braces in clang/lib/Format/
owenca [Sun, 22 May 2022 04:51:19 +0000 (21:51 -0700)]
[clang-format][NFC] Insert/remove braces in clang/lib/Format/

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

2 years ago[BOLT][NFC] Use ListSeparator in BinaryFunction print methods
Amir Ayupov [Wed, 25 May 2022 01:28:42 +0000 (18:28 -0700)]
[BOLT][NFC] Use ListSeparator in BinaryFunction print methods

Reviewed By: rafauler

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

2 years ago[BOLT][NFC] Customize endline character for printInstruction(s)
Amir Ayupov [Wed, 25 May 2022 01:25:40 +0000 (18:25 -0700)]
[BOLT][NFC] Customize endline character for printInstruction(s)

This would be used in `BF::dumpGraph` to dump left-justified text.

Reviewed By: rafauler

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

2 years ago[BOLT][NFC] Use for_each to simplify printLoopInfo
Amir Ayupov [Wed, 25 May 2022 01:04:42 +0000 (18:04 -0700)]
[BOLT][NFC] Use for_each to simplify printLoopInfo

Reviewed By: rafauler

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

2 years ago[BOLT][NFC] Remove unused BF::computeLocalUDChain method definition
Amir Ayupov [Wed, 25 May 2022 01:01:20 +0000 (18:01 -0700)]
[BOLT][NFC] Remove unused BF::computeLocalUDChain method definition

The function is only used inside AArch64MCPlusBuilder class, there are no uses
of it as a BinaryFunction method.

Reviewed By: rafauler

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

2 years ago[lldb] Improve TestAppleSimulatorOSType.py error message
Jonas Devlieghere [Wed, 25 May 2022 00:17:26 +0000 (17:17 -0700)]
[lldb] Improve TestAppleSimulatorOSType.py error message

This was inspired by D109336 which got reverted because we didn't want
the test to fail silently. This patch prints a more informative error
message when we fail to parse the simctl output while still failing the
test.

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

2 years ago[lldb] Disable modules in Apple-lldb-base
Jonas Devlieghere [Wed, 25 May 2022 00:07:36 +0000 (17:07 -0700)]
[lldb] Disable modules in Apple-lldb-base

The LLDB website recommends using the CMake caches to build on macOS.
Although modules result in a faster build, this configuration tends to
break occasionally because it's specific to our platform. I don't expect
newcomers to be able to deal with those kind of breakages so don't
enable them by default.

2 years ago[clang-tidy] Fix #55134 (regression introduced by 5da7c04)
Salman Javed [Tue, 24 May 2022 22:15:12 +0000 (10:15 +1200)]
[clang-tidy] Fix #55134 (regression introduced by 5da7c04)

5da7c04 introduced a regression in the NOLINT macro checking loop, replacing the
call to `getImmediateExpansionRange().getBegin()` with
`getImmediateMacroCallerLoc()`, which has similar but subtly different
behaviour.

The consequence is that NOLINTs cannot suppress diagnostics when they are
attached to a token that came from a macro **argument**, rather than elsewhere
in the macro expansion.

Revert to pre-patch behaviour and add test cases to cover this issue.

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

2 years ago[DFSan] Add option to specify individual library files, and an option to exit with...
Andrew Browne [Tue, 24 May 2022 21:42:41 +0000 (14:42 -0700)]
[DFSan] Add option to specify individual library files, and an option to exit with an error code if any library file was not found.

Reviewed By: vitalybuka

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

2 years ago[LLVM][IR] Fix assert in ConstantExpr::getPtrToInt so all vector types are supported.
Paul Walker [Tue, 24 May 2022 22:49:59 +0000 (23:49 +0100)]
[LLVM][IR] Fix assert in ConstantExpr::getPtrToInt so all vector types are supported.

Fixes: #55410

2 years ago[mlir][sparse] complex lowering
Aart Bik [Tue, 24 May 2022 22:17:39 +0000 (15:17 -0700)]
[mlir][sparse] complex lowering

Reviewed By: bixia

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

2 years ago[InstCombine] Fold memrchr calls with sequences of identical bytes.
Martin Sebor [Tue, 24 May 2022 23:00:11 +0000 (17:00 -0600)]
[InstCombine] Fold memrchr calls with sequences of identical bytes.

Reviewed By: nikic

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

2 years ago[libc] Add the pthread_mutex_t type.
Siva Chandra Reddy [Fri, 20 May 2022 06:44:35 +0000 (06:44 +0000)]
[libc] Add the pthread_mutex_t type.

Simple implementations of the functions pthread_mutex_init,
pthread_mutex_destroy, pthread_mutex_lock and pthread_mutex_unlock have
have also been added. Future patches will extend these functions to add
features required by the POSIX specification.

Reviewed By: lntue

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

2 years ago[OpenMP] Add codegen for 'omp_all_memory' reserved locator.
Mike Rice [Tue, 24 May 2022 18:48:42 +0000 (11:48 -0700)]
[OpenMP] Add codegen for 'omp_all_memory' reserved locator.

This creates an entry with address=nullptr and flag=0x80.
When an 'omp_all_memory' entry is specified any other 'out' or
'inout' entries are not needed and are not passed to the runtime.

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

2 years ago[RISCV] Ensure the forwarded AVL register is alive
Philip Reames [Tue, 24 May 2022 21:58:09 +0000 (14:58 -0700)]
[RISCV] Ensure the forwarded AVL register is alive

When the AVL value does not fit in 5 bits, the register in which this value is stored may be dead when we want to forward it. This patch ensure the kill flags on the register are cleared before forwarding.

Patch by: loralb
Differential Revision: https://reviews.llvm.org/D125971

2 years ago[mlir][sparse] add new complex ops to reduction recognition
Aart Bik [Tue, 24 May 2022 18:49:47 +0000 (11:49 -0700)]
[mlir][sparse] add new complex ops to reduction recognition

Reviewed By: bixia

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

2 years ago[RISCV] Add an operand kind to the opcode/imm returned from RISCVMatInt.
Craig Topper [Tue, 24 May 2022 21:54:57 +0000 (14:54 -0700)]
[RISCV] Add an operand kind to the opcode/imm returned from RISCVMatInt.

Instead of matching opcodes to know the format to emit, use an
enum value that we can get from the RISCVMatInt::Inst class.

Change the consumers to use fully covered switches so that we get
a compiler warning if a new kind is added. With the opcode checks
it was easier to forget to update one of the 3 consumers.

Reviewed By: reames

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

2 years ago[riscv] Use getFirstInstrTerminator [nfc]
Philip Reames [Tue, 24 May 2022 21:55:42 +0000 (14:55 -0700)]
[riscv] Use getFirstInstrTerminator [nfc]

2 years ago[RISCV] Hoist VSETVLI out of idiomatic fixed length vector loops
Philip Reames [Tue, 24 May 2022 21:17:43 +0000 (14:17 -0700)]
[RISCV] Hoist VSETVLI out of idiomatic fixed length vector loops

This patch teaches the VSETVLI insertion pass to perform a very limited form of partial redundancy elimination. The motivating example comes from the fixed length vectorization of a simple loop such as:

for (unsigned i = 0; i < a_len; i++)
    a[i] += b;

Without this change, the core vector loop and preheader is as follows:

.LBB0_3:                                # %vector.ph
andi a1, a6, -8
addi a4, a0, 16
mv a5, a1
.LBB0_4:                                # %vector.body
                                        # =>This Inner Loop Header: Depth=1
addi a3, a4, -16
vsetivli zero, 4, e32, m1, ta, mu
vle32.v v8, (a3)
vle32.v v9, (a4)
vadd.vx v8, v8, a2
vadd.vx v9, v9, a2
vse32.v v8, (a3)
vse32.v v9, (a4)
addi a5, a5, -8
addi a4, a4, 32
bnez a5, .LBB0_4

The key thing to note here is that, the execution of the vsetivli only needs to happen once. Since there's no tail folding happening here, the value of the vector configuration registers are invariant through the loop.

After this patch, we hoist the configuration into the preheader and perform it once.

.LBB0_3:                                # %vector.ph
andi a1, a6, -8
vsetivli zero, 4, e32, m1, ta, mu
addi a4, a0, 16
mv a5, a1
.LBB0_4:                                # %vector.body
                                        # =>This Inner Loop Header: Depth=1
addi a3, a4, -16
vle32.v v8, (a3)
vle32.v v9, (a4)
vadd.vx v8, v8, a2
vadd.vx v9, v9, a2
vse32.v v8, (a3)
vse32.v v9, (a4)
addi a5, a5, -8
addi a4, a4, 32
bnez a5, .LBB0_4

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

2 years ago[SelectionDAG] Add support to widen ISD::STEP_VECTOR operations.
Paul Walker [Sun, 22 May 2022 12:49:01 +0000 (13:49 +0100)]
[SelectionDAG] Add support to widen ISD::STEP_VECTOR operations.

Fixes: #55165

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

2 years ago[Flang][OpenMP] Fixes for unstructured OpenMP code
Kiran Chandramohan [Tue, 24 May 2022 21:31:57 +0000 (21:31 +0000)]
[Flang][OpenMP] Fixes for unstructured OpenMP code

Since the FIR operations are mostly structured, it is only the functions
that could contain multiple blocks inside an operation. This changes
with OpenMP since OpenMP regions can contain multiple blocks. For
unstructured code, the blocks are created in advance and belong to the
top-level function. This caused code in OpenMP region to be placed under
the function level.

In this fix, if the OpenMP region is unstructured then new blocks are
created inside it.

Note1: This is part of upstreaming from the fir-dev branch of
https://github.com/flang-compiler/f18-llvm-project. The code in this patch is a
subset of the changes in https://github.com/flang-compiler/f18-llvm-project/pull/1178.

Reviewed By: vdonaldson

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

Co-authored-by: Val Donaldson <vdonaldson@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: Valentin Clement <clementval@gmail.com>
2 years agoFix build failure revealed by c35ca3a1c78f693b749ad11742350b7fc6c5cd89
Amy Kwan [Tue, 24 May 2022 21:11:23 +0000 (16:11 -0500)]
Fix build failure revealed by c35ca3a1c78f693b749ad11742350b7fc6c5cd89

This commit resolves a Linux kernel build failure that was revealed by
c35ca3a1c78f693b749ad11742350b7fc6c5cd89. The patch introduces two new
intrinsics, which ultimately changes the intrinsic numbering of other PPC
intrinsics. This causes an issue introduced by
ff40fb07ad6309131c2448ca00572a078c7a2d59, as the patch checks for intrinsics
with particular values, but the addition of the fnabs/fnabss intrinsics updates
the original sqrt/sdiv intrinsic values.

2 years ago[flang][runtime] Catch decimal integer input overflow
Peter Klausler [Fri, 20 May 2022 23:16:09 +0000 (16:16 -0700)]
[flang][runtime] Catch decimal integer input overflow

B/O/Z input overflow is already caught, and real input overflow
is signalled as an IEEE arithmetic exception, but regular decimal
integer overflow was silent.

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

2 years ago[flang] Replace crash and improve a semantics TODO message
Peter Klausler [Fri, 20 May 2022 21:21:59 +0000 (14:21 -0700)]
[flang] Replace crash and improve a semantics TODO message

The derived type information table construction code had a
crash whose root cause was replacing an expression with one
of its operands -- the deletion of the LHS of that assignment
led to the RHS being invalidated before it could be read.
Fix by cloning the RHS.  Also update a TODO message to the
new "_todo_en_US" message class and add a comment about how
it should be resolved.

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

2 years ago[flang] Process subprogram BIND(C,NAME=...) locally
Peter Klausler [Fri, 20 May 2022 20:31:14 +0000 (13:31 -0700)]
[flang] Process subprogram BIND(C,NAME=...) locally

The scalar-default-character-expression that defines the interoperable
name of a function or subroutine (or interface) must have its names
resolved within the context of the subprogram, despite its appearance
on a function-stmt or a subroutine-stmt.  Failure to do so can lead
to bogus errors or to incorrect results.

The solution is to defer name resolution for function-stmt suffixes
(but not entry-stmt suffixes) and for subroutine-stmt language binding
specifications to EndSubprogram().  (Their resolution only need to be
deferred to the end of the specification part, but it's cleanest to
deal with it in EndSubprogram().)

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

2 years ago[clang][dataflow] Relax `Environment` comparison operation.
Yitzhak Mandelbaum [Tue, 24 May 2022 18:45:59 +0000 (18:45 +0000)]
[clang][dataflow] Relax `Environment` comparison operation.

Ignore `MemberLocToStruct` in environment comparison. As an ancillary data
structure, including it is redundant. We also can generate environments which
differ in their `MemberLocToStruct` but are otherwise equivalent.

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

2 years ago[flang] Fix false error for multiple defined I/O subroutines
Peter Klausler [Fri, 20 May 2022 15:45:46 +0000 (08:45 -0700)]
[flang] Fix false error for multiple defined I/O subroutines

User-defined derived type I/O subroutines need to be unique for
a given type and operation in any scope, but it is acceptable
to have more than one defined I/O subroutine so long as only one
of them is visible.

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

2 years ago[flang] Accept defined assignment with CLASS(*) RHS
Peter Klausler [Thu, 19 May 2022 23:30:04 +0000 (16:30 -0700)]
[flang] Accept defined assignment with CLASS(*) RHS

A utility predicate in semantics was incorrectly determining that
an INTERFACE ASSIGNMENT(=) (or other form of generic) could not have
a specific procedure with an unlimited polymorphic second argument.
This led to a crash later in expression analysis.  Fix, and
extend tests.

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

2 years ago[flang] Fix purity testing for generic calls
Peter Klausler [Thu, 19 May 2022 22:32:06 +0000 (15:32 -0700)]
[flang] Fix purity testing for generic calls

The purity or impurity of a call to a generic interface
depends on the attributes of the specific procedure or specific
binding.  Change expression analysis of calls to generic interfaces
to replace the symbol in the parse tree with the specific procedure
or binding; this ensures that later checking for purity in
DO CONCURRENT and other contexts will be accurate.

Remove an "XFAIL" from a test that now passes again with this fix.

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

2 years ago[clang][test] mark tests added in ee8524087c78 as unsupported on AIX
Alex Lorenz [Tue, 24 May 2022 20:38:04 +0000 (13:38 -0700)]
[clang][test] mark tests added in ee8524087c78 as unsupported on AIX

These tests are failing on the PPC64 AIX CI bot, but it's unclear why,
as they pass on other CI jobs.
I marked them as unsupported on AIX for now while investigating the failure.

2 years ago[flang] Don't prematurely resolve subprogram names
Peter Klausler [Thu, 19 May 2022 21:17:17 +0000 (14:17 -0700)]
[flang] Don't prematurely resolve subprogram names

Name resolution for subprograms checks whether the name is already
present in the enclosing scope as a generic interface, so that the
case of a generic with the same name as one of its specifics can be
handled.  The particular means by which the enclosing scope is searched
for the name would resolve the name (bind a symbol to it) as a side
effect.  This turns out to be the wrong thing to do when the subprogram
is going to have its symbol created in another scope to cope with its
BIND(C,NAME="name") name, and its Fortran name is already present in the
enclosing scope for a subprogram of the same name but without
BIND(C,NAME="name").

A very long explanation for a one-line fix, sorry.  In short, change
the code to look up the name but not resolve it at that point.

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

2 years ago[clang][dataflow] Make limit on fixpoint-algorithm iterations proportional to size...
Yitzhak Mandelbaum [Tue, 24 May 2022 19:04:54 +0000 (19:04 +0000)]
[clang][dataflow] Make limit on fixpoint-algorithm iterations proportional to size of CFG.

Currently, the maximum number of iterations of the loop for finding the fixpoint
of the dataflow analysis is set at 2^16. When things go wrong in an analysis,
this can be far too large.  This patch changes the limit to be proportional to
the size of the CFG, which will generally be far smaller than 2^16 (while still
maintaining 2^16 as the absolute limit).

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

2 years ago[Sanitizers][Darwin] Replace SANITIZER_MAC with SANITIZER_APPLE in source files
Mariusz Borsa [Mon, 23 May 2022 21:35:42 +0000 (14:35 -0700)]
[Sanitizers][Darwin] Replace SANITIZER_MAC with SANITIZER_APPLE in source files

This is a follow up to [Sanitizers][Darwin] Rename Apple macro SANITIZER_MAC -> SANITIZER_APPLE (D125816)

Performed a global search/replace as in title against LLVM sources

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