[Instrumentor] Add runtime examples: [1/N] A flop counter
This adds a instrumentor-tools folder into compiler RT to showcase
use cases of the instrumentor. The initial example is a program that,
via instrumentation, counts the number of flops performed. Call and
intrinsic support will follow after #198042.
Partially developped by Claude (AI), tested and verified by me.
Revert "[LifetimeSafety] Fix liveness propagation for all origin flows (#205323)" (#205687)
Revert "[LifetimeSafety] Fix liveness propagation for all origin flows
(#205323)"
This reverts commit 8d2a578b2130742c8790f3dba5fb414962eafcd5.
Revert "[LifetimeSafety] Model GNU statement expressions (#204841)"
This reverts commit 361f3b24f2a8703eb7a32c1ae081f490888238f3.
[Instrumentor] Add subtype IDs to complement type IDs for vectors/arrays (#205466)
If the type of an argument passed to the instrumentation is a vector or
array, we still want to filter on the underlying type, and the
instrumentation might also need to know. Thus, we can now pass a subtype
ID, which is -1 except if it's a vector or array, then it's the element
type ID. Structs need to be handled differently.
[Sema] Fix ICE when passing vector types to `abs` (#205017)
fix for ICE in `Sema::CheckAbsoluteValueFunction`
We failed to reject non-scalar types.
Fixes: #204777
[lldb][Mach-O] Bounds-check GetArchitectureAtIndex against m_fat_archs (#205289)
`ObjectContainerUniversalMachO::GetArchitectureAtIndex` used
`m_header.nfat_arch` (read directly from the file and untrusted, up to
0xFFFFFFFF) as the bound before indexing `m_fat_archs`. When ParseHeader
exhausts the data partway through and breaks early, `m_fat_archs.size()`
can be smaller than `nfat_arch`, so the indexed load is out of bounds.
Bound the check on the actual vector size instead.
Found by lldb-target-fuzzer.
---------
Co-authored-by: Alex Langford <nirvashtzero at gmail.com>
[flang][cmake] Enable the runtimes in the CMake caches (#205642)
I've tried to introduce that in the PR #198863, but sadly, the buildbots
could not cope with this, so I decided to introduce it separately.
This patch also fixes the relevant places in the docs.
[APInt] Consistently use the terms pdep/pext instead of expandBits/compressBits (#205112)
After some bikeshedding in #200570 - we decided on the terms pdep/pext
[AssumptionCache] Fix removeAffectedValues() when value is repeated in AssumeInst (#205275)
If a value appears more than once in an AssumeInst (e.g., `ptr %arg1` in
`call void @llvm.assume(i1 true) [ "dereferenceable"(ptr %arg1, i64 1),
"align"(ptr %arg1, i64 8) ]`) it will appear multiple times in the
result of findAffectedValues(). removeAffectedValues() may (depending on
how the results in AffectedValues.find_as(AV.Assume) are ordered),
nullify multiple values from AffectedValues.find_as(AV.Assume) in one
iteration of an outer for loop. The next iteration of that outer for
loop might then find a match only to a different AssumeInst, resulting
in an assertion failure.
This patch fixes the issue by counting the number of matching
ResultElems we expect to find.
This was a latent bug that was revealed by
https://github.com/llvm/llvm-project/pull/204432; the latter is not
itself buggy, but relies on AssumptionCache::removeAffectedValues().
[2 lines not shown]
[OpenMP][Offload] Use argument pointer array in host kernels (#205355)
This is a follow-up to #194333, which changed liboffload's kernel launch
interface to take an array of pointers to arguments instead of a
contiguous argument buffer, but left the old path intact for OpenMP, to
be cleaned up iteratively in later changes.
This patch modifies the offload host kernels, and the OpenMP clang
codegen, to also use argument pointer arrays. The host was the only
plugin that did not support the new submission path. With it converted,
OpenMP can migrate to use the new path in all scenarios, after which
everything related to contiguous argument buffer and its construction
can be removed from plugin interface and the backends.
The change itself is fairly straightforward. The bulk of the diff is
automated test updates. In the runtime, the host kernel signature
becomes an array of pointers (void **), and the codegen is updated to
match. With each argument being a pointer, the kernel function now adds
one load to read the argument's value.
Assisted-by: Claude
[mlir][bazel]: only depend on needed LLVM translations in ExecutionEngine (#205619)
ExecutionEngine currently pulls in `AllToLLVMIRTranslations` which
includes heavy dependencies on GPU dialects (notably NVVMDialect.cpp
which takes a whopping 2 minutes to compile!), despite the
ExecutionEngine not doing anything GPU-specific.
This change reduces the dependencies to just the subset of LLVMIR
translations that ExecutionEngine actually uses: Builtin, LLVM dialect,
and OpenMP dialect.
clang: Replace getTargetID API with isProcessorName (#205653)
The "target ID" naming is an AMDGPUism. Replace the getTargetID query
with an isProcessorName predicate so the target reports whether the
string should be considered a match. This makes alias handling more
natural than checking for exact match, and avoids an unnecessary
parse of the target ID.
Co-authored-by: Claude (Opus 4.8) <noreply at anthropic.com>
[lldb] Remove unused MemorySize methods (NFC) (#205463)
These `MemorySize` methods are unused. There are two remaining which are
used: `FileSpec::MemorySize` and `ConstString::MemorySize`.
[LV] Round outer-loop VPlan VF down to a power of two (#205646)
computeVPlanOuterloopVF computes the VF as max(1, RegSize / WidestType).
WidestType may not be a power of two, which resulted in a non-power-of-2
VF. Round down like in the inner loop path.
[flang] Relax ignore_tkr(c) for assumed-type BIND(C) descriptor dummies (#205445)
Relax `F2023 15.5.2.5 p2` derived-type checks for assumed-type
ignore_tkr(c) dummies passed by descriptor to bind(C) procedures. This
will allow passing a derived type with a type-bound procedure or FINAL
or a parameterized derived type to a TYPE(*), dimension(..) bind(C)
dummy.
[SLP][NFC] Remove extra checks from analyzeRtStrideCandidate() (#205415)
These checks duplicate the functionality of the additional checks added
in #204013
[CIR] Wire const goto labels into indirect branch
A computed goto through a constant dispatch table -- the GNU idiom
`static const void *tbl[] = {&&L1, &&L2}; goto *tbl[i];` -- reached
errorNYI("Indirect goto without a goto block") in emitIndirectGotoStmt.
#203644 emits the label-address constant (a value-like
#cir.block_addr_info) into the table, but it takes a label's address in a
constant context without registering the label as address-taken, so no
indirect-goto block is created and the following goto *tbl[i] has nothing
to branch to.
VisitAddrLabelExpr in the constant emitter now records each label via
takeAddressOfConstantLabel, which instantiates the indirect-goto block
and tracks the label. finishIndirectBranch then adds those labels as
cir.indirect_br successors, alongside the existing op-form labels. A
label named more than once in a table (`{&&A, &&A, &&B}`) is kept as a
distinct successor each time, matching classic codegen's
`indirectbr ... [label %A, label %A, label %B]`.
[5 lines not shown]
[OpenACC] add acc::ReductionAccumulateArrayOp (#205617)
Add an OpenACC Dialect operation to accumulate elements of a (private)
array across threads. This operation only specifies the PointerLikeType
and an acc::DataBoundsOp to represent the accumulation of the array at a
high level. This will ultimately get lowered by "codegen".
[docs] Enforce unambiguous toctree in llvm/docs
It seems like using a non-`hidden` `toctree` for page navigation is a
bit of a trap, in that every doc must have a single unique path through
the global toctree to the root doc, and it is very easy to end up with
multiple.
This patch tries to address the warnings (actually infos, hence why it
does not fail the build) in llvm/docs/, namely:
$ sphinx-build -b html -jauto llvm/docs/ /tmp/sphinx-out
checking consistency...
llvm/docs/AMDGPUDwarfExtensionAllowLocationDescriptionOnTheDwarfExpressionStack/AMDGPUDwarfExtensionAllowLocationDescriptionOnTheDwarfExpressionStack.md: document is referenced in multiple toctrees: ['UserGuides', 'AMDGPUUsage'], selecting: UserGuides <- AMDGPUDwarfExtensionAllowLocationDescriptionOnTheDwarfExpressionStack/AMDGPUDwarfExtensionAllowLocationDescriptionOnTheDwarfExpressionStack
llvm/docs/AMDGPUDwarfExtensionsForHeterogeneousDebugging.rst: document is referenced in multiple toctrees: ['UserGuides', 'AMDGPUUsage'], selecting: UserGuides <- AMDGPUDwarfExtensionsForHeterogeneousDebugging
llvm/docs/CommandGuide/llvm-reduce.rst: document is referenced in multiple toctrees: ['CommandGuide/index', 'CommandGuide/index', 'Reference'], selecting: Reference <- CommandGuide/llvm-reduce
llvm/docs/GitHub.rst: document is referenced in multiple toctrees: ['GettingInvolved', 'UserGuides'], selecting: UserGuides <- GitHub
llvm/docs/GlobalISel/IRTranslator.rst: document is referenced in multiple toctrees: ['GlobalISel/index', 'GlobalISel/Pipeline'], selecting: GlobalISel/index <- GlobalISel/IRTranslator
llvm/docs/GlobalISel/InstructionSelect.rst: document is referenced in multiple toctrees: ['GlobalISel/index', 'GlobalISel/Pipeline'], selecting: GlobalISel/index <- GlobalISel/InstructionSelect
llvm/docs/GlobalISel/Legalizer.rst: document is referenced in multiple toctrees: ['GlobalISel/index', 'GlobalISel/Pipeline'], selecting: GlobalISel/index <- GlobalISel/Legalizer
[35 lines not shown]
[docs] Create utils/docs
llvm-project is home to many sphinx documentation sites, each with
configuration quirks and bespoke extensions.
The sphinx config model makes sharing code somewhat difficult. There
are options like sphinx-multiproject, but some of our docs builds are
out of the source tree while some are done out of the binary tree, so
the multiproject configuration itself would need to be generated. It
also would impose more uniformity around extensions than required.
This change instead creates a python package at utils/docs/llvm_sphinx
and makes it available to all sphinx-build processes via PYTHONPATH.
Each conf.py does not modify its own sys.path because not all builds are
out of the source tree, so there isn't a stable relative path to use to
refer to the utils/docs/ directory.
Type checking via pyright in new package is pinned to being python 3.8
compatible.
[29 lines not shown]