[-Wunsafe-buffer-usage] Speed up warning a bit (#226605)
Checking a type is faster than calling ignoreUnsafeBufferIn...(). The
latter has to get the Stmt's begin loc, look up diagnostic state and
suppression, etc. And the type check lets us skip most Stmts cheaply, so
do that first.
In a sampling profile of 48 Chromium TUs (which are built with
-Wunsafe-buffer-usage), UnsafeBufferUsageReporter's
ignoreUnsafeBufferInLibcCall() and ignoreUnsafeBufferInContainer() were
1.35% and 1.29% of the total compile time, and 3.75% for
checkUnsafeBufferUsage() as a whole.
For 60 random Chromium TUs drawn with probability proportional to their
compile time, sum over all TUs:
CPU time: 242.9 s => 237.5 s, -2.2%
instructions: 2452.6e9 => 2371.8e9, -3.3%
No behavior change.
[X86][APX] Precommit test for BLSI/BLSMSK i8 patterns with EGPR (NFC) (#226793)
The i8 BLSI/BLSMSK patterns always select the VEX forms, so when only
extended GPRs (r16-r31) are available the operands get spilled instead
of using the EVEX forms.
Tests for #226796
Assisted-by: Claude Code
Co-authored-by: Claude Opus 5.5 (1M context) <noreply at anthropic.com>
X86: Mark EFLAGS dead on the FP control word OR (#227017)
Fix custom inserters to add dead flags.
Co-authored-by: Claude Opus 5 <noreply at anthropic.com>
[ADT] Extract SmallDenseMapStorage from SmallDenseMap (NFC) (#226882)
This patch extracts the inline and heap bucket and occupancy storage
management from SmallDenseMap into a new helper class,
densemap::detail::SmallDenseMapStorage, and updates SmallDenseMap to
use it via composition.
This is part of the effort to replace CRTP in DenseMapBase with
composition (see #168255 and #226664). With both DenseMapStorage and
SmallDenseMapStorage in place, the next patch will remove CRTP from
DenseMapBase.
Assisted-by: Antigravity
[clang] Add one-entry cache for ASTContext::getDeclAttrs() (#226610)
In libc++, almost every decl has attributes, so ASTContext::DeclAttrs
has 50k-150k entries when using libc++. But attributes are often queried
several times in a row for the same decl (e.g. `D->hasAttr<A>() ||
D->hasAttr<B>()`). Numbers for some Chromium TUs:
getDeclAttrs() same Decl as table
calls previous call size
blink logical_box_fragment.cc 19.6M 88.4% 156132
glic_webui_contents_manager.cc 16.0M 86.1% 144545
tflite kernels/conv.cc 6.1M 91.2% 52623
So add a one-element cache. AttrVecs are allocated separately, so
keeping a pointer to the result is safe.
Build time for 60 random Chromium TUs drawn with probability
proportional to their compile time:
[8 lines not shown]
[OpenMP] Preserve host capture lifetimes in frontend lowering
Mark captured alloca/global storage nofreeobj when Clang emits a synchronous
host parallel call. This preserves lifetime across outlining without claiming
that escaped capture slots are noalias or immutable, and without extending the
lifetime guarantee to pointers loaded from those slots.
Mark OpenMPIRBuilder's fresh host capture aggregate noalias and nofreeobj.
This covers the lowering path used by Flang and Clang's IRBuilder mode.
Replace callback Attributor seeding with frontend and translation tests,
including escaped captures, heap references, firstprivate pointers, debug
wrappers, serialized regions, and optimized load hoisting with OpenMPOpt
disabled. Refresh the affected parameter-attribute checks.
[ADT] Extract SmallDenseMapStorage from SmallDenseMap (NFC) (#226882)
This patch extracts the inline and heap bucket and occupancy storage
management from SmallDenseMap into a new helper class,
densemap::detail::SmallDenseMapStorage, and updates SmallDenseMap to
use it via composition.
This is part of the effort to replace CRTP in DenseMapBase with
composition (see #168255 and #226664). With both DenseMapStorage and
SmallDenseMapStorage in place, the next patch will remove CRTP from
DenseMapBase.
Assisted-by: Antigravity
AArch64: Mark the NZCV def dead for unused overflow results (#227018)
Avoid implicitly depending on later recomputed dead flags.
Co-authored-by: Claude Opus 5 <noreply at anthropic.com>
[HLSL] Preserve matrix layout as AST storage metadata (#225519)
fixes #213996
fixes #211977
fixes https://godbolt.org/z/rhTYx1KGf
Keep matrix layout metadata on noncanonical matrix types without
affecting type identity, overload resolution, deduction, or mangling.
Normalize matrix values to column-major register representation when
loading from memory, and convert them back to the destination layout
when storing. Preserve layout metadata through typedefs, arrays,
records, resources, serialization, AST import, and template
substitution.
This change also starts the reversal of encoding row\column major via
indexing changes in codegen and instead ops for a stable index but
transpose intrinsics for swapping matrix majorness.
[lldb][test] Don't add pdb to explicitly tagged debug info categories (#226999)
`LLDBTestCaseFactory` appends `"pdb"` to `dbginfo_categories` whenever
the class sets `TEST_WITH_PDB_DEBUG_INFO=True`. When a test method is
tagged with explicit debug info categories
(`@add_test_categories(["dwarf"])`), `dbginfo_categories` is the set
intersection of the method's categories and the known debug info
categories, not a list, so the class failed to load with
```
AttributeError: 'set' object has no attribute 'append'
```
and dotest reported the whole file as UNRESOLVED.
Only add "pdb" when the method is not tagged, which is also the only
case where the default categories are used.
rdar://188589961
CodeGen: Mark inline asm clobber defs dead
A clobber operand has no value associated with it, so the def is always
dead. Set the flag where the INLINEASM is built instead of relying on
later inference.
Co-authored-by: Claude Opus 5 <noreply at anthropic.com>
[llvm][Support] Use ::closesocket for native sockets on Windows (#226613)
Calling ::close on a Windows SOCKET that has not been converted with
_open_osfhandle crashes and aborts the process with 0xC0000409 instead
of returning an error.
Use ::closesocket on Windows for those sockets, and keep ::close on
POSIX.
AMDGPU: Remove update-only LiveVariables maintenance from SILowerControlFlow
This was only maintained, never relied on. Part of staged LiveVariables
removal.
Co-authored-by: Claude (Claude-Opus-4.8)
CodeGen: Remove LiveVariables use from TwoAddressInstructionPass
Now that LiveIntervals is computed unconditionally before TwoAddressInstructions
in the pipeline, the pass no longer needs LiveVariables.
Co-authored-by: Claude (Claude-Opus-4.8) <noreply at anthropic.com>
NVPTX: Drop LiveVariables from the register allocation pipeline
The optimized RegAlloc pipeline ran LiveVariables only to satisfy PHIElimination
and TwoAddressInstruction, both of which no longer need it. Remove the
LiveVariables run (and, in the new pass manager, the UnreachableMachineBlockElim
that was there only as a LiveVariables prerequisite).
Co-authored-by: Claude (Claude-Opus-4.8)
CodeGen: Drop the LiveVariables parameter from convertToThreeAddress
This was used for analysis updates, but now the analysis is being
removed.
Co-authored-by: Claude (Claude-Opus-4.8)
CodeGen: Compute LiveIntervals before TwoAddressInstructions
TwoAddressInstructions is the traditional primary use of LiveVariables,
but it has gained a LiveIntervals path. By moving LiveIntervals earlier,
the default flips to rely on it instead of LiveVariables. The overall
test churn is mostly neutral, with more net wins than losses.
This should move before phi elimination. This is a staging move to
incrementally remove the LiveVariables support from TwoAddressInstructions,
and because the move to running LiveIntervals on SSA is a bigger leap.
Co-authored-by: Claude (Claude-Opus-4.8)
releand "[clang-repl] Implement IncrementalHIPDeviceParser for HIP device compilation" (#226930)
This PR implements the IncrementalHIPDeviceParser. It takes each
incremental statement's device code and lowers it all the way to a
loadable HIP fat binary: linking the ROCm device libraries, running the
AMDGPU optimization/codegen pipeline, producing a .hsaco code object,
and embedding it as __hip_fatbin for the host runtime to register and
launch.
This PR only adds the parser class, wiring it into `Interpreter.cpp`;
the end-to-end tests will come in a follow-up.
Reland of #218337 (reverted in #226679 due to buildbot failures): the
original hit a build race where `DeviceOffload.cpp` could be compiled
before the tablegen-generated `AMDGPUTargetParserDef.inc` existed. Fixed
by adding `target_parser_gen `to `clang/lib/Interpreter/CMakeLists.txt`.
Assisted by Claude Opus 4.8