AddressSanitizer: Declare runtime functions with RuntimeLibcallsInfo
Declare the asan runtime functions with RuntimeLibcallsInfo, so they
get the signatures and attributes from the libcall definitions. The
ELF globals registration functions are only declared for ELF targets,
which are the only users.
It is now an error to run the pass for a target that does not provide
the asan runtime. Tests with no triple, or a triple without an OS, now
use a Linux triple.
The experiment report functions are only used by a hidden testing
option, so keep declaring them by name and drop their RuntimeLibcalls
entries.
The kind of hacky part of this is the pass is now reasoning directly
in terms of LibcallImpl, instead of looking up the LibcallImpl from
the Libcall. This is because at the moment non-codegen passes don't
have a simple way of using LibcallLoweringInfo. There arguably should
[4 lines not shown]
[orc-rt] Install headers via a CMake file set. (#248335)
The public headers were installed via the PUBLIC_HEADER property, which
flattened the directory structure and dropped files with duplicate names
in different directories.
Switch orc-rt-headers to a HEADERS file set so that the directory
structure is preserved.
Assisted-by: claude
[mlir][XeGPU] Do not widen leading-dim inst_data for multi_reduction (#245106)
#240592 made layout propagation keep a reused slice parent's larger
inst_data on every non-reduced dim of a vector.multi_reduction source.
When that dim comes before the last two, blocking produces tiles such as
2x8x16. Lane-level distribution of multi_reduction only supports sources
whose leading dims are unit, so the blocked op then fails to legalize.
This PR keeps the parent's inst_data only on the last two dims. Leading
dims keep inst_data[i] = lane_layout[i] * lane_data[i], so they stay
unit.
assisted-by-claude
---------
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[-Wunsafe-buffer-usage] Allow safe `memset(&x, val, sizeof(T))` calls (#247816)
`-Wunsafe-buffer-usage` currently treats `memset(&x, val, sizeof(x))` as
safe (via `isUnsafeMemset`), but warns on `memset(&x, val, sizeof(T))`
even when `x` has type T. This causes the checker to flag glibc's
`CPU_ZERO(&cpuset)` macro (which expands to `__builtin_memset(&cpuset,
'\0', sizeof(cpu_set_t))`)as unsafe.
This patch updates `isUnsafeMemset` to also consider `memset(&x, val,
sizeof(T))` safe when `x` is a `DeclRefExpr` whose type matches `T`.
---
*Disclosure: AI assistance was used in the development and
implementation of this change.*
[test][X86] Precommit tests for 32-bit ELF PIC local IFUNCs (#248322)
Add codegen tests for calls, tail calls, musttail calls, and address
materialization of internal, hidden, and dso_local IFUNCs on i386 ELF.
The test covers the pic and static relocation models with SelectionDAG,
FastISel, and GlobalISel. The checks record the current output, where
PIC code references these IFUNCs with R_386_PC32 and R_386_GOTOFF.
Needed by #248318.
Assisted-by: Gemini
[CIR] Add bytecode encodings for struct and union types (#247883)
Struct and union types were the last CIR types stored as their printed
text in bytecode. The printed form of a record expands every record it
reaches that has not been printed yet, so the text grows with the depth
of nesting and dominates CIR bytecode for C++.
A named record can refer to itself, so the reader creates it incomplete
and publishes it with tryStartCyclicRead (#229910) before reading its
members. Anonymous records cannot refer to themselves and are built once
their members are read.
Bytecode output for two of the CIR codegen TUs (-fclangir -emit-cir -c
on preprocessed sources, same binaries):
```
CIRGenModule.cpp: 7.3 GB, 4m41s, 10 GB RSS -> 4.5 MB, 19s, 1.2 GB RSS
CIRGenExprCXX.cpp: 3.9 GB, 2m11s, 6 GB RSS -> 2.0 MB, 12s, 0.9 GB RSS
```
For reference, their -O3 LLVM bitcode is 1.4 MB and 0.5 MB.
[CIR] Add verifier enforcement of illegal SVE types (#247874)
This change updates the VectorType verifier to reject illegal SVE vector
sizes and updates the StructType, UnionType, and ArrayType verifiers to
reject scalable SVE vectors and svecount as elements/members.
Although LLVM IR represents tuples as a struct of SVE vectors, I intend
to add a dedicated tuple type in CIR.
Assisted-by: Cursor / various models
EC2: Use stream-optimized VMDK format
Once enabled on all of the branches, this will reduce bandwidth
consumption from uploading weekly snapshot builds from ~500 GB to
~100 GB, as well as significantly speeding up the process.
MFC after: 2 months
Sponsored by: Amazon
(cherry picked from commit 34f2f57b836d9cec02130419f5272495860d4ddf)
[lld][MachO] Avoid redundant work in Writer::scanRelocations() (#246903)
During relocation scanning, `Writer::scanRelocations()` looks up
`target->getRelocAttrs(r.type)` up to three times per symbol relocation
(in `scanRelocations()`, `validateSymbolRelocation()`, and
`prepareSymbolRelocation()`), tests `r.referent` twice for symbol
referents, and makes an out-of-line call to `validateSymbolRelocation()`
on every symbol relocation even though it only rejects two rare
thread-local-variable cases.
Move `validateSymbolRelocation()` (whose only caller is
`Writer::scanRelocations()`) into `Writer.cpp`, split the rare TLV
validation logic into a `LLVM_ATTRIBUTE_NOINLINE` helper, and mark
`DylibSymbol` `final` so `dysym->isTlv()` avoids a virtual call on the
fast path. Fetch `RelocAttrs` once per relocation, pass it to
`validateSymbolRelocation()` and `prepareSymbolRelocation()`, hoist
loop-invariant `target->relocAttrs` and `config->emitChainedFixups`, and
dispatch on `r.referent` once for non-subtractor relocations.
Assisted by Gemini + Claude.
[lldb][NFC] Have a clearer contract for SymbolFiles to mark change (#241655)
SymbolFile::AddSymbols can add symbols to an ObjectFile's Symtab. It can
also modify the symbols in the Symtab -- e.g. SymbolFileWasm can add
mangled names to an existing symbol. For a recent PR, I added a call to
Symtab::SetSymbolFileAddedSymbols() when a name was added to an existing
symbol in the Symtab. But this still left open the possibility of future
SymbolFile plugins, or downstream ones, doing the same thing (changing a
symbol in a Symtab), and we would not detect that the Symtab has been
updated since its ObjectFile state.
This changes SymbolFile::AddSymbols to return a bool indicating if
Symbols were added or updated. And in SymbolFileCommon::GetSymtab,
instead of checking that the number of symbols had changed and calling
Symtab::SetSymbolFileAddedSymbols(), use this new returned value.
As I look towards a bloom filter representation of the ObjectFile's
symtab, I become more focused on making sure I can tell when a
SymbolFile has modified the Symtab in any way, so the bloom filter can
[3 lines not shown]
[MLIR][XeGPU] Spread replicated sg_layout outermost-first in expandDim (#244999)
When expandDim splits a dim whose sg_data spans the whole dim, every
subgroup holds all of it, so the replicated subgroups can sit on any of
the new dims. expandDim currently places them on the innermost new dim.
For example, expanding sg_layout = [2, 2], sg_data = [16, 1024] on dim 1
to [32, 32] gives sg_layout = [2, 1, 2], sg_data = [16, 32, 32]. This
layout by itself is fine, since the two subgroups on the inner dim are
replicas. But in the mxfp use case the inner dim is the one reduced to
compute the scale, so it is sliced away, and its two subgroups go with
it. The multi_reduction rule then no longer sees those subgroups and
splits the reduced dim across them.
This PR places replicated subgroups on the outermost new dims instead.
For the same example, expandDim now gives sg_layout = [2, 2, 1], sg_data
= [16, 32, 32]. The sliced dim then has only one subgroup, so the
reduction rule sees all subgroups in use and keeps the reduction within
each subgroup:
main: slice<sg_layout = [2, 1, 2], sg_data = [16, 32, 32], dims = [2]>
[12 lines not shown]
[lldb] Add a DataFileCache for ObjectFile header bytes (#231344)
When creating a memory-read module, lldb needs to read the binary's
header & load commands (Mach-O terminology) out of memory, and then read
the symbol table out of memory. In
https://github.com/llvm/llvm-project/pull/229305 I added a new setting
default-on which saves the symbol table for a memory-read binary in the
DataFileCache. But we're still reading the header and load command bytes
out of memory on every debug session, and if there are a large number of
binary images being read from memory, this packet communication will be
a real performance problem.
This patch enables a new DataFileCache file with the same
`symbols.enable-lldb-index-cache-memory-modules` default-on setting,
"headerbytes". After creating a memory-read binary, it saves the bytes
of the header to the DataFileCache. And before reading a new memory-read
binary, it looks in the DataFileCache to see if the header bytes are
already available. If so, it puts those bytes in the Process
memory-cache, and allows the ObjectFile plugin sublcass to read them.
[37 lines not shown]
[MLIR][XeGPU] Check that a split shape_cast layout collapses at subgroup level (#245861)
For a shape_cast that splits a source dim, the source layout is derived
by collapsing the result layout. That is only exact when each sg tile is
contiguous in the collapsed dim. setupShapeCastResultLayout already
checks this for inst_data and lane layouts, but not at subgroup level.
In simple_mxfp_gemm_quantizeA_F4/F8, the result layout sg_layout = [2,
1, 2], sg_data = [16, 32, 16] of a 32x1024 -> 32x32x32 shape_cast was
collapsed to sg_data = [16, 512]. Its sg tile is not contiguous, so the
scales came out wrong.
This PR adds the subgroup check. When a group does not collapse, its
subgroups move to the group's outer dims (here [2, 2, 1] / [16, 16,
32]), and a convert_layout gives the consumer its layout.
assisted-by-claude
---------
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[lld][MachO] Avoid redundant work in Writer::scanRelocations()
During relocation scanning, `Writer::scanRelocations()` looks up
`target->getRelocAttrs(r.type)` up to three times per symbol relocation
(in `scanRelocations()`, `validateSymbolRelocation()`, and
`prepareSymbolRelocation()`), tests `r.referent` twice for symbol
referents, and runs the full `validateSymbolRelocation()` body on every
symbol relocation even though it only rejects two rare
thread-local-variable cases.
Split the rare TLV validation logic in `validateSymbolRelocation()` into
a `LLVM_ATTRIBUTE_NOINLINE` helper, and mark `DylibSymbol` `final` so
`dysym->isTlv()` avoids a virtual call on the fast path. Fetch
`RelocAttrs` once per relocation, pass it to
`validateSymbolRelocation()` and `prepareSymbolRelocation()`, hoist
loop-invariant `target->relocAttrs` and `config->emitChainedFixups`, and
dispatch on `r.referent` once for non-subtractor relocations.