platform/upstream/llvm.git
17 months ago[mlir][Linalg] Add a transform.structured.lower_unpack op
Nicolas Vasilache [Mon, 30 Jan 2023 08:37:46 +0000 (00:37 -0800)]
[mlir][Linalg] Add a transform.structured.lower_unpack op

This revision introduces `transform.structured.lower_unpack` which allows
rewriting a `tensor.unpack` to `transpose` (`linalg.generic`) + `tensor.empty` + `tensor.collapse_shape` + `tensor.extract_slice`

The implementation is currently limited to static pack ops that do not have outer_dims permutations.

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

17 months ago[AArch64][SME2] Add LLVM IR intrinsics for multi-multi dots
David Sherwood [Wed, 1 Feb 2023 09:43:45 +0000 (09:43 +0000)]
[AArch64][SME2] Add LLVM IR intrinsics for multi-multi dots

Adds intrinsics for the following SME2 instructions:

* sdot (multi-multi, 2 and 4 vectors, 32-bit and 64-bit ZA)
* udot (multi-multi, 2 and 4 vectors, 32-bit and 64-bit ZA)
* usdot (multi-multi, 2 and 4 vectors)
* fdot (multi-multi, 2 and 4 vectors)
* bfdot (multi-multi, 2 and 4 vectors)

NOTE: These intrinsics are still in development and are subject to future changes.

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

17 months ago[NFC] Use GlobalObject::setAlignment that takes an Align in BitcodeReader
Guillaume Chatelet [Wed, 1 Feb 2023 09:34:46 +0000 (09:34 +0000)]
[NFC] Use GlobalObject::setAlignment that takes an Align in BitcodeReader

17 months ago[AArch64] Handle negative architecture features
David Green [Wed, 1 Feb 2023 09:21:07 +0000 (09:21 +0000)]
[AArch64] Handle negative architecture features

Currently negative architecture features passes to clang like -Xclang
-target-feature -Xclang -v9.3a will end up _enabling_ dependant target
features (like FEAT_MOPS). This patch fixes that by ensuring we don't
enable dependant target features when !Enabled.

Fixes #60375

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

17 months agoXFAIL new test available_externally_alias.ll on NVPTX
Jonas Hahnfeld [Wed, 1 Feb 2023 09:14:56 +0000 (10:14 +0100)]
XFAIL new test available_externally_alias.ll on NVPTX

17 months ago[NFC] Use GlobalObject::setAlignment that takes an Align in LLParser
Guillaume Chatelet [Wed, 1 Feb 2023 09:13:57 +0000 (09:13 +0000)]
[NFC] Use GlobalObject::setAlignment that takes an Align in LLParser

17 months ago[mlir][llvm] Opaque pointer support for atomic and call ops.
Tobias Gysi [Wed, 1 Feb 2023 09:08:42 +0000 (10:08 +0100)]
[mlir][llvm] Opaque pointer support for atomic and call ops.

This revision adapts the printers and parsers of the LLVM Dialect
AtomicRMWOp, AtomicCmpXchgOp, CallOp, and InvokeOp to support both
opaque and typed pointers by printing the pointer types explicitly.
Previously, the printers and parser of these operations silently assumed
typed pointers. This assumption is problematic if a lowering or the
LLVM IR import produce LLVM Dialect with opaque pointers and the IR is
then printed and parsed, for example, when running mlir-translate. In
LLVM IR itself all tests with typed pointers are already gone. It is
thus important to start switching to opaque pointers.

This revision can be seen as a preparation step for the switch of the
LLVM Dialect to opaque pointers. Once printing and parsing works
seamlessly, all lowerings to LLVM Dialect can be switched to produce
opaque pointers. After a transition period, LLVM Dialect itself can by
simplified to support opaque pointers only.

Reviewed By: ftynse, Dinistro

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

17 months ago[mlir][bufferization][NFC] Rename getAliasingOpOperand/getAliasingOpResult
Matthias Springer [Wed, 1 Feb 2023 08:33:22 +0000 (09:33 +0100)]
[mlir][bufferization][NFC] Rename getAliasingOpOperand/getAliasingOpResult

* `getAliasingOpOperand` => `getAliasingOpOperands`
* `getAliasingOpResult` => `getAliasingOpResults`

Also a few minor code cleanups and better documentation.

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

17 months ago[ARM] Allow selecting hard-float ABI in integer-only MVE.
Simon Tatham [Tue, 31 Jan 2023 17:31:33 +0000 (17:31 +0000)]
[ARM] Allow selecting hard-float ABI in integer-only MVE.

Armv8.1-M can be configured to support the integer subset of the MVE
vector instructions, and no floating point. In that situation, the FP
and vector registers still exist, and so do the load, store and move
instructions that transfer data in and out of them. So there's no
reason the hard floating point ABI can't be supported, and you might
reasonably want to use it, for the sake of intrinsics-based code
passing explicit MVE vector types between functions.

But the selection of the hard float ABI in the backend was gated on
Subtarget->hasVFP2Base(), which is false in the case of integer MVE
and no FP.

As a result, you'd silently get the soft float ABI even if you
deliberately tried to select it, e.g. with clang options such as
--target=arm-none-eabi -mfloat-abi=hard -march=armv8.1m.main+nofp+mve

The hard float ABI should have been gated on the weaker condition
Subtarget->hasFPRegs(), because the only requirement for being able to
pass arguments in the FP registers is that the registers themselves
should exist.

I haven't added a new test, because changing the existing
CodeGen/Thumb2/float-ops.ll test seemed sufficient. But I've added a
comment explaining why the results are expected to be what they are.

Reviewed By: lenary

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

17 months ago[CodeGen] Filter out available_externally aliases
Jonas Hahnfeld [Mon, 23 Jan 2023 13:09:48 +0000 (14:09 +0100)]
[CodeGen] Filter out available_externally aliases

The Language Reference says that aliases can have available_externally
linkage if their aliasee is an available_externally global value. Using
this kind of aliases resulted in crashes during code generation, filter
them out (the same that the AsmPrinter also filters out GlobalVariables
in emitSpecialLLVMGlobal(); Functions are discarded in the machine pass
infrastructure).

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

17 months ago[LoongArch] Support getHostCPUName and getHostCPUFeatures
wanglei [Wed, 1 Feb 2023 03:27:52 +0000 (11:27 +0800)]
[LoongArch] Support getHostCPUName and getHostCPUFeatures

Reviewed By: xen0n, MaskRay

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

17 months ago[MLIR] Propagate unpack through element-wise ops
Lorenzo Chelini [Tue, 31 Jan 2023 13:25:14 +0000 (14:25 +0100)]
[MLIR] Propagate unpack through element-wise ops

Introduce `pushDownUnPackOpThroughElemGenericOp` to propagate producer
unpack operation through an element-wise linalg.generic operation. This
pattern complements `BubbleUpPackOpThroughElemGenericOp`. The general
idea is to bubble up tensor.pack as much as possible while pushing down
tensor.unpack as much as possible, and canonicalize away symmetrical
tensor.pack and tensor.unpack operations.

Currently, `pushDownUnPackOpThroughElemGenericOp` expects a single
tensor.unpack operation as the producer of one of the linalg.generic's
operands.

Reviewed By: hanchung

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

17 months agoMake `prefetchit{0/1}` emit an assembler warning if the operand is not rip-rel
Noah Goldstein [Wed, 1 Feb 2023 05:23:29 +0000 (23:23 -0600)]
Make `prefetchit{0/1}` emit an assembler warning if the operand is not rip-rel

Without a rip-rel operand, `prefetchit{0/1}` is a nop. This is a
reasonable mistake for someone to make and is almost certainly not
what they are after.

This matches the same warning in `gas`.

Reviewed By: pengfei

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

17 months agoImprove and enable folding of conditional branches with tail calls.
Noah Goldstein [Wed, 1 Feb 2023 02:50:45 +0000 (20:50 -0600)]
Improve and enable folding of conditional branches with tail calls.

Improve and enable folding of conditional branches with tail calls.

1. Make it so that conditional tail calls can be emitted even when
   there are multiple predecessors.

2. Don't guard the transformation behind -Os. The rationale for
   guarding it was static-prediction can be affected by whether the
   branch is forward of backward. This is no longer true for almost any
   X86 cpus (anything newer than `SnB`) so is no longer a meaningful
   concern.

Reviewed By: pengfei

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

17 months agoUse autogenerated result for switch-bt.ll test; NFC
Noah Goldstein [Wed, 1 Feb 2023 05:23:12 +0000 (23:23 -0600)]
Use autogenerated result for switch-bt.ll test; NFC

Reviewed By: RKSimon

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

17 months agoTransform slow LEA_B_I_D/LEA_SLOWBASE_I -> LEA_IS_D/LEA_IS iff base == index
Noah Goldstein [Wed, 1 Feb 2023 05:23:18 +0000 (23:23 -0600)]
Transform slow LEA_B_I_D/LEA_SLOWBASE_I -> LEA_IS_D/LEA_IS iff base == index

The two 3c LEA cases:
    lea D(base, index,1)      -> lea D(,index,2)
    lea D(r13/rbp, index)     -> lea D(,r13/rbp,2) // D maybe zero

Current take 2 instructions to transform. We can do a bit better by
using LEA w.o a base if base == index and scale == 1.

Reviewed By: pengfei

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

17 months ago[mlir] return nullopt for getNeutralElement
Xiang [Tue, 31 Jan 2023 01:38:57 +0000 (20:38 -0500)]
[mlir] return nullopt for getNeutralElement

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

Crash for return Attribute instead of nullopt.

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

17 months ago[AArch64] Mark function calls as possibly changing FPCR
Serge Pavlov [Mon, 30 Jan 2023 12:49:57 +0000 (19:49 +0700)]
[AArch64] Mark function calls as possibly changing FPCR

This patch does the same changes as D111433 for PowerPC and D139549 for
X86, - in the strictfp function all calls are marked as implicit defs of
FPCR. It prevents from moving FP operations across function calls, which
may change rounding mode, as fesetround does.

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

17 months ago[github] update actions and make tweaks
Mohammed Keyvanzadeh [Tue, 31 Jan 2023 21:28:45 +0000 (00:58 +0330)]
[github] update actions and make tweaks

- Update the GitHub workflow actions to their latest versions.
- Use the latest Node.js LTS release.
- Use the latest Ubuntu version for consistency across all workflows.
- The `set-output` command is deprecated and will soon be disabled (https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/) so use the new recommended way.
- Use the `$()` expressions for string interpolation instead of the deprecated backticks in Bash.
- Format the YAML files.

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

17 months ago[lli] Don't create an ExecutorProcessControl in non-remote MCJIT config.
Lang Hames [Wed, 1 Feb 2023 02:17:09 +0000 (18:17 -0800)]
[lli] Don't create an ExecutorProcessControl in non-remote MCJIT config.

When lli is run with -jit-kind=mcjit and without remote JITing there is no need
to create an ExecutorProcessControl object.

This is nice cleanup, but as a bonus should silence the leak reports that we're
seeing in https://green.lab.llvm.org/green/job/clang-stage2-cmake-RgSan/9105/.
(Though as a side note I believe those reports are spurious. They are being
tracked by rdar://104825696).

17 months ago[NFC] Extract `CodeGenInstAlias` into its own *.h/*.cpp
Sergei Barannikov [Tue, 31 Jan 2023 10:54:40 +0000 (13:54 +0300)]
[NFC] Extract `CodeGenInstAlias` into its own *.h/*.cpp

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

17 months ago[ORC] Fix an iterator invalidation issue in JITDylib::defineMaterializing.
Lang Hames [Wed, 1 Feb 2023 01:55:29 +0000 (17:55 -0800)]
[ORC] Fix an iterator invalidation issue in JITDylib::defineMaterializing.

The loop body may add and remove entries in the symbol table so we can't hold
iterators to the entries. This commit updates the method to use the newly added
NonOwningSymbolStringPtr type as keys for removal instead.

Side note: This bug has been present since the introduction of the
defineMaterializing method, but the method is called rarely and DenseMap
resizes are also rare so we didn't see any fallout until a large program was
thrown at it. There's no testcase as I haven't been able to reproduce the
failure with smaller testcases.

17 months ago[ORC] Enable DenseMap<SymbolStringPtr, T>::find_as(NonOwningSymbolStringPtr).
Lang Hames [Wed, 1 Feb 2023 01:46:27 +0000 (17:46 -0800)]
[ORC] Enable DenseMap<SymbolStringPtr, T>::find_as(NonOwningSymbolStringPtr).

For maps of SymbolStringPtrs to values, enables lookup using
NonOwningSymbolStringPtr keys.

17 months ago[LoongArch] Enable shrink wrapping when optimize the function
wanglei [Wed, 1 Feb 2023 01:03:35 +0000 (09:03 +0800)]
[LoongArch] Enable shrink wrapping when optimize the function

We set it conservatively so that it is turned on when optimization
is enabled, i.e. when the optimization level is not `O0`.

Reviewed By: xen0n

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

17 months agoFix missing return of LogicalResult from D142848
Mahesh Ravishankar [Tue, 31 Jan 2023 23:20:58 +0000 (23:20 +0000)]
Fix missing return of LogicalResult from D142848

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

17 months agoFix bazel build
Jorge Gorbe Moya [Wed, 1 Feb 2023 01:05:49 +0000 (17:05 -0800)]
Fix bazel build

17 months ago[VE] Fix useDeprecatedPositionallyEncodedOperands errors.
James Y Knight [Tue, 31 Jan 2023 21:33:31 +0000 (16:33 -0500)]
[VE] Fix useDeprecatedPositionallyEncodedOperands errors.

This is a follow-on to https://reviews.llvm.org/D134073.

Behavior is unchanged by this cleanup, except that previously the
'CVTRDm' pattern was accidentally getting the top bit of 'sz' from the
'sx' input, instead of setting it to 0.

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

17 months ago[ORC] Further improvements to SymbolStringPtr & NonOwningSymbolStringPtr.
Lang Hames [Tue, 31 Jan 2023 22:43:11 +0000 (14:43 -0800)]
[ORC] Further improvements to SymbolStringPtr & NonOwningSymbolStringPtr.

A follow-up to https://reviews.llvm.org/D142314:

* Make SymbolStringPtrs constructible from NonOwningSymbolStringPtrs.

* Move and rename getRefCount and isValid (now poolEntryIsAlive) to improve
readability. Also updates these routines to make them safe for use with
sentinel values (null, empty, tombstone).

* Move ref-counting operations into their own incRef and decRef methods.

17 months ago[hexagon] add a -mcabac flag
Brian Cain [Tue, 31 Jan 2023 02:25:42 +0000 (18:25 -0800)]
[hexagon] add a -mcabac flag

For v73 and later, clang users who wish to use the cabac instructions need
a way to add the 'cabac' target feature.

Reviewed By: kparzysz

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

17 months ago[mlir] Register tensor dialect for transfer_read conversion
Kai Sasaki [Tue, 31 Jan 2023 23:58:58 +0000 (08:58 +0900)]
[mlir] Register tensor dialect for transfer_read conversion

Make sure to register tensor dialect as tensor.transfer_read can be dependent on its parameter. It resolves the issue causing the unregisterd dialect error to convert vector to SCF reported https://github.com/llvm/llvm-project/issues/60197.

Reviewed By: ftynse

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

17 months ago[RISCV][NFC] Update RISCVUsage.rst to sort vendor extensions
Philipp Tomsich [Tue, 31 Jan 2023 20:34:06 +0000 (21:34 +0100)]
[RISCV][NFC] Update RISCVUsage.rst to sort vendor extensions

17 months ago[GlobalISel] Don't combine instructions with unknown type in hoist_logic_op_with_same...
Vladislav Dzhidzhoev [Fri, 27 Jan 2023 02:01:22 +0000 (03:01 +0100)]
[GlobalISel] Don't combine instructions with unknown type in hoist_logic_op_with_same_opcode_hands.

This fixes failure for some LLVM IR.

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

17 months ago[lld][WebAssembly] Apply relocations to TLS data
Sam Clegg [Tue, 31 Jan 2023 21:33:29 +0000 (13:33 -0800)]
[lld][WebAssembly] Apply relocations to TLS data

This is only needed in the case of dynamic linking and pthreads.
Previously these relocations were simply not being applied.

Verified that this works using a more real world emscripten test:
https://github.com/emscripten-core/emscripten/pull/18641

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

17 months ago[lldb] Use ${CMAKE_COMMAND} -E remove instead of remove_directory
Jonas Devlieghere [Tue, 31 Jan 2023 23:33:46 +0000 (15:33 -0800)]
[lldb] Use ${CMAKE_COMMAND} -E remove instead of remove_directory

We no longer need to remove a directory downstream and also contrary to
my previous observations, remove_directory isn't sufficient to remove a
regular file.

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

17 months ago[libc++][ranges] Fix incorrect integer typedef in `elements_view` test.
Konstantin Varlamov [Tue, 31 Jan 2023 23:27:07 +0000 (15:27 -0800)]
[libc++][ranges] Fix incorrect integer typedef in `elements_view` test.

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

17 months ago[libc++] Use bounded iterators in std::string_view when the debug mode is enabled
Louis Dionne [Mon, 30 Jan 2023 15:57:26 +0000 (10:57 -0500)]
[libc++] Use bounded iterators in std::string_view when the debug mode is enabled

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

17 months agocompiler-rt/lib: Add .Linterceptor_sigsetjmp
H.J. Lu [Tue, 31 Jan 2023 22:30:55 +0000 (14:30 -0800)]
compiler-rt/lib: Add .Linterceptor_sigsetjmp

Older GNU assemblers generate R_X86_64_PC32 relocation against
defined non-weak global branch targets with default visibility.  A
linker may issue an error when building a shared library.  Add a local
alias, .Linterceptor_sigsetjmp, to __interceptor_sigsetjmp to avoid
R_X86_64_PC32 relocation for "jmp __interceptor_sigsetjmp" with older
GNU assemblers.

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

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

17 months ago[ORC] Add a NonOwningSymbolStringPtr utility.
Lang Hames [Sun, 22 Jan 2023 18:30:15 +0000 (10:30 -0800)]
[ORC] Add a NonOwningSymbolStringPtr utility.

Introduces a non-owning SymbolStringPool entry pointer. Instances of the new
type can be compared with SymbolStringPtr instances, but do not participate in
ref-counting and are therefore cheaper to copy. This makes it efficient to use
in algorithms that use symbol-strings as ids, e.g. ORC's waiting-on graph. A
future commit will rewrite ORC's waiting-on graph.

Reviewed By: dblaikie

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

17 months ago[DWARF] Fix handling of .debug_aranges with -g1
Alex Yermolovich [Tue, 31 Jan 2023 22:12:02 +0000 (14:12 -0800)]
[DWARF] Fix handling of .debug_aranges with -g1

Old behavior was to add to .debug_aranges only when we create a DIE. As the
result we could end up in situation where DW_AT_ranges have addresses that are
not in .debug_aranges. This has caused issues for LLDB: D136395.

Changed it to add addresses to .debug_aranges even when DIE is not created.

Reviewed By: dblaikie

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

17 months agoFix two warnings introduced by 69011a2ad0ce "[mlir][Linalg] Make Elementwise op fusio...
Jorge Gorbe Moya [Tue, 31 Jan 2023 21:49:07 +0000 (13:49 -0800)]
Fix two warnings introduced by 69011a2ad0ce "[mlir][Linalg] Make Elementwise op fusion return a map from existing values to values in the fused op." (NFCI)

- a -Wunused-result from ignoring a LogicalResult return value.
- an unused variable

17 months ago[VPlan] VPPredInstPHIRecipe does not read from memory.
Florian Hahn [Tue, 31 Jan 2023 21:51:03 +0000 (21:51 +0000)]
[VPlan] VPPredInstPHIRecipe does not read from memory.

VPPredInstPHIRecipe just merges the incoming values and does not write
to memory.

17 months ago[libc] Build two different static archives libc.a and libm.a under full build.
Siva Chandra Reddy [Tue, 31 Jan 2023 05:31:18 +0000 (05:31 +0000)]
[libc] Build two different static archives libc.a and libm.a under full build.

We currently put everything in one single archive libc.a which breaks in
certain situations where the compiler drivers expect libm.a also. With
this change, we separate out libc.a and libm.a functions as is done
conventionally and put them in two different static archives.

One will now have to build two targets, `libc` and `libm` which produce
`libc.a` and `libm.a` respectively. Under default build, one still builds only
one target named `libc` which produces `libllvmlibc.a`.

Reviewed By: jhuber6

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

17 months ago[lld][WebAssembly] Renamed a few tests to conform to naming convention. NFC
Sam Clegg [Tue, 31 Jan 2023 20:17:18 +0000 (12:17 -0800)]
[lld][WebAssembly] Renamed a few tests to conform to naming convention. NFC

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

17 months ago[gn build] Port 486729ce06c1
LLVM GN Syncbot [Tue, 31 Jan 2023 21:17:27 +0000 (21:17 +0000)]
[gn build] Port 486729ce06c1

17 months ago[RISCV] Move RISCVELFStreamer::getRelocPairForSize to RISCVFixUpKinds.h and reuse...
Craig Topper [Tue, 31 Jan 2023 21:09:56 +0000 (13:09 -0800)]
[RISCV] Move RISCVELFStreamer::getRelocPairForSize to RISCVFixUpKinds.h and reuse it. NFC

Reuse it for RISCVAsmBackend.cpp.
While there make the function return a pair of MCFixupKind to
remove static_casts elsewhere.

Reviewed By: reames

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

17 months ago[RISCV] Remove unneeded code from TTI::isLegalMaskedLoadStore/isLegalMaskedGatherScatter.
Craig Topper [Tue, 31 Jan 2023 20:44:42 +0000 (12:44 -0800)]
[RISCV] Remove unneeded code from TTI::isLegalMaskedLoadStore/isLegalMaskedGatherScatter.

We don't need to explicitly check ELEN. It's already handled by
isLegalElementTypeForRVV.

This is a leftover from before we had Zve32/64 extensions and used
a command line option for fixed vectors.

17 months ago[GVN] Don't count debug instructions when limit the number of checked instructions
Guozhi Wei [Tue, 31 Jan 2023 21:01:02 +0000 (21:01 +0000)]
[GVN] Don't count debug instructions when limit the number of checked instructions

Don't count debug instructions when limit the number of checked instructions.
Otherwise the debug information may impact optimization like the test case
shows.

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

17 months agoRe-land: [MTE] Add AArch64GlobalsTagging Pass
Mitch Phillips [Tue, 31 Jan 2023 20:28:28 +0000 (12:28 -0800)]
Re-land: [MTE] Add AArch64GlobalsTagging Pass

Adds an IR pass for -fsanitize=memtag-globals. This pass goes over the
tag-capable global variables, and replaces them with a tagged global
variable of the same contents. This new global variable will have its
size and alignment adjusted if neccesary so that they're both a multiple
of the tag granule size (16 bytes).

Global merge must also be suppressed for tagged globals, as each global
variable must have a unique tag. This can possibly be relaxed in future;
globals that are identical in size, alignment, and content can possibly
be merged. The major problem comes from tail- or head-merging, which if
left unchecked, could have partially-overlapping global variables with
different memory tags, leading to crashes at runtime.

Reviewed By: fmayer, eugenis

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

17 months ago[lldb][NFC] Remove copy of debugserver entitlements plist
Alex Langford [Tue, 31 Jan 2023 20:57:12 +0000 (12:57 -0800)]
[lldb][NFC] Remove copy of debugserver entitlements plist

An exact copy of this file exists in debugserver's resource directory
and this one is unused.

17 months agoFix Clang sphinx build
Aaron Ballman [Tue, 31 Jan 2023 20:41:09 +0000 (15:41 -0500)]
Fix Clang sphinx build

This addresses the issue found by:
https://lab.llvm.org/buildbot/#/builders/92/builds/39458

and it also fixes a follow-on error with building the RST.

17 months ago[gn build] Port e9c49901a43f
LLVM GN Syncbot [Tue, 31 Jan 2023 20:34:50 +0000 (20:34 +0000)]
[gn build] Port e9c49901a43f

17 months ago[gn build] Port 04ed86ff1b72
LLVM GN Syncbot [Tue, 31 Jan 2023 20:34:49 +0000 (20:34 +0000)]
[gn build] Port 04ed86ff1b72

17 months ago[gn] prepare for 40025761564 (awkward AMDGPUGenRegisterBank.inc include)
Nico Weber [Tue, 31 Jan 2023 20:34:18 +0000 (15:34 -0500)]
[gn] prepare for 40025761564 (awkward AMDGPUGenRegisterBank.inc include)

17 months ago[mlir][Linalg] Make Elementwise op fusion return a map from existing values to values...
Mahesh Ravishankar [Tue, 31 Jan 2023 20:33:19 +0000 (20:33 +0000)]
[mlir][Linalg] Make Elementwise op fusion return a map from existing values to values in the fused op.

This replacement can be used to eliminate all uses of the
producer/consumer for case where producer/consumer has other uses
outside of the producer/consumer pair. This makes the
producer/consumer dead.

Add test and minor fixup to the test harness.

Reviewed By: hanchung

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

17 months ago[Clang] Adjust PIC handling for the AMDGPU ToolChain
Joseph Huber [Tue, 31 Jan 2023 18:52:02 +0000 (12:52 -0600)]
[Clang] Adjust PIC handling for the AMDGPU ToolChain

The AMDGPU target only emits shared libraries currently. This patch
changes the handling of the PIC level to be managed in the
AMDGPUToolChain rather than having a special case for it. This causes
`--target=amdgcn--` to no longer set the PIC. This should be an
acceptable change since that doesn't use a correct toolchain anyway.

Reviewed By: arsenm

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

17 months agoRevert "[MTE] Add AArch64GlobalsTagging Pass"
Mitch Phillips [Tue, 31 Jan 2023 20:25:58 +0000 (12:25 -0800)]
Revert "[MTE] Add AArch64GlobalsTagging Pass"

This reverts commit 4edfcff71e150770675a19576f698c7bbe788ee2.

Broke the non-aarch64-containing target builds.
https://reviews.llvm.org/D133392 has more context.

17 months ago[gn] port 226c444b3882e
Nico Weber [Tue, 31 Jan 2023 20:17:46 +0000 (15:17 -0500)]
[gn] port 226c444b3882e

17 months ago[llvm-c-test] Fix warnings
Kazu Hirata [Tue, 31 Jan 2023 20:15:04 +0000 (12:15 -0800)]
[llvm-c-test] Fix warnings

This patch fixes:

  llvm/tools/llvm-c-test/metadata.c:49:16: error: unused variable
  'tmp' [-Werror,-Wunused-variable]

  llvm-project/llvm/tools/llvm-c-test/metadata.c:70:16: error: unused
  variable 'md' [-Werror,-Wunused-variable]

  llvm/tools/llvm-c-test/metadata.c:74:16: error: unused variable
  'md2' [-Werror,-Wunused-variable]

17 months agoRevert "[OpenMP][OMPIRBuilder]Move SIMD alignment calculation to LLVM Frontend"
Argyrios Kyrtzidis [Tue, 31 Jan 2023 20:01:32 +0000 (12:01 -0800)]
Revert "[OpenMP][OMPIRBuilder]Move SIMD alignment calculation to LLVM Frontend"

Causes clang build failures, see https://reviews.llvm.org/D141910#4089465 for details.

This reverts commit ca446037af019d1aa01b1352a30a18df33038359.

17 months ago[clang-format] Fix use after free in FormatTokenSource test
Benjamin Kramer [Tue, 31 Jan 2023 19:59:42 +0000 (20:59 +0100)]
[clang-format] Fix use after free in FormatTokenSource test

Add a lifetime annotation to IndexedTokenSource so we get a warning for
this pattern.

17 months ago[InstCombine] reduce icmp_ne0-of-and-of-select-of-constants
Sanjay Patel [Tue, 31 Jan 2023 19:29:57 +0000 (14:29 -0500)]
[InstCombine] reduce icmp_ne0-of-and-of-select-of-constants

Follow-up to:
D142847 / 98855059674c

This handles the 'ne' variant by inverting the result.

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

17 months ago[InstCombine] add tests for icmp-ne0-of-and-of-select-of-constants; NFC
Sanjay Patel [Tue, 31 Jan 2023 19:13:00 +0000 (14:13 -0500)]
[InstCombine] add tests for icmp-ne0-of-and-of-select-of-constants; NFC

17 months ago[-Wunsafe-buffer-usage] Introduce the unsafe_buffer_usage attribute
Rashmi Mudduluru [Tue, 31 Jan 2023 19:43:34 +0000 (11:43 -0800)]
[-Wunsafe-buffer-usage] Introduce the unsafe_buffer_usage attribute

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

17 months ago[AArch64] Make nosimd imply nocrypto
David Green [Tue, 31 Jan 2023 19:17:22 +0000 (19:17 +0000)]
[AArch64] Make nosimd imply nocrypto

This adds a quick check for -neon, making it imply the same as -crypto,
which helps get some features correct in more cases.

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

17 months ago[MemProf] Make test more resilient to cpu scheduling
Teresa Johnson [Tue, 31 Jan 2023 19:01:42 +0000 (11:01 -0800)]
[MemProf] Make test more resilient to cpu scheduling

Loosen up the matching so that occasional cpu migrations don't break the
test. This showed up occasionally in internal testing.

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

17 months ago[flang] Use fir.type_desc and delay type desc address resolution
Valentin Clement [Tue, 31 Jan 2023 19:09:56 +0000 (20:09 +0100)]
[flang] Use fir.type_desc and delay type desc address resolution

Makes use of fir.type_desc in order to delay the type desc address
resolution. The lowering inserts fir.type_desc operation instead of fir.addr_of
operation pointing to the fir.global type descriptor. The fir.type_desc
operation is then lowered in code gen to an address of operation in the LLVM
dialect. At this stage, the type descriptor is generated in all cases.

Reviewed By: vdonaldson

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

17 months ago[NFC][libc++] Addresses LWG3781.
Mark de Wever [Mon, 30 Jan 2023 18:09:30 +0000 (19:09 +0100)]
[NFC][libc++] Addresses LWG3781.

  LWG3781 The exposition-only alias templates cont-key-type and
  cont-mapped-type should be removed

Libc++ never implemented these aliases.

Reviewed By: #libc, philnik, ldionne

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

17 months ago[libc++] Addresses LWG3755.
Mark de Wever [Mon, 30 Jan 2023 17:30:03 +0000 (18:30 +0100)]
[libc++] Addresses LWG3755.

  LWG3755 tuple-for-each can call user-defined operator,

Reviewed By: #libc, ldionne, philnik

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

17 months ago[libc++] Marks LWG2970 as complete.
Mark de Wever [Sun, 29 Jan 2023 14:11:56 +0000 (15:11 +0100)]
[libc++] Marks LWG2970 as complete.

  LWG2970 Return type of std::visit misspecified

Was applied in D86006 including tests.

Reviewed By: #libc, ldionne

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

17 months ago[libc++] Partly addresses LWG3798.
Mark de Wever [Sat, 21 Jan 2023 12:38:43 +0000 (13:38 +0100)]
[libc++] Partly addresses LWG3798.

  LWG3798 Rvalue reference and iterator_category

The changes are only applied to `ranges::transform_view`, the other
views haven't been implemented yet.

Reviewed By: #libc, ldionne

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

17 months ago[libc++] Addresses LWG3764.
Mark de Wever [Sat, 21 Jan 2023 12:38:41 +0000 (13:38 +0100)]
[libc++] Addresses LWG3764.

  LWG3764 reference_wrapper::operator() should propagate noexcept

As drive-by adds constexpr to the synopsis, since it has already been
implemented.

Reviewed By: #libc, ldionne

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

17 months ago[NFC][libc++][format] Uses retarget buffer.
Mark de Wever [Sun, 29 Jan 2023 12:40:58 +0000 (13:40 +0100)]
[NFC][libc++][format] Uses retarget buffer.

Lets the tuple formatter use the retarget buffer added for the range
formatter.

Reviewed By: #libc, ldionne

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

17 months ago[lldb] Fix warning about unhandled enum value `WasmExternRef` (NFC).
Jorge Gorbe Moya [Tue, 31 Jan 2023 18:25:15 +0000 (10:25 -0800)]
[lldb] Fix warning about unhandled enum value `WasmExternRef` (NFC).

17 months ago[mlir][sparse] Extend sorting function generator to support operand beyond (lo, hi...
bixia1 [Tue, 31 Jan 2023 16:36:29 +0000 (08:36 -0800)]
[mlir][sparse] Extend sorting function generator to support operand beyond (lo, hi, xs, ys).

This is to prepare for implementing a hybrid quick sort, which switches to heap
sort when the recursive depth exceeds certain limits.

Reviewed By: aartbik

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

17 months ago[libc++] Fixes the Clang modular build.
Mark de Wever [Fri, 27 Jan 2023 07:02:09 +0000 (08:02 +0100)]
[libc++] Fixes the Clang modular build.

The patch
430b397f6715d4d2f2569716c93fcd6292ace3dc ("[libc++] Granularize <type_traits> includes in <iterator>") missed some exports in the modulemap with became apparent in the reverting commit 12cb1cb3720d.

This fixes the issue by updating the modulemap. Note that the Clang ICE is not fixed by this change.

Reviewed By: #libc, ldionne

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

17 months ago[mlir][Linalg] Add a transform.structured.lower_pack op
Nicolas Vasilache [Fri, 27 Jan 2023 16:24:14 +0000 (08:24 -0800)]
[mlir][Linalg] Add a transform.structured.lower_pack op

This revision introduces `transform.structured.lower_pack` which allows
rewriting a `tensor.pack` to `tensor.pad` + `tensor.expand_shape` + `linalg.transpose`.

The implementation is currently limited to static pack ops that do not have outer_dims permutations.

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

17 months ago[Kaleidoscope] Update code snippets in text to match full code listings
Dhruv Chawla [Tue, 31 Jan 2023 17:56:53 +0000 (23:26 +0530)]
[Kaleidoscope] Update code snippets in text to match full code listings

There were quite a few places in the tutorial where the snippets were not up to date with the full code listings given. I have updated all of the ones I could find, which mostly involves changing `.` to `->` when accessing through a `std::unique_ptr`, changing `while (1)` to `while (true)`, and other such small changes.

There are still however a few places where I am not sure what to do, such as:
- Chapter 4: `ParseTopLevelExpr()` in chapter 3 sets the ProtoTypeAST
             name to "", however it is referred to as "__anon_expr"
             in chapter 4. Would it be required to mention this change
             in chapter 4?
- Chapter 9: The code snippets refer to the top level expression as
             "main", however the full code listing refers to it as
             "__anon_expr". I think given the context of the chapter
             it makes sense to refer to it as "main", so I have
             updated the code listing to reflect that.
- Chapter 9: In chapter 9 the diff given for `HandleTopLevelExpression()`
             deletes code that is not mentioned anywhere else, so I am
             not sure what is to be done there.
- Miscellaneous: I don't think this is very important, however the
                 casing used for the first word of error messages
                 tends to vary between upper and lower case between
                 chapters and I do not know if it is worth reconciling
                 these differences.

Reviewed By: xgupta

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

17 months ago[llvm-c] add LLVMReplaceMDNodeOperandWith
Davide Bertola [Tue, 31 Jan 2023 17:02:50 +0000 (09:02 -0800)]
[llvm-c] add LLVMReplaceMDNodeOperandWith

I'm working on a tool that visits debug info and massages it using the
llvm-c API. I noticed that LLVMGetOperand special cases MDNodes so I
can get their operands, but I can't replace them. This patch adds
LLVMReplaceMDNodeOperandWith which boils down to
MDNode::replaceOperandWith.

The name was chosen for consistency with LLVMGetMDNodeOperands and
LLVMGetMDNodeNumOperands.

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

17 months ago[AST] assert(false) -> llvm_unreachable
Benjamin Kramer [Tue, 31 Jan 2023 17:55:58 +0000 (18:55 +0100)]
[AST] assert(false) -> llvm_unreachable

Has the advantage of not triggering missing return warnings even in
NDEBUG builds.

17 months ago[Clang] Do not attempt to directly link arch tools in 32-bit mode
Joseph Huber [Tue, 31 Jan 2023 17:55:05 +0000 (11:55 -0600)]
[Clang] Do not attempt to directly link arch tools in 32-bit mode

Summary:
We offer almost no support for offloading on 32-bit systems. This causes
some problems when cross-compiling for 32-bit machines as it will find
the CUDA from the host that is incompatible. Instead we force these to
always use the dynamically loaded version, which should always compile.

17 months ago[Clang] Add machinery to catch overflow in unary minus outside of a constant expressi...
Shafik Yaghmour [Tue, 31 Jan 2023 17:33:06 +0000 (09:33 -0800)]
[Clang] Add machinery to catch overflow in unary minus outside of a constant expression context

We provide several diagnostics for various undefined behaviors due to signed
integer overflow outside of a constant expression context. We were missing the
machinery to catch overflows due to unary minus.

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

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

17 months ago[llvm-ifs] Add support for --target=riscv
Alex Brachet [Tue, 31 Jan 2023 17:31:35 +0000 (17:31 +0000)]
[llvm-ifs] Add support for --target=riscv

17 months ago[MTE] Add AArch64GlobalsTagging Pass
Mitch Phillips [Tue, 31 Jan 2023 17:24:13 +0000 (09:24 -0800)]
[MTE] Add AArch64GlobalsTagging Pass

Adds an IR pass for -fsanitize=memtag-globals. This pass goes over the
tag-capable global variables, and replaces them with a tagged global
variable of the same contents. This new global variable will have its
size and alignment adjusted if neccesary so that they're both a multiple
of the tag granule size (16 bytes).

Global merge must also be suppressed for tagged globals, as each global
variable must have a unique tag. This can possibly be relaxed in future;
globals that are identical in size, alignment, and content can possibly
be merged. The major problem comes from tail- or head-merging, which if
left unchecked, could have partially-overlapping global variables with
different memory tags, leading to crashes at runtime.

Reviewed By: fmayer, eugenis

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

17 months ago[RISCV] Handle FRMArg as an optional operand instead of using InstAliases.
Craig Topper [Tue, 31 Jan 2023 17:08:13 +0000 (09:08 -0800)]
[RISCV] Handle FRMArg as an optional operand instead of using InstAliases.

Instead of having InstAliases without operand. Use the optional
operand infrastructure.

Still use the PrintAliases/NoAlias controls to determine if we
print "dyn" or not.

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

17 months ago[clang][WebAssembly] Initial support for reference type externref in clang
Paulo Matos [Mon, 9 Jan 2023 14:15:12 +0000 (15:15 +0100)]
[clang][WebAssembly] Initial support for reference type externref in clang

This patch introduces a new type __externref_t that denotes a WebAssembly opaque
reference type. It also implements builtin __builtin_wasm_ref_null_extern(),
that returns a null value of __externref_t. This lays the ground work
for further builtins and reference types.

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

17 months ago[flang] Single entry point for GET_ENVIRONMENT_VARIABLE
Leandro Lupori [Thu, 19 Jan 2023 17:45:19 +0000 (17:45 +0000)]
[flang] Single entry point for GET_ENVIRONMENT_VARIABLE

This patch refactors the runtime support for GET_ENVIRONMENT_VARIABLE
to have a single entry point instead of 2. It also updates lowering
accordingly.

This makes it easier to handle dynamically optional arguments.
See also https://reviews.llvm.org/D118777

Reviewed By: jeanPerier

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

17 months ago[SanitizerBinaryMetadata] Pretend compiler-generated loads/stores are atomic
Marco Elver [Tue, 31 Jan 2023 16:28:23 +0000 (17:28 +0100)]
[SanitizerBinaryMetadata] Pretend compiler-generated loads/stores are atomic

Profiling and GCOV generate known data-racy loads/stores. Pretend they
are atomic so that analysis using PC-keyed metadata for atomics do not
report them as data races (which would look like false positives).

Reviewed By: dvyukov

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

17 months ago[flang] Suppress a warning in D118631 [-Wunused-result]
Shao-Ce SUN [Tue, 31 Jan 2023 16:24:43 +0000 (00:24 +0800)]
[flang] Suppress a warning in D118631 [-Wunused-result]

Reviewed By: klausler

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

17 months ago[flang] More subscript triplet checking at compilation time
Peter Klausler [Mon, 30 Jan 2023 22:37:48 +0000 (14:37 -0800)]
[flang] More subscript triplet checking at compilation time

When a triplet's lower and upper bounds are the same, we can
check them without requiring a constant stride.

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

17 months ago[flang] Handle missing substring upper bound better when folding
Peter Klausler [Tue, 31 Jan 2023 00:06:09 +0000 (16:06 -0800)]
[flang] Handle missing substring upper bound better when folding

When folding a substring of a named constant or character literal,
acquire the value of a missing upper bound from the base object.

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

17 months ago[clangd] Add semantic token for angle brackets
Christian Kandeler [Wed, 20 Jul 2022 08:57:59 +0000 (10:57 +0200)]
[clangd] Add semantic token for angle brackets

This is needed for clients that would like to visualize matching
opening and closing angle brackets, which can be valuable in non-trivial
template declarations or instantiations.
It is not possible to do this with simple lexing, as the tokens
could also refer to operators.

Reviewed By: kadircet

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

17 months ago[clang-format][NFC] Bring FormatTokenSource under test.
Manuel Klimek [Tue, 31 Jan 2023 16:03:26 +0000 (16:03 +0000)]
[clang-format][NFC] Bring FormatTokenSource under test.

Add tests for FormatTokenSource and harden it against edge cases.

17 months ago[BranchRelaxation] Strengthen post condition assertions
Philip Reames [Tue, 31 Jan 2023 15:50:40 +0000 (07:50 -0800)]
[BranchRelaxation] Strengthen post condition assertions

The whole point of this pass is to rewrite branches so that branches are in bounds. We should assert that we succeeded rather than just that we kept our internal data structure in sync.

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

17 months ago[flang][driver] Add support for -embed-offload-object flag in flang
Jan Sjodin [Fri, 20 Jan 2023 19:33:22 +0000 (14:33 -0500)]
[flang][driver] Add support for -embed-offload-object flag in flang

This patch adds support for the -embed-offload-object flag to embed offloading
binaries in host code. This flag is identical to the clang flag with the same name.

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

Reviewed By: awarzynski, jhuber6

17 months ago[mlir][SubElements] Disambiguate cast<> call for MSVC
Benjamin Kramer [Tue, 31 Jan 2023 15:34:41 +0000 (16:34 +0100)]
[mlir][SubElements] Disambiguate cast<> call for MSVC

For some reason MSVC selects Attribute::cast here, and then fails to
call it because it takes no arguments. Feels like a generic lambda compiler
bug.

mlir/include\mlir/IR/StorageUniquerSupport.h(135): error C2672: 'mlir::Attribute::cast': no matching overloaded function found

17 months ago[PowerPC] Do not convert lwz to lwa if the offset is not a multiple of 4
Nemanja Ivanovic [Tue, 31 Jan 2023 15:52:13 +0000 (09:52 -0600)]
[PowerPC] Do not convert lwz to lwa if the offset is not a multiple of 4

The transform that converts this checks the alignment of the global
object being accessed. However, there was no check for the offset
within the global object which caused the compiler to produce a
DS relocation for an unaligned address.

17 months ago[RISCV] Add asserts that we don't increase codesize during pseudo expansion
Philip Reames [Tue, 31 Jan 2023 15:44:53 +0000 (07:44 -0800)]
[RISCV] Add asserts that we don't increase codesize during pseudo expansion

We currently assume that pseudo expansion doesn't increase the distance between a branch and it's label. This patch adds some asserts to catch violations of this property in pseudo expansion.

I chose to only do the assertion at the function level as we have to scan the whole function for size changes (since expansion can create multiple blocks). We could cache individual block sizes, and thus make the check cheap enough to do after every expansion, but that requires more complex code.

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

17 months ago[LLDB] Do not dereference promise pointer in `coroutine_handle` pretty printer
Adrian Vogelsgesang [Tue, 31 Jan 2023 13:16:04 +0000 (05:16 -0800)]
[LLDB] Do not dereference promise pointer in `coroutine_handle` pretty printer

So far, the pretty printer for `std::coroutine_handle` internally
dereferenced the contained frame pointer displayed the `promise`
as a sub-value. As noticed in https://reviews.llvm.org/D132624
by @labath, this can lead to an endless loop in lldb during printing
if the coroutine frame pointers form a cycle.

This commit breaks the cycle by exposing the `promise` as a pointer
type instead of a value type. The depth to which the `frame variable`
and the `expression` commands dereference those pointers can be
controlled using the `--ptr-depth` argument.

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

17 months ago[AArch64][SME2] Add LLVM IR intrinsics for multi-single dots
David Sherwood [Tue, 31 Jan 2023 15:18:58 +0000 (15:18 +0000)]
[AArch64][SME2] Add LLVM IR intrinsics for multi-single dots

Adds intrinsics for the following SME2 instructions:

* sdot (multi-single, 2 and 4 vectors, 32-bit and 64-bit ZA)
* udot (multi-single, 2 and 4 vectors, 32-bit and 64-bit ZA)
* usdot (multi-single, 2 and 4 vectors)
* sudot (multi-single, 2 and 4 vectors)
* fdot (multi-single, 2 and 4 vectors)
* bfdot (multi-single, 2 and 4 vectors)

NOTE: These intrinsics are still in development and are subject to future changes.

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

17 months ago[clang][CGCall] Remove header file not used. [NFCI]
Francesco Petrogalli [Tue, 31 Jan 2023 15:11:58 +0000 (16:11 +0100)]
[clang][CGCall] Remove header file not used. [NFCI]

Reviewed By: fpetrogalli

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