Reland "[SSAF][clang-reforge] Add end-to-end clang-reforge tests (#219085)"
This reverts commit 459dffa2ef4af2e3fd96ff35a235a301bdeeb32c
The new test added in the original PR uses 'clang-apply-replacements'
conditionally now. It checks if the tool is available before using it.
When the tool is not there, it only checks against replacement offsets
and texts.
Final step of:
rdar://185840466
[VPlan] Compute SCEV for ptrtoaddr. (#219848)
SCEV models ptrtoaddr via getPtrToAddrExpr. Mirror that in
getSCEVExprForVPValue. ptrtoint stays unmodelled, as createSCEV returns
an unknown for it.
Adds m_PtrToAddr to VPlanPatternMatch.
[mlir] Fix mlir-pdll-lsp-server link.
This is the same fix TableGenLspServerLib got in 9e469ced42cd.
This addresses the mlir-pdll-lsp-server instance of #152371.
MLIRPdllLspServerLib transitively needs LLVMTableGen, which is not part of
libLLVM.so, so MLIRPDLLParser already brings in static LLVMSupport. Linking the dylib here as well gives mlir-pdll-lsp-server two copies of LLVMSupport. Linking still succeeds, but with assertions view-output.test fails. The test trips over the two copies having different Hashing.h seeds, which is a separate defect to be addressed in another PR.
It has not shown up in CI because it needs the dylib and assertions at the same time, which rarely coincide. It also only became reachable once a3a25996b114 moved the LSP transport into libLLVM.so.
[CIR] Teach partial-array-destruction to work with arrays-of-records (#220045)
We currently assume that a partial-array destruction was a 1D array.
This is incorrect, as it can obviously be a MD array.
This patch comprehends the destruction across the array by using the
same begin/end iterators, but deleting these as element nodes.
Classic codegen does a full descent into the array types to do this
destruction, but I believe that is a side-effect of how it is going
through it. Treating arrays as contiguous and flattening the iterators
is effectively identical.
Note: Claude helped me extensively on the test, I believe all the
check-lines are correct, but I also pushed to make sure we got the full
structure checking correctly, so I hope this shows the differences above
properly.
[compiler-rt] Rename ubsan_device to ubsan_offload
The host interceptor and GPU handler library serve offload, not a
generic device sanitizer. Keep the Apple add_ubsan_device_testsuite name.
[BOLT] Parse .eh_frame CFI programs on demand to reduce memory
BOLT read the entire .eh_frame up front via DwCtx->getEHFrame(), which
parses and caches the CFI instruction program of every CIE/FDE in the
binary for the whole run. On a large binary, this dominated
file-object discovery: CFIProgram::parse accounted for ~6.5 GB and the
cached DWARFDebugFrame ~6.9 GB of live memory. Yet the CFI programs
are only consumed in CFIReaderWriter::fillCFIInfoFor, and only for the
functions BOLT actually disassembles. discoverFileObjects itself needs
nothing but each FDE's address and range for function-boundary checks.
Here we parse .eh_frame for its index only, and decode each function's
CFI program on demand, lazily, only for the functions that really need
it. In a large binary, DWARFDebugFrame::parse drops from 6922.2 MB
to 587.6 MB, the residual being the lightweight FDE/CIE index (entries
without instruction programs), and readSpecialSections falls from
7078.7 MB to 738.6 MB on the tested binary for which BOLT's RSS is
about 80-120GB.
[DebugInfo] Allow .eh_frame CFI programs to be parsed lazily (#214895)
BOLT read the entire .eh_frame up front via DwCtx->getEHFrame(), which
parses and caches the CFI instruction program of every CIE/FDE in the
binary for the whole run. On a large binary, this dominated file-object
discovery: CFIProgram::parse accounted for ~6.5 GB and the cached
DWARFDebugFrame ~6.9 GB of live memory (from 5 to 10% of total anon peak
RSS).
This new interface allows DebugInfo's users to optionally parse CFIs on
demand, only when necessary. On BOLT, this is an important lever to
manage memory utilization when processing large binaries. A real use
case is also implemented in llvm-dwarfdump: it now decodes CFIs lazily,
so if a user requests a dump of a specific entry, only that entry is
decoded. If another entry in that section is invalid, we don't error
anymore as that entry won't be decoded if the user did not request it.
[BOLT] Fix data race on the shared .dwp DWARF context
As noted by labrinea, 775dc9b8bf58 ("[BOLT] Create and release .dwo
DWARF contexts incrementally") releases every DWO context at the end
of readDebugInfo, leaving the bucket threads of the DWARF rewrite to
re-open them on demand. With a .dwp package that moved the first touch
of a shared context into the parallel phase, and multiple threads
compete for it, in a race for the abbrev table, causing intermittent
failures in dwarf5-ftypes-dwp-input-dwo-output.test.
Open the split CUs of a package up front, from a single thread, and
resolve the abbreviation table of every unit in it. This is not
relevant for the non-dwp case, which is unaffected.
[libc] Implement getpriority, setpriority, their unit tests; add the accompanying macros and type headers. (#219573)
Testing these is a bit tricky, so:
- For `getpriority`, ensure the call succeeds and round-trip the highest nice
value on Linux (19).
- For `setpriority`, ensure the call succeeds when setting it to the current nice.
- For both, test two failure modes that are easy to stably induce.
[clang][docs] Fix Sphinx 8.2 and MyST build errors in Clang docs (#220108)
Commit 66617db9163d bumped Sphinx to 8.2, Docutils to 0.22, and
MyST-Parser to 4.0.1.
When building Clang documentation with `-W`, this surfaced two
breakages:
1. `ControlFlowIntegrityDesign.md`: Dangling `[^ivtbl]` footnote
references without a matching footnote definition, leading to a docutils
`ERROR: Too many autonumbered footnote references: only 0 corresponding
footnote available` / `ERROR: Unknown target name: "ivtbl"`.
2. `ScalableStaticAnalysis/developer-docs/index.md`: `:numbered: true`
caused a `ValueError: invalid literal for int() with base 10: 'true'` in
MyST because `:numbered:` takes an integer depth or no argument. Fix it
to `:numbered:`.
AI tool usage: An AI assistant was used to help research and draft the
documentation updates.
[mlir] Migrate AMDGPU/ROCDL to targets, not chipset versions
**migration tl;dr:** `chipset=` becomes `triple=`, migrate off of
`amdgpu::Chipset` to `ROCDL::TargetInfo`, and eventually change
`gfxXYZ` to `amdgpuX.YZ-amd-amdhsa` in that `triple` argument.
`amdgpu::Chipset` was an awkward hack that was hard to keep up to date
with changes in the compiler/new architectures, and didn't properly
support generic targets (and has been strongly disfavored by the
compiler team).
This PR replaces `amdgpu::Chipset` with `ROCDL::TargetInfo`, a
structure that uses LLVM's TargetParser and the underlying LLVM
features tables to get the real nature of the target being compiled
for.
This also helps MLIR move to
new-style (`-mtriple=amdgpuX.YZ-amd-amdhsa`) over "old
style" (`-mtriple=amdgcn-amd-amdhsa -mcpu=gfxXYZ`) triples.
[40 lines not shown]
[mlir][AMDGPU][NFC] Pre-commit tests for incorrect version checks
There'll be a refactoring from `amdgpu::Chipset` to
`ROCDL::TargetInfo`, thus also moving from chip version checks to
features checks. This commit adds tests for incorrect lowerings that
were allowed by the current code.
- gfx90c is >= gfx90a but stil needs atomic emulation (it doesn't
have buffer fmax and so on).
- gfx90c is also >= gfx90a but has no barrier back-off, so it needs
the inline asm workaround around `s_barrier` that it isn't getting
- gfx908 doesn't have a packed fp16 atomic add but we thought it did
- gfx950 is mistakenly allowing xf32 MFMAs
- gfx1200 is allowing permlane_swap instructions that it doesn't have
- gfx11.7 should be allowing OCP FP8 conversions but isn't on the list
This also cleans up some redundant tests with a --check-prefixes
AI disclosure: Claude found these and wrote the tests.
[2 lines not shown]
[AMDGPU] Expose buffer resource num_records width in TargetParser
This also fixes the conflict in gfx12.
Co-Authored-By: Claude Opus 5 (1M context) <noreply at anthropic.com>
[AMDGPU] Sort frontend-visible feature, add feature-name parsing
Emit `AMDGPUFrontendVisibleFeatures` sorted by name so it can be
binary-searched.
Also add an API for mapping feature name(s) to updates to a feature
bitmap, allowing frontends (MLIR in particular) to parse a
`-mattr`-like string.
AI disclosure; Claude wrote this code.
Co-Authored-By: Claude Opus 5 (1M context) <noreply at anthropic.com>