platform/upstream/llvm.git
19 months agoworkflows: Don't try and run llvm-bugs in forks
Jessica Clarke [Thu, 16 Mar 2023 16:47:07 +0000 (16:47 +0000)]
workflows: Don't try and run llvm-bugs in forks

Most forks won't have an LLVM_BUGS_KEY secret, so Mailgun will error out
with a missing key, and if forks do happen to have such a secret then we
still don't want to be getting emails to LLVM's mailing lists for
downstream forks.

Reviewed By: tstellar

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

19 months ago[mlir][sparse] add test cases for sparse tensor slices on COO tensors
Peiming Liu [Tue, 14 Mar 2023 18:18:20 +0000 (18:18 +0000)]
[mlir][sparse] add test cases for sparse tensor slices on COO tensors

Reviewed By: aartbik, bixia

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

19 months ago[HWAsan] Fix returned PreservedAnalyses
Arthur Eubanks [Thu, 16 Mar 2023 16:38:35 +0000 (09:38 -0700)]
[HWAsan] Fix returned PreservedAnalyses

Initialization modifies the module.

19 months ago[FunctionImport] Fix returned PreservedAnalyses
Arthur Eubanks [Thu, 16 Mar 2023 16:37:26 +0000 (09:37 -0700)]
[FunctionImport] Fix returned PreservedAnalyses

19 months ago[Annotation2Metadata] Fix returned PreservedAnalyses
Arthur Eubanks [Thu, 16 Mar 2023 16:36:48 +0000 (09:36 -0700)]
[Annotation2Metadata] Fix returned PreservedAnalyses

19 months ago[flang] Make tests depend on llvm-readobj not llvm-readelf
David Spickett [Thu, 16 Mar 2023 16:29:18 +0000 (16:29 +0000)]
[flang] Make tests depend on llvm-readobj not llvm-readelf

d4320cb2a5ef1680e519fa6b7cfd3a2f88cfed16 fixed a regular build
issue by making the flang tests depend on llvm-readelf.

Turns out llvm-readelf is a symlink to llvm-readobj and for
whatever reason, doesn't have the right exports at the moment
to be picked up in a standalone build.

https://lab.llvm.org/buildbot/#/builders/175/builds/26448

Maybe we should fix that, but for now, just require llvm-readobj
instead.

19 months ago[AMDGPUCtorDtorLowering] Fix returned PreservedAnalyses
Arthur Eubanks [Thu, 16 Mar 2023 16:35:52 +0000 (09:35 -0700)]
[AMDGPUCtorDtorLowering] Fix returned PreservedAnalyses

19 months ago[RISCV] Fix missing addi in test to validate lower inline asm m with offset
Mikhail R. Gadelha [Thu, 16 Mar 2023 16:24:22 +0000 (13:24 -0300)]
[RISCV] Fix missing addi in test to validate lower inline asm m with offset

19 months ago[Coroutines] Add remarks in CoroSplit and CoroElide passes
Wei Wang [Thu, 23 Feb 2023 00:58:23 +0000 (16:58 -0800)]
[Coroutines] Add remarks in CoroSplit and CoroElide passes

Add remarks to show frame size and alignment.

Reviewed By: ChuanqiXu

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

19 months ago[flang] Do not try to rebox for assumed type
Valentin Clement [Thu, 16 Mar 2023 16:16:18 +0000 (17:16 +0100)]
[flang] Do not try to rebox for assumed type

Just use conversion from assuemd type to assumed type
because a rebox needs more information that are not available
with assumed type.

Also use `isAssumedType` instead of `isBoxNone` since assumed
type can have sequence information.

Depends on D146207

Reviewed By: PeteSteinfeld

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

19 months ago[AMDGPUUnifyDivergentExitNodes] Add NewPM support
Anshil Gandhi [Thu, 16 Mar 2023 16:09:42 +0000 (16:09 +0000)]
[AMDGPUUnifyDivergentExitNodes] Add NewPM support

Meanwhile, use UniformityAnalysis instead of LegacyDivergenceAnalysis to collect divergence info.

Reviewed By: arsenm, sameerds

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

19 months ago[RISCV] Added tests to validate lower inline asm m and A with offsets
Mikhail R. Gadelha [Thu, 16 Mar 2023 16:06:50 +0000 (13:06 -0300)]
[RISCV] Added tests to validate lower inline asm m and A with offsets

19 months ago[flang] Embox argument for assumed type dummy argument to !fir.box<none>
Valentin Clement [Thu, 16 Mar 2023 16:10:26 +0000 (17:10 +0100)]
[flang] Embox argument for assumed type dummy argument to !fir.box<none>

When passing an argument to an assumed type dummy argument, embox
it directly to a !fir.box<none> box.

Reviewed By: PeteSteinfeld

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

19 months ago[LICM] Add additional single thread promotion test (NFC)
Nikita Popov [Thu, 16 Mar 2023 15:58:24 +0000 (16:58 +0100)]
[LICM] Add additional single thread promotion test (NFC)

19 months ago[RISCV] Enable interleaved access vectorization
Luke Lau [Thu, 9 Mar 2023 16:18:28 +0000 (16:18 +0000)]
[RISCV] Enable interleaved access vectorization

The loop vectorizer supports generating interleaved loads and stores via
shuffle patterns for fixed length vectors.
This enables it for RISC-V, since interleaved shuffle patterns can be
lowered to vlseg/vsseg in https://reviews.llvm.org/D145022

Reviewed By: reames

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

19 months ago[RISCV] Don't accidentally match deinterleave masks as interleaves
Luke Lau [Wed, 15 Mar 2023 22:47:40 +0000 (22:47 +0000)]
[RISCV] Don't accidentally match deinterleave masks as interleaves

Consider a shuffle mask of <0, 2>:
This is one of two deinterleave masks to deinterleave a vector of 4
elements with factor 2.
Unfortunately, this is also technically an interleave mask, where
two subvectors of length 1 at indexes 0 and 2 will be interleaved.
This is because a mask can interleave non-contiguous subvectors:
e.g. <0, 6, 4, 1, 7, 5> on a vector of size 8:

```
<0 1 2 3 4 5 6 7> indices
 ^ ^     ^ ^ ^ ^
 0 0     2 2 1 1  deinterleaved subvector
```

This means that deinterleaving shuffles can accidentally be costed as
interleaves.
And it's incorrect in the context of interleaves, because the
only interleave shuffles we model at the moment are single permutation
shuffles, i.e. we are interleaving the first vector below and ignoring
the second:

shufflevector <2 x i32> %v0, <2 x i32> poison, <2 x i32> <i32 0, i32 2>

A mask of <0, 2> interleaves across both vectors.

The fix here is to set NumInputElts correctly: We were setting it to
twice the mask length, i.e. using both input vectors. But in fact we're
actually only using the first vector here, and isInterleaveMask actually
already has logic to ensure that the mask indices stay within the bounds
of the input vectors.

This lacks a test case due to how we're unable to test deinterleave
shuffles (because they are length changing), but is covered in the tests
in D145155

Reviewed By: reames

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

19 months ago[RISCV][MC][NFC] Refactor RISCVAsmPrinter::PrintAsmMemoryOperand to use early return
Alex Bradbury [Thu, 16 Mar 2023 15:02:53 +0000 (15:02 +0000)]
[RISCV][MC][NFC] Refactor RISCVAsmPrinter::PrintAsmMemoryOperand to use early return

19 months ago[mlir][Vector] Canonicalize create_mask(transpose)
Diego Caballero [Thu, 16 Mar 2023 04:14:16 +0000 (04:14 +0000)]
[mlir][Vector] Canonicalize create_mask(transpose)

When applying vector masking we may create a mask and then transpose it.
Transpositions are extremely expensive so this patch introduces a new
canonicalization pattern that remove the tranpose operation and create a
new transposed mask.

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

19 months ago[TLI] getMemValueType - break apart if-else chain and use auto with dyn_cast (style...
Simon Pilgrim [Thu, 16 Mar 2023 14:32:58 +0000 (14:32 +0000)]
[TLI] getMemValueType - break apart if-else chain and use auto with dyn_cast (style). NFC.

More closely matches getValueType

19 months ago[mlir][TilingInterface] Modify `TilingInterface` methods to better return the state...
Mahesh Ravishankar [Thu, 2 Mar 2023 00:33:14 +0000 (16:33 -0800)]
[mlir][TilingInterface] Modify `TilingInterface` methods to better return the state of the transformed IR.

Currently the `getTiledImplementation` and `generateResultTileValue`
return just `SmallVector<Operation *>` and `FailureOr<Value>`.

- For `getTiledImplementation` returning empty implies tiling wasnt
  done. There is also an implicit assumption that the tiled operation
  results correspond to the tiled values of the result of the original
  operation. This cannot handle cases where the tiled implementation
  might use multiple operations to compute the tiled value for the
  results of the untiled operation. Sometimes, the tiled operation
  might not directly give the tiled values, and might require casts,
  etc to get a replacement.
- For `generateResultTileValue`, it is assumed that the op defining
  the returned `Value` is the operation that represents the tiled
  computation. Again presence of casts, etc violate this.

Instead make these methods return
```
struct TilingResult {
  SmallVector<Operation *> tiledOps;
  SmallVector<Value> tiledValues;
};
```

The `tiledOps` represent the operations generated that are relevant
for subsequent transformations. The `tiledValues` represent the tiled
values for the results of the original operation. This better
transmits the state of the transformed IR.

As a consequence the following methods also return `FailureOr<TilingResult>`
- `tensor::replaceExtractSliceWithTiledProducer`
- `tensor::bubbleUpPadSlice`

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

19 months ago[mlir][vector] Add mask fold test for gather lowering
Jakub Kuderski [Thu, 16 Mar 2023 14:16:14 +0000 (10:16 -0400)]
[mlir][vector] Add mask fold test for gather lowering

Check that `scf.if` checks are folded when the mask is all set / not
set.

This to address post-commit feedback for
https://reviews.llvm.org/D145942.

Reviewed By: dcaballe

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

19 months ago[libc] Add missing dependencies to RISC-V startup implementation
Joseph Huber [Thu, 16 Mar 2023 14:12:36 +0000 (09:12 -0500)]
[libc] Add missing dependencies to RISC-V startup implementation

Summary:
Just like the last patch, the threads and envrion dependencies were
missing. This lead to linker failures when building the tests.

19 months ago[TLI] Bring isZExtFree declarations together. NFC.
Simon Pilgrim [Thu, 16 Mar 2023 14:06:23 +0000 (14:06 +0000)]
[TLI] Bring isZExtFree declarations together. NFC.

Don't spread them out over the header.

19 months agoRecommit DwarfEHPrepare: insert extra unwind paths for stack protector to instrument
Tim Northover [Tue, 7 Feb 2023 12:26:29 +0000 (12:26 +0000)]
Recommit DwarfEHPrepare: insert extra unwind paths for stack protector to instrument

This is a mitigation patch for
https://bugs.chromium.org/p/llvm/issues/detail?id=30, where existing stack
protection is skipped if a function is returned through by an unwinder rather
than the normal call/return path. The recent patch D139254 added the ability to
instrument a visible unwind path, at least in the IR case (I'm working on the
SelectionDAG instrumentation too) but there are still invisible unwinds it
can't reach.

So this patch adds logic to DwarfEHPrepare that goes through a function,
converting any call that might throw into an invoke to a simple resume cleanup,
and adding cleanup clauses to existing landingpads that lack them. Obviously we
don't really want to do this if it's wasted effort, so I also exposed
requiresStackProtector from the actual StackProtector code to skip the extra
paths if they won't be used.

Changes:
  * Move test to AArch64 directory as it relies on target presence.
  * Re-add Dominator-tree maintenance. Accidentally cherry-picked wrong patch.
  * Skip adding paths on Windows EH functions.

https://reviews.llvm.org/D143637

19 months ago[ARM][NFC] Use FPUKind enum instead of unsigned
Michael Platings [Wed, 15 Mar 2023 13:37:07 +0000 (13:37 +0000)]
[ARM][NFC] Use FPUKind enum instead of unsigned

Also rename some FPUID variables to FPUKind now it's clear that's what
they are.

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

19 months ago[ValueTracking] Return ConstantRange for intrinsic ranges (NFC)
Nikita Popov [Thu, 16 Mar 2023 13:24:18 +0000 (14:24 +0100)]
[ValueTracking] Return ConstantRange for intrinsic ranges (NFC)

Instead of setting Lower and Upper, return a ConstantRange.
Should do this for the others as well.

19 months ago[InstCombine] Add more vscale icmp tests (NFC)
Nikita Popov [Thu, 16 Mar 2023 13:10:47 +0000 (14:10 +0100)]
[InstCombine] Add more vscale icmp tests (NFC)

In particular cover cases where vscale_range entries are larger
than the vscale bitwidth.

19 months ago[mlir] Fix legal/illegal ops in TosaToTensor & TosaToLinalg
Maya Amrami [Thu, 16 Mar 2023 10:59:38 +0000 (12:59 +0200)]
[mlir] Fix legal/illegal ops in TosaToTensor & TosaToLinalg

tosa.reshape and tosa.concat were moved from TosaToLinalg to TosaToTensor
(D145119 & D145952). So now they are legal after applying TosaToLinalg patterns,
and illegal after applying TosaToTensor patterns.

This includes D146174 (thanks @ramiro050!)

Reviewed By: krzysz00

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

19 months ago[libc] Add missing environ dependency to AArch64 startup implementation
Joseph Huber [Thu, 16 Mar 2023 13:06:14 +0000 (08:06 -0500)]
[libc] Add missing environ dependency to AArch64 startup implementation

Summary:
Just like the last patch, this dependency was missing. This lead to
linker failures when building the tests.

19 months ago[libc] Add missing threads dependency to AArch64 startup implementation
Joseph Huber [Thu, 16 Mar 2023 13:00:14 +0000 (08:00 -0500)]
[libc] Add missing threads dependency to AArch64 startup implementation

Summary:
The changes in D146184 made the integration tests use the inhereted
dependencies from the startup code like a normal target. For the AArch64
target this resulted in the threads depenency not being pulled in
because it was not present in the original code.

19 months ago[libc] Inherit integration test dependencies from the startup target
Joseph Huber [Thu, 16 Mar 2023 01:12:16 +0000 (20:12 -0500)]
[libc] Inherit integration test dependencies from the startup target

All integration tests rely on the startup code to be run. Currently we
manually include a few of these dependencies that are relevant for the
Linux target. This patch changes this to make the integration test's
dependencies include all the dependencies of the startup code. This
simplifies the code and makes it easier to support different targets.
The changes here cause the integration test to be dependent on more
targets than previously necessary, but it should be fine.

Reviewed By: sivachandra

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

19 months ago[llvm][Bazel] Include .inc files in tblgen target.
Adrian Kuegel [Thu, 16 Mar 2023 12:11:24 +0000 (13:11 +0100)]
[llvm][Bazel] Include .inc files in tblgen target.

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

19 months ago[DAG] TargetLowering::ShrinkDemandedOp - move SmallVTBits iterator inside for loop...
Simon Pilgrim [Thu, 16 Mar 2023 12:05:23 +0000 (12:05 +0000)]
[DAG] TargetLowering::ShrinkDemandedOp - move SmallVTBits iterator inside for loop. NFC

19 months ago[DAG] TargetLowering::ShrinkDemandedOp - pull out repeated getValueType calls. NFC
Simon Pilgrim [Thu, 16 Mar 2023 11:57:29 +0000 (11:57 +0000)]
[DAG] TargetLowering::ShrinkDemandedOp - pull out repeated getValueType calls. NFC

19 months ago[clang] Fix a UsingTemplate regression after 3e78fa860235431323aaf08c8fa922d75a7cfffa
Haojian Wu [Thu, 16 Mar 2023 08:42:41 +0000 (09:42 +0100)]
[clang] Fix a UsingTemplate regression after 3e78fa860235431323aaf08c8fa922d75a7cfffa

TemplateName::getAsTemplateDecl() returns the underlying TemplateDecl
for a UsingTemplate kind template name. We should respect that in the
Profile method otherwise we might desugar the template name unexpectedly
(e.g. for template argument deduction with deduciton guides).

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

19 months agoRevert "DwarfEHPrepare: insert extra unwind paths for stack protector to instrument"
Tim Northover [Thu, 16 Mar 2023 11:55:53 +0000 (11:55 +0000)]
Revert "DwarfEHPrepare: insert extra unwind paths for stack protector to instrument"

It's caused more failures than are trivially fixable.

This reverts commit 203b6f31bb71ce63488eb96b303e000e91aee376.

19 months agoDwarfEHPrepare: insert extra unwind paths for stack protector to instrument
Tim Northover [Tue, 7 Feb 2023 12:26:29 +0000 (12:26 +0000)]
DwarfEHPrepare: insert extra unwind paths for stack protector to instrument

This is a mitigation patch for
https://bugs.chromium.org/p/llvm/issues/detail?id=30, where existing stack
protection is skipped if a function is returned through by an unwinder rather
than the normal call/return path. The recent patch D139254 added the ability to
instrument a visible unwind path, at least in the IR case (I'm working on the
SelectionDAG instrumentation too) but there are still invisible unwinds it
can't reach.

So this patch adds logic to DwarfEHPrepare that goes through a function,
converting any call that might throw into an invoke to a simple resume cleanup,
and adding cleanup clauses to existing landingpads that lack them. Obviously we
don't really want to do this if it's wasted effort, so I also exposed
requiresStackProtector from the actual StackProtector code to skip the extra
paths if they won't be used.

https://reviews.llvm.org/D143637

19 months agoStackProtector: expose RequiresStackProtector publicly. NFC.
Tim Northover [Tue, 7 Feb 2023 11:28:00 +0000 (11:28 +0000)]
StackProtector: expose RequiresStackProtector publicly. NFC.

19 months agoclang: Use ptrmask for pointer alignment
Matt Arsenault [Thu, 12 Jan 2023 14:33:37 +0000 (09:33 -0500)]
clang: Use ptrmask for pointer alignment

Avoid using ptrtoint/inttoptr.

19 months ago[docs] Document "PGO" (Profile-Guided Optimization) in the lexicon.
Frederic Cambus [Thu, 16 Mar 2023 11:14:44 +0000 (12:14 +0100)]
[docs] Document "PGO" (Profile-Guided Optimization) in the lexicon.

19 months ago[RFC][X86][MemFold] Upgrade the mechanism of auto-generated Memory Folding Table
Bing1 Yu [Wed, 8 Mar 2023 07:29:08 +0000 (15:29 +0800)]
[RFC][X86][MemFold] Upgrade the mechanism of auto-generated Memory Folding Table

1. Align ManualMapSet with X86MemoryFoldTableEntry instead of using UnfoldStrategy
2. ManualMapSet able to update the existing record in auto-generated MemFold table

Reviewed By: skan

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

19 months ago[InstCombine] Add additional vscale icmp tests (NFC)
Nikita Popov [Thu, 16 Mar 2023 10:36:42 +0000 (11:36 +0100)]
[InstCombine] Add additional vscale icmp tests (NFC)

The existing tests don't test the precise range bounds implied
by the vscale_range attribute.

19 months ago[SCEV] Add additional tests for vscale (NFC)
Nikita Popov [Thu, 16 Mar 2023 10:03:36 +0000 (11:03 +0100)]
[SCEV] Add additional tests for vscale (NFC)

19 months agoEmit const globals with constexpr destructor as constant LLVM values
Hans Wennborg [Mon, 6 Mar 2023 12:37:32 +0000 (13:37 +0100)]
Emit const globals with constexpr destructor as constant LLVM values

This follows 2b4fa53 which made Clang not emit destructor calls for such
objects. However, they would still not get emitted as constants since
CodeGenModule::isTypeConstant() returns false if the destructor is
constexpr. This change adds a param to make isTypeConstant() ignore the
dtor, allowing the caller to check it instead.

Fixes Issue #61212

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

19 months ago[Assignment Tracking] Allow salvaging with variadic expressions [4/x]
OCHyams [Thu, 16 Mar 2023 09:28:05 +0000 (09:28 +0000)]
[Assignment Tracking] Allow salvaging with variadic expressions [4/x]

Allow the value-component of a dbg.assign to be salvaged using a variadic
DIExpression.

Reviewed By: StephenTozer

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

19 months ago[Assignment Tracking] Do not convert variadic locations to kill locations [3/x]
OCHyams [Thu, 16 Mar 2023 09:25:01 +0000 (09:25 +0000)]
[Assignment Tracking] Do not convert variadic locations to kill locations [3/x]

Reviewed By: StephenTozer

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

19 months ago[Assignment Tracking][NFC] Use RawLocationWrapper in VarLocInfo [2/x]
OCHyams [Thu, 16 Mar 2023 08:48:36 +0000 (08:48 +0000)]
[Assignment Tracking][NFC] Use RawLocationWrapper in VarLocInfo [2/x]

Use RawLocationWrapper rather than a Value to represent the location operand(s)
so that it's possible to represent multiple location
operands. AssignmentTrackingAnalysis still converts variadic debug intrinsics
to kill locations so this patch is NFC.

Reviewed By: StephenTozer

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

19 months ago[DebugInfo][NFC] Add RawLocationWrapper to wrap location operand metadata [1/x]
OCHyams [Thu, 16 Mar 2023 08:46:02 +0000 (08:46 +0000)]
[DebugInfo][NFC] Add RawLocationWrapper to wrap location operand metadata [1/x]

RawLocationWrapper wraps the location operand of a debug intrinsic which may be
either (wrapped in MetadataAsValue) a DIArgList, ValueAsMetadata, or an empty
MDTuple. This class lets us avoid duplicating location handling code in a later
patch in this stack.

Reviewed By: StephenTozer

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

19 months ago[flang] Fix build error caused by missing llvm-readelf
Shao-Ce SUN [Thu, 16 Mar 2023 09:26:40 +0000 (17:26 +0800)]
[flang] Fix build error caused by missing llvm-readelf

Fix build error in D145883. Thanks @awarzynski!

Reviewed By: awarzynski

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

19 months ago[ConstantsTest] Fix unused variable warning (NFC)
Nikita Popov [Thu, 16 Mar 2023 09:43:13 +0000 (10:43 +0100)]
[ConstantsTest] Fix unused variable warning (NFC)

19 months ago[IR] Remove unused ConstantExpr::getOffsetOf() methods (NFC)
Nikita Popov [Thu, 16 Mar 2023 09:34:18 +0000 (10:34 +0100)]
[IR] Remove unused ConstantExpr::getOffsetOf() methods (NFC)

These are not used and should not be used (just like anything that
creates a constant expression only due to lack of DL-awareness).

19 months ago[ConstExpr] Remove select constant expression
Nikita Popov [Mon, 6 Mar 2023 09:46:22 +0000 (10:46 +0100)]
[ConstExpr] Remove select constant expression

This removes the select constant expression, as part of
https://discourse.llvm.org/t/rfc-remove-most-constant-expressions/63179.
Uses of this expressions have already been removed in advance,
so this just removes related infrastructure and updates tests.

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

19 months ago[clang][Lexer] Fix crash/assert clang::HeaderSearch::search_dir_nth
Dmitry Polukhin [Wed, 15 Mar 2023 17:45:07 +0000 (10:45 -0700)]
[clang][Lexer] Fix crash/assert clang::HeaderSearch::search_dir_nth

The issue was introduced in D135801. When there are only header maps in the SearchDirs,
the out of bounds value is assigned to FirstNonHeaderMapSearchDirIdx.

Test Plan: check-clang

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

19 months ago[libc] Enable __llvm_libc_syscall and fork
Mikhail R. Gadelha [Wed, 15 Mar 2023 17:10:54 +0000 (14:10 -0300)]
[libc] Enable __llvm_libc_syscall and fork

This patch enables the remaining calls from unistd.

The test cases had to be updated to:
1. Use SYS_symlinkat if SYS_symlink is not available
2. Use SYS_readlinkat if SYS_readlink is not available
3. Use SYS_unlinkat if SYS_unlink is not available
4. Use SYS_openat if SYS_open is not available

We also abort compilation if neither of the syscalls mentioned above are
available.

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

19 months ago[libc] Enable spawn lib in riscv
Mikhail R. Gadelha [Tue, 14 Mar 2023 20:50:09 +0000 (17:50 -0300)]
[libc] Enable spawn lib in riscv

In this patch we add support for the spawn lib in riscv.

Only small changes were required, the biggest one was to use of dup3
instead of dup2, if the latter is not available. This follows our
implementation of dup2.

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

19 months ago[libc] Update supported riscv libs
Mikhail R. Gadelha [Tue, 14 Mar 2023 17:06:01 +0000 (14:06 -0300)]
[libc] Update supported riscv libs

This patch removes some duplicated libs added to entrypoints.txt, adds
new libs supported to entrypoints.txt and updates header.txt

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

19 months ago[Test] Add test showing difference in behavior of Guard Widening depending on form
Max Kazantsev [Thu, 16 Mar 2023 09:09:41 +0000 (16:09 +0700)]
[Test] Add test showing difference in behavior of Guard Widening depending on form

Guards can be represented differently (as intrinsic calls and as explicit branches),
and the expectation is that Guard Widening should do the same things for them, no
matter what form it was suggested. Currently it seems to be not so.

We also don't want LICM to prevent guard widening.

19 months ago[Metarenamer] Distinguish instructions by opcodes
Max Kazantsev [Thu, 16 Mar 2023 06:23:11 +0000 (13:23 +0700)]
[Metarenamer] Distinguish instructions by opcodes

This should improve readability of metarenamed code.

Differential Revision: https://reviews.llvm.org/D145896
Reviewed By: nikic

19 months ago[InstCombine] Canonicalize icmp eq pow2 more thoroughly
Nikita Popov [Wed, 15 Mar 2023 15:40:59 +0000 (16:40 +0100)]
[InstCombine] Canonicalize icmp eq pow2 more thoroughly

We currently already canonicalize icmp eq (%x & Pow2), Pow2 to
icmp ne (%x & Pow2), 0. This patch generalizes the fold based on
known bits.

In particular, this allows us to handle comparisons against
!range !{i64 0, i64 2} loads, which addresses an optimization
regression in Rust caused by 8df376db7282b955e7990cb8887ee9dcd3565040.

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

19 months ago[clang-tidy] Correctly handle evaluation order of designated initializers.
Martin Braenne [Thu, 16 Mar 2023 07:33:49 +0000 (07:33 +0000)]
[clang-tidy] Correctly handle evaluation order of designated initializers.

As designated initializers show up only in the syntactic form of the
InitListExpr, we need to make sure we're searching both forms of the
InitListExpr when determining successors in the evaluation order.

This fixes a bug in bugprone-use-after-move where previously we erroneously
concluded that two designated initializers were unsequenced. The newly added
tests fail without the fix.

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

19 months ago[mlir][llvm] Add fastmathFlags to SelectOp
Jeff Niu [Fri, 10 Mar 2023 21:59:23 +0000 (13:59 -0800)]
[mlir][llvm] Add fastmathFlags to SelectOp

`select` has fastmath flags, which were missing from the LLVM dialect op
definition.

Reviewed By: ftynse, dcaballe, gysit

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

19 months ago[LoongArch] Emit bytepick for picking from concatenation of two values
WANG Xuerui [Thu, 16 Mar 2023 06:09:51 +0000 (14:09 +0800)]
[LoongArch] Emit bytepick for picking from concatenation of two values

It seems the ISA manual's pseudo-code description for the
`BYTEPICK.[WD]` instructions is inaccurate; the behavior described here
should be correct though. The instructions' names are misleading too
(they pick full GRLen-wide words instead of bytes; they just index by
bytes) but let's stick to the official names for now.

Reviewed By: SixWeining

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

19 months ago[LoongArch] Add baseline tests for `bytepick` codegen. NFC
WANG Xuerui [Thu, 16 Mar 2023 05:33:50 +0000 (13:33 +0800)]
[LoongArch] Add baseline tests for `bytepick` codegen. NFC

Reviewed By: SixWeining

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

19 months ago[mlir] Fix scf.for with signless iterations print/parse
Jacques Pienaar [Thu, 16 Mar 2023 06:12:17 +0000 (02:12 -0400)]
[mlir] Fix scf.for with signless iterations print/parse

There was accidentally a different form used for printing and parsing.

19 months agoUse *{Map,Set}::contains (NFC)
Kazu Hirata [Thu, 16 Mar 2023 05:55:35 +0000 (22:55 -0700)]
Use *{Map,Set}::contains (NFC)

19 months ago[LSAN][HWASAN] Turn on leak sanitizer in HWASAN for Linux
Kirill Stoimenov [Thu, 16 Mar 2023 05:45:03 +0000 (05:45 +0000)]
[LSAN][HWASAN] Turn on leak sanitizer in HWASAN for Linux

Reviewed By: vitalybuka

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

19 months ago[HWASAN] Fix a memory leak in realloc-test.cpp
Kirill Stoimenov [Thu, 16 Mar 2023 05:42:02 +0000 (05:42 +0000)]
[HWASAN] Fix a memory leak in realloc-test.cpp

Reviewed By: vitalybuka

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

19 months ago[RISCV][NFC] Add more floating point tests for SLP vectorization
Ben Shi [Wed, 15 Mar 2023 01:39:31 +0000 (09:39 +0800)]
[RISCV][NFC] Add more floating point tests for SLP vectorization

Reviewed By: reames

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

19 months ago[RISCV][NFC] Add tests for SLP vectorization of smin/smax/umin/umax
Ben Shi [Tue, 14 Mar 2023 07:26:35 +0000 (15:26 +0800)]
[RISCV][NFC] Add tests for SLP vectorization of smin/smax/umin/umax

Reviewed By: reames

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

19 months ago[libc][docs] Add a section about allocations and deallocations to the style doc.
Siva Chandra Reddy [Wed, 15 Mar 2023 07:29:59 +0000 (00:29 -0700)]
[libc][docs] Add a section about allocations and deallocations to the style doc.

Fixes #59277 - The main part of that bug has already been addressed. This commit
just adds documentation.

Reviewed By: jeffbailey

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

19 months ago[libc][docs] Move the link to "Compiler Support" under "Status".
Siva Chandra Reddy [Wed, 15 Mar 2023 05:52:53 +0000 (22:52 -0700)]
[libc][docs] Move the link to "Compiler Support" under "Status".

Also, fixed a minor typo in compiler_support.rst.

Reviewed By: jeffbailey, gchatelet

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

19 months agoThe test added in d8690bc requires ZLIB, so only run the test if LLVM_ENABLE_ZLIB...
Douglas Yung [Thu, 16 Mar 2023 03:19:23 +0000 (20:19 -0700)]
The test added in d8690bc requires ZLIB, so only run the test if LLVM_ENABLE_ZLIB is set.

This will fix buildbots that fail because they do not have ZLIB installed such as
https://lab.llvm.org/buildbot/#/builders/216/builds/18424

19 months ago[libc] Add missing return statements to wrapper functions
Joseph Huber [Thu, 16 Mar 2023 03:15:38 +0000 (22:15 -0500)]
[libc] Add missing return statements to wrapper functions

Summary:
I forgot to add return statements to these memory comparison functions.
This should hopefully resolve some BB errors.

19 months ago[RISCV]Optimize (riscvisd::select_cc x, 0, ne, x, 1)
LiaoChunyu [Thu, 16 Mar 2023 02:38:51 +0000 (10:38 +0800)]
[RISCV]Optimize (riscvisd::select_cc x, 0, ne, x, 1)

This patch reduces the number of unpredictable branches.

Reviewed By: craig.topper

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

19 months ago[libc] Do not attempt to determine CPU features in GPU mode
Joseph Huber [Thu, 16 Mar 2023 01:44:00 +0000 (20:44 -0500)]
[libc] Do not attempt to determine CPU features in GPU mode

Summary:
We don't use these features in the GPU build, trying to determine them
can cause errors. We should just return early if this is the case.

19 months ago[Clang][LoongArch] Implement patchable function entry
WANG Xuerui [Wed, 15 Mar 2023 09:12:48 +0000 (17:12 +0800)]
[Clang][LoongArch] Implement patchable function entry

Similar to D98610 for RISCV.

This is going to be required by the upcoming Linux/LoongArch
[[ https://git.kernel.org/linus/4733f09d88074 | support for dynamic ftrace ]].

Reviewed By: SixWeining, MaskRay

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

19 months ago[libc] Add aliases to C memory functions for integration tests
Joseph Huber [Wed, 15 Mar 2023 23:16:51 +0000 (18:16 -0500)]
[libc] Add aliases to C memory functions for integration tests

The integration tests require the C memory functions as the compiler may
emit calls to them directly. The tests normally use the `__internal__`
variant that is built for testing, but these memory functions were
linked directly to preserve the entrypoint. Instead, we forward delcare
the internal versions and map the entrypoints to them manually inside
the integration test. This allows us to use the internal versions of
these files like the rest of the test objects.

Reviewed By: sivachandra

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

19 months ago[clang] Use *{Map,Set}::contains (NFC)
Kazu Hirata [Thu, 16 Mar 2023 01:06:34 +0000 (18:06 -0700)]
[clang] Use *{Map,Set}::contains (NFC)

19 months ago[llvm] Use *{Map,Set}::contains (NFC)
Kazu Hirata [Thu, 16 Mar 2023 01:06:32 +0000 (18:06 -0700)]
[llvm] Use *{Map,Set}::contains (NFC)

19 months ago[Lex] Use false instead of 0 (NFC)
Kazu Hirata [Thu, 16 Mar 2023 01:06:31 +0000 (18:06 -0700)]
[Lex] Use false instead of 0 (NFC)

19 months ago[llvm-profdata] Add more unit tests to check --output-size-limit feature when compres...
William Huang [Tue, 21 Feb 2023 23:08:08 +0000 (23:08 +0000)]
[llvm-profdata] Add more unit tests to check --output-size-limit feature when compression is enabled

Add unit tests for ExtBinary format with compression. This patch doesn't imply there's a bug in the existing implementation,
but as a precaution that planned changes to SampleProfileReader may cause it to break.

Reviewed By: snehasish

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

19 months ago[scudo] Add a method to force release everything.
Christopher Ferris [Tue, 14 Mar 2023 20:27:32 +0000 (13:27 -0700)]
[scudo] Add a method to force release everything.

The force flag to releaseToOSMaybe does not release everything
since it is an expensive operation. Modify the release flag to
have three states: normal, force, forceall. Force behaves the same
as setting Force to true from before this change. Forceall will
release everything regardless of how much time it takes, or
how much there is to release.

In addition, add a new mallopt that will call the release function
with the forceall flag set.

Reviewed By: Chia-hungDuan

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

19 months ago[ADT][mlir] Fix gcc build error
Jakub Kuderski [Thu, 16 Mar 2023 00:22:35 +0000 (20:22 -0400)]
[ADT][mlir] Fix gcc build error

Add `template` to fix a buildbot:
https://lab.llvm.org/buildbot/#/builders/199/builds/18363.

This is a post-commit fix for https://reviews.llvm.org/D144503,
submitted as a0a76804c4b5.

19 months agoAdd a Debugger interruption mechanism in conjunction with the
Jim Ingham [Wed, 15 Mar 2023 18:20:20 +0000 (11:20 -0700)]
Add a Debugger interruption mechanism in conjunction with the
Command Interpreter mechanism.

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

19 months ago[ADT] Allow `llvm::enumerate` to enumerate over multiple ranges
Jakub Kuderski [Wed, 15 Mar 2023 23:34:21 +0000 (19:34 -0400)]
[ADT] Allow `llvm::enumerate` to enumerate over multiple ranges

This does not work by a mere composition of `enumerate` and `zip_equal`,
because C++17 does not allow for recursive expansion of structured
bindings.

This implementation uses `zippy` to manage the iteratees and adds the
stream of indices as the first zipped range. Because we have an upfront
assertion that all input ranges are of the same length, we only need to
check if the second range has ended during iteration.

As a consequence of using `zippy`, `enumerate` will now follow the
reference and lifetime semantics of the `zip*` family of functions. The
main difference is that `enumerate` exposes each tuple of references
through a new tuple-like type `enumerate_result`, with the familiar
`.index()` and `.value()` member functions.

Because the `enumerate_result` returned on dereference is a
temporary, enumeration result can no longer be used through an
lvalue ref.

Reviewed By: dblaikie, zero9178

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

19 months ago[Clang][AIX][p] Manually Claim -p in front end
Michael Francis [Wed, 1 Mar 2023 00:56:06 +0000 (00:56 +0000)]
[Clang][AIX][p] Manually Claim -p in front end

The current implementation of `-p` does not claim the argument once it
is passed. Since it pushes `-pg` directly, it is only ever referred to
again when linking. As a result, when compiling with `-S`, the compiler
warns that `-p` goes unused even though that is not the case.

With this patch, if both `-p` and `-pg` are passed, the argument that is
passed second will take precedence. `-p` will still throw an error on
unsupported platforms, regardless of precedence.

This revision includes a test case, which has been placed in
`clang/test/Driver/zos-profiling-error.c`. As a result,
`zos-profiling-error.c` has been renamed to `ibm-profiling.c`. This
revision also passes `clang/test/Driver/aix-ld.c`.

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

19 months ago[lldb] Update PythonDataObjectsTests for new exception formatting
Jonas Devlieghere [Wed, 15 Mar 2023 22:44:17 +0000 (15:44 -0700)]
[lldb] Update PythonDataObjectsTests for new exception formatting

PythonDataObjectsTest.TestExceptions started failing because the output
of the python traceback printers is now consistent between python and
cpython [1]. Work around the issue by supporting both variants.

Thanks to Ismail for identifying the root cause.

[1] https://github.com/python/cpython/issues/85203

19 months ago[libc][NFC] Clean up clang-tidy warnings for `src/__support` and `src/math`.
Tue Ly [Tue, 14 Mar 2023 14:50:02 +0000 (10:50 -0400)]
[libc][NFC] Clean up clang-tidy warnings for `src/__support` and `src/math`.

Clean up some warnings from running libc-lint for these folders.

Reviewed By: michaelrj, sivachandra

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

19 months agoConstantFolding: Minor cleanups for is_fpclass
Matt Arsenault [Wed, 15 Mar 2023 15:14:49 +0000 (11:14 -0400)]
ConstantFolding: Minor cleanups for is_fpclass

19 months agoRevert "[RISCV] Enable interleaved access vectorization"
Luke Lau [Wed, 15 Mar 2023 22:00:48 +0000 (22:00 +0000)]
Revert "[RISCV] Enable interleaved access vectorization"

This reverts commit acc03ad10af4f379a644e3956cb9aca54e40696c.

19 months ago[RISCV] Enable interleaved access vectorization
Luke Lau [Thu, 9 Mar 2023 16:18:28 +0000 (16:18 +0000)]
[RISCV] Enable interleaved access vectorization

The loop vectorizer supports generating interleaved loads and stores via
shuffle patterns for fixed length vectors.
This enables it for RISC-V, since interleaved shuffle patterns can be
lowered to vlseg/vsseg in https://reviews.llvm.org/D145022

Reviewed By: reames

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

19 months ago[Clang][Sema] Fix incorrect deletion of default constructors for some unions
Roy Jacobson [Sat, 11 Mar 2023 16:40:44 +0000 (18:40 +0200)]
[Clang][Sema] Fix incorrect deletion of default constructors for some unions

If a union has explicit initializers for some members, we shouldn't delete
its default constructor.
Fixes https://github.com/llvm/llvm-project/issues/48416.

Reviewed By: erichkeane

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

19 months ago[AArch64] Add hex comments to mov-imm spellings in the InstPrinter
Jon Roelofs [Wed, 15 Mar 2023 00:10:05 +0000 (17:10 -0700)]
[AArch64] Add hex comments to mov-imm spellings in the InstPrinter

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

19 months agoRevert "[AArch64] Add hex comments to mov-imm spellings in the InstPrinter"
Jon Roelofs [Wed, 15 Mar 2023 21:21:08 +0000 (14:21 -0700)]
Revert "[AArch64] Add hex comments to mov-imm spellings in the InstPrinter"

This reverts commit 1def3141135c072a1d3e51e82e113dd67b0def97.

19 months ago[AArch64] Add hex comments to mov-imm spellings in the InstPrinter
Jon Roelofs [Wed, 15 Mar 2023 00:10:05 +0000 (17:10 -0700)]
[AArch64] Add hex comments to mov-imm spellings in the InstPrinter

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

19 months ago[AArch64] Change GeneratePerfectShuffle to return one destination operand for zip...
Zain Jaffal [Wed, 15 Mar 2023 20:47:53 +0000 (20:47 +0000)]
[AArch64] Change GeneratePerfectShuffle to return one destination operand for zip and transpose operations.

The tests added where crashing because zip instruction was returning two destination operands. ZIP according to arm returns only one destination operand.

Reviewed By: dmgreen, fhahn

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

19 months agoRevert "[lldb] Change dwim-print to default to disabled persistent results"
Dave Lee [Wed, 15 Mar 2023 20:59:46 +0000 (13:59 -0700)]
Revert "[lldb] Change dwim-print to default to disabled persistent results"

This reverts commit 8bad4ae679df6fc7dbd016dccbd3da34206e836b.

19 months ago[SCEV] Do not strengthen nuw/nsw flags during get[Zero,Sign]ExtendedExpr.
Florian Hahn [Wed, 15 Mar 2023 20:57:32 +0000 (20:57 +0000)]
[SCEV] Do not strengthen nuw/nsw flags during get[Zero,Sign]ExtendedExpr.

Modifying AddRecs when constructing other expressions can lead to
surprising changes. It also seems like it is not really beneficial i
most cases.

At the moment, there's a single regression, but we still might be able
to improve the flags at AddRec construction.

Might help with the issue discussed in D143409.

Reviewed By: mkazantsev

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

19 months ago[mlir][sparse] Modify the pivot selection method for quick sort.
bixia1 [Tue, 14 Mar 2023 23:05:54 +0000 (16:05 -0700)]
[mlir][sparse] Modify the pivot selection method for quick sort.

Previously, we choose the median of three values. We now choose the median of
five values when the number of values being sorted exceed a threshold
(currently 100). This is similar to std::sort.

Reviewed By: aartbik

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

19 months ago[lldb] Change dwim-print to default to disabled persistent results
Dave Lee [Wed, 8 Mar 2023 21:22:00 +0000 (13:22 -0800)]
[lldb] Change dwim-print to default to disabled persistent results

Change `dwim-print` to now disable persistent results by default, unless requested by
the user with the `--persistent-result` flag.

Ex:

```
(lldb) dwim-print 1 + 1
(int) 2
(lldb) dwim-print --persistent-result on -- 1 + 1
(int) $0 = 2
```

Users who wish to enable persistent results can make and use an alias that includes
`--persistent-result on`.

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