[clang-tidy] Compact the confusable identifier table (#202626)
Encode confusable replacement strings once in a shared UTF-8 byte array.
Each sorted mapping becomes an eight-byte code point, 16-bit offset, and
16-bit length entry instead of reserving nineteen UTF-32 code points for
every replacement.
ConfusableIdentifierCheck appends the UTF-8 slice directly after the
binary search, removing the per-identifier UTF-32 to UTF-8 conversion.
Add compile-time assertions for the eight-byte entry layout and the 64
KiB replacement-data limit, plus generator-side overflow checks.
The logical table shrinks from 508,400 to 63,327 bytes, saving 445,073
bytes. A stripped standalone clang-tidy shrinks from 91,116,608 to
90,654,176 bytes, saving 462,432 bytes (0.508%).
A lookup microbenchmark improves from 79.9 to 40.4 ns median. A
100,000-identifier clang-tidy benchmark improves from 0.343 to 0.314
seconds mean.
[3 lines not shown]
[mlir][tosa] Fix TosaNarrowTypes conversion order to prevent rollback crash (#207372)
Fix #206952 by doing `convertRegionTypes` before moving and unlinking
the blocks when handling `tosa.cond_if` ops. This will cause a crash
when doing rollback.
[clang][AST] Outline constant-interpreter shift diagnostics (#202633)
CheckShift is instantiated for each primitive left-hand and right-hand
type
and for both shift directions. Its four diagnostic paths are cold, but
each
instantiation currently emits the diagnostic construction and undefined
behavior handling.
Move those paths to the non-template, noinline diagnoseShiftFailure
function.
Valid shifts retain the existing checks and do not call the outlined
function.
Invalid shifts preserve the same diagnostic arguments and call
noteUndefinedBehavior exactly once.
On arm64 macOS with a Release build of standalone Clang, this changes:
linked binary: 222,173,192 -> 221,924,960 bytes (-248,232)
[5 lines not shown]
[SystemZ][z/OS] Show instruction encoding in HLASM output (#181904)
This change adds the support to show instruction encoding as a comment
when emitting HLASM text. With this, the last 2 LIT tests migrate to
HLASM syntax.
[clang] accept member specializations declared in class scope (#207256)
Explicit specializations are not restricted to namespace scope since
CWG727 was accepted as a DR.
Also fixes a crash upon error recovery in this case which was a recent
unreleased regression.
Fixes #206866
[scudo] Remove internal linkage from LargeBlock header helpers (NFC) (#207708)
`addHeaderTag` and `getHeader` are static function templates in
`secondary.h,` so any TU that includes the header without using them
trips `-Wunused-template`. Dropping static fixes the warning.
Part of #202945.
[CodeGen] Compact cost table entries (#202836)
ISD and CostType can both be shrunk to uint16_t, which reduces the
binary by 16KB.
Work towards #202616
AI tool disclosure: Co-authored with OpenAI Codex.
[MLIR][OpenMP] Prevent openmp-device attribute being added to the host (#207719)
This attribute is only intended for an OpenMP target device but a recent
patch started causing it to appear on the host. This causes the
OpenMPOpt pass to treat the LLVM IR module as an OpenMP offloading
target, potentially introducing invalid modifications.
Fixes #207423.
[compiler-rt][sanitizer_common] Fix -Wunused-template in test helpers… (#207706)
`Ident` is a static function template in a test header, so any test TU
that never calls it trips `-Wunused-template`. Drop static.
`check_locked` in `sanitizer_mutex_test.cpp` has no callers.
Part of #202945.
[ORC] Track __emutls_t definitions in IRMaterializationUnit (#207161)
When emulated TLS is enabled, `IRMaterializationUnit`'s constructor
emits an `__emutls_t.<var>` symbol for each non-zero-initialized
`thread_local` global and records it in `SymbolFlags`, but never adds it
to `SymbolToDefinition`.
If the same weak (`linkonce_odr`) definition is materialized by more
than one module — e.g. an `inline` function that odr-uses such a
`thread_local`, pulled into two `PartialTranslationUnit`s by clang-repl
— `JITDylib::defineImpl` discards the duplicate via
`IRMaterializationUnit::discard()`. `discard()` looks the symbol up in
`SymbolToDefinition` and, finding nothing, dereferences `end()`: an
assertion failure in `+Asserts` builds and heap corruption otherwise.
Register `__emutls_t.<var>` in `SymbolToDefinition` alongside its flags,
mirroring the `__emutls_v.<var>` handling just above.
### Test
[11 lines not shown]
Improving MinUI and MaxUI implementation in valuebounds (#207701)
Previously, the valuebounds implementation for MinUI and MaxUI was too
conservative.
We can already make correct assumptions even when we know only one
operand is provably not negative.
[flang][cuda] Only strip internal linkage for device globals (#207521)
Stripping all linkage was too much. Only strip internal linkage so the
symbol is visible to CUDA API.
[InstCombine] Propagate debuglocs when replacing insert->extract elts (#206026)
InstCombine may replace an extractelement->insertelement chain, where
the insert vector is wider than the extract vector, with a pair of
shufflevectors - one to widen the extract vector, and one to perform the
extract+insert simultaneously. Currently the second shufflevector
correctly adopts the insertelement's debug location, since it replaces
the chain of instructions that culminates with the insert. The first
shufflevector however takes its debug location from its insert position,
if the extract vector was a PHI or non-instruction, and otherwise
receives no location.
Since the first shufflevector is really adapting the extract vector for
use by one or more other instructions, we can consider it an extension
of the extractvector. If the extract vector is an instruction, its debug
location should be used (even if it is a PHI - this likely defaults to a
CompilerGenerated debug location); otherwise, the extract vector is a
constant, and so the shufflevector represents a constant materialization
- so should receive a CompilerGenerated location.
[AMDGPU] Do not copy the range attribute onto a widened kernarg load (#207655)
Sub-dword args (e.g. i8) are loaded as a full i32 and truncated. Copying
the i8 range onto the i32 load is invalid IR, and its bounds are wrong
since the upper bytes hold other args
Only copy the range when the load type matches the argument type
[Clang][ExprConstant] Normalize aux target builtin IDs before dispatch (#201805)
When compiling for a device target that has an auxiliary host target
(for example OpenMP or CUDA offload), builtins of the auxiliary target
are registered with IDs shifted past the primary target's builtins. The
constant evaluator passed the raw ID straight into the target-specific
evaluation switches in the Pointer/Int/Vector/Float expression
evaluators, so a shifted auxiliary ID could fall through to an unrelated
builtin's case (or miss its case entirely) and fail to fold.
Add a getConstantEvaluatedBuiltinID() helper that translates auxiliary
builtin IDs back to their canonical target IDs via
BuiltinInfo::getAuxBuiltinID(), and use it before dispatching in each of
those evaluators.
[LVI] Do not walk past cross-lane ops while determining value range (#207711)
While walking the one-use chain to find a constraining select
in `getValueAtUse`, do not look through cross-lane operations,
as they may move wrapping lanes into positions where the select
condition is true, and inferring nowrap flags would be unsound.
Fixes: https://github.com/llvm/llvm-project/issues/207619.
[MC] Move addEncodingComment() into new base class MCAsmBaseStreamer (#188585)
This is in preparation to use this functionality in the
SystemZHLASMAsmStreamer. No functional change.
[mlir][tosa] Add new block-scaled tensor type and support for MXFP CAST (#203583)
This commit adds a new compound-block scaled tensor type and uses this
type to implement support for MXFP in the CAST operation, as per the
following specification changes:
https://github.com/arm/tosa-specification/pull/50,https://github.com/arm/tosa-specification/pull/53.
The new block-scaled type is closely modelled after the `quant` dialect
type and supports the following parameters:
- block shape - The size and axis of each block. Support for specifying
constant scale values has not been added in this commit, but will be
added in a later one.
- scale type - The type of the scale value associated with each block.
- value type - The type of the data values in each block.
Example syntax for the new block-scaled type:
```
tensor<160x!tosa.block_scaled<BLOCK_SHAPE_32:f8E8M0FNU:f8E5M2>>
[11 lines not shown]
[X86] Add ISD::VECREDUCE_MUL lowering instead of matching in DAG (#207593)
Add X86 support for ISD::VECREDUCE_MUL and remove it from
combineArithReduction - most of the change is refactoring the custom
promotion of vXi8 -> vXi16.
Another part of #194621