[clang][Driver] Use the Windows ARM64 defaults for aarch64-unknown-uefi
Match the Windows ARM64 driver defaults for aarch64-unknown-uefi, which
follows the same ABI:
* char is signed, so do not pass -fno-signed-char,
* the frame chain must stay valid even when frame pointers are omitted,
so -fomit-frame-pointer yields -mframe-pointer=reserved rather than
none, as the backend reserves the frame pointer for UEFI as well,
* -msign-return-address selects the B key, the only one the backend
accepts for Windows and UEFI.
Assisted-by: Claude
[clang] Add aarch64-unknown-uefi target
Add the aarch64-unknown-uefi target to clang, building on the backend
support added in the preceding patches. Like x86_64-unknown-uefi it
follows the Microsoft ABI conventions, matching the Windows ARM64 target
which is the only way EFI applications for AArch64 can be built with
Clang/LLVM today:
* add UEFIAArch64TargetInfo: LLP64 types, Microsoft C++ ABI, char*
based va_list and the Win64 calling convention kind,
* use the Windows AArch64 ABI info in CodeGen for UEFI,
* accept aarch64 for *-uefi triples in the driver.
The UEFI toolchain already handles the linker invocation (lld-link with
/subsystem:efi_application), so no further driver changes are needed.
Assisted-by: Claude
[AArch64] Apply the Windows SEH and CRT codegen constraints to UEFI
aarch64-unknown-uefi uses SEH unwind information and has no C runtime
library, so the remaining Windows specific codegen decisions that follow
from this apply to it too:
* do not align loops or basic blocks, since SEH unwind info generation
needs the exact function layout before alignment padding is inserted,
* sign return addresses with the B key by default and reject A key
signing, matching the pac_sign_lr unwind code used by the unwinder;
the branch protection parser defaults to the B key for UEFI as well,
so that -mbranch-protection=pac-ret keeps working,
* do not lower wide shifts to libcalls at -Oz, as those helpers are not
available.
The corresponding Windows tests gain aarch64-unknown-uefi run lines and
the LLVM release notes announce the new target, which completes the
backend side of aarch64-unknown-uefi support.
Assisted-by: Claude
[SLP][modularisation][NFC] Move getReductionInstr to SLPReductionUtils, getAggregateSize to SLPUtils
Move the reduction-root helper getReductionInstr out of SLPVectorizer.cpp
into the self-contained SLPVectorizer/SLPReductionUtils.{h,cpp} module.
getAggregateSize is not reduction-specific: its only user is
findBuildAggregate and it only computes the element count of a homogeneous
aggregate from its type. Move it to the generic SLPVectorizer/SLPUtils
module instead.
Part of the SLPVectorizer.cpp modularization effort:
https://discourse.llvm.org/t/modularizing-slpvectorizer-cpp/90922
Assisted by AI
[SLP][modularisation][NFC] Move loop trip-count helpers to SLPUtils
Move the BoUpSLP-independent helpers findInnermostNonInvariantLoop and
getLoopTripCount out of SLPVectorizer.cpp into the self-contained
SLPVectorizer/SLPUtils.{h,cpp} module. getLoopTripCount reads the file-local
LoopAwareTripCount cl::opt, which stays static in SLPVectorizer.cpp and is
passed to the moved helper as an explicit parameter. NFC.
Part of the SLPVectorizer.cpp modularization effort:
https://discourse.llvm.org/t/modularizing-slpvectorizer-cpp/90922
[clang-tidy] Fix readability-redundant-parentheses false positives on decltype (#224715)
Preserve parentheses that affect type deduction in `decltype` operands
and
`decltype(auto)` initializers and return statements. This also covers
dependent operands in templates and their instantiations, and operands
that create temporaries. Continue diagnosing redundant parentheses whose
removal does not affect type deduction, such as those in
`decltype((1))`.
Fixes #223522.
Test constrained and explicit object operators in defaulted postfix operators
Cover prefix and postfix operators that are constrained or declared with
an explicit object parameter, and add the remaining deletion and
constexpr-mismatch notes that were not yet tested: the decrement forms,
protected members, and non-constexpr constructors, conversion functions
and consteval declarations.
Co-Authored-By: Claude Fable 5.1 <noreply at anthropic.com>
Defer all defaulted postfix operator checks in dependent contexts
Return early from CheckExplicitlyDefaultedPostfixOperator when the first
parameter type is dependent or the function is in a dependent context,
after the prefix operator lookup. A deduced return type in a template is
now diagnosed when the template is instantiated.
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
Extract the copy and destroy check for defaulted postfix operators
Move the checks that C can be direct-initialized from an lvalue of type C
and then destroyed, from the context of the function body, into
canCopyAndDestroyForDefaultedPostfixOperator.
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
Use InitializationSequence::Diagnose for defaulted postfix operator copy
Replace the hand-written explanation of why copy construction fails in a
defaulted postfix operator with InitializationSequence::Diagnose. This
emits errors rather than notes, so it is a FIXME for now.
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
[M68k,Xtensa][test] Regenerate tests after LiveVariables removal changes (#233183)
Fix after #229069 (InstrEmitter no longer emits kill flags) and #228618
(LiveIntervals runs before PHIElimination).
[tools] Parse library options into LLVMContext (#233182)
cl::ParseCommandLineOptions sets library options in T::Global, so IR
options will no longer affect them after LLVMCore migrates off cl::opt.
Switch to cl::parseCommandLineOptions.
[libc++] Fix use-after-free during self-assignment (#225296)
The range [data(), data() + size() + 1) points into the string's own
buffer and is one element longer than the capacity when the buffer is
full, so assigning it reallocates:
std::string str;
str.resize(str.capacity(), 'a'); // size() == capacity()
str.assign(str.data(), str.data() + str.size() + 1); // reallocates
__assign_trivial called __grow_by_without_replace up front and read the
range afterwards, by which point the buffer holding it had been
released: that is a heap-use-after-free for a long string, and for a
short string the long representation has been written over the small
buffer the range points into, so the assignment silently stores garbage.
Allocate the new buffer and read the range into it before releasing the
buffer the string holds. That also keeps the range valid in the exotic
case where it is the byte representation of the string object itself,
[14 lines not shown]
[lld][MachO][NFC] Don't let the output path trip cstring-dedup.s's check-not (#232631)
The __cstring check uses --implicit-check-not foo/bar, but llvm-objdump
prints the input file's full path first. When that path contains "bar"
(e.g. /home/isanbard/...), the test fails. Pass --no-leading-headers so
the path isn't printed. That also suppresses the "Contents of
(__TEXT,__cstring) section" line, so drop that STR check; --section
already restricts the output to __cstring.
Assisted-by: Claude Opus 5.5
[flang][OpenMP] Don't treat different runtime conditions as subsets
When two METADIRECTIVE candidates have the same score and one selector is
a strict subset of the other, the superset wins. Flang ranks every
runtime condition with the same property, so isStrictSubset saw
different conditions as the same:
!$omp metadirective &
!$omp& when(user={condition(a)}, &
!$omp& implementation={vendor(score(4): llvm)}: taskyield) &
!$omp& when(user={condition(b)}, device={kind(host)}, &
!$omp& implementation={vendor(score(3): llvm)}: taskwait)
Both candidates score 5, and `b` was tested first, so TASKWAIT ran when
both conditions were true. Neither selector is a subset of the other, so
clause order should decide.
This patch adds a UserCondition key to VariantMatchInfo, and
isStrictSubset requires equal keys when the first selector has a
[9 lines not shown]
[LFI][MC] Mark .note.LFI.ABI section with SHF_GNU_RETAIN (#233164)
Sections in a COMDAT group are subject to garbage collection during
linking when `--gc-sections` is enabled (even SHT_NOTE sections).
Because nothing references `.note.LFI.ABI.<arch>`, the deduplicated note
was previously removed by the linker with `-Wl,--gc-sections`.
Add `SHF_GNU_RETAIN` to `.note.LFI.ABI.<arch>` so that linkers recognize
it as a GC root while still deduplicating it via COMDAT.
Fixes #233086.
[libc][math] Add integer-only implementation for exp2f.
- Correctly rounded to all rounding mode (statically).
- Share core computations with expf integer-only static-rounding version
- Optimize for code size.
Assisted-by: Gemini for analysis and refactoring.
[libc] Add floating-point bitwise operations to FPUtil.
Add `fp_and`, `fp_or`, `fp_xor`, `fp_andnot`, and `fp_not` to
`src/__support/FPUtil/fp_bitwise.h` to perform bitwise operations on
floating-point values directly in FP/SIMD registers when SSE2 or AArch64 NEON
is available, avoiding GPR round-trips.
[mlir][ArithToLLVM] Preserve defined signed remainder by -1
Select a zero dividend when the divisor is -1 before emitting llvm.srem.
This preserves arith.remsi(INT_MIN, -1) == 0 without introducing LLVM UB.
Support scalar and vector operands, including multidimensional vectors.
Add regression coverage to the existing ArithToLLVM conversion test.
Tests were not run as requested.
[libc][NFC] Fix typo 'implemenation' in comments (#233089)
Fix the misspelling "implemenation" -> "implementation" in comments in
libc/src/__support/mathvec/*.h and libc/src/string/string_length.h.
No functional change.
[clang][Driver] Honor `--offload-jobs` in device-only compilation
`--offload-jobs=N` runs independent device compilations in parallel, but
it had no effect when only device code is compiled; multi-target
device-only builds still compiled each target one at a time.
Two things got in the way. The device-only compile produces an object
directly, and that step was not treated as one that can run in parallel.
Each target's compile is also followed by its own device link, so the
compiles that could run together are not next to each other, and only
neighboring steps were grouped for parallel execution.
Treat the object-producing device compile as parallelizable, and group
same-kind compiles even when other independent steps sit between them.
The grouped compiles do not depend on those in-between steps, so the
output is unchanged and only the build time drops.
[llvm-reduce] Parse library options into LLVMContext (#233162)
cl::ParseCommandLineOptions sets library options in T::Global,
no longer read by LibraryOptionsContext::get since #233044.
Switch to cl::parseCommandLineOptions.