platform/upstream/llvm.git
10 months ago[NFC][PowerPC] use script to regenerate the CHECK lines
Chen Zheng [Thu, 29 Feb 2024 09:41:39 +0000 (04:41 -0500)]
[NFC][PowerPC] use script to regenerate the CHECK lines

(cherry picked from commit 3196005f6bedbed61a86626a9e4f8fee7437a914)

10 months ago[msan] Re-exec with no ASLR if memory layout is incompatible on Linux (#85142)
Thurston Dang [Fri, 15 Mar 2024 16:49:00 +0000 (09:49 -0700)]
[msan] Re-exec with no ASLR if memory layout is incompatible on Linux (#85142)

This ports the change from TSan
(https://github.com/llvm/llvm-project/commit/0784b1eefa36d4acbb0dacd2d18796e26313b6c5).

Testing notes: run 'sudo sysctl vm.mmap_rnd_bits=32; ninja check-msan'
before and after this patch.

N.B. aggressive ASLR may also cause the app to overlap with the
allocator region; for MSan, this was fixed in
https://github.com/llvm/llvm-project/commit/af2bf86a372cacf5f536bae06e2f2d3886eefb7b

(cherry picked from commit 58f7251820b14c93168726a24816d8a094599be5)

10 months ago[msan] Add 'MappingDesc::ALLOCATOR' type and check it is available (#85153)
Thurston Dang [Thu, 14 Mar 2024 23:19:30 +0000 (16:19 -0700)]
[msan] Add 'MappingDesc::ALLOCATOR' type and check it is available (#85153)

MSan divides the virtual address space into APP, INVALID, SHADOW and
ORIGIN memory. The allocator usually just steals a bit of the APP
address space: typically the bottom portion of the PIE binaries section,
which works because the Linux kernel maps from the top of the PIE
binaries section. However, if ASLR is very aggressive, the binary may
end up mapped in the same location where the allocator wants to live;
this results in a segfault.

This patch adds in a MappingDesc::ALLOCATOR type and enforces that the
memory range for the allocator is not occupied by anything else.

Since the allocator range information is not readily available in
msan.h, we duplicate the information from msan_allocator.cpp.

Note: aggressive ASLR can also lead to a different type of failure,
where the PIE binaries/libraries are mapped entirely outside of the
APP/ALLOCATOR sections; that will be addressed in a separate patch
(https://github.com/llvm/llvm-project/pull/85142).

(cherry picked from commit af2bf86a372cacf5f536bae06e2f2d3886eefb7b)

10 months ago[clang][CodeGen] Allow `memcpy` replace with trivial auto var init
Antonio Frighetto [Thu, 7 Mar 2024 06:49:40 +0000 (07:49 +0100)]
[clang][CodeGen] Allow `memcpy` replace with trivial auto var init

When emitting the storage (or memory copy operations) for constant
initializers, the decision whether to split a constant structure or
array store into a sequence of field stores or to use `memcpy` is
based upon the optimization level and the size of the initializer.
In afe8b93ffdfef5d8879e1894b9d7dda40dee2b8d, we extended this by
allowing constants to be split when the array (or struct) type does
not match the type of data the address to the object (constant) is
expected to contain. This may happen when `emitStoresForConstant` is
called by `EmitAutoVarInit`, as the element type of the address gets
shrunk. When this occurs, let the initializer be split into a bunch
of stores only under `-ftrivial-auto-var-init=pattern`.

Fixes: https://github.com/llvm/llvm-project/issues/84178.
11 months ago[LoongArch] Assume no-op addrspacecasts by default (#82332)
hev [Wed, 21 Feb 2024 13:15:17 +0000 (21:15 +0800)]
[LoongArch] Assume no-op addrspacecasts by default (#82332)

This PR indicates that `addrspacecasts` are always no-ops on LoongArch.

Fixes #82330

(cherry picked from commit dd3e0a4643670f33850278ad281a358bbdd04e92)

11 months ago[SROA]: Only defer trying partial sized ptr or ptr vector types
Jeffrey Byrnes [Mon, 19 Feb 2024 20:59:13 +0000 (12:59 -0800)]
[SROA]: Only defer trying partial sized ptr or ptr vector types

Change-Id: Ic77f87290905addadd5819dff2d0c62f031022ab
(cherry picked from commit 1e828f838cc0f15074f3dbbb04929c06ef0c9729)

11 months ago[ARM] Update IsRestored for LR based on all returns (#82745)
ostannard [Mon, 26 Feb 2024 12:23:25 +0000 (12:23 +0000)]
[ARM] Update IsRestored for LR based on all returns (#82745)

PR #75527 fixed ARMFrameLowering to set the IsRestored flag for LR based
on all of the return instructions in the function, not just one.
However, there is also code in ARMLoadStoreOptimizer which changes
return instructions, but it set IsRestored based on the one instruction
it changed, not the whole function.

The fix is to factor out the code added in #75527, and also call it from
ARMLoadStoreOptimizer if it made a change to return instructions.

Fixes #80287.

(cherry picked from commit 749384c08e042739342c88b521c8ba5dac1b9276)

11 months agoPre-commit test showing bug #80287
Oliver Stannard [Fri, 23 Feb 2024 09:31:25 +0000 (09:31 +0000)]
Pre-commit test showing bug #80287

This test shows the bug where LR is used as a general-purpose register
on a code path where it is not spilled to the stack.

(cherry picked from commit 8779cf68e80dcc0b15e8034f39e6ce18b08352b6)

11 months agoBump version to 18.1.3 (#86168)
Tom Stellard [Fri, 22 Mar 2024 18:44:29 +0000 (11:44 -0700)]
Bump version to 18.1.3 (#86168)

11 months ago[X86] Add missing subvector_subreg_lowering for BF16 (#83720)
Phoebe Wang [Mon, 4 Mar 2024 10:09:41 +0000 (18:09 +0800)]
[X86] Add missing subvector_subreg_lowering for BF16 (#83720)

11 months ago[C++20] [Moduls] Avoid computing odr hash for functions from comparing constraint...
Chuanqi Xu [Mon, 11 Mar 2024 03:14:40 +0000 (11:14 +0800)]
[C++20] [Moduls] Avoid computing odr hash for functions from comparing constraint expression

Previously we disabled to compute ODR hash for declarations from the
global module fragment. However, we missed the case that the functions
lives in the concept requiments (see the attached the test files for
example). And the mismatch causes the potential crashment.

Due to we will set the function body as lazy after we deserialize it and
we will only take its body when needed. However, we don't allow to take
the body during deserializing. So it is actually potentially problematic
if we set the body as lazy first and computing the hash value of the
function, which requires to deserialize its body. So we will meet a
crash here.

This patch tries to solve the issue by not taking the body of the
function from GMF. Note that we can't skip comparing the constraint
expression from the GMF directly since it is an key part of the
function selecting and it may be the reason why we can't return 0
directly for `FunctionDecl::getODRHash()` from the GMF.

11 months ago[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
Luke Lau [Thu, 22 Feb 2024 03:50:27 +0000 (11:50 +0800)]
[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (#82506)

This fixes the miscompile reported in #82430 by telling
isSimpleVIDSequence to sign extend to XLen instead of the width of the
indices, since the "sequence" of indices generated by a strided load
will be at XLen.

This was the simplest way I could think of getting isSimpleVIDSequence
to treat the indexes as if they were zero extended to XLenVT.

Another way we could do this is by refactoring out the "get constant
integers" part from isSimpleVIDSequence and handle them as APInts so we
can separately zero extend it.

Fixes #82430

(cherry picked from commit 815644b4dd882ade2e5649d4f97c3dd6f7aea200)

11 months ago[RISCV] Adjust test case to show wrong stride. NFC
Luke Lau [Thu, 22 Feb 2024 03:05:06 +0000 (11:05 +0800)]
[RISCV] Adjust test case to show wrong stride. NFC

See https://github.com/llvm/llvm-project/pull/82506#discussion_r1498080785

(cherry picked from commit 11d115d0569b212dfeb7fe6485be48070e068e19)

11 months ago[RISCV] Add test case for miscompile in gather -> strided load combine. NFC
Luke Lau [Wed, 21 Feb 2024 10:05:04 +0000 (18:05 +0800)]
[RISCV] Add test case for miscompile in gather -> strided load combine. NFC

This shows the issue in #82430, but triggers it via the widening SEW combine
rather than a GEP that RISCVGatherScatterLowering doesn't detect.

(cherry picked from commit 2cd59bdc891ab59a1abfe5205feb45791a530a47)

11 months ago[TSan] Fix atomicrmw xchg with pointer and floats (#85228)
Nikita Popov [Fri, 15 Mar 2024 08:02:10 +0000 (09:02 +0100)]
[TSan] Fix atomicrmw xchg with pointer and floats (#85228)

atomicrmw xchg also accepts pointer and floating-point values. To handle
those, insert necessary casts to and from integer. This is what we do
for cmpxchg as well.

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

(cherry picked from commit ff2fb2a1d78585944dcdb9061c8487fe1476dfa4)

11 months ago[AVR] Remove earlyclobber from LDDRdPtrQ (#85277)
Patryk Wychowaniec [Fri, 15 Mar 2024 11:07:54 +0000 (12:07 +0100)]
[AVR] Remove earlyclobber from LDDRdPtrQ (#85277)

LDDRdPtrQ was marked as `earlyclobber`, which doesn't play well with
GreedyRA (which can generate this instruction through `loadRegFromStackSlot()`).

This seems to be the same case as:

https://github.com/llvm/llvm-project/blob/a99b912c9b74f6ef91786b4dfbc25160c27d3b41/llvm/lib/Target/AVR/AVRInstrInfo.td#L1421

Closes https://github.com/llvm/llvm-project/issues/81911.

11 months agoRevert "release/18.x: [openmp] __kmp_x86_cpuid fix for i386/PIC builds. (#846…"
David CARLIER [Sat, 16 Mar 2024 13:41:33 +0000 (13:41 +0000)]
Revert "release/18.x: [openmp] __kmp_x86_cpuid fix for i386/PIC builds. (#846…"

This reverts commit 9b3edb592debc00a5c3fbf7a71f63e07d6af44be.

11 months ago[PowerPC] Update chain uses when emitting lxsizx (#84892)
Qiu Chaofan [Mon, 18 Mar 2024 14:31:05 +0000 (22:31 +0800)]
[PowerPC] Update chain uses when emitting lxsizx (#84892)

(cherry picked from commit e5b20c83e5ba25e6e0650df30352ce54c2f6ea2f)

11 months ago[llvm-shlib] Fix the version naming style of libLLVM for Windows (#85710)
Martin Storsjö [Tue, 19 Mar 2024 06:48:57 +0000 (08:48 +0200)]
[llvm-shlib] Fix the version naming style of libLLVM for Windows (#85710)

This reverts the changes from 91a384621e5b762d9c173ffd247cfeadd5f436a2
for Windows targets. The changes in that commit don't work as expected
for Windows targets (those parts of llvm_add_library don't quite behave
the same for Windows), while the previous status quo (producing a
library named "libLLVM-<major>.dll") is the defacto standard way of
doing versioned library names there, contrary to on Unix.

After that commit, the library always ended up named "libLLVM.dll",
executables linking against it would reference "libLLVM.dll", and
"libLLVM-<major>.dll" was provided as a symlink.

Thus revert this bit back to as it were, so that executables actually
link against a versioned libLLVM, and no separate symlink is needed.

The only thing that might be improved compared to the status quo as it
was before these changes, is that the import library is named
"lib/libLLVM-<major>.dll.a", while the common style would be to name it
plainly "lib/libLLVM.dll.a" (even while it produces references to
"libLLVM-<major>.dll", but none of these had that effect for Windows
targets.

(As a side note, the llvm-shlib library can be built for MinGW, but not
currently in MSVC configurations.)

(cherry picked from commit cb2ca23345d3d9bde027a18d301949e8bdf606a6)

11 months ago[llvm-shlib] Fix libLLVM-18 symlink on mingw (#85554)
Tom Stellard [Sun, 17 Mar 2024 05:47:27 +0000 (22:47 -0700)]
[llvm-shlib] Fix libLLVM-18 symlink on mingw (#85554)

The TARGET_SONAME_FILE_NAME generator expression is not available on dll
target platforms.

(cherry picked from commit f84980570d3f85bdf5c9432647c05bae04a735a0)

11 months agollvm-shlib: Fix libLLVM-${MAJOR}.so symlink on MacOS (#85163)
Tom Stellard [Fri, 15 Mar 2024 15:16:46 +0000 (08:16 -0700)]
llvm-shlib: Fix libLLVM-${MAJOR}.so symlink on MacOS (#85163)

This is a partial revert of 10c48a772742b7afe665a815b7eba2047f17dc4b
with a fix for the symlink target name on MacOS

See #84637

(cherry picked from commit ec2b7522dbee1cb91111d6ade6e1768462247dcf)

11 months ago[WebAssembly] Change the default linker for `wasm32-wasip2` (#84569)
Alex Crichton [Tue, 19 Mar 2024 00:55:34 +0000 (19:55 -0500)]
[WebAssembly] Change the default linker for `wasm32-wasip2` (#84569)

This commit changes the default linker in the WebAssembly toolchain for
the `wasm32-wasip2` target. This target is being added to the
WebAssembly/wasi-sdk and WebAssembly/wasi-libc projects to target the
Component Model by default, in contrast with the preexisting
`wasm32-wasi` target (in the process of being renamed to
`wasm32-wasip1`) which outputs a core WebAssembly module by default.

The `wasm-component-ld` project currently lives in my GitHub account at
https://github.com/alexcrichton/wasm-component-ld and isn't necessarily
"official" yet, but it's expected to continue to evolve as the
`wasm32-wasip2` target continues to shape up and evolve.

(cherry picked from commit d66121d74a458e098511b9de920d815440acaa1b)

11 months agoworkflows: Fix baseline version for llvm abi checks (#85166)
Tom Stellard [Tue, 19 Mar 2024 13:55:10 +0000 (06:55 -0700)]
workflows: Fix baseline version for llvm abi checks (#85166)

The baseline version calculations was assuming the minor release would
always be 0.

(cherry picked from commit d93363a0e803a9fb2889ff03237f4e93aacf0108)

11 months ago[InstCombine] Drop UB-implying attrs/metadata after speculating an instruction (...
Yingwei Zheng [Sun, 17 Mar 2024 06:15:27 +0000 (14:15 +0800)]
[InstCombine] Drop UB-implying attrs/metadata after speculating an instruction (#85542)

When speculating an instruction in `InstCombinerImpl::FoldOpIntoSelect`,
the call may result in undefined behavior. This patch drops all
UB-implying attrs/metadata to fix this.

Fixes #85536.

(cherry picked from commit 252d01952c087cf0d141f7f281cf60efeb98be41)

11 months ago[lld][LoongArch] Fix handleUleb128
Weining Lu [Tue, 5 Mar 2024 15:19:16 +0000 (23:19 +0800)]
[lld][LoongArch] Fix handleUleb128

(cherry picked from commit a41bcb3930534ef1525b4fc30e53e818b39e2b60)

11 months ago[lld][test] Fix sanitizer buildbot failure
Weining Lu [Tue, 5 Mar 2024 14:01:07 +0000 (22:01 +0800)]
[lld][test] Fix sanitizer buildbot failure

Buildbot failure:
https://lab.llvm.org/buildbot/#/builders/5/builds/41530/steps/9/logs/stdio

(cherry picked from commit d9b435c24ddddcc8148fd97b42f6bb1124e52307)

11 months agoRemove support for EXPORTAS in def files to maintain ABI compatibility for COFFShortE...
Daniel Paoliello [Wed, 13 Mar 2024 23:18:10 +0000 (16:18 -0700)]
Remove support for EXPORTAS in def files to maintain ABI compatibility for COFFShortExport

11 months ago[Arm64EC] Copy import descriptors to the EC Map (#84834)
Daniel Paoliello [Tue, 12 Mar 2024 21:10:49 +0000 (14:10 -0700)]
[Arm64EC] Copy import descriptors to the EC Map (#84834)

As noted in <https://github.com/llvm/llvm-project/pull/78537>, MSVC
places import descriptors in both the EC and regular map - that PR moved
the descriptors to ONLY the regular map, however this causes linking
errors when linking as Arm64EC:

```
bcryptprimitives.lib(bcryptprimitives.dll) : error LNK2001: unresolved external symbol __IMPORT_DESCRIPTOR_bcryptprimitives (EC Symbol)
```

This change copies import descriptors from the regular map to the EC
map, which fixes this linking error.

11 months ago[llvm-lib][Object] Add support for EC importlib symbols. (#81059)
Jacek Caban [Sat, 10 Feb 2024 11:46:42 +0000 (12:46 +0100)]
[llvm-lib][Object] Add support for EC importlib symbols. (#81059)

ARM64EC import libraries expose two additional symbols: mangled thunk
symbol (like `#func`) and auxiliary import symbol (like`__imp_aux_func`).
The main functional change with this patch is that those symbols are
properly added to static library ECSYMBOLS.

11 months ago[llvm-lib][llvm-dlltool][Object] Add support for EXPORTAS name types. (#78772)
Jacek Caban [Sat, 10 Feb 2024 00:00:14 +0000 (01:00 +0100)]
[llvm-lib][llvm-dlltool][Object] Add support for EXPORTAS name types. (#78772)

EXPORTAS is a new name type in import libraries. It's used by default on ARM64EC,
but it's allowed on other platforms as well.

11 months ago[llvm-readobj][Object][COFF] Print COFF import library symbol export name. (#78769)
Jacek Caban [Tue, 6 Feb 2024 12:47:58 +0000 (13:47 +0100)]
[llvm-readobj][Object][COFF] Print COFF import library symbol export name. (#78769)

getExportName implementation is based on lld-link. In its current form,
it's mostly about convenience, but it will be more useful for EXPORTAS
support, for which export name is not possible to deduce from other
printed properties.

11 months ago[libc++] Use clang-tidy version that matches the compiler we use in the CI (#85305)
Louis Dionne [Sat, 16 Mar 2024 22:32:44 +0000 (18:32 -0400)]
[libc++] Use clang-tidy version that matches the compiler we use in the CI (#85305)

This works around ODR violations in the clang-tidy plugin we use to
perform the modules tests.

Fixes #85242

11 months ago[clangd] [HeuristicResolver] Protect against infinite recursion on DependentNameTypes...
Nathan Ridge [Mon, 4 Mar 2024 05:12:56 +0000 (00:12 -0500)]
[clangd] [HeuristicResolver] Protect against infinite recursion on DependentNameTypes (#83542)

When resolving names inside templates that implement recursive
compile-time functions (e.g. waldo<N>::type is defined in terms
of waldo<N-1>::type), HeuristicResolver could get into an infinite
recursion, specifically one where resolveDependentNameType() can
be called recursively with the same DependentNameType*.

To guard against this, HeuristicResolver tracks, for each external
call into a HeuristicResolver function, the set of DependentNameTypes
that it has seen, and bails if it sees the same DependentNameType again.

To implement this, a helper class HeuristicResolverImpl is introduced
to store state that persists for the duration of an external call into
HeuristicResolver (but does not persist between such calls).

Fixes https://github.com/clangd/clangd/issues/1951

(cherry picked from commit e6e53ca8470d719882539359ebe3ad8b442a8cb0)

11 months ago[clang][modules] giving the __stddef_ headers their own modules can cause redeclarati...
Ian Anderson [Wed, 13 Mar 2024 18:15:41 +0000 (11:15 -0700)]
[clang][modules] giving the __stddef_ headers their own modules can cause redeclaration errors with -fbuiltin-headers-in-system-modules (#84127)

On Apple platforms, some of the stddef.h types are also declared in
system headers. In particular NULL has a conflicting declaration in
<sys/_types/_null.h>. When that's in a different module from
<__stddef_null.h>, redeclaration errors can occur.

Make the \_\_stddef_ headers be non-modular in
-fbuiltin-headers-in-system-modules and restore them back to not
respecting their header guards. Still define the header guards though.
__stddef_max_align_t.h was in _Builtin_stddef_max_align_t prior to the
addition of _Builtin_stddef, and it needs to stay in a module because
struct's can't be type merged. __stddef_wint_t.h didn't used to have a
module, but leave it in it current module since it doesn't really belong
to stddef.h.

(cherry picked from commit f50d3582b4844b86ad86372028e44b52c560ec7d)

11 months agoworkflows: Add workaround for lld failures on MacOS (#85021) (#85110)
Tom Stellard [Fri, 15 Mar 2024 15:15:53 +0000 (08:15 -0700)]
workflows: Add workaround for lld failures on MacOS (#85021) (#85110)

See #81967

(cherry picked from commit 175b533720956017bb18d1280362f6890ee15b05)

11 months agorelease/18.x: [openmp] __kmp_x86_cpuid fix for i386/PIC builds. (#84626) (#85053)
David CARLIER [Fri, 15 Mar 2024 04:43:47 +0000 (04:43 +0000)]
release/18.x: [openmp] __kmp_x86_cpuid fix for i386/PIC builds. (#84626) (#85053)

11 months ago[clangd] Add clangd 18 release notes (#84436)
Nathan Ridge [Fri, 15 Mar 2024 04:37:43 +0000 (00:37 -0400)]
[clangd] Add clangd 18 release notes (#84436)

11 months ago[runtimes] Prefer -fvisibility-global-new-delete=force-hidden (#84917)
Martin Storsjö [Wed, 13 Mar 2024 20:01:01 +0000 (22:01 +0200)]
[runtimes] Prefer -fvisibility-global-new-delete=force-hidden (#84917)

27ce26b06655cfece3d54b30e442ef93d3e78ac7 added the new option
-fvisibility-global-new-delete=, where -fvisibility-global-new-delete=force-hidden
is equivalent to the old option -fvisibility-global-new-delete-hidden.
At the same time, the old option was deprecated.

Test for and use the new option form first; if unsupported, try
using the old form.

This avoids warnings in the MinGW builds, if built with Clang 18 or
newer.

(cherry picked from commit 1f973efd335f34c75fcba1ccbe288fd5ece15a64)

11 months ago[ELF] Eliminate symbols demoted due to /DISCARD/ discarded sections (#85167)
Fangrui Song [Thu, 14 Mar 2024 16:51:27 +0000 (09:51 -0700)]
[ELF] Eliminate symbols demoted due to /DISCARD/ discarded sections (#85167)

#69295 demoted Defined symbols relative to discarded sections.
If such a symbol is unreferenced, the desired behavior is to
eliminate it from .symtab just like --gc-sections discarded
definitions.
Linux kernel's CONFIG_DEBUG_FORCE_WEAK_PER_CPU=y configuration expects
that the unreferenced `unused` is not emitted to .symtab
(https://github.com/ClangBuiltLinux/linux/issues/2006).

For relocations referencing demoted symbols, the symbol index restores
to 0 like older lld (`R_X86_64_64 0` in `discard-section.s`).

Fix #85048

(cherry picked from commit 8fe3e70e810b409dce36f6d415e86f0f9b1cf22d)

11 months agoSystemZ release notes for 18.x. (#84560)
Jonas Paulsson [Wed, 13 Mar 2024 23:27:21 +0000 (19:27 -0400)]
SystemZ release notes for 18.x. (#84560)

11 months ago[X86][Inline] Skip inline asm in inlining target feature check (#83820)
Nikita Popov [Tue, 5 Mar 2024 13:21:33 +0000 (14:21 +0100)]
[X86][Inline] Skip inline asm in inlining target feature check (#83820)

When inlining across functions with different target features, we
perform roughly two checks:
 1. The caller features must be a superset of the callee features.
2. Calls in the callee cannot use types where the target features would
change the call ABI (e.g. by changing whether something is passed in a
zmm or two ymm registers). The latter check is very crude right now.

The latter check currently also catches inline asm "calls". I believe
that inline asm should be excluded from this check, as it is independent
from the usual call ABI, and instead governed by the inline asm
constraint string.

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

(cherry picked from commit e84182af919d136d74b75ded4d599b38fb47dfb0)

11 months ago[Inline] Add test for #67054 (NFC)
Nikita Popov [Mon, 4 Mar 2024 10:32:07 +0000 (11:32 +0100)]
[Inline] Add test for #67054 (NFC)

(cherry picked from commit cad6ad2759a782c48193f83886488dacc9f330e3)

11 months ago[ValueTracking] Treat phi as underlying obj when not decomposing further (#84339)
Florian Hahn [Tue, 12 Mar 2024 08:55:03 +0000 (08:55 +0000)]
[ValueTracking] Treat phi as underlying obj when not decomposing further (#84339)

At the moment, getUnderlyingObjects simply continues for phis that do
not refer to the same underlying object in loops, without adding them to
the list of underlying objects, effectively ignoring those phis.

Instead of ignoring those phis, add them to the list of underlying
objects. This fixes a miscompile where LoopAccessAnalysis fails to
identify a memory dependence, because no underlying objects can be found
for a set of memory accesses.

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

PR: https://github.com/llvm/llvm-project/pull/84339
(cherry picked from commit b274b23665dec30f3ae4fb83ccca8b77e6d3ada3)

11 months ago[LAA] Add test case for #82665.
Florian Hahn [Thu, 7 Mar 2024 13:53:02 +0000 (13:53 +0000)]
[LAA] Add test case for #82665.

Test case for https://github.com/llvm/llvm-project/issues/82665.

(cherry picked from commit 4cfd4a7896b5fd50274ec8573c259d7ad41741de)

11 months ago[Release] Install compiler-rt builtins during Phase 1 on AIX (#81485)
azhan92 [Fri, 16 Feb 2024 02:27:45 +0000 (21:27 -0500)]
[Release] Install compiler-rt builtins during Phase 1 on AIX (#81485)

The current test-release.sh script does not install the necessary
compiler-rt builtin's during Phase 1 on AIX, resulting on a
non-functional Phase 1 clang. Futhermore, the installation is also
necessary for Phase 2 on AIX.

Co-authored-by: Alison Zhang <alisonzhang@ibm.com>
(cherry picked from commit 3af5c98200e0b1268f755c3f289be4f73aac4214)

11 months ago[ArgPromotion] Remove incorrect TranspBlocks set for loads. (#84835)
Florian Hahn [Tue, 12 Mar 2024 09:47:42 +0000 (09:47 +0000)]
[ArgPromotion] Remove incorrect TranspBlocks set for loads. (#84835)

The TranspBlocks set was used to cache aliasing decision for all
processed loads in the parent loop. This is incorrect, because each load
can access a different location, which means one load not being modified
in a block doesn't translate to another load not being modified in the
same block.

All loads access the same underlying object, so we could perhaps use a
location without size for all loads and retain the cache, but that would
mean we loose precision.

For now, just drop the cache.

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

PR: https://github.com/llvm/llvm-project/pull/84835
(cherry picked from commit bba4a1daff6ee09941f1369a4e56b4af95efdc5c)

11 months ago[ArgPromotion] Add test case for #84807.
Florian Hahn [Mon, 11 Mar 2024 21:06:03 +0000 (21:06 +0000)]
[ArgPromotion] Add test case for #84807.

Test case for https://github.com/llvm/llvm-project/issues/84807,
showing a mis-compile in ArgPromotion.

(cherry picked from commit 31ffdb56b4df9b772d763dccabbfde542545d695)

11 months ago[LLD] [COFF] Set the right alignment for DelayDirectoryChunk (#84697)
Martin Storsjö [Mon, 11 Mar 2024 22:03:26 +0000 (00:03 +0200)]
[LLD] [COFF] Set the right alignment for DelayDirectoryChunk (#84697)

This makes a difference when linking executables with delay loaded
libraries for arm32; the delay loader implementation can load data from
the registry with instructions that assume alignment.

This issue does not show up when linking in MinGW mode, because a
PseudoRelocTableChunk gets injected, which also sets alignment, even if
the chunk itself is empty.

(cherry picked from commit c93c76b562784926b22a69d3f82a5032dcb4a274)

11 months ago[X86] combineAndShuffleNot - ensure the type is legal before create X86ISD::ANDNP...
Simon Pilgrim [Sun, 10 Mar 2024 16:23:51 +0000 (16:23 +0000)]
[X86] combineAndShuffleNot - ensure the type is legal before create X86ISD::ANDNP target nodes

Fixes #84660

(cherry picked from commit 862c7e0218f27b55a5b75ae59a4f73cd4610448d)

11 months ago[DSE] Remove malloc from EarliestEscapeInfo before removing. (#84157)
Florian Hahn [Wed, 6 Mar 2024 20:08:00 +0000 (20:08 +0000)]
[DSE] Remove malloc from EarliestEscapeInfo before removing. (#84157)

Not removing the malloc from earliest escape info leaves stale entries
in the cache.

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

PR: https://github.com/llvm/llvm-project/pull/84157
(cherry picked from commit eb8f379567e8d014194faefe02ce92813e237afc)

11 months ago[InstCombine] Fix miscompilation in PR83947 (#83993)
Yingwei Zheng [Tue, 5 Mar 2024 14:34:04 +0000 (22:34 +0800)]
[InstCombine] Fix miscompilation in PR83947 (#83993)

https://github.com/llvm/llvm-project/blob/762f762504967efbe159db5c737154b989afc9bb/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp#L394-L407

Comment from @topperc:
> This transforms assumes the mask is a non-zero splat. We only know its
a splat and not provably all 0s. The mask is a constexpr that includes
the address of the global variable. We can't resolve the constant
expression to an exact value.

Fixes #83947.

11 months ago[Clang][LoongArch] Fix wrong return value type of __iocsrrd_h (#84100)
wanglei [Wed, 6 Mar 2024 02:03:28 +0000 (10:03 +0800)]
[Clang][LoongArch] Fix wrong return value type of __iocsrrd_h (#84100)

relate:
https://gcc.gnu.org/pipermail/gcc-patches/2024-February/645016.html
(cherry picked from commit 2f479b811274fede36535e34ecb545ac22e399c3)

11 months ago[Clang][LoongArch] Precommit test for fix wrong return value type of __iocsrrd_h...
wanglei [Tue, 5 Mar 2024 11:44:28 +0000 (19:44 +0800)]
[Clang][LoongArch] Precommit test for fix wrong return value type of __iocsrrd_h. NFC

(cherry picked from commit aeda1a6e800e0dd6c91c0332b4db95094ad5b301)

11 months ago[LoongArch] Make sure that the LoongArchISD::BSTRINS node uses the correct `MSB`...
wanglei [Mon, 11 Mar 2024 00:59:17 +0000 (08:59 +0800)]
[LoongArch] Make sure that the LoongArchISD::BSTRINS node uses the correct `MSB` value (#84454)

The `MSB` must not be greater than `GRLen`. Without this patch, newly
added test cases will crash with LoongArch32, resulting in a 'cannot
select' error.

(cherry picked from commit edd4c6c6dca4c556de22b2ab73d5bfc02d28e59b)

11 months ago[analyzer] Fix crash on dereference invalid return value of getAdjustedParameterIndex...
Exile [Wed, 6 Mar 2024 16:01:30 +0000 (00:01 +0800)]
[analyzer] Fix crash on dereference invalid return value of getAdjustedParameterIndex() (#83585)

Fixes #78810
Thanks for Snape3058 's comment

---------

Co-authored-by: miaozhiyuan <miaozhiyuan@feysh.com>
(cherry picked from commit d4687fe7d1639ea5d16190c89a54de1f2c6e2a9a)

11 months ago[libc++] Enable availability based on the compiler instead of __has_extension (#84065)
Louis Dionne [Thu, 7 Mar 2024 20:12:21 +0000 (15:12 -0500)]
[libc++] Enable availability based on the compiler instead of __has_extension (#84065)

__has_extension(...) doesn't work as intended when -pedantic-errors is
used with Clang. With that flag, __has_extension(...) is equivalent to
__has_feature(...), which means that checks like

    __has_extension(pragma_clang_attribute_external_declaration)

will return 0. In turn, this has the effect of disabling availability
markup in libc++, which is undesirable.

rdar://124078119
(cherry picked from commit 292a28df6c55679fad0589dea35278a8c66b2ae1)

11 months ago[InstCombine] Handle scalable splat in `getFlippedStrictnessPredicateAndConstant`
Yingwei Zheng [Tue, 5 Mar 2024 09:21:16 +0000 (17:21 +0800)]
[InstCombine] Handle scalable splat in `getFlippedStrictnessPredicateAndConstant`

(cherry picked from commit d51fcd4ed86ac6075c8a25b053c2b66051feaf62)

11 months ago[lld][LoongArch] Support the R_LARCH_{ADD,SUB}_ULEB128 relocation types (#81133)
Jinyang He [Tue, 5 Mar 2024 07:50:14 +0000 (15:50 +0800)]
[lld][LoongArch] Support the R_LARCH_{ADD,SUB}_ULEB128 relocation types (#81133)

For a label difference like `.uleb128 A-B`, MC generates a pair of
R_LARCH_{ADD,SUB}_ULEB128 if A-B cannot be folded as a constant. GNU
assembler generates a pair of relocations in more cases (when A or B is
in a code section with linker relaxation). It is similar to RISCV.

R_LARCH_{ADD,SUB}_ULEB128 relocations are created by Clang and GCC in
`.gcc_except_table` and other debug sections with linker relaxation
enabled. On LoongArch, first read the buf and count the available space.
Then add or sub the value. Finally truncate the expected value and fill
it into the available space.

(cherry picked from commit eaa9ef678c63bf392ec2d5b736605db7ea7e7338)

11 months ago[Clang] [Sema] Handle placeholders in '.*' expressions (#83103)
Sirraide [Tue, 27 Feb 2024 19:19:44 +0000 (20:19 +0100)]
[Clang] [Sema] Handle placeholders in '.*' expressions (#83103)

When analysing whether we should handle a binary expression as an
overloaded operator call or a builtin operator, we were calling
`checkPlaceholderForOverload()`, which takes care of any placeholders
that are not overload sets—which would usually make sense since those
need to be handled as part of overload resolution.

Unfortunately, we were also doing that for `.*`, which is not
overloadable, and then proceeding to create a builtin operator anyway,
which would crash if the RHS happened to be an unresolved overload set
(due hitting an assertion in `CreateBuiltinBinOp()`—specifically, in one
of its callees—in the `.*` case that makes sure its arguments aren’t
placeholders).

This pr instead makes it so we check for *all* placeholders early if the
operator is `.*`.

It’s worth noting that,
1. In the `.*` case, we now additionally also check for *any*
placeholders (not just non-overload-sets) in the LHS; this shouldn’t
make a difference, however—at least I couldn’t think of a way to trigger
the assertion with an overload set as the LHS of `.*`; it is worth
noting that the assertion in question would also complain if the LHS
happened to be of placeholder type, though.
2. There is another case in which we also don’t perform overload
resolution—namely `=` if the LHS is not of class or enumeration type
after handling non-overload-set placeholders—as in the `.*` case, but
similarly to 1., I first couldn’t think of a way of getting this case to
crash, and secondly, `CreateBuiltinBinOp()` doesn’t seem to care about
placeholders in the LHS or RHS in the `=` case (from what I can tell,
it, or rather one of its callees, only checks that the LHS is not a
pseudo-object type, but those will have already been handled by the call
to `checkPlaceholderForOverload()` by the time we get to this function),
so I don’t think this case suffers from the same problem.

This fixes #53815.

---------

Co-authored-by: Aaron Ballman <aaron@aaronballman.com>
11 months ago[RISCV] Fix crash when unrolling loop containing vector instructions (#83384)
Shih-Po Hung [Sat, 2 Mar 2024 04:33:55 +0000 (12:33 +0800)]
[RISCV] Fix crash when unrolling loop containing vector instructions (#83384)

When MVT is not a vector type, TCK_CodeSize should return an invalid
cost. This patch adds a check in the beginning to make sure all cost
kinds return invalid costs consistently.

Before this patch, TCK_CodeSize returns a valid cost on scalar MVT but
other cost kinds doesn't.

This fixes the issue #83294 where a loop contains vector instructions
and MVT is scalar after type legalization when the vector extension is
not enabled,

(cherry picked from commit fb67dce1cb87e279593c27bd4122fe63bad75f04)

11 months ago[ELF] Internalize enum
Fangrui Song [Fri, 1 Mar 2024 19:17:22 +0000 (11:17 -0800)]
[ELF] Internalize enum

g++ -flto has a diagnostic `-Wodr` about mismatched redeclarations,
which even apply to `enum`.

Fix #83529

Reviewers: thesamesam

Reviewed By: thesamesam

Pull Request: https://github.com/llvm/llvm-project/pull/83604

(cherry picked from commit 4a3f7e798a31072a80a0731b8fb1da21b9c626ed)

11 months agoUnbreak *tf builtins for hexfloat (#82208)
Alexander Richardson [Wed, 21 Feb 2024 20:59:56 +0000 (12:59 -0800)]
Unbreak *tf builtins for hexfloat (#82208)

This re-lands cc0065a7d082f0bd322a538cf62cfaef1c8f89f8 in a way that
keeps existing targets working.

---------

Original commit message:
#68132 ended up removing
__multc3 & __divtc3 from compiler-rt library builds that have
QUAD_PRECISION but not TF_MODE due to missing int128 support.
I added support for QUAD_PRECISION to use the native hex float long double representation.

---------

Co-authored-by: Sean Perry <perry@ca.ibm.com>
(cherry picked from commit 99c457dc2ef395872d7448c85609f6cb73a7f89b)

11 months ago[AArch64] Skip over shadow space for ARM64EC entry thunk variadic calls (#80994)
Billy Laws [Tue, 27 Feb 2024 18:32:15 +0000 (18:32 +0000)]
[AArch64] Skip over shadow space for ARM64EC entry thunk variadic calls (#80994)

When in an entry thunk the x64 SP is passed in x4 but this cannot be
directly passed through since x64 varargs calls have a 32 byte shadow
store at SP followed by the in-stack parameters. ARM64EC varargs calls
on the other hand expect x4 to point to the first in-stack parameter.

11 months ago[AArch64] Fix generated types for ARM64EC variadic entry thunk targets (#80595)
Billy Laws [Mon, 5 Feb 2024 17:26:16 +0000 (17:26 +0000)]
[AArch64] Fix generated types for ARM64EC variadic entry thunk targets (#80595)

ISel handles filling in x4/x5 when calling variadic functions as they
don't correspond to the 5th/6th X64 arguments but rather to the end of
the shadow space on the stack and the size in bytes of all stack
parameters (ignored and written as 0 for calls from entry thunks).

Will PR a follow up with ISel handling after this is merged.

11 months ago[AArch64] Fix variadic tail-calls on ARM64EC (#79774)
Billy Laws [Wed, 31 Jan 2024 02:32:15 +0000 (02:32 +0000)]
[AArch64] Fix variadic tail-calls on ARM64EC (#79774)

ARM64EC varargs calls expect that x4 = sp at entry, special handling is
needed to ensure this with tail calls since they occur after the
epilogue and the x4 write happens before.

I tried going through AArch64MachineFrameLowering for this, hoping to
avoid creating the dummy object but this was the best I could do since
the stack info that uses isn't populated at this stage,
CreateFixedObject also explicitly forbids 0 sized objects.

11 months ago[LoongArch] Override LoongArchTargetLowering::getExtendForAtomicCmpSwapArg (#83656)
Lu Weining [Mon, 4 Mar 2024 00:38:52 +0000 (08:38 +0800)]
[LoongArch] Override LoongArchTargetLowering::getExtendForAtomicCmpSwapArg (#83656)

This patch aims to solve Firefox issue:
https://bugzilla.mozilla.org/show_bug.cgi?id=1882301

Similar to 616289ed2922. Currently LoongArch uses an ll.[wd]/sc.[wd]
loop for ATOMIC_CMP_XCHG. Because the comparison in the loop is
full-width (i.e. the `bne` instruction), we must sign extend the input
comparsion argument.

Note that LoongArch ISA manual V1.1 has introduced compare-and-swap
instructions. We would change the implementation (return `ANY_EXTEND`)
when we support them.

(cherry picked from commit 5f058aa211995d2f0df2a0e063532832569cb7a8)

11 months ago[TableGen] Fix wrong codegen of BothFusionPredicateWithMCInstPredicate (#83990)
Wang Pengcheng [Tue, 5 Mar 2024 11:54:02 +0000 (19:54 +0800)]
[TableGen] Fix wrong codegen of BothFusionPredicateWithMCInstPredicate (#83990)

We should generate the `MCInstPredicate` twice, one with `FirstMI`
and another with `SecondMI`.

(cherry picked from commit de1f33873beff93063577195e1214a9509e229e0)

11 months ago[OpenMP] fix endianness dependent definitions in OMP headers for MSVC (#84540)
Vadim Paretsky [Sat, 9 Mar 2024 18:47:31 +0000 (10:47 -0800)]
[OpenMP] fix endianness dependent definitions in OMP headers for MSVC (#84540)

MSVC does not define __BYTE_ORDER__ making the check for BigEndian
erroneously evaluate to true and breaking the struct definitions in MSVC
compiled builds correspondingly. The fix adds an additional check for
whether __BYTE_ORDER__ is defined by the compiler to fix these.

---------

Co-authored-by: Vadim Paretsky <b-vadipa@microsoft.com>
(cherry picked from commit 110141b37813dc48af33de5e1407231e56acdfc5)

11 months agoReleaseNotes for LLVM binary utilities (#83751)
Fangrui Song [Mon, 11 Mar 2024 20:40:01 +0000 (13:40 -0700)]
ReleaseNotes for LLVM binary utilities (#83751)

11 months ago[InstCombine] Fix infinite loop in select equivalence fold (#84036)
Nikita Popov [Wed, 6 Mar 2024 08:33:51 +0000 (09:33 +0100)]
[InstCombine] Fix infinite loop in select equivalence fold (#84036)

When replacing with a non-constant, it's possible that the result of the
simplification is actually more complicated than the original, and may
result in an infinite combine loop.

Mitigate the issue by requiring that either the replacement or
simplification result is constant, which should ensure that it's
simpler. While this check is crude, it does not appear to cause
optimization regressions in real-world code in practice.

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

(cherry picked from commit 9f45c5e1a65a1abf4920b617d36ed05e73c04bea)

11 months ago [InstCombine] Fix shift calculation in InstCombineCasts (#84027)
Quentin Dian [Tue, 5 Mar 2024 22:16:28 +0000 (06:16 +0800)]
 [InstCombine] Fix shift calculation in InstCombineCasts (#84027)

Fixes #84025.

(cherry picked from commit e96c0c1d5e0a9916098b1a31acb006ea6c1108fb)

11 months ago[test] Make two sanitize-coverage tests pass with glibc 2.39+
Fangrui Song [Wed, 6 Mar 2024 21:17:43 +0000 (13:17 -0800)]
[test] Make two sanitize-coverage tests pass with glibc 2.39+

glibc 2.39 added `nonnull` attribute to most libio functions accepting a
`FILE*` parameter, including fprintf[1]. The -fsanitize=undefined mode
checks the argument to fprintf and has extra counters, not expected by
two tests. Specify -fno-sanitize=nonnull-attribute to make the two tests
pass.

Fix #82883

[1]: https://sourceware.org/git/?p=glibc.git;a=commit;h=64b1a44183a3094672ed304532bedb9acc707554

Pull Request: https://github.com/llvm/llvm-project/pull/84231

(cherry picked from commit c3acbf6bb06f9039f9850e18e0ae2f2adef63905)

11 months ago[DSE] Delay deleting non-memory-defs until end of DSE. (#83411)
Florian Hahn [Sat, 2 Mar 2024 12:34:36 +0000 (12:34 +0000)]
[DSE] Delay deleting non-memory-defs until end of DSE. (#83411)

DSE uses BatchAA, which caches queries using pairs of MemoryLocations.
At the moment, DSE may remove instructions that are used as pointers in
cached MemoryLocations. If a new instruction used by a new MemoryLoation
and this instruction gets allocated at the same address as a previosuly
cached and then removed instruction, we may access an incorrect entry in
the cache.

To avoid this delay removing all instructions except MemoryDefs until
the end of DSE. This should avoid removing any values used in BatchAA's
cache.

Test case by @vporpo from
https://github.com/llvm/llvm-project/pull/83181.
(Test not precommitted because the results are non-determinstic - memset
only sometimes gets removed)

PR: https://github.com/llvm/llvm-project/pull/83411
(cherry picked from commit 10f5e983a9e3162a569cbebeb32168716e391340)

11 months ago[clang][fat-lto-objects] Make module flags match non-FatLTO pipelines (#83159)
Paul Kirth [Thu, 29 Feb 2024 03:11:55 +0000 (19:11 -0800)]
[clang][fat-lto-objects] Make module flags match non-FatLTO pipelines (#83159)

In addition to being rather hard to follow, there isn't a good reason
why FatLTO shouldn't just share the same code for setting module flags
for (Thin)LTO. This patch simplifies the logic and makes sure we use set
these flags in a consistent way, independent of FatLTO.

Additionally, we now test that output in the .llvm.lto section actually
matches the output from Full and Thin LTO compilation.

(cherry picked from commit 7d8b50aaab8e0f935e3cb1f3f397e98b9e3ee241)

11 months agoAllow .alt_entry symbols to pass the .cfi nesting check (#82268)
Jon Roelofs [Wed, 28 Feb 2024 21:03:35 +0000 (13:03 -0800)]
Allow .alt_entry symbols to pass the .cfi nesting check (#82268)

A symbol with an `N_ALT_ENTRY` attribute may be defined in the middle of
a subsection, so it is reasonable to opt them out of the
`.cfi_{start,end}proc` nesting check.

Fixes: https://github.com/llvm/llvm-project/issues/82261
(cherry picked from commit 5b91647e3f82c9747c42c3239b7d7f3ade4542a7)

11 months agoMIPS: fix emitDirectiveCpsetup on N32 (#80534)
YunQiang Su [Mon, 26 Feb 2024 21:08:58 +0000 (05:08 +0800)]
MIPS: fix emitDirectiveCpsetup on N32 (#80534)

In gas, .cpsetup may expand to one of two code sequences (one is related to `__gnu_local_gp`), depending on -mno-shared and -msym32.
Since Clang doesn't support -mno-shared or -msym32, .cpsetup expands to one code sequence.
The N32 condition incorrectly leads to the incorrect `__gnu_local_gp` code sequence.

```
00000000 <t1>:
   0:   ffbc0008        sd      gp,8(sp)
   4:   3c1c0000        lui     gp,0x0
                        4: R_MIPS_HI16  __gnu_local_gp
   8:   279c0000        addiu   gp,gp,0
                        8: R_MIPS_LO16  __gnu_local_gp
```

Fixes: #52785
(cherry picked from commit 860b6edfa9b344fbf8c500c17158c8212ea87d1c)

11 months ago[libc++][modules] Fixes naming inconsistency. (#83036)
Mark de Wever [Tue, 27 Feb 2024 17:10:53 +0000 (18:10 +0100)]
[libc++][modules] Fixes naming inconsistency. (#83036)

The modules used is-standard-library and is-std-library. The latter is
the name used in the SG15 proposal,

Fixes: https://github.com/llvm/llvm-project/issues/82879
(cherry picked from commit b50bcc7ffb6ad6caa4c141a22915ab59f725b7ae)

11 months agoBump version to 18.1.2 (#84655)
Tom Stellard [Mon, 11 Mar 2024 14:31:28 +0000 (07:31 -0700)]
Bump version to 18.1.2 (#84655)

11 months agoBump version to 18.1.1
Tom Stellard [Fri, 8 Mar 2024 05:27:31 +0000 (21:27 -0800)]
Bump version to 18.1.1

11 months agoRemove RC suffix
Tobias Hieta [Tue, 19 Sep 2023 07:44:33 +0000 (09:44 +0200)]
Remove RC suffix

11 months agoMIPS: Fix asm constraints "f" and "r" for softfloat (#79116)
YunQiang Su [Tue, 27 Feb 2024 06:08:36 +0000 (14:08 +0800)]
MIPS: Fix asm constraints "f" and "r" for softfloat (#79116)

This include 2 fixes:
        1. Disallow 'f' for softfloat.
        2. Allow 'r' for softfloat.

Currently, 'f' is accpeted by clang, then LLVM meets an internal error.

'r' is rejected by LLVM by: couldn't allocate input reg for constraint
'r'.

Fixes: #64241, #63632
---------

Co-authored-by: Fangrui Song <i@maskray.me>
(cherry picked from commit c88beb4112d5bbf07d76a615ab7f13ba2ba023e6)

11 months ago[Mips] Fix unable to handle inline assembly ends with compat-branch o… (#77291)
yingopq [Sat, 24 Feb 2024 07:13:43 +0000 (15:13 +0800)]
[Mips] Fix unable to handle inline assembly ends with compat-branch o… (#77291)

…n MIPS

Modify:
Add a global variable 'CurForbiddenSlotAttr' to save current
instruction's forbidden slot and whether set reorder. This is the
judgment condition for whether to add nop. We would add a couple of
'.set noreorder' and '.set reorder' to wrap the current instruction and
the next instruction.
Then we can get previous instruction`s forbidden slot attribute and
whether set reorder by 'CurForbiddenSlotAttr'.
If previous instruction has forbidden slot and .set reorder is active
and current instruction is CTI. Then emit a NOP after it.

Fix https://github.com/llvm/llvm-project/issues/61045.

Because https://reviews.llvm.org/D158589 was 'Needs Review' state, not
ending, so we commit pull request again.

(cherry picked from commit 96abee5eef31274415681018553e1d4a16dc16c9)

11 months ago[NFC][AArch64] fix whitespace in AArch64SchedNeoverseV1 (#81744)
Philipp Tomsich [Thu, 15 Feb 2024 00:54:08 +0000 (16:54 -0800)]
[NFC][AArch64] fix whitespace in AArch64SchedNeoverseV1 (#81744)

One of the whitespace fixes didn't get added to the commit introducing
the Ampere1B model.
Clean it up.

(cherry picked from commit 3369e341288b3d9bb59827f9a2911ebf3d36408d)

11 months ago[AArch64] Initial Ampere1B scheduling model (#81341)
Philipp Tomsich [Wed, 14 Feb 2024 14:23:14 +0000 (06:23 -0800)]
[AArch64] Initial Ampere1B scheduling model (#81341)

The Ampere1B core is enabled with a new scheduling/pipeline model, as it
provides significant updates over the Ampere1 core; it reduces latencies
on many instructions, has some micro-ops reassigned between the XY and X
units, and provides modelling for the instructions added since Ampere1
and Ampere1A.

As this is the first model implementing the CSSC instructions, we update
the UnsupportedFeatures on all other models (that have CompleteModel
set).

Testcases are added under llvm-mca: these showed the FullFP16 feature
missing, so we are adding it in as part of this commit.

This *adds tests and additional fixes* compared to the reverted #81338.

(cherry picked from commit dd1897c6cb028bda7d4d541d1bb33965eccf0a68)

11 months ago[AArch64] Add the Ampere1B core (#81297)
Philipp Tomsich [Fri, 9 Feb 2024 23:22:09 +0000 (15:22 -0800)]
[AArch64] Add the Ampere1B core (#81297)

The Ampere1B is Ampere's third-generation core implementing a
superscalar, out-of-order microarchitecture with nested virtualization,
speculative side-channel mitigation and architectural support for
defense against ROP/JOP style software attacks.

Ampere1B is an ARMv8.7+ implementation, adding support for the FEAT
WFxT, FEAT CSSC, FEAT PAN3 and FEAT AFP extensions. It also includes all
features of the second-generation Ampere1A, such as the Memory Tagging
Extension and SM3/SM4 cryptography instructions.

(cherry picked from commit fbba818a78f591d89f25768ba31783714d526532)

11 months ago[AArch64] Make +pauth enabled in Armv8.3-a by default (#78027)
Anatoly Trosinenko [Thu, 1 Feb 2024 16:23:55 +0000 (19:23 +0300)]
[AArch64] Make +pauth enabled in Armv8.3-a by default (#78027)

Add AEK_PAUTH to ARMV8_3A in TargetParser and let it propagate to
ARMV8R, as it aligns with GCC defaults.

After adding AEK_PAUTH, several tests from TargetParserTest.cpp crashed
when trying to format an error message, thus update a format string in
AssertSameExtensionFlags to account for bitmask being pre-formatted as
std::string.

The CHECK-PAUTH* lines in aarch64-target-features.c are updated to
account for the fact that FEAT_PAUTH support and pac-ret can be enabled
independently and all four combinations are possible.

(cherry picked from commit a52eea66795018550e95c4b060165a7250899298)

11 months ago[Clang] Fixes to immediate-escalating functions (#82281)
cor3ntin [Wed, 21 Feb 2024 19:53:44 +0000 (20:53 +0100)]
[Clang] Fixes to immediate-escalating functions (#82281)

* Consider that immediate escalating function can appear at global
scope, fixing a crash

* Lambda conversion to function pointer was sometimes not performed in
an immediate function context when it should be.

Fixes #82258

(cherry picked from commit baf6bd303bd58a521809d456dd9b179636982fc5)

11 months ago[llvm-shlib] Change libLLVM-$MAJOR.so symlink to point to versioned SO (#82660)
Tom Stellard [Fri, 23 Feb 2024 23:58:32 +0000 (15:58 -0800)]
[llvm-shlib] Change libLLVM-$MAJOR.so symlink to point to versioned SO (#82660)

This symlink was added in 91a384621e5b762d9c173ffd247cfeadd5f436a2 to
maintain backwards compatibility, but it needs to point to
libLLVM.so.$MAJOR.$MINOR rather than libLLVM.so. This works better for
distros that ship libLLVM.so and libLLVM.so.$MAJOR.$MINOR in separate
packages and also prevents mistakes like
libLLVM-19.so -> libLLVM.so -> libLLVM.so.18.1

Fixes #82647

(cherry picked from commit 10c48a772742b7afe665a815b7eba2047f17dc4b)

11 months ago[llvm][AArch64] Do not inline a function with different signing scheme. (#80642)...
Dani [Mon, 26 Feb 2024 23:13:43 +0000 (00:13 +0100)]
[llvm][AArch64] Do not inline a function with different signing scheme. (#80642) (#82743)

f the signing scheme is different that maybe the functions assumes
different behaviours and dangerous to inline them without analysing
them. This should be a rare case.

11 months ago[clang][CodeGen] Keep processing the rest of AST after encountering unsupported MC...
Wentao Zhang [Thu, 22 Feb 2024 22:04:25 +0000 (16:04 -0600)]
[clang][CodeGen] Keep processing the rest of AST after encountering unsupported MC/DC expressions (#82464)

Currently, upon seeing unsupported decisions (more than 6 conditions, or
split nesting), the post-visitor hook dataTraverseStmtPost() returns a
false. As a result, in the rest of tree even supported decisions will
be skipped as well. Like in the below code:

{ // CompoundStmt
  a && b;           // 1: BinaryOperator (supported)
  a && foo(b && c); // 2: BinaryOperator (not yet supported due to split
                    //                    nesting)
  a && b;           // 3: BinaryOperator (supported)
}

Decision 3 will not be processed at all. And only one "Decision" region
will be emitted. Compiler explorer example:
https://godbolt.org/z/Px61sesoo

We hope to process such cases and emit two "Decision" regions (1 and 3)
in the above example.

(cherry picked from commit d4bfca3b2e673789f7c278d46a199ae8910ddd37)

11 months agoFix build on musl by including stdint.h (#81434)
Daniel Martinez [Thu, 22 Feb 2024 21:14:27 +0000 (21:14 +0000)]
Fix build on musl by including stdint.h (#81434)

openmp fails to build on musl since it lacks the defines for int32_t

Co-authored-by: Daniel Martinez <danielmartinez@cock.li>
(cherry picked from commit 45fe67dd61a6ac7df84d3a586e41c36a4767757f)

11 months ago[FlattenCFG] Fix the miscompilation where phi nodes exist in the merge point (#81987)
Yingwei Zheng [Sun, 25 Feb 2024 14:01:13 +0000 (22:01 +0800)]
[FlattenCFG] Fix the miscompilation where phi nodes exist in the merge point (#81987)

When there are phi nodes in the merge point of the if-region, we cannot
do the merge.
Alive2: https://alive2.llvm.org/ce/z/DbgEan
Fixes #70900.

(cherry picked from commit f920b746ea818f1d21f317116cbb105e3e85979a)

11 months ago[GVN] Drop nsw/nuw flags when replacing the result of a with.overflow intrinsic with...
Yingwei Zheng [Mon, 26 Feb 2024 07:55:56 +0000 (15:55 +0800)]
[GVN] Drop nsw/nuw flags when replacing the result of a with.overflow intrinsic with a overflowing binary operator (#82935)

Alive2: https://alive2.llvm.org/ce/z/gyL7mn
Fixes https://github.com/llvm/llvm-project/issues/82884.

(cherry picked from commit 892b4beeac50920e630f10905b2916295e2eb6d8)

11 months ago[SystemZ] Use VT (not ArgVT) for SlotVT in LowerCall(). (#82475)
Jonas Paulsson [Wed, 21 Feb 2024 15:26:16 +0000 (16:26 +0100)]
[SystemZ] Use VT (not ArgVT) for SlotVT in LowerCall(). (#82475)

When an integer argument is promoted and *not* split (like i72 -> i128 on
a new machine with vector support), the SlotVT should be i128, which is
stored in VT - not ArgVT.

Fixes #81417

(cherry picked from commit 9c0e45d7f0e2202e16dbd9a7b9f462e2bcb741ae)

11 months ago[SystemZ] Require D12 for i128 accesses in isLegalAddressingMode() (#79221)
Jonas Paulsson [Wed, 24 Jan 2024 19:16:05 +0000 (20:16 +0100)]
[SystemZ] Require D12 for i128 accesses in isLegalAddressingMode() (#79221)

Machines with vector support handle i128 in vector registers and
therefore only have the small displacement available for memory
accesses. Update isLegalAddressingMode() to reflect this.

(cherry picked from commit 84dcf3d35b6ea8d8b6c34bc9cf21135863c47b8c)

11 months agofix links on clang 18.1.0rc release page (#82739)
h-vetinari [Mon, 26 Feb 2024 14:06:56 +0000 (15:06 +0100)]
fix links on clang 18.1.0rc release page (#82739)

Looking at the [release
notes](https://prereleases.llvm.org/18.1.0/rc3/tools/clang/docs/ReleaseNotes.html)
for clang 18.1.0rc, there's some broken links, and many issue numbers
mis-formatted with an extra colon. Aside from being used inconsistently
(with/without colon), I think it should be uncontroversial that `See
(#62707).` is better than `See (#62707:).`

CC @tstellar @AaronBallman

Co-authored-by: Aaron Ballman <aaron@aaronballman.com>
12 months agoBackport 0bf4f82 to release/18.x (#82571)
Wentao Zhang [Sat, 24 Feb 2024 00:07:23 +0000 (18:07 -0600)]
Backport 0bf4f82 to release/18.x (#82571)

Manually cherry-pick 0bf4f82f661817c79bd538c82c99515837cf1cf8 (#80952)
and resolve conflicts

Closes #82570

12 months ago[libc++] Add details about string annotations (#82730)
Tacet [Fri, 23 Feb 2024 21:06:47 +0000 (22:06 +0100)]
[libc++] Add details about string annotations (#82730)

This commit adds information that only long strings are annotated, and
with all allocators by default.

To read why short string annotations are not turned on yet, read
comments in a related PR:
https://github.com/llvm/llvm-project/pull/79536

Upstreamed in: 7661ade5d1ac4fc8e1e2339b2476cb8e45c24641
Upstream PR: #80912

---------

Co-authored-by: Mark de Wever <zar-rpg@xs4all.nl>
Co-authored-by: Mark de Wever <zar-rpg@xs4all.nl>
12 months ago[llvm-readobj,ELF] Support --decompress/-z (#82594)
Fangrui Song [Thu, 22 Feb 2024 17:24:21 +0000 (09:24 -0800)]
[llvm-readobj,ELF] Support --decompress/-z (#82594)

When a section has the SHF_COMPRESSED flag, -p/-x dump the compressed
content by default. In GNU readelf, if --decompress/-z is specified,
-p/-x will dump the decompressed content. This patch implements the
option.

Close #82507

(cherry picked from commit 26d71d9ed56c4c23e6284dac7a9bdf603a5801f3)

12 months ago[docs][llvm-objcopy] Add missing formats (#81981)
Ulrich Weigand [Fri, 16 Feb 2024 11:11:04 +0000 (12:11 +0100)]
[docs][llvm-objcopy] Add missing formats (#81981)

Bring list of supported formats in docs back in sync with the code.

(cherry picked from commit bf471c915d14035a24ec027fb2bb0373cefdabe1)