platform/upstream/llvm.git
13 months ago[mlir][tensor] More static padding sizes for PadOp
Matthias Springer [Fri, 30 Jun 2023 10:44:48 +0000 (12:44 +0200)]
[mlir][tensor] More static padding sizes for PadOp

Improve `tensor::createPadHighOp`: more static padding sizes when possible.

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

13 months ago[mlir][Affine] Delete duplicate code: `applyMapToValues`
Matthias Springer [Fri, 30 Jun 2023 10:44:33 +0000 (12:44 +0200)]
[mlir][Affine] Delete duplicate code: `applyMapToValues`

The same functionality is provided by `makeComposedFoldedAffineApply`.

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

13 months ago[mlir][NFC] Clean up builder usage around constants/non-foldable ops
Matthias Springer [Fri, 30 Jun 2023 10:44:18 +0000 (12:44 +0200)]
[mlir][NFC] Clean up builder usage around constants/non-foldable ops

* Use `create` instead of `createOrFold` for constant ops. Constants cannot be folded any further.
* Use `create` instead of `createOrFold` for ops that do not have a folder.
* Use C++ op builders that take an `int` instead of creating a `ConstantIndexOp`.
* Create `tensor::DimOp` instead of `linalg::createOrFoldDimOp` when it is certain that the operand is a tensor.

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

13 months ago[tests] precommit test for MachineLICM subloops
Jingu Kang [Fri, 30 Jun 2023 11:34:21 +0000 (12:34 +0100)]
[tests] precommit test for MachineLICM subloops

13 months agoRevert "clang: Use new frexp intrinsic for builtins and add f16 version"
Hans Wennborg [Fri, 30 Jun 2023 11:14:17 +0000 (13:14 +0200)]
Revert "clang: Use new frexp intrinsic for builtins and add f16 version"

This caused asserts in some Android and Windows builds:

SelectionDAGNodes.h:1138: llvm::SDValue::SDValue(SDNode *, unsigned int):
Assertion `(!Node || !ResNo || ResNo < Node->getNumValues()) && "Invalid result number for the given node!"' failed.

See comment on https://github.com/llvm/llvm-project/commit/85bdea023f5116f789095b606554739403042a21

Also revert "HIP: Use frexp builtins in math headers"
which seems to depend on this change.

This reverts commit 85bdea023f5116f789095b606554739403042a21.
This reverts commit bf8e92c0e792cbe3c9cc50607a1e33c6912ffd0e.

13 months ago[AArch64] Fold tree of offset loads combine
David Green [Fri, 30 Jun 2023 11:25:07 +0000 (12:25 +0100)]
[AArch64] Fold tree of offset loads combine

This attempts to fold trees of add(ext(load p), shl(ext(load p+4)) into a
single load of twice the size, that we extract the bottom part and top part so
that the shl can start to use a shll2 instruction. The two loads in that
example can also be larger trees of instructions, which are identical except
for the leaves which are all loads offset from the LHS, including buildvectors
of multiple loads. For example:
sub(zext(buildvec(load p+4, load q+4)), zext(buildvec(load r+4, load s+4)))

Whilst it can be common for the larger loads to replace LDP instructions (which
doesn't gain anything on its own), the larger loads in buildvectors can help
create more efficient code, and prevent the need for ld1 lane inserts which can
be more expensive than continuous loads.

This creates a fairly niche, fairly large combine that attempts to be fairly
general where it is beneficial. It helps some SLP vectorized code to avoid the
use of the more expensive ld1 lane inserting loads.

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

13 months ago[AArch64] Codegen tests for fold from D153972. NFC
David Green [Fri, 30 Jun 2023 10:21:26 +0000 (11:21 +0100)]
[AArch64] Codegen tests for fold from D153972. NFC

13 months ago[LV] Add additional tests with dead vector epilogues.
Florian Hahn [Fri, 30 Jun 2023 11:17:56 +0000 (12:17 +0100)]
[LV] Add additional tests with dead vector epilogues.

13 months ago[ARM] armv6m eXecute Only (XO) long branch Thunk
Keith Walker [Thu, 22 Jun 2023 13:53:13 +0000 (14:53 +0100)]
[ARM] armv6m eXecute Only (XO) long branch Thunk

This patch adds a thunk for Thumb long branch on V6-M for eXecute Only.

Note that there is currently no support for a position independant and
eXecute Only V6-M long branch thunk

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

13 months ago[DAG][AArch64] Fold shuffle_vector<4,5,6,7> to extract_subvector
David Green [Fri, 30 Jun 2023 10:13:39 +0000 (11:13 +0100)]
[DAG][AArch64] Fold shuffle_vector<4,5,6,7> to extract_subvector

During legalization, we can end up with shuffles that are identity masks, so
act like extract_subvector, but do not simplify to extract_subvector. This
adjusts the profitability heuristic in foldExtractSubvectorFromShuffleVector to
allow identity vectors that do not start at element 0. Undef masks elements are
excluded as it can be more useful to keep the undef elements.

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

13 months agoRevert "Reland [SLP] Provide an universal interface for FixedVectorType::get. NFC."
Nikita Popov [Fri, 30 Jun 2023 09:27:44 +0000 (11:27 +0200)]
Revert "Reland [SLP] Provide an universal interface for FixedVectorType::get. NFC."

This reverts commit 19b1d3bd7eeecbeb1e45045960faf325c7bc5c64.

Both the commit and the review are missing a patch description.

13 months agoAdd [mlir][nvvm] `mbarrier.test.wait`
Guray Ozen [Thu, 29 Jun 2023 12:49:19 +0000 (14:49 +0200)]
Add [mlir][nvvm] `mbarrier.test.wait`

This work adds `mbarrier.test.wait` and `mbarrier.test.wait.shared` Ops in NVVM dialect. Since they are already implemented in the LLVM kernel, it only calls createIntrinsicCall.

Reviewed By: qcolombet

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

13 months ago[mlir] Add result to mbarrier.arrive
Guray Ozen [Thu, 29 Jun 2023 10:09:31 +0000 (12:09 +0200)]
[mlir] Add result to mbarrier.arrive

`mbarrier.arrive` returns token. This PR adds result to these ops.

Reviewed By: qcolombet

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

13 months ago[lldb] Check that qLaunchGDBServer packet does not return an error
David Spickett [Thu, 22 Jun 2023 09:15:34 +0000 (09:15 +0000)]
[lldb] Check that qLaunchGDBServer packet does not return an error

While looking at https://github.com/llvm/llvm-project/issues/61955
I noticed that when we send qLaunchGDBServer we check that we got a response
but not what kind of response it was.

I think this was why the bug reporter saw:
(lldb) run
error: invalid host:port specification: '[192.168.64.2]'

The missing port is because we went down a path we only should have
chosen if the operation succeeded. Since we didn't check, we went ahead
with an empty port number.

To test this I've done the following:
* Make a temporary copy of lldb-server.
* Run that as a platform.
* Remove the copy.
* Attempt to create and run a target.

This fails because the running lldb-server will try to invoke itself
and it no longer exists.

Reviewed By: jasonmolenda

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

13 months ago[clang][Interp][NFC] Add type checks to InterpStack::peek()
Timm Bäder [Fri, 30 Jun 2023 06:26:36 +0000 (08:26 +0200)]
[clang][Interp][NFC] Add type checks to InterpStack::peek()

13 months ago[clang][Diagnostics] Fix diagnostic line numbers
Timm Bäder [Tue, 27 Jun 2023 09:33:22 +0000 (11:33 +0200)]
[clang][Diagnostics] Fix diagnostic line numbers

The first line of the code snippet we print is potentially lower than
the caret line, so handle that case.

Fixes #63524

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

13 months ago[clang] Do not discard cleanups while processing immediate invocation
Mariya Podchishchaeva [Fri, 30 Jun 2023 08:21:43 +0000 (04:21 -0400)]
[clang] Do not discard cleanups while processing immediate invocation

Since an immediate invocation is a full expression itself - it requires
an additional ExprWithCleanups node, but it can participate to a bigger
full expression which actually requires cleanups to be run after.

Thanks @ilya-biryukov for helping reducing the reproducer and confirming
that the analysis is correct.

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

Reviewed By: ilya-biryukov

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

13 months ago[clang] NFC, replace llvm::writeFileAtomically with llvm::writeToOutput API inGlobalM...
Haojian Wu [Fri, 30 Jun 2023 08:28:01 +0000 (10:28 +0200)]
[clang] NFC, replace llvm::writeFileAtomically with llvm::writeToOutput API inGlobalModuleIndex.cpp

We're in favor of writeToOutput.

13 months ago[clang][analyzer] No end-of-file when seek to file begin.
Balázs Kéri [Fri, 30 Jun 2023 07:40:30 +0000 (09:40 +0200)]
[clang][analyzer] No end-of-file when seek to file begin.

If `fseek` is used with 0 position and SEEK_SET it sets the position
to the start of the file. This should not cause FEOF (end of file) error.
The case of an empty file is not handled for simplification.
It is not exactly defined in what cases `fseek` produces the different
error states. Normally feof should not happen at all because it is
possible to set the position after the end of file, but previous tests
showed that still feof (and any other error cases) can happen.

Reviewed By: donat.nagy

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

13 months ago[clang] NFC, replace llvm::writeFileAtomically with llvm::writeToOutput
Haojian Wu [Fri, 30 Jun 2023 08:17:10 +0000 (10:17 +0200)]
[clang] NFC, replace llvm::writeFileAtomically with llvm::writeToOutput
API in ASTUnit.cpp

writeFileAtomically is going to be deprecated, in favor of
writeToOutput.

13 months agoReland [BOLT][Instrumentation] Add mmap return value assertions
Denis Revunov [Thu, 29 Jun 2023 21:14:45 +0000 (00:14 +0300)]
Reland [BOLT][Instrumentation] Add mmap return value assertions

In a very rare case that mmap call fails, we'll at least get a message
instead of segfault.

Reviewed By: rafauler, Amir
Differential Revision: https://reviews.llvm.org/D154056

13 months agoReland [BOLT][Instrumentation][NFC] define and use mmap flags
Denis Revunov [Thu, 29 Jun 2023 08:57:48 +0000 (11:57 +0300)]
Reland [BOLT][Instrumentation][NFC] define and use mmap flags

Reviewed By: rafauler, Amir
Differential Revision: https://reviews.llvm.org/D154056

13 months ago[clangd] Replace writeFileAtomically with writeToOutput, NFC
Haojian Wu [Fri, 30 Jun 2023 07:52:24 +0000 (09:52 +0200)]
[clangd] Replace writeFileAtomically with writeToOutput, NFC

We're going to deprecate the writeFileAtomically API, in favour of
writeToOutput.

13 months agoRevert "[AMDGPU] Mark mbcnt as convergent"
Sameer Sahasrabuddhe [Fri, 30 Jun 2023 07:40:44 +0000 (13:10 +0530)]
Revert "[AMDGPU] Mark mbcnt as convergent"

This reverts commit 37114036aa57e53217a57afacd7f47b36114edfb.

The output of mbcnt does not depend on other active lanes, and hence it is not
convergent. The original change was made as a possible fix for

https://github.com/ROCm-Developer-Tools/HIP/issues/3172

But changing mbcnt does not fix that issue.

Reviewed By: ruiling, foad, yaxunl

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

13 months ago[AArch64] Add patterns for scalar FMUL, FMULX
OverMighty [Fri, 30 Jun 2023 07:34:20 +0000 (08:34 +0100)]
[AArch64] Add patterns for scalar FMUL, FMULX

Scalar FMUL, FMULX instructions perform better or the same compared to indexed
FMUL, FMULX.

For example, the Arm Cortex-A55 Software Optimization Guide lists the following
instructions with a throughput of 2 IPC:
 - "FP multiply" FMUL
 - "ASIMD FP multiply" FMULX

whereas it lists the following with a throughput of 1 IPC:
 - "ASIMD FP multiply, by element" FMUL, FMULX

The Arm Cortex-A510 Software Optimization Guide, however, does not separately
list "by element" variants of the "ASIMD FP multiply" instructions, which are
listed with the same throughput as the non-ASIMD ones.

Fixes #60817.

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

13 months ago[flang][hlfir] Codegen of hlfir.region_assign where LHS conflicts
Jean Perier [Fri, 30 Jun 2023 06:48:42 +0000 (08:48 +0200)]
[flang][hlfir] Codegen of hlfir.region_assign where LHS conflicts

When the analysis of hlfir.region_assign determined that the LHS region
evaluation may be impacted by the assignment effects, all LHS must be
fully evaluated and saved before any assignment is done.

This patch adds TemporaryStorage variants to save address, including
vector subscripted entities addresses whose shape must be saved.
It uses the DescriptorStack runtime to deal with complex cases inside
forall. For the sake of simplicity, this is also used for vector
subscripted LHS outside of foralls (each element address is saved as
a descriptor on this stack. This is a bit suboptimal, but it is a safe
start that will work with all kinds of type (polymorphic, PDTs...)
without further work). Another approach would be to saved only the
values that are conflicting in the LHS computation, but this would
require a much more complex analysis of the LHS region DAG.

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

13 months ago[Support] Don't set "all_exe" mode by default for file written by llvm::writeToOutput
Haojian Wu [Fri, 23 Jun 2023 18:01:31 +0000 (20:01 +0200)]
[Support] Don't set "all_exe" mode by default for file written by llvm::writeToOutput

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

13 months ago[NFC][X86] Add missing CPUID related changes for AMX-COMPLEX.
Freddy Ye [Fri, 30 Jun 2023 07:15:37 +0000 (15:15 +0800)]
[NFC][X86] Add missing CPUID related changes for AMX-COMPLEX.

13 months ago[mlir][affinexpr] add parseAffineExpr to parser API
Aart Bik [Fri, 30 Jun 2023 03:13:33 +0000 (20:13 -0700)]
[mlir][affinexpr] add parseAffineExpr to parser API

Similar to AffineMap and IntegerSet parsing, this change makes the more fine-grained AffineExpr available for general parsing, using a preset symbol set to recognize variables.

Motivation:
The AffineExpr parser will be used by the new sparse tensor encoding surface syntax. Originally, we planned to duplicate the affine parser completely, but that would be a terrible waste of a good thing. With this minor API change, we prepare the way for the sparse tensor dialect (and others) to reuse the AffineExpr parser outside the context of a more restricted AffineMap parser.

Reviewed By: Peiming

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

13 months ago[Coroutines] Don't transform cmpinst prematurely in simplifyTerminatorLeadingToRet
Chuanqi Xu [Fri, 30 Jun 2023 05:59:39 +0000 (13:59 +0800)]
[Coroutines] Don't transform cmpinst prematurely in simplifyTerminatorLeadingToRet

Previously, we would try to transform cmpinst in
simplifyTerminatorLeadingToRet if we found it was a constant. However,
this is incorrect.

Since the resolved constants in simplifyTerminatorLeadingToRet are not
truely constants. They are basically constants along cerntain code
paths.

In this way, it is clearly incorrect to transform the compare
instruction to a constant.

It will cause confusing miscompilations. This patch tries to fix this.

13 months agoReland [SLP] Provide an universal interface for FixedVectorType::get. NFC.
Han-Kuan Chen [Thu, 29 Jun 2023 17:07:02 +0000 (10:07 -0700)]
Reland [SLP] Provide an universal interface for FixedVectorType::get. NFC.

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

13 months ago[NFC][X86] Correct tests with wrong locations before.
Freddy Ye [Fri, 30 Jun 2023 06:14:31 +0000 (14:14 +0800)]
[NFC][X86] Correct tests with wrong locations before.

13 months ago[Attributor][NFCI] Remove the (already "unused") ModuleSlice
Johannes Doerfert [Fri, 30 Jun 2023 05:07:14 +0000 (22:07 -0700)]
[Attributor][NFCI] Remove the (already "unused") ModuleSlice

At some point we alloed the CGSCC traversal to look at the entire module
slice (see definition below). However, we don't allow that anymore,
mostly for compile time and complexity reasons. Consequently, there is
no need to build the ModuleSlice as we can replacve it with the SCC
wherever it was still used.

13 months ago[Attributor][NFCI] Avoid creating unnecessary AAs
Johannes Doerfert [Fri, 30 Jun 2023 04:52:03 +0000 (21:52 -0700)]
[Attributor][NFCI] Avoid creating unnecessary AAs

If the IR has a boolean attribute, or the function is not IPO amendable,
we can avoid creating AAs that would just be forced into a trivial
fixpoint anyway. Since we check boolean IR attributes via
`AA::hasAssumedIRAttr`, we don't need AAs even if they would be fixed
optimistic right away. The only change is in the dependency graph
ordering as we move AAs around to simplify the code flow. There is no
reason for the order we seed AAs, so this order is just as fine.

13 months agolit::max-failures.py is flaky and hangs randomly on multi-core systems.
Galina Kistanova [Fri, 30 Jun 2023 06:06:38 +0000 (23:06 -0700)]
lit::max-failures.py is flaky and hangs randomly on multi-core systems.

13 months ago[BOLT][NFC] Simplify postProcessJumpTables
Amir Ayupov [Fri, 30 Jun 2023 05:21:44 +0000 (22:21 -0700)]
[BOLT][NFC] Simplify postProcessJumpTables

Reviewed By: #bolt, rafauler

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

13 months ago[loop-deletion] Overly defensive with undef-ing dbg.values.
Carlos Alberto Enciso [Fri, 30 Jun 2023 05:09:44 +0000 (06:09 +0100)]
[loop-deletion] Overly defensive with undef-ing dbg.values.

Explicitly inserting undef is overly defensive. Any values computed
nside the loop that are referenced by dbg.values should naturally
become undef when the loop is deleted, and all other values that
are loop invariant must be preserved.

Reviewed By: scott.linder

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

13 months ago[x86] Add missing FeatureCMOV in frontend targets.
Freddy Ye [Fri, 30 Jun 2023 05:17:22 +0000 (13:17 +0800)]
[x86] Add missing FeatureCMOV in frontend targets.

The missing info is gathered from X86.td.

Reviewed By: craig.topper

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

13 months agoRevert "[BOLT][Instrumentation][NFC] define and use mmap flags"
Amir Aupov [Fri, 30 Jun 2023 05:11:17 +0000 (22:11 -0700)]
Revert "[BOLT][Instrumentation][NFC] define and use mmap flags"

This reverts commit f0b45fba4b64ab0b5d6c50d978e02f0d12d4d070.

The stack broke https://lab.llvm.org/buildbot/#/builders/252.

13 months agoRevert "[BOLT][Instrumentation] Add mmap return value assertions"
Amir Aupov [Fri, 30 Jun 2023 05:10:31 +0000 (22:10 -0700)]
Revert "[BOLT][Instrumentation] Add mmap return value assertions"

This reverts commit 8f7c53ef81c17ae9d773818181d04ef1c3890912.

The stack broke https://lab.llvm.org/buildbot/#/builders/252.

13 months ago[NFC] cleanup of parser
Aart Bik [Fri, 30 Jun 2023 03:54:51 +0000 (20:54 -0700)]
[NFC] cleanup of parser

This revision fixes a typo, where printIntegerSet() was used where it should have been parseIntegerSet().It also removes a dangling getDimsAndSymbolSSAIds() declaration that is never used.

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

13 months agoRevert "[SLP] Provide an universal interface for FixedVectorType::get. NFC."
Arthur Eubanks [Fri, 30 Jun 2023 04:45:24 +0000 (21:45 -0700)]
Revert "[SLP] Provide an universal interface for FixedVectorType::get. NFC."

This reverts commit fcd58ea50c218b61a58d6815b9d15bad7dbc75a3.

Causes crashes, see comments on D154114.

13 months ago[M68k][MC] Add support for 32 bit register-register multiply/divide
Ian Douglas Scott [Fri, 30 Jun 2023 03:53:22 +0000 (20:53 -0700)]
[M68k][MC] Add support for 32 bit register-register multiply/divide

Previously when targeting 68020+, instruction selection attempted to
emit a 32-bit register-register multiplication, but failed at instruction
selection. With this, it succeeds.

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

13 months ago[gn build] Port b5270ba20dc3
Arthur Eubanks [Fri, 30 Jun 2023 04:24:04 +0000 (21:24 -0700)]
[gn build] Port b5270ba20dc3

13 months ago[gn build] Port 853b2a84cb99
Arthur Eubanks [Fri, 30 Jun 2023 04:24:03 +0000 (21:24 -0700)]
[gn build] Port 853b2a84cb99

13 months agoRevert "[MC,x86-32] Remove a gold<2.34 workaround"
Arthur Eubanks [Fri, 30 Jun 2023 04:19:07 +0000 (21:19 -0700)]
Revert "[MC,x86-32] Remove a gold<2.34 workaround"

This reverts commit a699921baa91e6c2979ec0f0482430c57f51761d.

Seems to cause miscompiles (https://crbug.com/1459232), following up with author.

13 months ago[RISCV] Mark zvkn* and zvks* extensions as enabled when all their subextensions are.
Craig Topper [Fri, 30 Jun 2023 03:58:55 +0000 (20:58 -0700)]
[RISCV] Mark zvkn* and zvks* extensions as enabled when all their subextensions are.

These extensions don't contain any instructions on their own, they
are just aliases for a set of extensions. We should set the preprocessor
define anytime all the sub-extensions are supported.

Reviewed By: kito-cheng, eopXD

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

13 months ago[CSKY] Optimize subtraction with SUBI32/SUBI16
Ben Shi [Tue, 20 Jun 2023 10:00:56 +0000 (18:00 +0800)]
[CSKY] Optimize subtraction with SUBI32/SUBI16

Reviewed By: zixuan-wu

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

13 months ago[flang] Reinstate class query test
V Donaldson [Fri, 30 Jun 2023 03:23:56 +0000 (20:23 -0700)]
[flang] Reinstate class query test

Remove kind=10 test variant, which is not universally supported.

13 months ago[LoongArch] Reuse LoongArchRegWithSubRegs class to shorten some code in LoongArchRegi...
wanglei [Tue, 11 Apr 2023 03:48:42 +0000 (11:48 +0800)]
[LoongArch] Reuse LoongArchRegWithSubRegs class to shorten some code in LoongArchRegisterInfo.td. NFC

13 months ago[RISCV][NFC] Replace Join with !interleave
wangpc [Fri, 30 Jun 2023 03:01:58 +0000 (11:01 +0800)]
[RISCV][NFC] Replace Join with !interleave

Reviewed By: craig.topper

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

13 months ago[RISCV][NFC] Format TableGen files and remove unused defs
wangpc [Fri, 30 Jun 2023 02:51:41 +0000 (10:51 +0800)]
[RISCV][NFC] Format TableGen files and remove unused defs

Make sure there is no single line for '{' to be consistent with
other codes.

`InvalidIndex` is removed since it's unused now. And comments are
updated.

Reviewed By: craig.topper

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

13 months agoRevert "[BOLT][Instrumentation] Don't share counters when using append-pid"
Amir Ayupov [Fri, 30 Jun 2023 02:54:29 +0000 (19:54 -0700)]
Revert "[BOLT][Instrumentation] Don't share counters when using append-pid"

This reverts commit 02c3724d43840339fdc91d21747e96b5f7405bb0.

This change breaks instrumented Clang:
https://lab.llvm.org/buildbot/#/builders/252/builds/2700

13 months agoRevert "[BOLT][Instrumentation] Put Allocator itslef in shared memory by default"
Amir Ayupov [Fri, 30 Jun 2023 02:29:36 +0000 (19:29 -0700)]
Revert "[BOLT][Instrumentation] Put Allocator itslef in shared memory by default"

This reverts commit ad4e0770ca7ebbc4dd6635b17421819b2393aa33.
Breaks BOLT upstream testing:
https://lab.llvm.org/buildbot/#/builders/244/builds/13736

13 months ago[flang] test update
V Donaldson [Fri, 30 Jun 2023 01:28:11 +0000 (18:28 -0700)]
[flang] test update

13 months ago"fp" -> "flags" typeo in description of generic registers
Jason Molenda [Fri, 30 Jun 2023 01:21:57 +0000 (18:21 -0700)]
"fp" -> "flags" typeo in description of generic registers

the list of generic registers is meant to include
LLDB_REGNUM_GENERIC_FLAGS but it copy & pasted the
name "fp".

rdar://100857252

13 months ago[OpenMPOpt][FIX] Internalization is an IR change too
Johannes Doerfert [Fri, 30 Jun 2023 01:02:20 +0000 (18:02 -0700)]
[OpenMPOpt][FIX] Internalization is an IR change too

The bots reported that we changed the IR w/o reporting it. The reason
was that internalization was not reported as changed. Forwarding the
result solves the problem.

Test coverage via
llvm/test/Transforms/Attributor/reduced/openmp_opt_constant_type_crash.ll

13 months ago[AArch64][MachO] Drop a 2015 ld64 workaround avoiding local relocations
Fangrui Song [Fri, 30 Jun 2023 00:59:15 +0000 (17:59 -0700)]
[AArch64][MachO] Drop a 2015 ld64 workaround avoiding local relocations

Commit d6223a24718df3c30b67422c2eb6d0e93af9c4e8 introduced an ld64 workaround
that disables local relocations for many pointer-sized relocations (e.g.
relocations referencing `__DATA,__literal*`).

ld64 has been fixed long ago (2015). Drop this workaround so that the
behavior matches x86-64.

Reviewed By: pete

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

13 months agoRecognize BSS-only DATA segments as sections that need to be slid
Jason Molenda [Fri, 30 Jun 2023 00:50:21 +0000 (17:50 -0700)]
Recognize BSS-only DATA segments as sections that need to be slid

ObjectFileMachO::SetLoadAddress() should allow for a DATA segment
that has no file content to be slid in the vmaddr, it is valid
to have such a section.

Differential Revision: https://reviews.llvm.org/D154037
rdar://99744343

13 months ago[flang] Test update
V Donaldson [Fri, 30 Jun 2023 00:42:05 +0000 (17:42 -0700)]
[flang] Test update

13 months ago[PowerPC][NFC] add SADDO/SSUBO test case
Ting Wang [Fri, 30 Jun 2023 00:35:59 +0000 (20:35 -0400)]
[PowerPC][NFC] add SADDO/SSUBO test case

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

Reviewed By: qiucf

13 months ago[PowerPC][NFC] expose issue on absol-jump-table-enabled.ll (relocation-model=pic...
Ting Wang [Fri, 30 Jun 2023 00:32:15 +0000 (20:32 -0400)]
[PowerPC][NFC] expose issue on absol-jump-table-enabled.ll (relocation-model=pic + ppc-use-absolute-jumptables)

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

13 months ago[SLP] Provide an universal interface for FixedVectorType::get. NFC.
Han-Kuan Chen [Thu, 29 Jun 2023 17:07:02 +0000 (10:07 -0700)]
[SLP] Provide an universal interface for FixedVectorType::get. NFC.

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

13 months agoAdd 'target dump section-load-list' for lldb debugging
Jason Molenda [Fri, 30 Jun 2023 00:01:16 +0000 (17:01 -0700)]
Add 'target dump section-load-list' for lldb debugging

A command to dump the Target's SectionLoadList, to debug
possible issues with the table.

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

13 months ago[flang] IEEE_ARITHMETIC intrinsic module procedures
V Donaldson [Thu, 29 Jun 2023 18:32:56 +0000 (11:32 -0700)]
[flang] IEEE_ARITHMETIC intrinsic module procedures

Implement

 - IEEE_CLASS
 - IEEE_COPY_SIGN
 - IEEE_GET_ROUNDING_MODE
 - IEEE_IS_FINITE
 - IEEE_IS_NAN
 - IEEE_IS_NEGATIVE
 - IEEE_IS_NORMAL
 - IEEE_SET_ROUNDING_MODE
 - IEEE_SIGNBIT
 - IEEE_SUPPORT_ROUNDING
 - IEEE_UNORDERED
 - IEEE_VALUE

for all REAL kinds (2, 3, 4, 8, 10, 16) where applicable.

13 months ago[RISCV] Rename a couple of binary vector td classes/multiclasses
Philip Reames [Thu, 29 Jun 2023 23:10:32 +0000 (16:10 -0700)]
[RISCV] Rename a couple of binary vector td classes/multiclasses

These used a different naming scheme than the rest of the file.  The base class itself isn't too confusing - it's just a TA suffix vs the usual unsuffixed.  However, the multiclass having a TA suffix while defining all three of TA, TU, and MASK was rather confusing.

13 months ago[Clang] Fix crash in isCXXDeclarationSpecifier when attempting to annotate template...
Shafik Yaghmour [Thu, 29 Jun 2023 22:38:14 +0000 (15:38 -0700)]
[Clang] Fix crash in isCXXDeclarationSpecifier when attempting to annotate template name

When attempting to decide if in C++17 a type template for class template
argument deduction and the code is ill-formed the condition to break is
checking the current token is an identifier when it should be checking
if the next token is not ::.

This fixes: https://github.com/llvm/llvm-project/issues/57495
https://github.com/llvm/llvm-project/issues/63052

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

13 months ago[libc++][Modules] Make module exports consistent with header includes
Ian Anderson [Mon, 26 Jun 2023 22:07:24 +0000 (15:07 -0700)]
[libc++][Modules] Make module exports consistent with header includes

Some modules export modules that they don't import (i.e. that their header doesn't directly include). That sometimes works when the exported submodule is in the same module, but when the `std` mega module is broken up (D144322), some of the exports stop working. Make the exports and includes consistent, either by adding includes for the exports, or by removing exports for missing includes.

The `concepts.equality_comparable` export in `std.iterator.__iterator.concepts` isn't doing anything because 1) it's resolved as `std.iterator.__iterator.concepts.equality_comparable` and 2) there's a `__concepts` submodule in between `std.concepts` and `equality_comparable`. Fix it to be `std.concepts.__concepts.equality_comparable`.

<span> is listed in both `std.span` and `std.experimental.span`. Delete the latter module.
There is no `__errc` module or header, so remove that export from `std.system_error`.

Reviewed By: ldionne, #libc

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

13 months agoAdjust tests in 632dd6a4ca0036009f for ARM host
Yuanfang Chen [Thu, 29 Jun 2023 22:33:00 +0000 (15:33 -0700)]
Adjust tests in 632dd6a4ca0036009f for ARM host

size_t is unsigned int on ARM.

13 months ago[Flang] [OpenMP] [Semantics] Change SIMD ALIGNED clause support from parsing a std...
Raghu Maddhipatla [Fri, 9 Jun 2023 23:27:35 +0000 (18:27 -0500)]
[Flang] [OpenMP] [Semantics] Change SIMD ALIGNED clause support from parsing a std::list<Name> to OmpObjectlist

This is an assisting patch which is implemented to address review comment to switch std::list<Name> to OmpObjectlist from https://reviews.llvm.org/D142722.

Also addressed a semantic check https://github.com/llvm/llvm-project/issues/61161 OpenMP 5.2 standard states that only pointer variables (C_PTR, Cray pointers, POINTER or ALLOCATABLE items) can appear in SIMD aligned clause (section 5.11). And not to allow common block names on an ALIGNED clause.

Reviewed By: kiranchandramohan

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

13 months ago[BOLT][Instrumentation] Add dumping function to instrumentation hash tables
Denis Revunov [Tue, 20 Jun 2023 15:04:17 +0000 (15:04 +0000)]
[BOLT][Instrumentation] Add dumping function to instrumentation hash tables

Since there are no other means to debug the instrumentation library
other than using stdout, having a function to print hash table entries
is very useful.

Reviewed By: rafauler, Amir
Differential Revision: https://reviews.llvm.org/D153771

13 months ago[BOLT][Instrumentation] Disallow combining append-pid with sleep-time/wait-forks
Denis Revunov [Wed, 21 Jun 2023 07:21:50 +0000 (07:21 +0000)]
[BOLT][Instrumentation] Disallow combining append-pid with sleep-time/wait-forks

The point of instrumentation-sleep-time option is to have a watcher
process which shares memory with all other forks and dumps a common
profile each n seconds. Combining it with append-pid suggests that we
should get a private profile of each fork every n seconds, but such
behavior is not implemented currently and is not easy to implement in
general, because we somehow need to intercept each individual fork,
launch a watcher process just for that fork, and also map counters so
that they're only shared with that single fork. Since we're not doing
it, we just disallow such combination of options.

Reviewed By: rafauler, Amir
Differential Revision: https://reviews.llvm.org/D153771

13 months ago[BOLT][Instrumentation] Put Allocator itslef in shared memory by default
Denis Revunov [Tue, 20 Jun 2023 15:00:36 +0000 (15:00 +0000)]
[BOLT][Instrumentation] Put Allocator itslef in shared memory by default

In absence of instrumentation-file-append-pid option,
global allocator uses shared pages for allocation. However, since it is a
global variable, it gets COW'd after fork if instrumentation-sleep-time
is used, or if a process forks by itself. This means it handles the same
pages to every process which causes hash table corruption. Thus, if we
want shared pages, we need to put the allocator itself in a shared page,
which we do in this commit in __bolt_instr_setup.
I also added a couple of assertions to sanity-check the hash table.

Reviewed By: rafauler, Amir
Differential Revision: https://reviews.llvm.org/D153771

13 months ago[BOLT][Instrumentation] Don't share counters when using append-pid
Denis Revunov [Thu, 15 Jun 2023 15:43:04 +0000 (15:43 +0000)]
[BOLT][Instrumentation] Don't share counters when using append-pid

The point of append-pid option is to record separate profiles for
separate forks, which is impossible when counters are the same for
every process. It leads to a sum of all profiles in every file, plus
GlobalWriteProfileMutex located in a shared memory prevents some
processes from dumping their data at all.

Reviewed By: rafauler, Amir
Differential Revision: https://reviews.llvm.org/D153771

13 months ago[BOLT][Instrumentation] Add mmap return value assertions
Denis Revunov [Thu, 29 Jun 2023 21:14:45 +0000 (00:14 +0300)]
[BOLT][Instrumentation] Add mmap return value assertions

In a very rare case that mmap call fails, we'll at least get a message
instead of segfault.

Reviewed By: rafauler, Amir
Differential Revision: https://reviews.llvm.org/D154056

13 months ago[BOLT][Instrumentation][NFC] define and use mmap flags
Denis Revunov [Thu, 29 Jun 2023 08:57:48 +0000 (11:57 +0300)]
[BOLT][Instrumentation][NFC] define and use mmap flags

Reviewed By: rafauler, Amir
Differential Revision: https://reviews.llvm.org/D154056

13 months agoFix -Wunused-variable in release build.
Haojian Wu [Thu, 29 Jun 2023 22:02:05 +0000 (00:02 +0200)]
Fix -Wunused-variable in release build.

13 months ago[AMDGPU] Reserve SGPR pair when long branches are present
Brendon Cahoon [Thu, 29 Jun 2023 20:37:56 +0000 (15:37 -0500)]
[AMDGPU] Reserve SGPR pair when long branches are present

Branch relaxation requires 2 additional SGPRs for AMDGPU to handle the
case when an indirect branch target is too far away. The register
scavanger may not find available registers, which causes a “did not find
scavenging index” assert to occur in assignRegToScavengingIndex.

In this patch, we estimate before register allocation whether an
indirect branch is likely to be needed, and reserve 2 SGPRs if the
branch distance is found to be above a threshold. The distance threshold
is an approximation as the exact code size and branch distance are
unknown prior to register allocation.

Patch by Corbin Robeck. Thanks!

Differential Review: https://reviews.llvm.org/D149775

13 months ago[libc++] Remove the legacy debug mode.
varconst [Thu, 29 Jun 2023 21:49:45 +0000 (14:49 -0700)]
[libc++] Remove the legacy debug mode.

See https://discourse.llvm.org/t/rfc-removing-the-legacy-debug-mode-from-libc/71026

Reviewed By: #libc, Mordante, ldionne

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

13 months ago[Clang] Implements CTAD for aggregates P1816R0 and P2082R1
Yuanfang Chen [Thu, 1 Dec 2022 02:44:10 +0000 (18:44 -0800)]
[Clang] Implements CTAD for aggregates P1816R0 and P2082R1

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

13 months ago[mlir] Remove self-include from BytecodeOpInterface.h (NFC)
philass [Thu, 29 Jun 2023 21:14:00 +0000 (14:14 -0700)]
[mlir] Remove self-include from BytecodeOpInterface.h (NFC)

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

13 months ago[libc++] Stop using __builtin_assume in _LIBCPP_ASSERT
Louis Dionne [Wed, 28 Jun 2023 13:22:34 +0000 (09:22 -0400)]
[libc++] Stop using __builtin_assume in _LIBCPP_ASSERT

__builtin_assume can sometimes worsen code generation. For now, the
guideline seems to be to avoid adding assumptions without a clear
optimization intent. Since _LIBCPP_ASSERT is very general, we can't
have a clear optimization intent at this level, which makes
__builtin_assume the wrong tool for the job -- at least until
__builtin_assume is changed.

See https://discourse.llvm.org/t/llvm-assume-blocks-optimization/71609
for a discussion of this.

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

13 months ago[libc] Enable the 'div' routines on the GPU
Joseph Huber [Thu, 29 Jun 2023 20:03:18 +0000 (15:03 -0500)]
[libc] Enable the 'div' routines on the GPU

This patch simply enables the `div`, `ldiv,` and, `lldiv` functions on
the GPU. This should be straightforward enough.

Reviewed By: jdoerfert

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

13 months ago[Attributor][NFC] Introduce IRP helpers for Attr and Arg handling
Johannes Doerfert [Mon, 19 Jun 2023 21:58:12 +0000 (14:58 -0700)]
[Attributor][NFC] Introduce IRP helpers for Attr and Arg handling

13 months ago[Attributor] Remove now obsolete initialization code
Johannes Doerfert [Fri, 23 Jun 2023 01:32:25 +0000 (18:32 -0700)]
[Attributor] Remove now obsolete initialization code

With the helpers in place to judge AAs [1] we can remove the custom
rolled initialization checking code. This exposed a minor oversight in
the AAMemoryLocation where we did not check the IR before we gave up for
a declaration.

[1] https://github.com/llvm/llvm-project/commit/d33bca840a824f59296230e83181012a0b1ba7ec

13 months ago[flang] Block containing an interface
V Donaldson [Thu, 29 Jun 2023 17:58:05 +0000 (10:58 -0700)]
[flang] Block containing an interface

Name mangling may be invoked for an interface procedure contained in
a block in a context that does not have access to block ID mapping.
Procedures can't be defined inside a block, so name mangling doesn't
need a block map. Relax an assert to account for this.

    block
      interface
        subroutine ss(n) bind(c)
          integer :: n
        end subroutine
      end interface
      call ss(5)
    end block
    end

13 months ago[clang][modules] Avoid serializing all diag mappings in non-deterministic order
Ben Langmuir [Wed, 28 Jun 2023 22:54:17 +0000 (15:54 -0700)]
[clang][modules] Avoid serializing all diag mappings in non-deterministic order

When writing a pcm, we serialize diagnostic mappings in order to
accurately reproduce the diagnostic environment inside any headers from
that module. However, the diagnostic state mapping table contains
entries for every diagnostic ID ever accessed, while we only want to
serialize the ones that are actually modified from their default value.
Futher, we need to serialize them in a deterministic order.

rdar://111477511

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

13 months ago[lld][AArch64] Add BTI landing pad to PLT entries when the symbol is exported.
Daniel Kiss [Thu, 29 Jun 2023 17:31:22 +0000 (19:31 +0200)]
[lld][AArch64] Add BTI landing pad to PLT entries when the symbol is exported.

With relative vtables the caller jumps directly to the plt entries in the shared object,
therefore landing pad is need for these entries.

Reproducer:
main.cpp
```
#include "v.hpp"
int main() {
    A* a = new B();
    a->do_something2();
    return 0;
}
```
v.hpp
```
struct A {
    virtual void do_something() = 0;
    virtual void do_something2();
};
struct B : public A {
    void do_something() override;
    void do_something2() override;
};
```
v.cpp
```
#include "v.hpp"
void A::do_something2() { }
void B::do_something() { }
void B::do_something2() { }
```
```
CC="clang++ --target=aarch64-unknown-linux-gnu -fuse-ld=lld -mbranch-protection=bti"
F=-fexperimental-relative-c++-abi-vtables
${=CC} $F -shared v.cpp -o v.so -z force-bti
${=CC} $F main.cpp -L./ v.so -Wl,-rpath=. -z force-bti
qemu-aarch64-static -L /usr/aarch64-linux-gnu -cpu max ./a.out
```
For v.so, the regular vtable entry is relocated by an R_AARCH64_ABS64 relocation referencing _ZN1B13do_something2Ev.
```
_ZTV1B:
.xword  _ZN1B13do_something2Ev
```
Using relative vtable entry for a DSO has a downside of creating many PLT entries and making their addresses escape.
The relative vtable entry references a PLT entry _ZN1B13do_something2Ev@plt.
```
.L_ZTV1A.local:
        .word   (_ZN1A13do_something2Ev@PLT-.L_ZTV1A.local)-8
```

fixes: #63580

Reviewed By: peter.smith, MaskRay

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

13 months ago[gn build] Port b4ff893877ff
LLVM GN Syncbot [Thu, 29 Jun 2023 20:10:25 +0000 (20:10 +0000)]
[gn build] Port b4ff893877ff

13 months ago[scudo] Use getMonotonicTimeFast for tryLock.
Christopher Ferris [Thu, 29 Jun 2023 02:36:29 +0000 (19:36 -0700)]
[scudo] Use getMonotonicTimeFast for tryLock.

In tryLock, the Precedence value is set using the fast time function
now. This should speed up tryLock calls slightly.

This should be okay even though the value is used as a kind of random
value in getTSDAndLockSlow. The fast time call still sets enough bits
to avoid getting the same TSD on every call.

Reviewed By: Chia-hungDuan

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

13 months ago[libc++][mdspan] Implement layout_left
Christian Trott [Thu, 29 Jun 2023 19:36:07 +0000 (13:36 -0600)]
[libc++][mdspan] Implement layout_left

This commit implements layout_left in support of C++23 mdspan
(https://wg21.link/p0009). layout_left is a layout mapping policy
whose index mapping corresponds to the memory layout of Fortran arrays.
Thus the left most index has stride-1 access, and the right most index
is associated with the largest stride.

Co-authored-by: Damien L-G <dalg24@gmail.com>
Differential Revision: https://reviews.llvm.org/D153783

13 months agoRevert D145226 "[mlir][Transforms][NFC] CSE: Add non-pass entry point"
Fangrui Song [Thu, 29 Jun 2023 19:53:31 +0000 (12:53 -0700)]
Revert D145226 "[mlir][Transforms][NFC] CSE: Add non-pass entry point"

This reverts commit 189033e6bede96de0d74e61715fcd1b48d95e247.

This commit causes memory leak. See comments on D145226.

13 months ago[Attributor][FIX] Check AA preconditions
Johannes Doerfert [Thu, 29 Jun 2023 17:22:04 +0000 (10:22 -0700)]
[Attributor][FIX] Check AA preconditions

AAs often have preconditions, e.g., that the associated type is a
pointer type. If these do not hold, we do not need to bother creating
the AA. Best case, we invalidate it right away, worst case, we crash or
do something wrong (as happend in the issues below).

Fixes: https://github.com/llvm/llvm-project/issues/63553
Fixes: https://github.com/llvm/llvm-project/issues/63597

13 months ago[Attributor][FIX] Ensure AAAssumptionInfo properly reports change
Johannes Doerfert [Thu, 29 Jun 2023 19:01:39 +0000 (12:01 -0700)]
[Attributor][FIX] Ensure AAAssumptionInfo properly reports change

I have no test as I just noticed the wrong change status reported by
update randomly.

13 months ago[Attributor] Introduce helpers to judge AAs prior to creation
Johannes Doerfert [Fri, 23 Jun 2023 21:32:31 +0000 (14:32 -0700)]
[Attributor] Introduce helpers to judge AAs prior to creation

This is a partial cleanup to centralize the initialization and update
decisions for AAs. Lifting the burdon and boilerplate on users and
making it harder to accidentally perform unsound deductions.

The two static helpers show how we can lift the decisions to generate an
AA into the Attributor, avoiding trivial AAs that just cost us compile
time and maintenance code (to check for pre-conditions).

13 months ago[lldb-vscode] Adjusting CreateSource to detect compiler generated frames.
John Harrison [Thu, 29 Jun 2023 18:53:52 +0000 (14:53 -0400)]
[lldb-vscode] Adjusting CreateSource to detect compiler generated frames.

Reviewed By: wallace

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

13 months ago[ConstraintElimination] Handle solving-only `ICMP_NE` predicates
Antonio Frighetto [Thu, 29 Jun 2023 18:32:55 +0000 (20:32 +0200)]
[ConstraintElimination] Handle solving-only `ICMP_NE` predicates

Simplification of non-equality predicates for solving constraint
systems is now supported by checking the validity of related
inequalities and equalities.

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

13 months ago[dataflow] fix compile on gcc7
Sam McCall [Thu, 29 Jun 2023 19:20:53 +0000 (21:20 +0200)]
[dataflow] fix compile on gcc7

Reported on https://reviews.llvm.org/D153674
This returned expression is move-eligible, this is a bug in old GCC.

13 months ago[OMP5.2] Initial support for doacross clause.
Jennifer Yu [Wed, 21 Jun 2023 23:26:35 +0000 (16:26 -0700)]
[OMP5.2] Initial support for doacross clause.

13 months ago[HIP] Fix version detection for old HIP-PATH
Yaxun (Sam) Liu [Thu, 29 Jun 2023 13:00:39 +0000 (09:00 -0400)]
[HIP] Fix version detection for old HIP-PATH

ROCm used to install components under individual directories,
e.g. HIP installed to /opt/rocm/hip and rocblas installed to
/opt/rocm/rocblas. ROCm has transitioned to a flat directory
structure where all components are installed to /opt/rocm.
HIP-PATH and --hip-path are supposed to be /opt/rocm as
clang detect HIP version by /opt/rocm/share/hip/version.
However, some existing HIP app still uses HIP-PATH=/opt/rocm/hip.
To avoid regression, clang will also try detect share/hip/version
under the parent directory of HIP-PATH or --hip-path.
This way, the detection will work for both new HIP-PATH and
old HIP-PATH.

Reviewed by: Artem Belevich

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

Fixes: SWDEV-407757