Fangrui Song [Fri, 2 Aug 2024 17:10:15 +0000 (10:10 -0700)]
[asan,test] Disable _FORTIFY_SOURCE test incompatible with glibc 2.40
In terms of bug catching capability, `_FORTIFY_SOURCE` does not perform
as well as some dynamic instrumentation tools. When a sanitizer is used,
generally `_FORTIFY_SOURCE` should be disabled since sanitizer runtime
does not implement most `*_chk` functions. Using `_FORTIFY_SOURCE`
will regress error checking (asan/hwasan/tsan) or cause false positives
(msan).
`*printf_chk` are the most pronounced `_chk` interceptors for
uninstrumented DSOes (https://reviews.llvm.org/D40951).
glibc 2.40 introduced `pass_object_info` style fortified source for some
functions ([1]). `fprintf` will be mangled as
`_ZL7fprintfP8_IO_FILEU17pass_object_size1PKcz`, which has no associated
interceptor, leading to printf-fortify-5.c failure.
Just disable the test. Fix #100877
[1]: https://sourceware.org/pipermail/libc-alpha/2024-February/154531.html
Pull Request: https://github.com/llvm/llvm-project/pull/101566
(cherry picked from commit
bbdccf4c94ff18a0761b03a0e2c8b05805385132)
Pavel Skripkin [Fri, 2 Aug 2024 15:04:57 +0000 (18:04 +0300)]
[analyzer] Fix crash on using `bitcast(<type>, <array>)` as array subscript (#101647)
Current CSA logic does not expect `LazyCompoundValKind` as array index.
This may happen if array is used as subscript to another, in case of
bitcast to integer type.
Catch such cases and return `UnknownVal`, since CSA cannot model
array -> int casts.
Closes #94496
(cherry picked from commit
d96569ecc2807a13dab6495d8cc4e82775b00af1)
Stefan Pintilie [Mon, 29 Jul 2024 15:17:04 +0000 (11:17 -0400)]
[PowerPC] Add phony subregisters to cover the high half of the VSX registers. (#94628)
On PowerPC there are 128 bit VSX registers. These registers are half
overlapped with 64 bit floating point registers (FPR). The 64 bit half
of the VXS register that does not overlap with the FPR does not overlap
with any other register class. The FPR are the only subregisters of the
VSX registers but they do not fully cover the 128 bit super register.
This leads to incorrect lane masks being created.
This patch adds phony registers for the other half of the VSX registers
in order to fully cover them and to make sure that the lane masks are
not the same for the VSX and the floating point register.
(cherry picked from commit
53c37f300dd1b450671f2aee4cc649c380adb5ad)
Mital Ashok [Thu, 1 Aug 2024 14:05:46 +0000 (15:05 +0100)]
[Clang] Fix definition of layout-compatible to ignore empty classes (#92103)
Also changes the behaviour of `__builtin_is_layout_compatible`
None of the historic nor the current definition of layout-compatible
classes mention anything about base classes (other than implicitly
through being standard-layout) and are defined in terms of members, not
direct members.
Sander de Smalen [Mon, 29 Jul 2024 10:23:25 +0000 (11:23 +0100)]
Reland: "[Clang] Demote always_inline error to warning for mismatching SME attrs" (#100991) (#100996)
Test `aarch64-sme-inline-streaming-attrs.c` caused some buildbot
failures, because the test was missing a `REQUIRES: aarch64-registered
target`. This was because we've demoted the error to a warning, which
then resulted in a different error message, because Clang can't actually
CodeGen the IR.
(cherry picked from commit
389679d5f9055bffe8bbd25ae41f084a8d08e0f8)
Rainer Orth [Tue, 30 Jul 2024 07:02:05 +0000 (09:02 +0200)]
[sanitizer_common][test] Fix InternalMmapWithOffset on 32-bit Linux/s… (#101011)
…parc64
```
SanitizerCommon-Unit :: ./Sanitizer-sparc-Test/SanitizerCommon/InternalMmapWithOffset
```
`FAIL`s on 32-bit Linux/sparc64:
```
projects/compiler-rt/lib/sanitizer_common/tests/./Sanitizer-sparc-Test --gtest_filter=SanitizerCommon.InternalMmapWithOffset
--
compiler-rt/lib/sanitizer_common/tests/sanitizer_libc_test.cpp:335: Failure
Expected equality of these values:
'A'
Which is: 'A' (65, 0x41)
p[0]
Which is: '\0'
```
It turns out the `pgoffset` arg to `mmap2` is passed incorrectly in this
case, unlike the 64-bit test. The caller, `MapWritableFileToMemory`,
passes an `u64` arg, while `mmap2` expects an `off_t`. This patch casts
the arg accordingly.
Tested on `sparc64-unknown-linux-gnu` and `x86_64-pc-linux-gnu`.
(cherry picked from commit
1c25f2cd470c2882e422b66d0482f5a120960394)
Rainer Orth [Tue, 30 Jul 2024 06:59:12 +0000 (08:59 +0200)]
[sanitizer_common] Fix signal_line.cpp on SPARC (#100535)
```
SanitizerCommon-ubsan-sparc-Linux :: Linux/signal_line.cpp
```
currently `FAIL`s on Linux/sparc64 (32 and 64-bit) for `n == 2`. Instead
of the expected `SIGSEGV`, the test dies with `SIGBUS`. `strace` reveals
that this is due to a unaligned access:
```
--- SIGBUS {si_signo=SIGBUS, si_code=BUS_ADRALN, si_addr=0x1} ---
```
which is to be expected on a strict-alignment target like SPARC. Fixed
by changing the invalid pointer to be better aligned.
Tested on `sparc64-unknown-linux-gnu` and `x86_64-pc-linux-gnu`.
(cherry picked from commit
94394ca980f8ecbd845155d2170cfd865e4d62dc)
NAKAMURA Takumi [Fri, 26 Jul 2024 01:03:17 +0000 (10:03 +0900)]
Mel Chen [Thu, 25 Jul 2024 07:14:39 +0000 (15:14 +0800)]
[VP] Refactor VectorBuilder to avoid layering violation. NFC (#99276)
This patch refactors the handling of reduction to eliminate layering
violations.
* Introduced `getReductionIntrinsicID` in LoopUtils.h for mapping
recurrence kinds to llvm.vector.reduce.* intrinsic IDs.
* Updated `VectorBuilder::createSimpleTargetReduction` to accept
llvm.vector.reduce.* intrinsic directly.
* New function `VPIntrinsic::getForIntrinsic` for mapping intrinsic ID
to the same functional VP intrinsic ID.
(cherry picked from commit
6d12b3f67df429bffff6e1953d9f55867d7e2469)
NAKAMURA Takumi [Sun, 28 Jul 2024 07:48:23 +0000 (16:48 +0900)]
[Bazel] Use PACKAGE_VERSION for version string.
This enables "-rc" suffix in release branches.
(cherry picked from commit
25efb746d907ce0ffdd9195d191ff0f6944ea3ca)
Sjoerd Meijer [Fri, 2 Aug 2024 12:25:35 +0000 (13:25 +0100)]
Ofast deprecation clarifications (#101005)
Following up on the RFC discussion, this is clarifying that the main
purpose and effect of the -Ofast deprecation is to discourage its usage
and that everything else is more or less open for discussion, e.g. there
is no timeline yet for removal.
---------
Co-authored-by: Aaron Ballman <aaron@aaronballman.com>
(cherry picked from commit
48d4d4b641702bf6db03a1bac73b7e13dea28349)
Donát Nagy [Fri, 2 Aug 2024 10:43:06 +0000 (12:43 +0200)]
[analyzer] Restore recognition of mutex methods (#101511)
Before commit
705788c the checker alpha.unix.BlockInCriticalSection
"recognized" the methods `std::mutex::lock` and `std::mutex::unlock`
with an extremely trivial check that accepted any function (or method)
named lock/unlock.
To avoid matching unrelated user-defined function, this was refined to a
check that also requires the presence of "std" and "mutex" as distinct
parts of the qualified name.
However, as #99628 reported, there are standard library implementations
where some methods of `std::mutex` are inherited from an implementation
detail base class and the new code wasn't able to recognize these
methods, which led to emitting false positive reports.
As a workaround, this commit partially restores the old behavior by
omitting the check for the class name.
In the future, it would be good to replace this hack with a solution
which ensures that `CallDescription` understands inherited methods.
(cherry picked from commit
99ae2edc2592e602b0eb5a287f4d003aa3902440)
Luke Lau [Tue, 30 Jul 2024 16:28:52 +0000 (00:28 +0800)]
[RISCV] Fix vmerge.vvm/vmv.v.v getting folded into ops with mismatching EEW (#101152)
As noted in
https://github.com/llvm/llvm-project/pull/100367/files#r1695448771, we
currently fold in vmerge.vvms and vmv.v.vs into their ops even if the
EEW is different which leads to an incorrect transform.
This checks the op's EEW via its simple value type for now since there
doesn't seem to be any existing information about the EEW size of
instructions. We'll probably need to encode this at some point if we
want to be able to access it at the MachineInstr level in #100367
Qiongsi Wu [Thu, 1 Aug 2024 13:51:07 +0000 (09:51 -0400)]
[AIX] Turn on `#pragma mc_func` check by default (#101336)
https://github.com/llvm/llvm-project/pull/99888 added a check (and
corresponding options) to flag uses of `#pragma mc_func` on AIX.
This PR turns on the check by default.
(cherry picked from commit
b9335176db718bf64c72d48107eb9dff28ed979e)
Nikolas Klauser [Fri, 2 Aug 2024 08:53:33 +0000 (10:53 +0200)]
[Clang] Add a release note deprecating __is_nullptr
Fangrui Song [Thu, 1 Aug 2024 17:22:03 +0000 (10:22 -0700)]
[ELF] Support relocatable files using CREL with explicit addends
... using the temporary section type code 0x40000020
(`clang -c -Wa,--crel,--allow-experimental-crel`). LLVM will change the
code and break compatibility (Clang and lld of different versions are
not guaranteed to cooperate, unlike other features). CREL with implicit
addends are not supported.
---
Introduce `RelsOrRelas::crels` to iterate over SHT_CREL sections and
update users to check `crels`.
(The decoding performance is critical and error checking is difficult.
Follow `skipLeb` and `R_*LEB128` handling, do not use
`llvm::decodeULEB128`, whichs compiles to a lot of code.)
A few users (e.g. .eh_frame, LLDDwarfObj, s390x) require random access. Pass
`/*supportsCrel=*/false` to `relsOrRelas` to allocate a buffer and
convert CREL to RELA (`relas` instead of `crels` will be used). Since
allocating a buffer increases, the conversion is only performed when
absolutely necessary.
---
Non-alloc SHT_CREL sections may be created in -r and --emit-relocs
links. SHT_CREL and SHT_RELA components need reencoding since
r_offset/r_symidx/r_type/r_addend may change. (r_type may change because
relocations referencing a symbol in a discarded section are converted to
`R_*_NONE`).
* SHT_CREL components: decode with `RelsOrRelas` and re-encode (`OutputSection::finalizeNonAllocCrel`)
* SHT_RELA components: convert to CREL (`relToCrel`). An output section can only have one relocation section.
* SHT_REL components: print an error for now.
SHT_REL to SHT_CREL conversion for -r/--emit-relocs is complex and
unsupported yet.
Link: https://discourse.llvm.org/t/rfc-crel-a-compact-relocation-format-for-elf/77600
Pull Request: https://github.com/llvm/llvm-project/pull/98115
(cherry picked from commit
0af07c078798b7c427e2981377781b5cc555a568)
Xing Xue [Thu, 1 Aug 2024 11:25:01 +0000 (07:25 -0400)]
[NFC][libc++][libc++abi][libunwind][test] Fix/unify AIX triples used in LIT tests (#101196)
This patch fixes/unifies AIX target triples used in libc++, libc++abi,
and libunwind LIT tests.
(cherry picked from commit
2d3655037ccfa276cb0949c2ce0cff56985f6637)
Damien L-G [Thu, 1 Aug 2024 14:39:27 +0000 (10:39 -0400)]
[libc++] Increase atomic_ref's required alignment for small types (#99654)
This patch increases the alignment requirement for std::atomic_ref
such that we can guarantee lockfree operations more often. Specifically,
we require types that are 1, 2, 4, 8, or 16 bytes in size to be aligned
to at least their size to be used with std::atomic_ref.
This is the case for most types, however a notable exception is
`long long` on x86, which is 8 bytes in length but has an alignment
of 4.
As a result of this patch, one has to be more careful about the
alignment of objects used with std::atomic_ref. Failure to provide
a properly-aligned object to std::atomic_ref is a precondition
violation and is technically UB. On the flipside, this allows us
to provide an atomic_ref that is actually lockfree more often,
which is an important QOI property.
More information in the discussion at https://github.com/llvm/llvm-project/pull/99570#issuecomment-
2237668661.
Co-authored-by: Louis Dionne <ldionne.2@gmail.com>
(cherry picked from commit
59ca618e3b7aec8c32e24d781bae436dc99b2727)
Dimitry Andric [Thu, 1 Aug 2024 07:28:29 +0000 (09:28 +0200)]
[lldb][FreeBSD] Fix NativeRegisterContextFreeBSD_{arm,mips64,powerpc} declarations (#101403)
Similar to #97796, fix the type of the `native_thread` parameter for the
arm, mips64 and powerpc variants of `NativeRegisterContextFreeBSD_*`.
Otherwise, this leads to compile errors similar to:
```
lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_powerpc.cpp:85:39: error: out-of-line definition of 'NativeRegisterContextFreeBSD_powerpc' does not match any declaration in 'lldb_private::process_freebsd::NativeRegisterContextFreeBSD_powerpc'
85 | NativeRegisterContextFreeBSD_powerpc::NativeRegisterContextFreeBSD_powerpc(
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
(cherry picked from commit
7088a5ed880f29129ec844c66068e8cb61ca98bf)
Tom Stellard [Thu, 1 Aug 2024 18:23:03 +0000 (11:23 -0700)]
workflows: Fix libclc-tests (#101524)
The old out-of-tree build configuration stopped working and in tree
builds are supported now, so we should use the in tree configuration.
The only downside is we can't run the tests any more, but at least we
will be able to test the build again.
(cherry picked from commit
0512ba0a435a9d693cb61f182fc9e3eb7f6dbd6a)
Dimitry Andric [Mon, 29 Jul 2024 18:34:01 +0000 (20:34 +0200)]
[InstrProf] Remove duplicate definition of IntPtrT
In
16e74fd48988a (for #82711) a duplicate definition of `IntPtrT` was
added to `InstrProfiling.h`, leading to warnings:
compiler-rt/lib/profile/InstrProfiling.h:52:15: warning: redefinition of typedef 'IntPtrT' is a C11 feature [-Wtypedef-redefinition]
52 | typedef void *IntPtrT;
| ^
compiler-rt/lib/profile/InstrProfiling.h:34:15: note: previous definition is here
34 | typedef void *IntPtrT;
| ^
Fix the warnings by removing the duplicate typedef.
(cherry picked from commit
2c376fe96c83443c15e6485d043ebe321904546b)
Alexandre Ganea [Tue, 30 Jul 2024 23:06:03 +0000 (19:06 -0400)]
[Support] Silence warnings when retrieving exported functions (#97905)
Since functions exported from DLLs are type-erased, before this patch I
was seeing the new Clang 19 warning `-Wcast-function-type-mismatch`.
This happens when building LLVM on Windows.
Following discussion in
https://github.com/llvm/llvm-project/commit/
593f708118aef792f434185547f74fedeaf51dd4#commitcomment-
143905744
(cherry picked from commit
39e192b379362e9e645427631c35450d55ed517d)
Louis Dionne [Wed, 31 Jul 2024 14:40:14 +0000 (10:40 -0400)]
[libc++] Revert "Use GCC type traits builtins for remove_cv and remove_cvref (#81386)"
This reverts commit
55357160d0e151c32f86e1d6683b4bddbb706aa1.
This is only being reverted from the LLVM 19 branch as a
convenience to avoid breaking some IDEs which were not ready
for that change.
Fixes #99464
Piyou Chen [Wed, 31 Jul 2024 07:54:03 +0000 (00:54 -0700)]
Revert "[compiler-rt][RISCV] Implement __init_riscv_feature_bits (#85790)"
This reverts commit
a41a4ac78294c728fb70a51623c602ea7f3e308a.
Fangrui Song [Tue, 30 Jul 2024 21:52:29 +0000 (14:52 -0700)]
Revert "[MC] Compute fragment offsets eagerly"
This reverts commit
1a47f3f3db66589c11f8ddacfeaecc03fb80c510.
Fix #100283
This commit is actually a trigger of other preexisting problems:
* Size change of fill fragments does not influence the fixed-point iteration.
* The `invalid number of bytes` error is reported too early. Since
`.zero A-B` might have temporary negative values in the first few
iterations.
However, the problems appeared at least "benign" (did not affect the
Linux kernel builds) before this commit.
(cherry picked from commit
4eb5450f630849ee0518487de38d857fbe5b1aee)
Nikita Popov [Tue, 30 Jul 2024 07:25:03 +0000 (09:25 +0200)]
[Sanitizers] Avoid overload ambiguity for interceptors (#100986)
Since glibc 2.40 some functions like openat make use of overloads when
built with `-D_FORTIFY_SOURCE=2`, see:
https://github.com/bminor/glibc/blob/master/io/bits/fcntl2.h
This means that doing something like `(uintptr_t) openat` or `(void *)
openat` is now ambiguous, breaking the compiler-rt build on new glibc
versions.
Fix this by explicitly casting the symbol to the expected function type
before casting it to an intptr. The expected type is obtained as
`decltype(REAL(func))` so we don't have to repeat the signature from
INTERCEPTOR in the INTERCEPT_FUNTION macro.
Fixes https://github.com/llvm/llvm-project/issues/100754.
(cherry picked from commit
155b7a12820ec45095988b6aa6e057afaf2bc892)
Alexandros Lamprineas [Tue, 23 Jul 2024 18:24:41 +0000 (19:24 +0100)]
[clang][FMV][AArch64] Improve streaming mode compatibility.
* Allow arm-streaming if all the functions versions adhere to it.
* Allow arm-streaming-compatible if all the functions versions adhere to it.
* Allow arm-locally-streaming regardless of the other functions versions.
When the caller needs to toggle the streaming mode all the function versions
of the callee must adhere to the same mode, otherwise the call will yield a
runtime error.
Imagine the versions of the callee live in separate TUs. The version that
is visible to the caller will determine the calling convention used when
generating code for the callsite. Therefore we cannot support mixing
streaming with non-streaming function versions. Imagine TU1 has a streaming
caller and calls foo._sme which is streaming-compatible. The codegen for
the callsite will not switch off the streaming mode. Then in TU2 we have
a version which is non-streaming and could potentially be called in
streaming mode. Similarly if the caller is non-streaming and the called
version is streaming-compatible the codegen for the callsite will not
switch on the streaming mode, but other versions may be streaming.
Hubert Tong [Tue, 30 Jul 2024 21:56:55 +0000 (17:56 -0400)]
ReleaseNotes.rst: Fix typo "my" for "may"
Replace typo for "may" with "can".
Jacek Caban [Tue, 30 Jul 2024 12:22:50 +0000 (14:22 +0200)]
[CodeGen][ARM64EC] Use alias symbol for exporting hybrid_patchable functions. (#100872)
Exporting $hp_target symbol doesn't make sense, use the unmangled alias instead.
This is not compatible with MSVC, but it makes using dllexport together with
hybrid_patchable attribute possible.
(cherry picked from commit
41c0f89f5532ec110b927c3a67ceac83448c5d98)
Xing Xue [Tue, 30 Jul 2024 10:28:59 +0000 (06:28 -0400)]
[libunwind][AIX] Fix the wrong traceback from signal handler (#101069)
Patch [llvm#92291](https://github.com/llvm/llvm-project/pull/92291)
causes wrong traceback from a signal handler for AIX because the AIX
unwinder uses the traceback table at the end of each function instead of
FDE/CIE for unwinding. This patch adds a condition to exclude traceback
table based unwinding from the code added by the patch.
(cherry picked from commit
d90fa612604b49dfc81c3f42c106fab7401322ec)
Stefan Pintilie [Wed, 24 Jul 2024 01:59:27 +0000 (21:59 -0400)]
[RegisterCoalescer] Fix SUBREG_TO_REG handling in the RegisterCoalescer. (#96839)
The issue with the handling of the SUBREG_TO_REG is that we don't join
the subranges correctly when we join live ranges across the
SUBREG_TO_REG. For example when joining across this:
```
32B %2:gr64_nosp = SUBREG_TO_REG 0, %0:gr32, %subreg.sub_32bit
```
we want to join these live ranges:
```
%0 [16r,32r:0) 0@16r weight:0.
000000e+00
%2 [32r,112r:0) 0@32r weight:0.
000000e+00
```
Before the fix the range for the resulting merged `%2` is:
```
%2 [16r,112r:0) 0@16r weight:0.
000000e+00
```
After the fix it is now this:
```
%2 [16r,112r:0) 0@16r L000000000000000F [16r,112r:0) 0@16r weight:0.
000000e+00
```
Two tests are added to this fix. The X86 test fails without the patch.
The PowerPC test passes with and without the patch but is added as a way
track future possible failures when register classes are changed in a
future patch.
(cherry picked from commit
26fa399012da00fbf806f50ad72a3b5f0ee63eab)
Mark de Wever [Thu, 25 Jul 2024 16:37:36 +0000 (18:37 +0200)]
[libc++][spaceship] Marks P1614 as complete. (#99375)
Implements parts of:
- P1902R1 Missing feature-test macros 2017-2019
Completes:
- P1614R2 The Mothership has Landed
Fixes #100018
Rainer Orth [Tue, 30 Jul 2024 06:54:10 +0000 (08:54 +0200)]
[sanitizer_common][test] Always skip select allocator tests on SPARC V9 (#100530)
Two allocator tests `FAIL` on Linux/sparc64:
```
SanitizerCommon-Unit :: ./Sanitizer-sparcv9-Test/SanitizerCommon/CombinedAllocator32Compact
SanitizerCommon-Unit :: ./Sanitizer-sparcv9-Test/SanitizerCommon/SizeClassAllocator32Iteration
```
The failure mode is the same on Solaris/sparcv9, where those tests are
already disabled since
0f69cbe2694a4740e6db5b99bd81a26746403072.
Therefore, this patch skips them on SPARC in general.
Tested on `sparc64-unknown-linux-gnu` and `sparcv9-sun-solaris2.11`.
(cherry picked from commit
3d149123f46cee5ac8d961c6bf77c5c566f1e410)
Jacek Caban [Sat, 27 Jul 2024 12:29:05 +0000 (14:29 +0200)]
[clang][ARM64EC] Add support for hybrid_patchable attribute. (#99478)
(cherry picked from commit
ea98dc8b8f508b8393651992830e5e51d3876728)
Nikita Popov [Mon, 29 Jul 2024 20:46:18 +0000 (22:46 +0200)]
[NVPTX] Fix DwarfFrameBase construction (#101000)
The `{0}` here was initializing the first union member `Register`,
rather than the union member used by CFA, which is `Offset`. Prior to
https://github.com/llvm/llvm-project/pull/99263 this was harmless, but
now they have different layout, leading to test failures on some
platforms (at least i686 and s390x).
(cherry picked from commit
842a332f11f53c698fa0560505e533ecdca28876)
Owen Pan [Tue, 30 Jul 2024 01:01:44 +0000 (18:01 -0700)]
[clang-format] Fix misannotations of `<` in ternary expressions (#100980)
Fixes #100300.
(cherry picked from commit
73c961a3345c697f40e2148318f34f5f347701c1)
Daniel Martinez [Mon, 29 Jul 2024 22:20:18 +0000 (22:20 +0000)]
[nsan] Remove mallopt from nsan_interceptors (#101055)
Fixes a build failure on 19.1.0-rc1 when building on linux with musl as
the libc
musl does not provide mallopt, whereas glibc does. mallopt has
portability issues with other libc implementations. Just remove the use.
Co-authored-by: Daniel Martinez <danielmartinez@cock.li>
(cherry picked from commit
2c3eb8db057b9d58acd4735999f0f5d5d8d55b0d)
Dimitry Andric [Mon, 29 Jul 2024 20:00:07 +0000 (22:00 +0200)]
[compiler-rt] Fix format string warnings in FreeBSD DumpAllRegisters (#101072)
On FreeBSD amd64 (aka x86_64), registers are always defined as
`int64_t`, which in turn is equivalent to `long`. This leads to a number
of warnings in `DumpAllRegisters()`:
compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp:2245:31: warning:
format specifies type 'unsigned long long' but the argument has type
'__register_t' (aka 'long') [-Wformat]
2245 | Printf("rax = 0x%016llx ", ucontext->uc_mcontext.mc_rax);
| ~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
| %016lx
compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp:2246:31: warning:
format specifies type 'unsigned long long' but the argument has type
'__register_t' (aka 'long') [-Wformat]
2246 | Printf("rbx = 0x%016llx ", ucontext->uc_mcontext.mc_rbx);
| ~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
| %016lx
... more of these ...
Fix it by using the `lx` format.
(cherry picked from commit
62bd08acedc88d8976a017f7f6818f3167dfa697)
Daniil Kovalev [Wed, 24 Jul 2024 21:24:50 +0000 (00:24 +0300)]
[PAC][clang][test] Implement missing tests for some PAuth features (#100206)
Implement tests for the following PAuth-related features:
- driver, preprocessor and ELF codegen tests for type_info vtable
pointer discrimination #99726;
- driver, preprocessor, and ELF codegen (emitting function attributes) +
sema (emitting errors) tests for indirect gotos signing #97647;
- ELF codegen tests for ubsan type checks + auth #99590;
- ELF codegen tests for constant global init with polymorphic MI #99741;
- ELF codegen tests for C++ member function pointers auth #99576.
(cherry picked from commit
70c6e79e6d3e897418f3556a25e22e66ff018dc4)
Daniil Kovalev [Fri, 26 Jul 2024 20:00:16 +0000 (23:00 +0300)]
[PAC][test] Add tests against Linux triples for auth/resign lowering (#100744)
The lowering implementation and tests against arm64e-apple-darwin triple
were added previously in #79024.
(cherry picked from commit
53283dc4645ee13f33dd9b98cc935b376bf78232)
Hari Limaye [Thu, 25 Jul 2024 17:54:24 +0000 (18:54 +0100)]
[StackFrameLayoutAnalysis] Support more SlotTypes (#100562)
Add new SlotTypes to StackFrameLayoutAnalysis to disambiguate Fixed and
Variable-Sized stack slots from Variable slots. As Offsets are
unreliable for VLA-area objects, sort these to the end of the list -
using the Frame Index to ensure a deterministic order when Offsets are
equal.
(cherry picked from commit
e31794f99d72dd764c4bc5c5583a0a4c89df22c3)
Hari Limaye [Thu, 25 Jul 2024 08:03:48 +0000 (09:03 +0100)]
[StackFrameLayoutAnalysis] Use target-specific hook for SP offsets (#100386)
StackFrameLayoutAnalysis currently calculates SP-relative offsets in a
target-independent way via MachineFrameInfo offsets. This is incorrect
for some Targets, e.g. AArch64, when there are scalable vector stack
slots.
This patch adds a virtual function to TargetFrameLowering to provide
offsets from SP, with a default implementation matching what is
currently used in StackFrameLayoutAnalysis, and refactors
StackFrameLayoutAnalysis to use this function. Only non-zero scalable
offsets are output by the analysis pass.
An implementation of this function is added for AArch64 targets, which
aims to provide correct SP offsets in most cases.
(cherry picked from commit
dc1c00f6b13f724154f9883990f8b21fb8dcccef)
Joseph Huber [Wed, 24 Jul 2024 03:04:47 +0000 (22:04 -0500)]
Update libc/docs/configure.rst
Joseph Huber [Wed, 24 Jul 2024 02:35:09 +0000 (21:35 -0500)]
[libc] Fix leftover debug commandline argument
Summary:
Fixes https://github.com/llvm/llvm-project/issues/100289
(cherry picked from commit
0420d2f97eac49af5e816b0e3f2a9135d1673168)
Rainer Orth [Wed, 24 Jul 2024 08:03:47 +0000 (10:03 +0200)]
[asan][cmake][test] Fix finding dynamic asan runtime lib (#100083)
In a `runtimes` build on Solaris/amd64, there are two failues:
```
AddressSanitizer-Unit :: ./Asan-i386-calls-Dynamic-Test/failed_to_discover_tests_from_gtest
AddressSanitizer-Unit :: ./Asan-i386-inline-Dynamic-Test/failed_to_discover_tests_from_gtest
```
This happens when `lit` enumerates the tests with `--gtest_list_tests
--gtest_filter=-*DISABLED_*`. The error is twofold:
- The `LD_LIBRARY_PATH*` variables point at the 64-bit directory
(`lib/clang/19/lib/x86_64-pc-solaris2.11`) for a 32-bit test:
```
ld.so.1: Asan-i386-calls-Dynamic-Test: fatal:
/var/llvm/local-amd64-release-stage2-A-flang-clang18-runtimes/tools/clang/stage2-bins/./lib/../lib/clang/19/lib/x86_64-pc-solaris2.11/libclang_rt.asan.so:
wrong ELF class: ELFCLASS64
```
- While the tests are linked with `-Wl,-rpath`, that path always is the
64-bit directory again.
Accordingly, the fix consists of two parts:
- The code in `compiler-rt/test/asan/Unit/lit.site.cfg.py.in` to adjust
the `LD_LIBRARY_PATH*` variables is guarded by a `config.target_arch !=
config.host_arch` condition. This is wrong in two ways:
- The adjustment is always needed independent of the host arch. This is
what `compiler-rt/test/lit.common.cfg.py` already does.
- Besides, `config.host_arch` is ultimately set from
`CMAKE_HOST_SYSTEM_PROCESSOR`. On Linux/x86_64, this is `x86_64` (`uname
-m`) while on Solaris/amd64 it's `i386` (`uname -p`), explaining why the
transformation is skipped on Solaris, but not on Linux.
- Besides, `RPATH` needs to be set to the correct subdirectory, so
instead of using the default arch in `compiler-rt/CMakeLists.txt`, this
patch moves the code to a function which takes the test's arch into
account.
Tested on `amd64-pc-solaris2.11` and `x86_64-pc-linux-gnu`.
(cherry picked from commit
c34d673b02ead039acd107f096c1f32c16b61e07)
Rainer Orth [Mon, 29 Jul 2024 07:12:15 +0000 (09:12 +0200)]
[compiler-rt][test] Disable lld tests on SPARC (#100533)
As detailed in Issue #100320, a considerable number of tests that
explicitly use `-fuse-ld=lld` `FAIL` on Linux/sparc64 due to several
`lld` limitations (no 32-bit SPARC support, lack of support for various
relocations, ...).
To reduce the noise, this patch disables `COMPILER_RT_HAS_LLD` on SPARC
wholesale.
Tested on `sparc64-unknown-linux-gnu`.
(cherry picked from commit
33a50e0eaa80cf3db1b944762db9a37a06f3ac32)
wanglei [Fri, 26 Jul 2024 06:38:36 +0000 (14:38 +0800)]
[lld][ELF][LoongArch] Support R_LARCH_TLS_{LD,GD,DESC}_PCREL_S2
Reviewed By: MaskRay, SixWeining
Pull Request: https://github.com/llvm/llvm-project/pull/100105
(cherry picked from commit
0057a969a2a397c1ba57e06b65a8bb56af2ce987)
Aiden Grossman [Sat, 27 Jul 2024 17:53:23 +0000 (10:53 -0700)]
[llvm-exegesis] Use correct rseq struct size (#100804)
Glibc v2.40 changes the definition of __rseq_size to the usable area of
the struct rather than the actual size of the struct to accommodate
users trying to figure out what features can be used. This change breaks
llvm-exegesis trying to disable rseq as the size registered in the
kernel is no longer equal to __rseq_size. This patch adds a check to see
if __rseq_size is less than 32 bytes and uses 32 as a value if it is
given alignment requirements.
Fixes #100791.
(cherry picked from commit
1e8df9e85a1ff213e5868bd822877695f27504ad)
Fangrui Song [Sat, 27 Jul 2024 17:58:27 +0000 (10:58 -0700)]
[ELF] Use invokeOnRelocs. NFC
(cherry picked from commit
c7231e49099d56fdc5b2207142184a0bf2544ec1)
Fangrui Song [Sat, 27 Jul 2024 17:55:17 +0000 (10:55 -0700)]
[ELF] Add Relocs and invokeOnRelocs. NFC
Relocs is to simplify CREL support (#98115) while invokeOnRelocs
simplifies some relsOrRelas call sites that will use the CREL iterator.
(cherry picked from commit
6efc3774bd8c5fcb105cda73ec27c05ef850dc19)
Fangrui Song [Fri, 26 Jul 2024 00:11:52 +0000 (17:11 -0700)]
[ELF,test] Improve negative linker script tests
(cherry picked from commit
8644a2aa0f3540c69464f56b3d538e888b6cbdcb)
Fangrui Song [Thu, 25 Jul 2024 23:45:09 +0000 (16:45 -0700)]
[ELF] Remove obsoleted comment after #99567
(cherry picked from commit
026972af9c3cbd85b654b67a5b5c3b754a78a997)
Utkarsh Saxena [Wed, 24 Jul 2024 13:58:52 +0000 (15:58 +0200)]
Fix lifetimebound for field access (#100197)
Fixes: https://github.com/llvm/llvm-project/issues/81589
There is no way to switch this off without `-Wno-dangling`.
Louis Dionne [Tue, 23 Jul 2024 18:04:54 +0000 (13:04 -0500)]
[libc++][libc++abi] Minor follow-up changes after ptrauth upstreaming (#87481)
This patch applies the comments provided on #84573. This is done as a
separate PR to avoid merge conflicts with downstreams that already had
ptrauth support.
(cherry picked from commit
e64e745e8fb802ffb06259b1a5ba3db713a17087)
Craig Topper [Sat, 27 Jul 2024 00:11:01 +0000 (17:11 -0700)]
[RISCV] Don't crash in RISCVMergeBaseOffset if INLINE_ASM uses address register in a non-memory constraint. (#100790)
If the register is used by a non-memory constraint we should disable the
fold. Otherwise, we may leave CommonOffset unassigned.
Fixes #100779.
(cherry picked from commit
c901b739b67476b00209b7ee706de94c0595d763)
Louis Dionne [Fri, 26 Jul 2024 18:10:06 +0000 (13:10 -0500)]
[libc++] Fix bug in atomic_ref's calculation of lock_free-ness (#99570)
The builtin __atomic_always_lock_free takes into account the type of the
pointer provided as the second argument. Because we were passing void*,
rather than T*, the calculation failed. This meant that
atomic_ref<T>::is_always_lock_free was only true for char & bool.
This bug exists elsewhere in the atomic library (when using GCC, we fail
to pass a pointer at all, and we fail to correctly align the atomic like
_Atomic would).
This change also attempts to start sorting out testing difficulties with
this function that caused the bug to exist by using the
__GCC_ATOMIC_(CHAR|SHORT|INT|LONG|LLONG|POINTER)_IS_LOCK_FREE predefined
macros to establish an expected value for `is_always_lock_free` and
`is_lock_free` for the respective types, as well as types with matching
sizes and compatible alignment values.
Using these compiler pre-defines we can actually validate that certain
types, like char and int, are actually always lock free like they are on
every platform in the wild.
Note that this patch was actually authored by Eric Fiselier but I picked
up the patch and GitHub won't let me set Eric as the primary author.
Co-authored-by: Eric Fiselier <eric@efcs.ca>
(cherry picked from commit
cc1dfb37aa84d1524243b83fadb8ff0f821e03e9)
wanglei [Fri, 26 Jul 2024 06:36:54 +0000 (14:36 +0800)]
[LoongArch][MC] Support %[ld_/gd_/desc_]pcrel_20
Reviewed By: SixWeining, MaskRay
Pull Request: https://github.com/llvm/llvm-project/pull/100104
(cherry picked from commit
e27358c8ed7abac200546e808ea30a86aa9aa580)
Owen Pan [Thu, 25 Jul 2024 02:22:18 +0000 (19:22 -0700)]
Revert "[clang-format] Fix a bug in annotating `*` in `#define`s (#99433)"
This reverts commit
ce1a87437cc143889665c41046107e84cdf6246e.
Closes #100304.
(cherry picked from commit
7e7a9069d4240d2ae619cb50eba09f948c537ce3)
Tobias Hieta [Fri, 26 Jul 2024 12:00:03 +0000 (14:00 +0200)]
Set version to 19.1.0-rc1
Aiden Grossman [Tue, 23 Jul 2024 19:54:18 +0000 (12:54 -0700)]
[MLGO][Infra] Add mlgo-utils to bump-version script (#100186)
This patch adds support in the bump-version script for bumping the
version of the mlgo-utils package. This should hopefully streamline the
processor for that with the rest of the project and prevent having to
manually update this package individually.
Tobias Hieta [Tue, 23 Jul 2024 14:52:51 +0000 (16:52 +0200)]
[Utils] Updates to bump-version.py (#100089)
* Add support for --git flag to bump version for a git suffix
* Update location of the new file where the version is stored
Abid Qadeer [Thu, 25 Jul 2024 12:52:50 +0000 (13:52 +0100)]
[flang][debug] Set scope of internal functions correctly. (#99531)
Summary:
The functions internal to subroutine should have the scope set to the
parent function. This allows a user to evaluate local variables of
parent function when control is stopped in the child.
Fixes #96314
Test Plan:
Reviewers:
Subscribers:
Tasks:
Tags:
Differential Revision: https://phabricator.intern.facebook.com/
D60250527
(cherry picked from commit
626022bfd18f335ef62a461992a05dfed4e6d715)
Daniil Kovalev [Thu, 25 Jul 2024 19:21:03 +0000 (22:21 +0300)]
[PAC] Sign LR with B key for non-leaf functions with ptrauth-returns attr (#100552)
For pauthtest ABI, there is a bunch of ptrauth-* options, including
ptrauth-returns. Use "ptrauth-returns" function attribute to indicate
need for LR signing with B key for non-leaf function to avoid using
"sign-return-address" and "sign-return-address-key" which were
originally designed for pac-ret.
Co-authored-by: Ahmed Bougacha <ahmed@bougacha.org>
Co-authored-by: Anatoly Trosinenko <atrosinenko@accesssoftek.com>
(cherry picked from commit
56fd2472d887392855ad85c53df5782a2c3f8ddb)
Nikita Popov [Thu, 25 Jul 2024 10:25:19 +0000 (12:25 +0200)]
[BasicAA] Fix handling of indirect assumption based results (#100130)
If a result is potentially based on a not yet proven assumption,
BasicAA will remember it inside AssumptionBasedResults and remove
the cache entry if an assumption higher up is later disproved.
However, we currently miss the case where another cache entry ends
up depending on such an AssumptionBased result.
Fix this by introducing an additional AssumptionBased state for
cache entries. If such a result is used, we'll still increment
AAQI.NumAssumptionUses, which means that the using entry will
also become AssumptionBased and be cleared if the assumption is
disproved.
At the end of the root query, convert remaining AssumptionBased
results into definitive results.
Fixes https://github.com/llvm/llvm-project/issues/98978.
(cherry picked from commit
91073380ac5a0dceebdd09f360a1dc194d7ee93f)
Alan Zhao [Fri, 26 Jul 2024 00:38:44 +0000 (17:38 -0700)]
[compiler-rt][ubsan][nfc-ish] Fix a type conversion bug (#100665)
If the inline asm version of `ptrauth_strip` is used instead of the
builtin, the inline asm implementation currently returns an unsigned
long, causing an incompatible pointer conversion issue. The spec for
`ptrauth_sign` is that the result has the same type as the original
value, so we add a cast to the result of the inline asm.
(cherry picked from commit
25f9415713f9f57760a5322876906dc11385ef8e)
Tom Eccles [Thu, 25 Jul 2024 15:53:27 +0000 (16:53 +0100)]
[flang][OpenMP] Initialize privatised derived type variables (#100417)
Fixes #91928
(cherry picked from commit
98e733eaf2af1a5c1d9392e279d21182ffdf560d)
Anton Korobeynikov [Thu, 25 Jul 2024 18:57:46 +0000 (11:57 -0700)]
Normalize ptrauth handling in sanitizer runtime (#100483)
1. Include `ptrauth.h` if `ptrauth_intrinsics` language feature is specified (per ptrauth spec, this is what enables `ptrauh.h` usage and functions like `ptrauth_strip`)
2. For PAC-RET fallback implement two changes:
1. Switch to macro, so we can ignore key argument
2. Ensure the unsigned value is erased from LR, so the possibility of gadget reuse is reduced.
Fixes #100467
(cherry picked from commit
cc4f98979b079b517edd8a71f56a8975f436e63d)
Louis Dionne [Thu, 25 Jul 2024 17:16:48 +0000 (12:16 -0500)]
[libc++] Add missing xlocale.h include on Apple and FreeBSD (#99689)
The `<locale>` header uses `strtoll_l` and friends which are defined in
`<xlocale.h>` on these platforms. While this works via transitive
includes when modules are disabled, this doesn't work anymore if the
platforms are modularized properly.
(cherry picked from commit
a55df237375e98cfc2520d5eb1a23b302ef02ba0)
Vlad Serebrennikov [Thu, 25 Jul 2024 16:15:14 +0000 (20:15 +0400)]
[clang] Remove `__is_layout_compatible` from revertible type traits list (#100572)
`__is_layout_compatible` was added in Clang 19 (#81506), and at that
time it wasn't entirely clear whether it should be a revertible type
trait or not. We decided to follow the example of other type traits.
Since then #95969 happened, and now we know that we don't want new
revertible type traits.
This patch removes `__is_layout_compatible` from revertible type traits
list, and leaves a comment what revertible type traits are, and that new
type traits should not be added there.
The intention is to also cherry-pick this to 19 branch.
(cherry picked from commit
3295d377f37a60597321f502d164b5d6b1948e28)
Kerry McLaughlin [Wed, 24 Jul 2024 13:30:25 +0000 (14:30 +0100)]
[AArch64][SME] Rewrite __arm_get_current_vg to preserve required registers (#100143)
The documentation for the __arm_get_current_vg support routine specifies
that the following registers are call-preserved:
- X1-X15, X19-X29 and SP
- Z0-Z31
- P0-P15
This patch rewrites the implementation of this routine in compiler-rt,
as the current version does not guarantee that these registers will be
preserved.
(cherry picked from commit
6da6772bf0a33131aa8540c9d4f60d5db75c32b5)
Kiran Chandramohan [Wed, 24 Jul 2024 15:28:24 +0000 (16:28 +0100)]
[Flang][Driver] Enable config file options (#100343)
Config files provide a facility to invoke the compiler with a predefined
set of options. The patch only enables these options in the flang
driver. Functionality was always there.
(cherry picked from commit
8a77961280536b680c404a49002a00b988ca45fc)
Joseph Huber [Thu, 25 Jul 2024 02:06:19 +0000 (21:06 -0500)]
[libc] Only add '-fno-builtin-*' on the entrypoints that use them (#100481)
Summary:
The GPU build needs to be able to inline stuff in LTO. Builtin
transformations cause problems on the functions that the optimizer does
heavy libcall recognition on. Previously we moved to using
`-fno-builtin-*` to allow us to only disable the problematic ones.
However, this still didn't allow inlining because each function had the
attribute that told the inliner not to inlining a nobuiltin function
into a non-nobuiltin function
This patch fixes that by only applying these attributes to the
entrypoints that define them. That is enough to prevent recursive calls
within the definitoins themselves.
(cherry picked from commit
8e43acbfedf53ded43ec693ddaaf518cb7416c1c)
Daniil Kovalev [Wed, 24 Jul 2024 23:13:30 +0000 (02:13 +0300)]
[PAC][clang] Enable `-fptrauth-indirect-gotos` as part of pauthtest ABI (#100480)
(cherry picked from commit
3f6eb13abf643afec17a73448ede380606531226)
Carlos Seo [Wed, 24 Jul 2024 21:14:05 +0000 (18:14 -0300)]
[Flang][Docs] Update information about AArch64 trampolines (#100391)
Commits
c4b66bf and
7647174 add support for AArch64 trampolines. Updated
documentation to reflect the changes.
(cherry picked from commit
c6e69b041a7e6d18463f6cf684b10fd46a62c496)
Carlos Seo [Wed, 24 Jul 2024 14:18:08 +0000 (11:18 -0300)]
[AArch64] Implement INIT/ADJUST_TRAMPOLINE (#70267)
Add support for llvm.init.trampoline and llvm.adjust.trampoline
intrinsics for AArch64.
Fixes https://github.com/llvm/llvm-project/issues/65573
Fixes https://github.com/llvm/llvm-project/issues/76927
Fixes https://github.com/llvm/llvm-project/issues/83555
Updates https://github.com/llvm/llvm-project/pull/66157
(cherry picked from commit
c4b66bf4d065d3bbc2e2fac8512a6df8e013c704)
Eli Friedman [Wed, 24 Jul 2024 19:36:08 +0000 (12:36 -0700)]
[ExprConstant] Handle shift overflow the same way as other kinds of overflow (#99579)
We have a mechanism to allow folding expressions that aren't ICEs as an
extension; use it more consistently.
This ends up causing bad effects on diagnostics in a few cases, but
that's not specific to shifts; it's a general issue with the way those
uses handle overflow diagnostics.
(cherry picked from commit
20eff684203287828d6722fc860b9d3621429542)
Mark de Wever [Wed, 24 Jul 2024 17:42:48 +0000 (19:42 +0200)]
[libc++][spaceship] Implements X::iterator container requirements. (#99343)
This implements the requirements for the container iterator requirements
for array, deque, vector, and `vector<bool>`.
Implements:
- LWG3352 strong_equality isn't a thing
Implements parts of:
- P1614R2 The Mothership has Landed
Fixes: https://github.com/llvm/llvm-project/issues/62486
Louis Dionne [Wed, 24 Jul 2024 16:03:52 +0000 (11:03 -0500)]
[libc++] Improve behavior when using relative path for LIBCXX_ASSERTION_HANDLER_FILE (#100157)
Fixes #80696
(cherry picked from commit
046a17717d9c5b5385ecd914621b48bdd91524d0)
cor3ntin [Wed, 24 Jul 2024 15:27:58 +0000 (17:27 +0200)]
[Clang][NFC] Simplify initialization of `OverloadCandidate` objects. (#100318)
Initialize some fields of OverloadCandidate in its constructor. The goal
here is try to fix read of uninitialized variable (which I was not able
to reproduce)
https://github.com/llvm/llvm-project/pull/93430#issuecomment-
2187544278
We should certainly try to improve the construction of
`OverloadCandidate` further as it can be quite britle.
(cherry picked from commit
7d787df5b932b73aae6532d1e981152f103f9244)
cor3ntin [Wed, 24 Jul 2024 15:28:44 +0000 (17:28 +0200)]
[Clang] Fix an assertion failure introduced by #93430 (#100313)
The PR #93430 introduced an assertion that did not make any sense. and
caused a regression. The fix is to simply remove the assertion.
No changelog. the intent is to backport this fix to clang 19.
(cherry picked from commit
dd82a84e0eeafb017c7220c4a9fbd0a8a407f8a9)
Wesley Wiser [Tue, 23 Jul 2024 16:43:30 +0000 (11:43 -0500)]
[LLVM] [MC] Update frame layout & CFI generation to handle frames larger than 2gb (#99263)
Rebase of #84114. I've only included the core changes to frame layout
calculation & CFI generation which sidesteps the regressions found after
merging #84114. Since these changes are a necessary precursor to the
overall fix and are themselves slightly beneficial as CFI is now
generated correctly, I think it is reasonable to merge this first step.
---
For very large stack frames, the offset from the stack pointer to a
local can be more than 2^31 which overflows various `int` offsets in the
frame lowering code.
This patch updates the frame lowering code to calculate the offsets as
64-bit values and fixes CFI to use the corrected sizes.
After this patch, additional work is needed to fix offset truncations in
each target's codegen.
(cherry picked from commit
ca076f7a63f6a80e2e38315ec462be354b196b8d)
Ian Anderson [Tue, 23 Jul 2024 20:02:59 +0000 (13:02 -0700)]
[clang][headers] Including stddef.h always redefines NULL (#99727)
stddef.h always includes __stddef_null.h. This is fine in modules
because it's not possible to re-include the pcm, and it's necessary to
export the _Builtin_stddef.null submodule. However, without modules it
causes NULL to always get redefined which disrupts some C++ code. Rework
the inclusion of __stddef_null.h so that with not building with modules
it's only included if __need_NULL is set by the includer, or it's the
first time stddef.h is being included.
(cherry picked from commit
92a9d4831d5e40c286247c30fcd794563adbef6e)
Mark de Wever [Tue, 23 Jul 2024 16:59:23 +0000 (18:59 +0200)]
[libc++][doc] Update the release notes for LLVM 19. (#99061)
This is a preparation for the upcoming LLVM 19 release.
Fangrui Song [Tue, 23 Jul 2024 16:44:00 +0000 (09:44 -0700)]
[ARM] Create mapping symbols with non-unique names
Similar to #99836 for AArch64.
Non-unique names save .strtab space and match GNU assembler.
Pull Request: https://github.com/llvm/llvm-project/pull/99906
(cherry picked from commit
298a9223a57c50cb0d24b82687ad1bc2f7a022e6)
Sudharsan Veeravalli [Tue, 23 Jul 2024 13:19:57 +0000 (18:49 +0530)]
[RISCV] Fix InsnCI register type (#100113)
According to the spec the CI type instructions can take any of the 32
RVI registers.
Fixes #100112
(cherry picked from commit
1ebfc81a91194c000ac70b4ea53891cc956aa6eb)
jeanPerier [Wed, 24 Jul 2024 08:24:04 +0000 (10:24 +0200)]
[flang] fix C_PTR function result lowering (#100082)
Functions returning C_PTR were lowered to function returning intptr (i64
on 64bit arch). This caused conflicts when these functions were defined
as returning !fir.ref<none>/llvm.ptr in other compiler generated
contexts (e.g., malloc).
Lower them to return !fir.ref<none>.
This should deal with https://github.com/llvm/llvm-project/issues/97325
and https://github.com/llvm/llvm-project/issues/98644.
(cherry picked from commit
1ead51a86c6c746a1b9948ca1ee142df223ffebd)
Akira Hatanaka [Wed, 24 Jul 2024 09:04:37 +0000 (02:04 -0700)]
[PAC] Define __builtin_ptrauth_type_discriminator (#100204)
The builtin computes the discriminator for a type, which can be used to
sign/authenticate function pointers and member function pointers.
If the type passed to the builtin is a C++ member function pointer type,
the result is the discriminator used to signed member function pointers
of that type. If the type is a function, function pointer, or function
reference type, the result is the discriminator used to sign functions
of that type. It is ill-formed to use this builtin with any other type.
A call to this function is an integer constant expression.
Co-Authored-By: John McCall rjmccall@apple.com
(cherry picked from commit
666e3326fedfb6a033494c36c36aa95c4124d642)
Yingwei Zheng [Wed, 24 Jul 2024 12:06:36 +0000 (20:06 +0800)]
[ValueTracking] Don't use CondContext in dataflow analysis of phi nodes (#100316)
See the following case:
```
define i16 @pr100298() {
entry:
br label %for.inc
for.inc:
%indvar = phi i32 [ -15, %entry ], [ %mask, %for.inc ]
%add = add nsw i32 %indvar, 9
%mask = and i32 %add, 65535
%cmp1 = icmp ugt i32 %mask, 5
br i1 %cmp1, label %for.inc, label %for.end
for.end:
%conv = trunc i32 %add to i16
%cmp2 = icmp ugt i32 %mask, 3
%shl = shl nuw i16 %conv, 14
%res = select i1 %cmp2, i16 %conv, i16 %shl
ret i16 %res
}
```
When computing knownbits of `%shl` with `%cmp2=false`, we cannot use
this condition in the analysis of `%mask (%for.inc -> %for.inc)`.
Fixes https://github.com/llvm/llvm-project/issues/100298.
(cherry picked from commit
59eae919c938f890e9b9b4be8a3fa3cb1b11ed89)
Benjamin Maxwell [Wed, 24 Jul 2024 09:06:34 +0000 (10:06 +0100)]
[LSR] Fix matching vscale immediates (#100080)
Somewhat confusingly a `SCEVMulExpr` is a `SCEVNAryExpr`, so can have
> 2 operands. Previously, the vscale immediate matching did not check
the number of operands of the `SCEVMulExpr`, so would ignore any
operands after the first two.
This led to incorrect codegen (and results) for ArmSME in IREE
(https://github.com/iree-org/iree), which sometimes addresses things
that are a `vscale * vscale` multiple away. The test added with this
change shows an example reduced from IREE. The second write should
be offset from the first `16 * vscale * vscale` (* 4 bytes), however,
previously LSR dropped the second vscale and instead offset the write by
`#4, mul vl`, which is an offset of `16 * vscale` (* 4 bytes).
(cherry picked from commit
7fad04e94b7b594389111ae7eca0883ef18dc90b)
Benjamin Maxwell [Tue, 23 Jul 2024 07:30:02 +0000 (07:30 +0000)]
Precommit vscale-fixups.ll test (NFC)
Precommit test for #100080.
(cherry picked from commit
c1b70fa5bfea973d4141e27cf9668e9325609e19)
Chris Copeland [Wed, 24 Jul 2024 12:53:39 +0000 (05:53 -0700)]
[clang] Define `ATOMIC_FLAG_INIT` correctly for C++. (#97534)
(cherry picked from commit
4bb3a1e16f3a854d05bc0b8c5b6f8f78effb1d93)
Jan Leyonberg [Wed, 24 Jul 2024 13:57:39 +0000 (09:57 -0400)]
[clang][OpenMP] Propoagate debug location to OMPIRBuilder reduction codegen (#100358)
This patch propagates the debug location from Clang to the
OpenMPIRBuilder.
Fixes https://github.com/llvm/llvm-project/issues/97458
(cherry picked from commit
5b15d9c441810121c23f9f421bbb007fd4c448e8)
azhan92 [Tue, 23 Jul 2024 13:49:41 +0000 (09:49 -0400)]
[PowerPC] Add support for -mcpu=pwr11 / -mtune=pwr11 (#99511)
This PR adds support for -mcpu=pwr11/power11 and -mtune=pwr11/power11 in
clang and llvm.
(cherry picked from commit
1df4d866cca51eeab8f012a97cc50957b45971fe)
Mark de Wever [Tue, 23 Jul 2024 16:13:22 +0000 (18:13 +0200)]
[libc++][string] Fixes shrink_to_fit. (#97961)
This ensures that shrink_to_fit does not increase the allocated size.
Partly addresses #95161
(cherry picked from commit
d0ca9f23e8f25b0509c3ff34ed215508b39ea6e7)
Mark de Wever [Tue, 23 Jul 2024 16:03:28 +0000 (18:03 +0200)]
[libc++][vector<bool>] Tests shrink_to_fit requirement. (#98009)
`vector<bool>`'s shrink_to_fit implementation is using the
"swap-to-free-container-resources-trick" which only shrinks when the
input vector is empty. Since the request to shrink_to_fit is
non-binding, this is a valid implementation. It is not a high-quality
implementation. Since `vector<bool>` is not a very popular container the
implementation has not been changed and only a test to validate the
non-growing property has been added.
This was discovered while investigating #95161.
(cherry picked from commit
c2e438675754b83c31d7d5ba40cb13fe77e795de)
PaulXiCao [Tue, 23 Jul 2024 15:11:44 +0000 (15:11 +0000)]
[libc++][math] Fix undue overflowing of `std::hypot(x,y,z)` (#93350)
The 3-dimentionsional `std::hypot(x,y,z)` was sub-optimally implemented.
This lead to possible over-/underflows in (intermediate) results which
can be circumvented by this proposed change.
The idea is to to scale the arguments (see linked issue for full
discussion).
Tests have been added for problematic over- and underflows.
Closes #92782
(cherry picked from commit
9628777479a970db5d0c2d0b456dac6633864760)
azhan92 [Tue, 23 Jul 2024 13:51:13 +0000 (09:51 -0400)]
[PowerPC] Add builtin_cpu_is P11 support (#99550)
This PR adds support for __builtin_cpu_is ("power11")
(cherry picked from commit
63b382bbde5994e8f2cec75883320e3ad9fd618f)
Joseph Huber [Tue, 23 Jul 2024 17:54:00 +0000 (12:54 -0500)]
[NVPTX] Fix internal indirect call prototypes not obeying the ABI (#100131)
Summary:
The NVPTX backend optimizes the ABI for functions that are internal,
however, this is not legal for indirect call prototypes. Previously, we
would modify the ABI on an aggregate byval type passed to an indirect
call prototype, which would make PTXAS error. This patch just passes the
function as a nullptr to force strict ABI compliance without
modification in the helper function.
Fixes https://github.com/llvm/llvm-project/issues/100055
(cherry picked from commit
e0649a5dfc6b859d652318f578bc3d49674787a4)
hev [Wed, 24 Jul 2024 04:08:43 +0000 (12:08 +0800)]
[LoongArch] Fix codegen for ISD::ROTR (#100292)
This patch fixes the code generation for IR:
sext i32 (trunc i64 (rotr i64 %x, i64 %y) to i32) to i64
(cherry picked from commit
e386aacb747b4512dedf481ad83e054d3dd641e6)
Akira Hatanaka [Tue, 23 Jul 2024 21:39:58 +0000 (14:39 -0700)]
[PAC][compiler-rt][UBSan] Strip signed vptr instead of authenticating it (#100153)
vptr cannot be authenticated without knowing the class type if it was
signed with type discrimination.
Co-authored-by: Oliver Hunt <oliver@apple.com>
(cherry picked from commit
0a6a3c152faf56e07dd4f9e89e534d2b97eeab56)