[MLIR][Python] Do not install ExecutionEngine wrapper when disabled (#211250)
The `_mlirExecutionEngine` extension is declared only when
`MLIR_ENABLE_EXECUTION_ENGINE` is enabled. However,
`execution_engine.py` and its type stub are currently added to the
Python package unconditionally.
This leaves an installed `mlir.execution_engine` module that fails
immediately when imported because its native extension is absent. It
also exposes a type stub for an unavailable API.
Making sure they're added only if `MLIR_ENABLE_EXECUTION_ENGINE` is
enabled.
[llvm-objdump] Factor the load command prologue into a shared function (#210881)
Move the repeated code to print cmd and cmdsize into a shared function.
[AMDGPU] Using feature to define vmem cacheline size (#207884)
Co-authored-by: shore <shorshen at amd.com>
Co-authored-by: Matt Arsenault <Matthew.Arsenault at amd.com>
[AllocToken] Fix typeContainsPointer for references, PMFs, blocks, ObjC pointers (#211349)
When evaluating whether an allocated type contains a pointer to generate
the alloc_token metadata, typeContainsPointer() previously only checked
for PointerType.
Expand typeContainsPointer() to check isAnyPointerType(),
isReferenceType(), isMemberFunctionPointerType(), and
isBlockPointerType().
[libc] Add err.h to Linux public header target lists (#210995)
Add libc.include.err to TARGET_PUBLIC_HEADERS for Linux targets
(aarch64, arm, riscv, x86_64) so that err.h gets generated and
installed.
Assisted-by: Automated tooling, human reviewed.
[CodeGen] Precompute pressure-set register classes (#210751)
Profiling sqlite on aarch64-O3 shows ~1.26% of compile-time is spent in
RegisterClassInfo::computePSetLimit. This is called from
ScheduleDAGMILive::initRegPressure via
RegClassInfo->getRegPressureSetLimit.
computePSetLimit scans every register class and its pressure-set list to
find the class with the largest RegClassWeight::WeightLimit. This is
cached, but must be recomputed on every cache invalidation.
AArch64 has 530 register classes and 190 pressure sets. Populating all
pressure-set limits visits 530 x 190 = 100,700 register classes. This
can be precomputed in TableGen, while retaining the MF-dependent
reserved-register adjustment in computePSetLimit.
CTMark results [1]:
- stage1-aarch64-O3: -1.85% geomean; Bullet -4.01%.
- stage1-O3 (x86): -0.04%; Bullet -0.13%.
[7 lines not shown]
Add missing opcode for offset validity check (#211186)
During offset validity check, the common API in HexagonInstrInfo does
not handle the opcode. Adding it fixes wherever offset calculation is
made for the instruction.
Co-authored-by: quic-santdas <quic_santdas at quicinc.com>
clang/AMDGPU: Fix handling of subarch only targets with no -mcpu
Extracted this out of the main clang triple conversion patches. This
should be applied to the release branch so you get consistent behavior
if you do build with subarch triples.
[lldb/script] Remove verbose comments following c4962f5721a3 (NFC) (#210827)
This removes verbose comments from c4962f5721a3 following a post-merge
comment.
Signed-off-by: Med Ismail Bennani <ismail at bennani.ma>
(cherry picked from commit e6cde20367a82aca112db73a3d1c76e77fe580f1)
[lldb/script] Only auto-open the generator template in an editor when interactive (#210808)
`scripting extension generate` always launched the external editor after
writing the template to disk, which is fine when a user types the
command at the prompt but is undesirable when the command runs from the
test suite, a headless driver, or a script -- each invocation spawns an
editor that nobody sees.
Extend `--open-editor` (`-e`) so that the default (`eLazyBoolCalculate`)
now dispatches on `CommandReturnObject::GetInteractive()`, which
`SBCommandInterpreter::HandleCommand` explicitly clears. That's the
accurate signal even when the process' stdin is a TTY inherited from the
parent (e.g. `lldb-dotest` invoked from a terminal). `--open-editor yes`
and `--open-editor no` still force the behavior explicitly.
Signed-off-by: Med Ismail Bennani <ismail at bennani.ma>
(cherry picked from commit 3d0f18b6210e8cbc9fa04bca91581e25371c5b14)
[lldb/script] Add scripting extension template generator (#209647)
This patch adds a `scripting extension generate <ExtensionType>...`
command that introspects a Python extension base class and emits a
skeleton subclass with `# TODO: Implement` stubs for its abstract
methods (or, with `-a`, every method), then opens the result in an
editor.
Generated imports use `from <module> import <class>`, and the generated
`__init__` forwards its arguments to `super().__init__(...)` since every
base class relies on its constructor to set up attributes
(`self.target`, `self.process`, ...) that inherited, non-overridden
methods depend on. When the host can't open an external editor (e.g.
non-macOS), the command reports that as a message rather than an error,
since the file is already written.
To catch regressions in the generator itself instead of just checking
that a file was produced, this patch adds
`TestScriptingExtensionGenerate.py`, which generates a template for
[6 lines not shown]
[lldb/script] Migrate frame recognizers onto ScriptedPythonInterface (#209805)
Give `frame recognizer add -l` a formal
ScriptedStackFrameRecognizerInterface, matching the architecture already
used by ScriptedProcess, ScriptedBreakpoint, etc.: a C++ interface
header, a Python-backed implementation built on
ScriptedPythonInterface's CreatePluginObject/Dispatch machinery,
PluginManager registration, and a generatable Python ABC template
(scripted_stackframe_recognizer.py).
get_recognized_arguments' documented contract returns a plain list of
lldb.SBValue (not an lldb.SBValueList), so it bypasses the generic
Dispatch<ValueObjectListSP>() extractor and calls the SWIG bridge
directly, matching the legacy behavior exactly.
ScriptedStackFrameRecognizer now holds a single interface object created
once in its constructor and reused across every RecognizeFrame() call,
same lifecycle as before.
[2 lines not shown]
[lldb/script] Add type hints to scripted extension base classes (#209680)
This patch adds type annotations to every method (parameters and return
types) and every `self.<name>` attribute of the scripted extension base
classes shipped under `lldb/examples/python/templates/`. Extension
authors reading the base classes -- or an IDE navigating them -- can now
see the `lldb.SB*` contract each method exposes without having to
cross-reference the docstring.
`scripting extension generate` also picks the annotations up: derived
class docstrings advertise each inherited attribute together with its
declared type, and the generated method signatures carry their parameter
and return annotations too.
The classes covered are `ScriptedProcess`, `ScriptedThread`,
`ScriptedFrame`, `PassthroughScriptedProcess`,
`PassthroughScriptedThread`, `ScriptedFrameProvider`,
`ScriptedBreakpointResolver`, `ScriptedThreadPlan`, `ScriptedHook`,
`ScriptedPlatform`, and `OperatingSystem`.
[3 lines not shown]
[lldb/script] Improve `scripting extension list` output and filtering (#209400)
This patch improves `scripting extension list` in three ways.
First, it groups the output by `ScriptedExtension`: instead of one row
per registered plugin instance, one entry per extension is printed with
a combined `Language` field.
Second, it colorizes and visually separates the output. Each entry is
preceded by a dimmed dashed separator; field labels are printed in bold
green, the extension name value in bold cyan as a mini-heading, and
`None` usage values are dimmed, all via the same
`ansi::FormatAnsiTerminalCodes(..., use_color)` idiom
`Breakpoint::GetDescription` uses elsewhere, gracefully no-op when color
is disabled or unsupported. `ScriptedInterfaceUsages::Dump` takes an
optional `use_color` parameter so its own `API Usages:` / `Command
Interpreter Usages:` labels can match.
Third, it adds `-j`/`--json` to emit a JSON array of `{name,
[16 lines not shown]
[libunwind][AIX] Handle VAPI-based return addresses in stack unwinding for LLU (#209280)
In AIX's implementation of LLU (Live Library Update), the caller of a
Virtual API (VAPI) interface instead calls VAPI glue and the
implementation for a VAPI function is entered from the VAPI glue. If a
VAPI is not already active on the thread, the VAPI calls the
implementation of the VAPI function with the link register (LR) value
set to a return address in the VAPI glue. In this case, the LR (return
address) value on entry to the VAPI glue is saved in the VAPI control
block. This PR checks whether the return address in a stack frame falls
within the VAPI address range. If it does, the unwinder retrieves the LR
value from the VAPI control block and uses it as the return address
during stack unwinding. In addition, before transferring control to a
landing pad, this PR executes the VAPI return glue to clear the VAPI
control block if the VAPI glue was used.
---------
Co-authored-by: Hubert Tong <hubert.reinterpretcast at gmail.com>
(cherry picked from commit 8aa808457c6aeba25ec0e17139c3fcab59923c3c)
[Matrix] Use incoming terminator as insert point in visitPHI. (#211211)
For some instructions, like invoke, getInsertionPointAfterDef may return
an std::nullopt. Using the insert point after the phi is then incorrect.
Use the incoming terminator as default insert point to fix a crash in
the added test cases.
PR: https://github.com/llvm/llvm-project/pull/211211
(cherry picked from commit 8c556564a2199e13f59dc43bfa5ef4345a89ae3b)
[flang][OpenMP] Add lowering for assume and assumes directives (#205615)
Adds lowering for the assume and assumes directives. holds clauses are lowered to llvm.assume, the other assumption clauses are ignored, and assumes is a no-op. Hints are skipped under -fopenmp-simd.
[Clang][coro] Fix `coro.free` in `.resume` clones with `[[clang::coro_await_elidable]]` (#207799)
Fixes https://github.com/llvm/llvm-project/issues/188230
CoroAnnotationElide rewrites annotated safe calls to the `.noalloc`
variant. The noalloc frame is caller-owned, but its `.resume` clone is
shared with ordinary heap-allocated instances.
With a `suspend_never` final suspend, normal resumption falls through to
the `coro.free` deallocation path. Regular frontend cleanup has already
run before this point. `coro.free` must therefore produce the frame
pointer for a heap instance and null for a `.noalloc` instance.
Use the frame destroy slot as a per-instance allocation tag. Cache its
value at resume entry, before user code can resume and release the
enclosing caller frame, then compare it with the cleanup clone. Replace
each `coro.free` result with the frame pointer for a heap instance and
null for an elided instance.
[5 lines not shown]
[PAC][libc++] Fix build with `ptrauth_calls` feature (#211033)
After partial revert of #208330 in #209928, the libcxx build started
failing because of missing `<cstdint>` include required for `uintptr_t`
declaration used only by code behind `ptrauth_calls` feature check. See
https://lab.llvm.org/buildbot/#/builders/227/builds/3358
This patch adds the missing include.
(cherry picked from commit 12e1c7f70f34d59c023d05d0fe2c228a4e9aac11)
[clang-format][clang-tools-extra] Fix leaking of host-level config into test environment (#206358)
These leaks were causing false test failures due to my global
.clang-format being in an ancestor directory of the build directory.
These changes prevent those issues when running the tests on my system.
I used MiMo v2.5 Pro agentically in Zed to find and fix the issue. But I
understand the changes and judge them to be safe and a clear improvement
over the status quo.
[lldb] Fix Unicode code point formatting to use proper notation (#211131)
- use uppercase hex digits
- only emit "U+" notation for valid code points (<= U+10FFFF),
zero-padded to a minimum of four digits.
rdar://173817553
Assisted-by: claude
(cherry picked from commit 0cd942fa1b6de94fd6d7fa7ba73f0233293115f8)
[RISCV][P-ext] Add packed sign and zero extend intrinsics (#208685)
Add SelectionDAG and intrinsic support for the RISC-V P packed sign- and
zero-extend operations.
Sign-extend is matched through `sext_inreg` (folded from the `shl`/`ashr`
idiom by the generic combiner) and selects to `psext.*`. Zero-extend reuses
the existing `PPAIRE` node with a zero operand instead of a new target node,
since `pzext.* rd, rs` is an alias of `ppaire.* rd, rs, x0`: implementing
`isVectorClearMaskLegal` lets the generic `DAGCombiner::XformToShuffleWithZero`
rewrite the `(and vXi16, 0xff)` / `(and vXi32, 0xffff)` idiom into a shuffle
with a zero operand, which `lowerVECTOR_SHUFFLEAsPPair` folds to `PPAIRE`.
Also adds the LLVM IR intrinsics `llvm.riscv.psext.b`/`.h` and
`llvm.riscv.pzext.b`/`.h`. For RV64 32-bit packed results, the lowering widens
to the legal 64-bit type and extracts the low subvector.
[DTLTO] Forward loop interchange to DTLTO remote compilations (#208591)
Recent upstream LLVM changes enabled `LoopInterchangePass` by default
through `PipelineTuningOptions`. TLTO observes that state directly from
the LTO config, but DTLTO was not forwarding the equivalent Clang option
to the remote compiler. As a result, TLTO could run loop interchange
pass while DTLTO did not, producing codegen differences for
configurations that exposed profitable/legally interchangeable loops.
Note that this was a pre-existing issue, the change in default has
simply exposed it.
Forward `C.PTO.LoopInterchange` as `-floop-interchange` when
constructing the common DTLTO remote compiler options. Extend the
testing to check that the SN-DBS remote command line includes the
forwarded option.
The code for forwarding such options is only intended as a temporary
measure. A more comprehensive solution is in discussion here:
https://discourse.llvm.org/t/synchronizing-lto-code-generation-configuration-between-clang-and-lld-dtlto
[2 lines not shown]
[DTLTO] Add remote compiler option forwarding coverage (#208589)
Add a cross-project DTLTO test that checks the existing LTO
configuration state serialized into the remote Clang command line. The
test uses the validate.py distributor to inspect the generated DTLTO
JSON.
Cover all the existing forwarded options.
Add paired negative checks for optional flags so the test also verifies
they are not emitted when the corresponding configuration state is not
set.
(cherry picked from commit c012610ab9924f465baea5e62397056ea9594567)