[SampleProfile] Support Eytzinger layout in SecNameTable (#211027)
This patch supports writing SecNameTable in Eytzinger layout for
ExtBinary MD5 sample profiles via a hidden command-line option,
-sample-profile-write-eytzinger-name-tables.
Specifically, this patch partitions function GUIDs in SecNameTable into
three mutually exclusive sets:
- CSKeys: Those GUIDs used as keys in context-sensitive SecLBRProfile.
- FlatKeys: Those GUIDs used as keys in flat SecLBRProfile.
- Inlinees: Those GUIDs mentioned in SecLBRProfile but not as keys.
Each set is constructed as an independent Eytzinger array using
llvm::EytzingerTable. The section starts out with the three element
counts followed by the three successive spans.
A subsequent patch will add FuncOffsetTable as arrays parallel to
CSKeys and FlatKeys. It will introduce binary search into the
[5 lines not shown]
[LoopVersioningLICM] Do not let llvm.pseudoprobe block loop versioning (#209684)
`LoopVersioningLICM::instructionSafeForVersioning()` rejects any call
that is
not proven to not access memory. `llvm.pseudoprobe` is declared
`IntrInaccessibleMemOnly` (so the optimizer will not delete or sink it),
so
`AA->doesNotAccessMemory()` returns false and the probe is treated as an
unsafe
call site. This disables loop-versioning LICM for essentially every hot
loop
in a sample-based / CSSPGO profile-guided build (in the presence of
`-fpseudo-probe-for-profiling`), since a pseudo probe is inserted on
every basic block.
Pseudo probes are pure profiling placeholders with no observable effect
on the
loop's memory accesses, so skip them in the call-safety check.
RFC:
https://discourse.llvm.org/t/csspgo-unblocking-pseudo-probe-safe-optimizations/90946
[clang-tidy][docs] Rename static analyzer check docs to Markdown
Tracking issue: #201242
See the [migration guide] for more information.
[migration guide]: https://llvm.org/docs/SphinxQuickstartTemplate.html#markdown-migration-guidelines
This is the initial straight rename commit. It will probably break the docs build, but it has to be a separate PR for blame preservation purposes.
[LoopInfo] Derive Loop::contains(BlockT*) from the block-to-loop map (#207613)
Each Loop stored its blocks twice: the Blocks vector and a DenseBlockSet
used only for O(1) contains(BlockT *). Block lists are inclusive, so building
LoopInfo inserted every block into that set once per enclosing loop --
an O(blocks * depth) cost.
Drop DenseBlockSet and answer contains(BlockT *) from the innermost loop
in LoopInfoBase's block-number-indexed map. This removes the per-build
set maintenance and shrinks sizeof(Loop) from 160 to 72 bytes. Each Loop
keeps a back-pointer to its LoopInfo for the lookup; contains() stays
total for a block from another function (e.g. a global's use).
Note: A pass restructuring the loop nest must not rely on
`contains(BlockT *)` while the block lists and the map are transiently
out of sync, and should scan getBlocks() instead (as FixIrreducible and
LoopSimplifyCFG do). LoopInfoBase::verify() checks the block lists
rather than contains() for the same reason.
Aided by Claude Opus 4.8
[Offload][OpenMP] Skip RPC callback registration when plugin has no devices (#211447)
`__tgt_register_rpc_callback` unconditionally called
`Plugin::getRPCServer()` which asserts if the RPC server pointer is
null. When a plugin is initialized but its RPC server has not been
created (e.g., `NumDevices == 0` in `GenericPluginTy::init()`), this
triggers a crash.
Rather than introducing a nullable accessor, guard the call by also
checking that the plugin has at least one device. A zero-device plugin
has no RPC server to register callbacks with, so the extra check is both
correct and sufficient.
Suggested by @jhuber6 in the review of the previous attempt (#210215).
[docs][clang-format] Migrate generated clang-format docs to markdown
The challenge here is that the documentation is generated from Doxygen
comments in headers, `Format.h` and `IncludeStyle.h`.
First, the generator was updated to generate markdown constructs, and
then the Doxygen comments were also modified to use markdown constructs.
Mostly this means using single backticks instead of double backticks,
which is the Doxygen-native way of expressing code font blocks anyway,
so that's good.
To validate, I built the Sphinx docs and the doxygen, and I confirmed
that the generator script is idempotent, meaning it doesn't change the
markdown output. When I add a new option to clang-format, it shows up in
the help text block, so it works.
Before/after validation links:
| Source file | Before HTML | After HTML |
| --- | --- | --- |
[4 lines not shown]
[CodeGen] Mark LIFETIME_START and LIFETIME_END as not safe to move (#211179)
PR #210028 added a run of EarlyMachineLICM before StackColoring removed
LIFETIME_START/LIFETIME_END markers, and it ended up hoisting them which
led to miscompiles. This marks them as not safe to move in
`MachineInstr::isSafeToMove`.
---------
Co-authored-by: Matt Arsenault <arsenm2 at gmail.com>
[X86] Reuse already-materialized values when forming LEAs (#210739)
For code like
``` cpp
int f(int &a, const int &b) {
a += b + 17;
return a + b;
}
```
the x86 backend emitted three LEAs, rematerializing `a+b` instead of
reusing the value it had just computed and stored:
``` asm
leal (%rdi,%rsi), %eax # a+b (recomputed)
leal 17(%rdi,%rsi), %ecx # a+b+17 (stored)
movl %ecx, (%rdx)
leal 17(%rsi,%rax), %eax # (a+b)+b+17
[68 lines not shown]
[docs][clang-format] Migrate generated clang-format docs to markdown
The challenge here is that the documentation is generated from Doxygen
comments in headers, `Format.h` and `IncludeStyle.h`.
First, the generator was updated to generate markdown constructs, and
then the Doxygen comments were also modified to use markdown constructs.
Mostly this means using single backticks instead of double backticks,
which is the Doxygen-native way of expressing code font blocks anyway,
so that's good.
To validate, I built the Sphinx docs and the doxygen, and I confirmed
that the generator script is idempotent, meaning it doesn't change the
markdown output. When I add a new option to clang-format, it shows up in
the help text block, so it works.
Before/after validation links:
| Source file | Before HTML | After HTML |
| --- | --- | --- |
[4 lines not shown]
[docs][clang-format] Rename docs to Markdown
Rename ClangFormat and ClangFormatStyleOptions from reStructuredText to Markdown.
Update the clang-format documentation generator scripts and CMake custom targets to point at the renamed .md files so the generated documentation paths remain valid. Keep this changeset limited to rename/path updates; Markdown content cleanup is in the follow-up rewrite changeset.
[clang-tidy][docs] Rename static analyzer check docs to Markdown
Tracking issue: #201242
See the [migration guide] for more information.
[migration guide]: https://llvm.org/docs/SphinxQuickstartTemplate.html#markdown-migration-guidelines
This is the initial straight rename commit. It will probably break the docs build, but it has to be a separate PR for blame preservation purposes.
[CI] Add precommit CIs to test compiler-rt + LLVM libc integration. (#200196)
Add Pre-commit CI to test compiler-rt builtins with libc to check it
works without issues
Split from #197950
Part of #197824
---------
Co-authored-by: Michael Jones <michaelrj at google.com>
[Offload] Add numLanes device info to liboffload (#211380)
This adds `OL_DEVICE_INFO_NUM_LANES` to the Offload API device-info enum
and wires it through `olGetDeviceInfo`.
[mlir-c] Add 1:N TypeConverter conversion and materialization bindings (#208935)
Builds on the source/target materialization C bindings (#208934) to
expose the 1:N dialect-conversion functionality through the MLIR C API.
Continues the buildout of the dialect-conversion C bindings (follows
#206146 and #206161).
Assisted by: Claude
[clang-tidy] Ignore standard tag dispatch types in readability-named-parameter (#208730)
Parameters whose type is a standard tag type (e.g. std::in_place_t,
std::nothrow_t,
iterator tags, lock tags) are used purely for overload resolution and
don't need
a name. This patch skips them.
Added an IgnoredTypes option so users can customize the list. Default
covers 24
standard tag types.
Fixes #208448.
AI Usage: This commit is AI-assisted, reviewed and verified by me.
[SSAF] Fix a stage2 test failure with ASan-instrumented clang
ASan emits a symbol for a static global in
`Analysis/Scalable/source-edit-generation/Plugins/TestTransformationPlugin/TestTransformation.cpp`
that causes link issues in green dragon.
Added `__attribute__((no_sanitize("address")))` to that static global to fix
the test.
rdar://182623740
[clang-tidy] Generate Markdown documentation for new checks (#210574)
Update `add_new_check.py` to generate MyST Markdown documentation for
new checks.
Part of https://github.com/llvm/llvm-project/issues/201242
[Matrix] Add/remove transposes to row vectors to see them as column vectors
In column-major, add or remove transposes to row vectors in order to see
them as column vector during the rest of the lowering.
[Matrix] Split TileSize into per-dimension fields; add remainder loop infrastructure
Split the single TileSize field in TileInfo into TileNumRows,
TileNumInner, and TileNumColumns to enable non-square tiles.
Add CreateTiledLoopsWithRemainder() which generates a full loop
nest covering remainder rows and columns that don't evenly divide
the tile size.
Expose asIndex()/indexType() helpers from MatrixUtils.cpp for use
by callers building the tiled loop bodies.
In LowerMatrixIntrinsics, replace the old TileSize/TileLoopsThreshold
cl::opts with per-dimension TileSizeRows/Inner/Columns and add
TileUseLoops (default false) as the explicit opt-in for loop-based
tiling. Add isTilingLoopProfitable() to gate when loops are
worthwhile vs. inlining the tile computation.
[llvm-profgen] Fix isLBRSample check for 1-deep brstack (#211182)
`isLBRSample` in `checkPerfScriptType` currently don't differentiate the
LBR records in hybrid sample (LBR+Stack) or an LBR sample. It checks
"0x" and "/" for the second pair as a unified way to tell whether the
record is an LBR pair. However, this requires a minimal of 2 pairs of
hybrid LBR samples, otherwise, even a valid LBR record will fail the
`isLBRSample` check. This fix adds an initial check for "0x" and "/" for
the first LBR record so we can handle the case where only 1 pair of LBR
record exists in the hybrid sample.