[AsmPrinter] Emit !pcsections auxiliary data after each PC (#243020)
PCSectionsMetadata.md specifies that the auxiliary constants follow each
emitted PC. emitPCSections instead grouped all instructions of a
function that share one MDNode, emitted their PCs, and then the
auxiliary data once, producing records like [pc1][pc2][aux] that a
reader cannot split. This happens whenever an instruction carrying
!pcsections with auxiliary data is duplicated within a function, e.g.
when the same callee is inlined twice.
Emit one complete record per instruction. No in-tree producer attaches
auxiliary data to instructions, so their output is unchanged.
Also use a MapVector for PCSectionsSymbols: iterating a DenseMap keyed
by pointer made the order of records depend on pointer values, and the
object file nondeterministic.
A node that requests the same section twice emits one record per
request; add a test for that.
Assisted-by: Antigravity
[mlir][vector][unroll] Remove redundant RUN and CHECK lines (nfc) (#243460)
* No RUN line with `check-prefix=UNROLL` was specified, hence removing
the corresponding "check" lines (e.g. `UNROLL-LABEL`).
* The RUN line with "unroll-order=0,3,1,2" and "--check-prefix=BATCHED"
only applied to one example (`@vector_contract_batched`). No unroll
_order_ was not verified for that test, hence specifying it was
redundant.
Part of #233408
[lld][COFF] Add per-target runtime directories to library search path (#227744)
Currently when -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=On, lld can't find
clang_rt or flang_rt. This patch fixes this issue by adding the
per-target runtime directories to the search path. This change only
affects -msvc triples; in the mingw case the compiler driver handles
calling the linker and adding the correct library paths itself.
[mlir][bytecode] Allow custom encodings for mutable types (#229910)
A mutable type can refer to itself, so the reader needs somewhere to put
the incomplete type while its body is still being read. Add
DialectBytecodeReader::tryStartCyclicRead, the bytecode analogue of
AsmParser::tryStartCyclicParse: the dialect publishes the incomplete
type before reading the body, and a nested reference back to the same
entry resolves to it instead of recursing. Entries that were only
answered with a partial are completed through the deferred worklist
afterwards.
The writer and numbering passes drop the IsMutable exclusion for types.
Mutable attributes still fall back, there is no attribute-side analogue
yet.
This is needed in order to implement bytecode support for `cir.record`
(not part of this PR). We've been using it downstream for CIR for a
couple months now (selfhosting clang with it, linking with our custom
CIR linker, etc)
[FunctionAttrs][NFC] Skip computing initializes if an exit is reachable without writes (#241973)
When the argument is written outside the entry block, `inferInitializes`
computes initialized ranges for every block, but the entry block's
result is empty if a path from it reaches an exit without a write, which
is common. Check for such a path first. Also checked by differential
fuzzing on random CFGs.
`opt -passes='default<O3>'` instructions on CTMark bitcode: sqlite3
-0.14%, SPASS -0.17%.
Co-authored-by: Matt Arsenault <Matthew.Arsenault at amd.com>
Assisted-by: Claude Opus 5.5
tests/sys/pmc/amd: add IBS, row allocation, PerfEvtSel and PerfMonV2 tests
- pmc_ibs_test: the IBS class.
- pmc_ibs_fetch_op_test: Fetch and Op together (572cd669d6) and IBS
interrupt accounting (c97cea955f).
- pmcstat_ibs_test: pmcstat records and replays IBS samples.
- pmc_rowalloc_test: core row allocation.
- pmc_start_msr_test: PerfEvtSel.En and PerfCntrGlobalCtl after pmc_start().
- pmu_perfmonv2_test: the PerfMonV2 global-control path.
- amd_pmc_test_common.h: also match the AMD-<n> row names of D60100.
Reviewed by: mhorne
Sponsored by: Advanced Micro Devices, Inc.
Signed-off-by: Osvaldo Janeri Filho <ojanerif at amd.com>
Signed-off-by: Davi C.A <davi.chavesazevedo at amd.com>
Differential Revision: https://reviews.freebsd.org/D61063
[Attributor] Drop writable when AAMemoryLocation manifests no argmem writes (#241968)
`AAMemoryLocation` ignores stack memory, so a function that only stores
its writable argument into an `alloca` can get `memory(none)` while
keeping `writable`, which fails the verifier. Like `FunctionAttrs`, drop
writable when the function doesn't write argument memory.
Co-authored-by: Matt Arsenault <Matthew.Arsenault at amd.com>
Assisted-by: Claude Opus 5.5
[mlir] Index remark queries by location (#243011)
Use exact-location indexes for `RemarkQuery::at(loc)` instead of
scanning every pending and emitted remark. Other filters apply within
the selected bucket; queries without a location retain the full scan.
History builds and extends its index only on location queries. Final
builds its pending index on the first location query of each batch.
Stable owned remarks preserve indexed addresses across replacement and
set growth. Existing custom policy visitors work through a filtering
fallback.
Validation: assertions and `-Werror` build; 230 IR and 12 remark unit
tests; C API and pass remark lit tests; clang-format on changed lines.
Tests cover growth, replacement, history resets, custom policies, and
concurrent location queries.
Local microbenchmark: 50k distinct locations, two reports per location,
500 repeated queries (median of three runs; harness and `Remarks.cpp` at
[13 lines not shown]
Merge alembic heads for API key name strip
Revision ac2610fcbe38 in the 27.0 branch is a second head next to da5e4232c6ca.
Revision 78cd0350b141 merges the two heads.
[RISCV][P-ext] Avoid folding byte multiply-parts into accumulate (#243005)
Currently `combineAddMulParts` folds multiply-parts intrinsics into
their accumulating forms without checking the input element width. For
byte inputs, this creates an unsupported accumulate intrinsic, causing
instruction selection failures or a type legalization assertion on RV64.
This commit fixes the problem by bailing out of the combine for
byte-width inputs, leaving the multiply and packed add operations
separate.
Closes #243004
[Offload][NFC] Move plugins under liboffload
Liboffload is the only library calling the plugins directly now, so move
the code inside it to reflect this change.
Also, adjust the CMake targets to also reflect this change by moving
from omptarget prefixes to LLVMOffload ones.
Assisted by Claude.
tests/sys/pmc: Pass pmcstat -n before -P in pmc_callchain_ur_test
pmcstat -n sets the sampling rate only for the sampling PMCs that follow
it on the command line. pmc_callchain_ur_test passed it after -P, so
UR_RATE was never applied and the PMC sampled at the default rate from
pmc_pmu_sample_rate_get(): 65536 on AMD, and 2000003 for
inst_retired.any on Intel, about 20 times fewer samples than intended.
Move -n ahead of -P in both pmcstat invocations.
Reported by: llm-postcr
Reviewed by: mhorne
Fixes: 546a76463123
Sponsored by: Advanced Micro Devices, Inc.
Signed-off-by: Osvaldo Janeri Filho <ojanerif at amd.com>
Differential Revision: https://reviews.freebsd.org/D61458
pmc: Exit with EX_OK when the pmc record time limit ends the capture
cmd_pmc_record() stores the return value of kevent() in status, which
is also its exit status. When the -t time limit elapses, the
EVFILT_TIMER branch jumps to done with status still holding kevent()'s
result, 1, so a timed recording exits with status 1, while one
interrupted with SIGINT exits with EX_OK.
Keep kevent()'s return value in its own variable and start status at
EX_OK. The kevent() failure and unknown signal cases called err() and
exited without stopping and releasing the PMCs; set status to EX_OSERR
and go through done instead, as the SIGIO case does.
pmc_cli_test and amd/pmc_frontend_test accepted status 1 to work around
this; make them require 0.
Reported by: llm-postcr
Reviewed by: mhorne
Fixes: a79a051e7d16 ("pmc: pmc record command")
[3 lines not shown]
tests/sys/pmc: Keep atf_fail reasons on a single line
Several tests put the output of pmc record, pmc info or pmcstat into the
atf_fail reason. That output spans several lines, and ATF reports a
multi-line reason as a broken test instead of a failed one, with the
captured output mangled into the error.
Copy the output to stderr, where kyua keeps it in the report, and use a
single-line reason.
Reviewed by: mhorne
Fixes: 546a76463123 ("tests/sys/pmc: add pidtrack, callchain, ...")
Sponsored by: Advanced Micro Devices, Inc.
Signed-off-by: Osvaldo Janeri Filho <ojanerif at amd.com>
Differential Revision: https://reviews.freebsd.org/D61459
Merge the 27.1 API key migration head into master
Revision 78cd0350b141 from the 27.1 branch is a second head next to b1c68df7d8a1.
Revision a63aa16e89f1 merges the two heads.
Merge alembic heads for API key name strip
Revision ac2610fcbe38 in the 27.0 branch is a second head next to da5e4232c6ca.
Revision 78cd0350b141 merges the two heads.