[BOLT] Fix shifted DWARF inline-scope ranges; track scope boundaries (#207291)
Summary:
BOLT updated DWARF lexical-scope ranges (DW_TAG_inlined_subroutine /
lexical_block low_pc/high_pc and DW_AT_ranges) via
translateInputToOutputRange(), which mapped a boundary using its input
offset relative to the start of the containing basic block:
OutAddr = BB.getOutputAddressRange().first + (InputOffset -
BB.getOffset())
This assumes intra-block byte offsets are preserved input->output. Any
pass that changes instruction sizes within a block ahead of a scope
boundary breaks that assumption. With --plt=all, each `call foo at PLT` (5
bytes, e8+rel32) is rewritten to `call *foo at GOT(%rip)` (6 bytes, ff
15+rel32); N such calls before a boundary shift its emitted low_pc/
high_pc N bytes too early, onto the preceding instruction. The range
stays within the parent so `llvm-dwarfdump --verify` does not catch it;
symbolizers then attribute samples on those instructions to the wrong
[44 lines not shown]
[lldb] Use std::atomic<bool> for Editline's pending-resize flag (#209619)
TerminalSizeChanged() used a volatile std::sig_atomic_t to record that a
resize is pending. That type was chosen because the SIGWINCH handler ran
in async-signal context and could only touch an sig_atomic_t. Signals
are now handled on a dedicated thread, so the flag is written from a
normal thread and std::atomic<bool> is sufficient to handle that.
el_resize() still runs on the thread that owns libedit, in its read
loop. I discovered that it is not safe to run elsewhere, because it
resets libedit's display model without redrawing. Applying it off that
thread seems to throw it off and makes it duplicate the prompt.
[lldb][test] Deflake the statusline scripted-command output test (#209643)
test_scripted_command_output_not_eaten failed intermittently in CI on
its assertIn(b"\x1b7", data) guard because the captured window held no
statusline escape at all, only the command output and the next prompt.
The cause is a thread-scheduling race, not a bug. The statusline is
redrawn on the event thread once per progress event, but on a loaded
machine the event thread need not run until the flood command has
already returned, so it drains the queued progress events after (lldb)
was matched and the capture stopped, leaving no redraw to inspect.
Widen the flood (the line count is now an argument) so the event thread
has a larger window to redraw in, and retry until at least one complete
cursor save/restore pair is observed before checking that no output was
spliced into it. If a redraw is never seen, skip rather than fail.
I deliberately avoided a per-line sleep as it would let each redraw
finish between prints and hide the very interleaving the test looks for.
Fixes #209605
[msan][NFCI] Add forceIntegerIntrinsic option to handleIntrinsicByApplyingToShadow() (#207053)
Currently, if handleIntrinsicByApplyingToShadow() is given an
IntrinsicInst with floating-point arguments, it will cast the shadows to
floating-point, apply the intrinsic, and then cast the result back to
integer/shadow. This is inefficient, and, depending on the intrinsic,
may also result in floating-point exceptions.
The user can explicitly supply an integer variant of the intrinsic to be
applied to the shadow (shadowIntrinsicID), but this does not work if the
integer and floating-point variants are overloaded forms of the same
intrinsic ID.
This patch adds an option, 'forceIntegerIntrinsic', which will pass the
shadows as integers to the intrinsic, thus avoiding unnecessary casts.
(This is not enabled by default since some intrinsics do not support
integer arguments.)
As an example, future work can use 'forceIntegerIntrinsic' to handle
[4 lines not shown]
[msan][NFCI] Add AVX512 DQ tests (#207059)
This adds tests for AVX512 DQ ("Doubleword and Quadword Instructions",
not to be mistaken with Dairy Queen), forked from
llvm/test/CodeGen/X86/avx512dq-intrinsics.ll.
[lldb] Distinguish DWARF binary type-check error messages (#209644)
CheckScalarOperandsHaveSameType reported every operand-check failure
with the same "requires operands to have the same type" message, even
though it rejects operands for three different reasons: mismatched type
kind, mismatched size, and mismatched signedness. That made a failed
check hard to diagnose from the error alone.
Parameterize the message so each check names what actually differs
(type, size, or signedness).
Follow-up to Augusto's review of #209641.
[analyzer] Disable lock order reversal check by default in PthreadLoc… (#202452)
…kChecker
Lock order reversal is a real source of deadlocks, but the current
single-path intraprocedural analysis is a single-path analysis, and it
cannot reason about potentially overlapping executions.This makes this
part of the checker too imprecise for default-on.
Add a WarnOnLockOrderReversal option (default: false) for the previous
behavior.
[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,
[14 lines not shown]
Thread Safety Analysis: Handle statement expressions in try-lock conditions (#209330)
Previously, statement expressions (`({ bool b = mu.TryLock(); b; })`)
used as try-lock conditions were not supported. Handle StmtExpr in
getTrylockCallExpr() by recursively analyzing the last statement of the
statement expression.
[lldb][bazel] Add ScriptedFrameProvider plugin to the Bazel overlay (#209634)
Adds the PluginScriptedFrameProvider cc_library for the new
SyntheticFrameProvider/ScriptedFrameProvider category and registers it
in DEFAULT_PLUGINS. Deps mirror the plugin's CMakeLists.txt (lldbCore,
lldbInterpreter, lldbTarget, lldbUtility, Support) plus the
:PluginScriptedProcess plugin dep it uses.
The ScriptedFrameProvider plugin was added upstream in PR #161870
("[lldb] Introduce ScriptedFrameProvider for real threads"), relanded as
PR #170236; this wires it into the Bazel overlay build.
bazel rule creation assisted with: claude
Can confirm this rule translates into a valid buck2 rule for Meta to
build internally, but no bazel build locally; will await CI testing.
[NVPTX] Promote internal function alignments in IR pass (#208040)
During lowering NVPTX will update the alignment of parameters and return
values if the function is internal and has only compatible direct calls.
Previously this happened within the alignment helper functions during
ISel and assembly printing making it opaque and unreliable. This change
moves that logic to an IR pass so that it can be inspected and disabled
more easily.
[lldb] Allow generic operands in DWARF binary type check (#209641)
fc298ccbc52a's CheckScalarOperandsHaveSameType also rejects legitimate
generic-typed operands, breaking breakpad STACK WIN / raSearch unwinding
on 32-bit targets. For `DW_OP_breg7 +0, DW_OP_consts +80, DW_OP_plus`,
DW_OP_breg yields a register-sized (8-byte) scalar while DW_OP_const*
yields an address-sized (4-byte) generic one. The strict size gate ran
before the genericness escape, and the escape only checked the left
operand, so the CFA expression was rejected and the unwind failed.
Reorder so two integers that are each at least as wide as the generic
type are accepted before the size/signedness gate. The commit's own
type-check unit tests still pass.
Also fix a latent crash the failure exposed: ReadFrameAddress and
GetReturnAddressHint only consumed the error inside an UNWIND_LOG
argument, which is skipped when the log is off, so the errored Expected
was destroyed unchecked and aborted. Consume it via LLDB_LOG_ERROR /
LLDB_LOG_ERRORV instead.
[mlir][sparse] Handle dense iterators in sparse iteration lowering (#208963)
Fixes #205980.
`lower-sparse-iteration-to-scf` always called `linkNewScope()` when
lowering
iterators handled by `scf.for`. Dense levels are random-access
iterators, and
`linkNewScope()` asserts for random-access iterators because those
should be
traversed by coordinate.
Use `locate()` for random-access iterators and keep `linkNewScope()` for
non-random-access iterators.
Verification:
- `cmake --build /tmp/mlir-208198 --target mlir-opt`
- `/tmp/mlir-208198/bin/mlir-opt -lower-sparse-iteration-to-scf
/tmp/issue-
[4 lines not shown]
[flang][OpenMP] Check the context of the declare_simd directive (#209318)
OpenMP 6.0, 9.8 "declare_simd Directive", restricts the placement of the
directive:
Any declare_simd directive must appear in the specification part of a
subroutine subprogram, function subprogram, or interface body to which
it applies.
Flang did not enforce this, and accepted the directive in the
specification part of a module, submodule, main program or block data.
Note: the restriction requiring the argument to name the procedure to
which the directive applies is not implemented here.
Fixes #205478
[orc-rt] Make noDispatch test helper fail in -Asserts builds. (#209493)
noDispatch guards Sessions that must never dispatch a wrapper call, but
it did so with assert(false), which compiles out under NDEBUG.
Replace the assert with ADD_FAILURE(), which records a failure in every
build mode, and then complete the call via its Return continuation with
an out-of-band error. Completing the call means a caller awaiting the
result unblocks and fails too, rather than hanging, even when the
dispatch arrives on a non-test thread where ADD_FAILURE() alone may not
be observed.
Make ios_base::xalloc non-atomic with LIBCXX_ENABLE_THREADS=OFF. (#208356)
762b77a moved the definition of "xindex" out of the header, and in the
process dropped the _LIBCPP_HAS_THREADS check. Re-add the check to
maintain the status quo.
The discussion on https://github.com/llvm/llvm-project/pull/198994
indicates it's not clear whether LIBCXX_ENABLE_THREADS=OFF is actually
supposed to mean single-threaded. But it clearly does in practice:
atomic_support.h uses non-atomic ops when threads are disabled, and a
few other APIs have explicit non-atomic fallback paths.
My team ran into this trying to run libc++ tests for a RISC-V core
without the "a" extension.
[libc++] Compute a confidence interval in compare-benchmarks (#208090)
When comparing benchmark results with more than one sample per
benchmark, compute a confidence interval and flag rows that are
statistically significant. This should make the A/B comparison PR job
more robust to noise and easier to rely on. After this change, output
for a multi-sample run looks like:
```
Benchmark Baseline Candidate Difference % Difference Significant? 95% C.I. of %diff
------------------------------ ---------- ----------- ------------ -------------- -------------- -------------------
std::any_of(list<int>)/32 39.92 39.22 -0.70 -1.75% [-6.5%, +1.6%]
std::any_of(list<int>)/32768 54071.34 65395.51 11324.17 20.94% [-2.8%, +34.5%]
std::any_of(list<int>)/50 67.39 69.08 1.69 2.51% x [+0.2%, +4.7%]
std::any_of(list<int>)/8 7.21 6.46 -0.75 -10.40% x [-25.0%, -0.7%]
std::any_of(list<int>)/8192 21745.58 22299.32 553.74 2.55% [-20.3%, +38.4%]
std::any_of(vector<int>)/32 24.21 14.61 -9.60 -39.65% x [-41.2%, -38.4%]
std::any_of(vector<int>)/32768 24365.14 12498.21 -11866.93 -48.70% x [-48.9%, -48.6%]
Geomean 324.15 247.83 -76.32 -23.54%
[16 lines not shown]
[SSAF] Add EntitySourceLocationsSummary and JSON format (#208841)
Adds a per-entity TU-level summary recording the canonical (file, line,
column) of each declaration registered against an entity. The data feeds
a follow-on whole-program analysis that groups entities sharing a
declaration source-location into equivalence classes.
Assisted-By: Claude Opus 4.7
[lldb-dap][test] Fix stackTrace test in symlink environment (#209595)
This test (edited in #209236) fails when run in an environment where
source files are symlinks. Using `realpath` breaks that, as we use the
path in assertions later. The var is already constructed as `source_file
= self.getSourcePath("main.c")` which should be sufficient for
`_RecurseSource()` to work.