[Object] Handle K_DARWIN64 in Archive::Symbol::getNext() (#233339)
Symbol::getNext() had no case for K_DARWIN64, so a __.SYMDEF_64 table
fell through to the generic path that advances to the next NUL in the
string table. That is only correct when the strings are stored in
ranlib_64 entry order. Tables whose ranlib_64 entries are sorted by name
while the strings stay in member order, as produced by Apple's ar,
paired symbol names with the wrong members.
Handle K_DARWIN64 together with K_BSD, parameterized by word size.
[Flang][OpenMP] Flag for switching off implicit allocatable member mapping via default declare mapper (#228748)
Part of the OpenMP specification requires implicitly mappiing
allocatable members in derived types. However, it is quite an expensive
overhead to perform implicit allocatable member mapping as it requires a
mapper to do so due to the nature of possibly nested allocatable derived
types etc. Alongside a fairly comprehensive map of the record, this in
particular comes at a fairly substantial cost for arrays of derived
types that trigger this behaviour. Some of this may or may not be
mitigatable over time.
But for the moment this PR seeks to follow the example of other Fortran
OpenMP compilers (Cray in particular I think) and utilise a flag that
can switch this behaviour on and off, so that applications not depending
on the crutch of this implicit mapping can deactivte it and not pay the
overhead, and those that like the compiler to do this for them can
continue to do so.
[lldb] Rename ELF core register contexts (#239069)
The current RegisterContextPOSIXCore naming is confusing for the
following reasons:
- The filename is `RegisterContextPOSIXCore_*` but the class name is
`RegisterContextCorePOSIX_*`.
- POSIX does not require the OS to execute ELF binaries. An example of
this is macOS which runs Mach-O executables.
- Other process plugins have register context classes named
`RegisterContext<plugin's name>`, but elf-core plugin has POSIX in its
register context class name.
This happened because the base class was named RegisterContextPOSIX, but
this was renamed to `RegisterContextCore` in eeb24ee48aa2 because it was
only used by coredump process plugins and did not directly call POSIX
APIs.
To reflect the change, rename elf-core's register context class names to
[2 lines not shown]
[AVR] Port ExpandPseudo to NewPM
Standard NewPM pass porting. Also note that this pass preserves the CFG
in the LegacyPM.
Reviewers: benshi001, arsenm
Pull Request: https://github.com/llvm/llvm-project/pull/236482
[Object][Wasm] Validate section index and type for section symbols (#239408)
`WASM_SYMBOL_TYPE_SECTION` symbols must reference a valid custom
section, matching the check already performed for `WASM_COMDAT_SECTION`
entries in `parseLinkingSectionComdat`.
Previously, `parseLinkingSectionSymtab` did not check that the section
index was in bounds or that the referenced section was a custom section,
leading to out-of-bounds accesses in `WasmObjectFile` or a null-pointer
dereference in `wasm-ld`.
See: https://github.com/WebAssembly/tool-conventions/pull/272
Fixes: #239393
[tsan] Calibrate jmp_buf SP mangling lazily on Linux (#237466)
Avoid running two `_setjmp` probes during startup in binaries that never
call `longjmp`/`siglongjmp`, and unify regular Linux with Android's
on-first-use calibration from #216558 using a separate atomic flag so
zero keys (identity mangling) remain handled.
Assisted-by: Gemini
[Demangle] Support template arguments on vendor extended types
The Itanium ABI grammar is 'u <source-name> [<template-args>]', but the
demangler only accepted a single type argument after the name (used for
builtin type transformations). Clang emits names such as
u11matrix_typeILm1ELm2EjE for matrix types and HLSL, which were left
mangled. Parse general template arguments; a single type argument keeps
the existing transformation output.
Part of #111345.
LLM-aided
WasmEHPrepare: Use RuntimeLibcallsInfo (#239024)
Take the function type, attributes and calling convention from
RuntimeLibcallsInfo instead of constructing them by hand. Also
validate the required functions are available.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[NFC] Extract fmul(x, CRHS) tests from nofpclass-fmul.ll (#239424)
Moves all `fmul(x, CRHS)` tests from `nofpclass-fmul.ll` to
`nofpclass-fmul-crhs.ll`. Also updated the tests from `--version 2` to
`--version 6`, and updated some of the literals to the modern
`f0x3F800000` form.
[HLSL] Revert `WaveMultiPrefixCountBits` (#239439)
Revert commit `926040bad7abaff76e07a854f9f3edb3ca490248` (#238132) after
the Fuchsia build reports failures in the Clang
`WaveMultiPrefixCountBits` test.
Resolve the merge conflicts to remove only CountBits. Keep BitAnd,
BitXor, Product, Sum, and BitOr. Restore the original inline mask check
for those operations.
Remove the CountBits builtin, its HLSL alias, its DirectX intrinsic and
operation, and its tests. This change reverses the added and removed
lines from #238132 in all 12 affected files.
Assisted by: GitHub Copilot
Co-authored-by: Copilot <223556219+Copilot at users.noreply.github.com>
Copilot-Session: 40997c2f-5aaa-41c6-8d1f-3e2e9ada315f
[MSan] Intercept ftw, nftw, ftw64, and nftw64 in sanitizer_common. (#238166)
For `ftw`, `nftw`, `ftw64`, and `nftw64`, libc allocates a buffer for
path string and structs, before invoking the user-supplied callback.
They are uninstrumented in MemorySanitizer, so they trigger
false-positive use-of-uninitialized-value reports.
This PR adds `sanitizer_common` interceptors for `ftw` and `nftw` on
Linux (`SI_LINUX_NOT_ANDROID`) and `ftw64` and `nftw64` on glibc
(`SI_GLIBC`). Wrap the user callback in a thread-local trampoline that
unpoisons parameter shadow TLS and initializes the memory ranges for
arguments before forwarding to the user callback, saving and restoring
the previous callback pointer across calls to support nested
invocations. Resolve `nftw` and `nftw64` with a minimum glibc symbol
version so `dlvsym` selects `__new_nftw` rather than the legacy
`GLIBC_2.2.5` compatibility symbol that strips `FTW_ACTIONRETVAL`.
Assisted-by: Gemini
[ORC] Remove dead code from EPCDynamicLibrarySearchGenerator. (#239008)
Search generators should not error on missing symbols (the search should
be allowed to fall through to subsequent generators and dylibs in the
search order). EPCDynamicLibrarySearchGenerator::tryToGenerate supports
this by using WeaklyReferencedSymbol for all search elements, but also
had an unreachable "missing symbols" error path. This commit removes the
unreachable error path, plus the now-unused `ExecutionSession&` member.
[lldb] Test unterminated ELF symbol names (#239425)
Cover the ELF side of c38a7054a1d8, which only added a Mach-O test.
rdar://187064381
Assisted-by: Claude
RuntimeLibcalls: Add signatures for the SME ABI support routines (#239366)
Use the prototypes from the AArch64 SME ABI. __arm_sme_state returns two
64-bit values.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[clang][Parse][NFC] Share parsing for astype and convertvector builtins (#239107)
Share the parsing logic for __builtin_astype and
__builtin_convertvector, then dispatch to their respective Sema actions.
Preserve diagnostics and error recovery.
[HIP] Use positional ordering for ROCm include paths
Instead of using path-based heuristics to choose between -idirafter and
-internal-isystem for the ROCm include path, split AddHIPIncludeArgs
into two phases:
- Early phase (AddHIPIncludeArgs): emits wrapper headers (cuda_wrappers/)
before C++ stdlib headers, preserving #include_next chains.
- Late phase (AddHIPIncludeArgsLate): emits the ROCm toolkit include
path after C++ stdlib but before C system headers, so the selected
ROCm installation's HIP headers always take precedence over any
distro-installed copies in /usr/include.
This replaces the previous conditional that compared the include path
against {SysRoot}/usr/ to decide the flag. That approach had two bugs
identified in review: a double-slash with trailing-slash sysroots, and
/usr/local/rocm still using -idirafter. The positional approach handles
all install locations uniformly without path comparisons.
Co-Authored-By: Claude Opus 4.6 <noreply at anthropic.com>
[CIR] Add unadjusted align to the CIR record layout (#238913)
The unadjusted align of a record (the alignment calculated by the AST
before adjustments such as attributes are applied) is needed to perform
ABI classification for AArch64 targets. This change adds this field to
the CIR RecordLayoutAttr but does not yet enable the AArch64 calling
convention lowering. That will be done in a future change.
Assisted-by: Cursor / various models
[AMDGPU] Validate prefetch length and cache policy operands (#232143)
Two operands of the AMDGPU prefetch intrinsics, the length and the cache
policy, are not validated. An out-of-range length is encoded differently
from what the assembly says, and an out-of-range cache policy is
silently miscompiled or rejected late by the backend.
Fixes:
- Length: Instruction selection now keeps only the low 5 bits of a
constant length, so the assembly shows the value that is encoded. The
object code is the same as before. As a safeguard for hand-written
assembly, including inline `asm`, the assembler on GFX12 and later now
rejects an immediate length that does not fit in 5 bits instead of
silently truncating it.
- Cache policy: clang and the IR verifier now reject a cache policy that
sets any bit other than th (bits 0-2), scope (bits 3-4) and nv (bit 5),
or that uses the reserved th value 7. The assembler needs no change: it
already rejects th 7.
[clang][CUDA] Search include/cccl of CUDA 13 installations (#235910)
From CUDA 13.0 on, the CUDA C++ Core Libraries (libcu++, CUB and Thrust)
are in `include/cccl` of the CUDA installation rather than in
`include/`. Some of the toolkit's own headers include them, so with CUDA
13 something as simple as `#include <cooperative_groups.h>` fails to
compile with Clang:
```
cooperative_groups/details/info.h: fatal error:
'cuda/std/type_traits' file not found
```
nvcc searches `include/cccl` right after `include/`. This makes Clang do
the same, when the directory exists. `-nogpuinc` still leaves it out,
and the user's own include directories are still searched first.
The HIP toolchain already does the equivalent for
[`include/libhipcxx`](https://github.com/llvm/llvm-project/blob/fe84f6e3b0ae40ef28998cd9cee3220eec2ea261/clang/lib/Driver/ToolChains/AMDGPU.cpp#L617-L624).
Assisted-by: Devin
RuntimeLibcalls: Add signatures for the Darwin sincos stret functions
__sincos_stret and __sincosf_stret return a struct holding the 2
results. Describe the C struct return type in the signature table and
lower for the target ABI. This is a vector on x86-64 for float,
through memory on x86-32 and APCS ARM, and as a struct elsewhere.
This replaces the special case that built the types in C++. Ideally we
would be using the ABI library, but it's incomplete for most targets
and it requires some relayering to use here.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
RuntimeLibcalls: Describe the stack guard and safestack variables
The stack guard and the unsafe stack pointer are global variables, not
functions. Describe them as variables in the signature table, with the
unsafe stack pointer thread local in the alloca address space, and
declare them as globals.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
RuntimeLibcalls: Add a signature for the stack probe functions
The stack probe functions are assembly routines with their own unnamed
calling convention. The allocation size is passed in a fixed register
that is not the standard first argument register (rax/eax on x86, x15
in 16-byte units on AArch64, r4 in 4-byte units on ARM), almost all
registers are preserved, and the i386 _alloca variant also moves the
stack pointer. It's not ideal, but short of defining a custom calling
convention, just declare them with no arguments.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[AMDGPU] Update src2 live range when converting WMMA to three-address form
Since #225174, `LiveIntervals` is computed before the two-address instruction
pass. A two-address WMMA ties `src2` to an early-clobber `vdst`, so if `src2`
dies at the WMMA, its live range ends at the early-clobber slot. When the pass
converts the WMMA to the three-address form, `src2` is no longer tied and is
read at the register slot, but `SIInstrInfo::convertToThreeAddress` only updates
the live range of the def. The machine verifier then reports "Live segment
ending at early clobber slot must be redefined by an EC def in the same
instruction".
This PR moves the end of such a segment to the register slot, for the main range
and the subranges.
Fixes LCOMPILER-3197.
[flang-rt][cuda] Add support to build temporary-stack (#239403)
These functions are used when lowering some forall statements. It would
fails to link with code like:
```fortran
!$acc serial copyin(k) copyout(kk,kkk,kkkk)
forall (n=1:nb)
kk(n,:)=k(n,:)
kk(n,:)=kk(n,:)+1
kkk(n,:)=k(n,:)
kkk(n,:)=kkk(n,:)+1
kkkk(n,:)=k(n,:)
kkkk(n,:)=kkkk(n,:)+1
end forall
!$acc end serial
```