[clang][PAC] Fix crashes on _Atomic __ptrauth-qualified objects (#240294)
Implicit `_Atomic` operations on a `__ptrauth`-qualified object assert
in CodeGen, because the pointer-authentication helpers do not look
through `AtomicType`: https://godbolt.org/z/6KE7Ez5P4 (a trunk build, so
the link stops crashing once this lands).
Fix the crashes. In a build without assertions the same code miscompiled
an `_Atomic` function pointer under `-fptrauth-calls`, signing it twice
or leaving it unsigned. Nothing else changes: the tests simply document
current behavior, with a FIXME on what I propose fixing in follow-ups,
for example https://godbolt.org/z/hGosq14ea.
Assisted-by: AI
usbhid: Retry fetching the report descriptor
So far only seen with a wireless mouse on a Logitech Unifying
receiver. The receiver can time out on GET_DESCRIPTOR(REPORT) while
still starting up after power is applied, for example after resume
or when switched back through a USB switch. On failure, hms falls
back to the boot protocol descriptor and the mouse loses its wheel.
Wired mice have not shown the problem.
Retry the request up to five times with a 100 ms pause, stopping
early on a stall since that means the device has no descriptor.
Linux usbhid retries this request in the same way.
usbhid: Retry fetching the report descriptor
So far only seen with a wireless mouse on a Logitech Unifying
receiver. The receiver can time out on GET_DESCRIPTOR(REPORT) while
still starting up after power is applied, for example after resume
or when switched back through a USB switch. On failure, hms falls
back to the boot protocol descriptor and the mouse loses its wheel.
Wired mice have not shown the problem.
Retry the request up to five times with a 100 ms pause, stopping
early on a stall since that means the device has no descriptor.
Linux usbhid retries this request in the same way.
[DSE][AMDGPU] Remove dead LDS writes at wave exit
LDS is freed once every wave of a work-group has terminated, and a
wave terminates when its entry function returns. Other waves can only
observe its LDS writes through a synchronizing operation. DSE still
kept every such write, because it treats LDS like any other global.
Add a TTI hook that reports address spaces whose writes cannot be
observed once a function returns, and let DSE treat globals in them
like allocas at function exit. AMDGPU reports LDS in entry functions.
Loads, barriers, fences, atomics and calls still keep earlier writes.
Change-Id: I3147eae461cf85e9e1f15d5626266c496fb4c430
Co-Authored-By: Claude Fable 5.2 <noreply at anthropic.com>
[DSE][AMDGPU] Add LDS store-at-exit tests (NFC)
DSE keeps LDS writes that nothing reads or synchronizes before an
entry function returns. Record the current behavior before changing
it.
Change-Id: If7c568ce3aec9e7fe847fccd6698ac71733b2364
Co-Authored-By: Claude Fable 5.2 <noreply at anthropic.com>
CodeGen: Share atomic libcall selection between the legalizers (#239083)
SelectionDAG and GlobalISel each had their own copies of the choice
between an outline atomic and a __sync_* call. Move it into a common
helper.
The __sync_* call is now always looked up in the DAG's libcall info,
rather than sometimes in the TargetLowering defaults. Also disable
the untested __sync call case in GlobalISel.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[Clang][CFI] Don't report sanitizer stats for unchecked VFE loads (#241641)
With virtual function elimination (3b598b9c867a),
`EmitVTableTypeCheckedLoad` is also used for calls that have no
`cfi-vcall` check, such as calls in `no_sanitize("cfi-vcall")` functions
or on ignorelisted classes. It reported `-fsanitize-stats` for these
calls anyway, so the stats counted checks that were never performed.
Report stats only when the check is emitted.
Assisted-by: Gemini
[mlir][vector] Handle rank zero case in resolveAllTrueCreateMaskOp (#240128)
- handle rank-0 case in `resolveAllTrueCreateMaskOp` that crashed
assuming operand count equals rank, which isn't true in the case of
rank-0.
- now `resolveAllTrueCreateMaskOp` handles rank-0 case the same way
`CreateMaskFolder` does, by using a shape of {1} with scalable flags
{false}, reused the existing pattern for consistency.
- fix `ConstantMaskOp::build` bug @FedericoBruzzone pointed out. now the
builder passes {1} for `AllTrue`, {0} for `AllFalse` when the rank is 0
and produces valid IR.
- add repro and constant rank 0 case as regression test .
fixes #240008 crash
Co-authored-by: Andrzej Warzyński <andrzej.warzynski at gmail.com>
[lldb] Suggest 'bugreport' after errors that may be LLDB bugs (#241615)
Errors that were likely caused by an LLDB bug ended in ad-hoc variations
of "please file a bug and attach the file at the start of this error
message". Report them with the new Debugger::ReportInternalError
instead, which follows the error with one shared note:
```
note: if you believe this is a bug, use the 'bugreport' command
```
Each debugger shows the note once per distinct failure, deduplicated
with the same ThreadSafeDenseSet that Module uses for its own
diagnostics. The new diagnostics.suggest-bugreport setting turns the
note off. Because the note is part of the event message, the setting
also suppresses it for SB clients such as lldb-dap.
Assisted-by: Claude
[RISCV][GlobalISel] Preserve KCFI type on indirect calls (#240364)
The commit propagates `CallLoweringInfo::CFIType` to the call
instruction in GlobalISel so the KCFI pass can emit indirect-call
checks, matching SelectionDAG lowering.
AI Usage: Assisted by Amp (Opus 5.5)
Reproducer: https://godbolt.org/z/M14bnYqKn
---------
Co-authored-by: Amp <amp at ampcode.com>
[AMDGPU] Precommit test before making gfx1250 packed FP32 shuffles free (#241409)
Precommit test before https://github.com/llvm/llvm-project/pull/240999
is reviewed.
---------
Co-authored-by: Tim Gymnich <tim at gymni.ch>
[IR] Make optnone imply noinline (#228169)
Previously the verifier required every `optnone` function to also carry
`noinline`. Instead, make `optnone` imply `noinline` so the pairing is
no
longer necessary.
To avoid each user having to remember to check both attributes, add
`Function::isNoInline()` (true for `noinline` or `optnone`) and make
`CallBase::isNoInline()` defer to it for the callee. Existing direct
queries of `Attribute::NoInline` on functions are migrated to the
helper.
The verifier now explicitly rejects `alwaysinline` + `optnone`, which
was
previously only enforced transitively via the `noinline` requirement.
ForceFunctionAttrs and llvm-reduce no longer need to keep the two
attributes paired.
Assisted-By: Claude
[IR] Skip removeDeadConstantUsers use-list walks to save ~0.25% wall time (#240626)
GlobalOpt's `deleteIfDead` calls `removeDeadConstantUsers()` on every
global before checking whether it is dead. For a function, that walks
the whole use list, which is mostly call sites, and loads each user only
to find that it is an instruction. Those loads usually miss in cache. In
AMD IBS profiles of `opt -O2` on four large LLVM TUs (X86ISelLowering,
AArch64ISelLowering, DAGCombiner, ScalarEvolution),
`removeDeadConstantUsers` accounts for 10-19% of the loads served from
L3 or DRAM, but only about 0.5% of cycles.
Only constants that are not globals can be dead users, and with opaque
pointers most functions have none. This patch adds a `GlobalValue` bit,
`MayHaveConstantUsers`. The bit is set when such a constant takes the
global as an operand: in `ConstantUniqueMap::create` and
`replaceOperandsInPlace`, and for `DSOLocalEquivalent` and `NoCFIValue`.
`removeDeadConstantUsers` returns immediately when the bit is clear. It
clears the bit after a walk that leaves no live non-global constant
users. Only those constant-creation paths set the bit, and they are
[18 lines not shown]
[MemoryBuiltins] Check alloc/free type first to save ~0.1% instrs (#240677)
Profiling showed that `isAlloc*Fn` and `getFreedOperand` execute many
instructions to detect malloc-like and free-like instructions.
Rejecting calls with the wrong return type before querying attributes
and TargetLibraryInfo in these allocator classification routines reduces
opt's user instruction count by about 0.5% on a call-heavy InstCombine
microbenchmark, with no change in output.
Allocation functions return a pointer to the new block of memory, and
deallocation functions return void: LangRef requires this of
`allockind("free")` functions, and `isLibFreeFunction` already requires
it of library free functions. InstCombine calls `getFreedOperand` and
`isRemovableAlloc` on every call it visits, so the `nobuiltin`,
`allockind`, and TLI queries that these checks skip add up.
Compile-time tracker:
https://llvm-compile-time-tracker.com/compare.php?from=6e58f6f5536016c55365ac55be11e6ac783d64cf&to=bbbd87d2271c7f02d7bca8f881220647da532d99&stat=instructions:u
[6 lines not shown]
[InstSimplify] Check call args are constant first to save ~0.04% instrs (#240676)
`tryConstantFoldCall` runs two checks before continuing to fold:
1. It calls `canConstantFoldCallTo`, which checks if the call is marked
nobuiltin and that it is a known library call (cached)
2. It scans the arguments and bails out if any of them are non-Constant
It turns out that querying attributes and TLI is more expensive than
scanning for Constant arguments, so do that first. This patch swaps the
order so the common case exits early.
Compile-time tracker:
https://llvm-compile-time-tracker.com/compare.php?from=6e58f6f5536016c55365ac55be11e6ac783d64cf&to=ebc6a8a748f0d3338efc8c2633f057418ebca43a&stat=instructions:u
This is worth ~0.15% on my workload, but only ~0.04% on the CTT Clang
build. Again, I think this might show that my workload is intrinsic-call
heavy, but I haven't confirmed that yet.
LLM-aided
tpm: crb: Support the ACPI start method
Some AMD firmware TPMs report StartMethod 2 and had no driver. They never
acknowledge CTRL_REQ, so skip the idle and ready requests.
Do not harvest entropy from these TPMs on AMD: on a Ryzen 7 7735HS each
periodic TPM2_GetRandom froze every CPU, for up to 1.2 s (AMD PA-410).
Reviewed by: kbowling
Approved by: kbowling
Differential Revision: https://ron-dev.freebsd.org/FreeBSD/src/pulls/103
(cherry picked from commit 6af18560a124b84549713a5f2b667a1df0990929)
tpm_crb: Use locality registers only with plain CRB
The locality release wait times out on every command on a Framework 13
(Pluton start method), logging every 10 seconds.
Reported by: emaste, tuexen
Reviewed by: kbowling
Approved by: kbowling
Fixes: bfe4be85a935 ("tpm_crb: wait for idle and locality release after each command")
(cherry picked from commit 1dade7024457ee10df1ccae22e3c454e80f82b76)
tpm_crb: wait for idle and locality release after each command
transmit only requested GO_IDLE and the locality release, so a back-to-back
command could see stale state and fail with EIO.
A post-send idle timeout no longer discards a completed response.
Reviewed by: kbowling
Approved by: kbowling
Differential Revision: https://ron-dev.freebsd.org/FreeBSD/src/pulls/93
(cherry picked from commit bfe4be85a9354b92135e105028f2e1b3e0307ada)