[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)
[Clang][CFI] Skip unused diagnostic data in trap and minimal-runtime vtable checks (#241640)
`EmitVTableCheck` emitted the static diagnostic data and, without
cross-DSO CFI, an `"all-vtables"` type test before deciding how to
report
a failure. Trap mode and the minimal runtime use neither, so they were
left as dead globals and instructions. Local trap mode also called
`EmitTrapCheck` directly instead of `EmitCheck`, so
`-fsanitize-skip-hot-cutoff` and `-ubsan-guard-checks` did not apply to
vtable checks.
Skip the static diagnostic data in trap mode and local minimal-runtime
checks, emit the `"all-vtables"` test only for local full-runtime
checks, and route local trap and minimal-runtime checks through
`EmitCheck`.
Assisted-by: Gemini
tpm: crb: Dump register state on command failures
Include the command code in notification failures and the command code
and execution timeout in completion failures. Capture CRB control
registers on completion timeouts and Pluton mailbox readiness or
acknowledgement timeouts, before cancellation or cleanup changes them.
Include locality registers when present and mailbox registers for the
Pluton start method. The dump contains transport state without command
payloads or response data.
Tested by: olivier, tuexen
Sponsored by: BBOX.io
Differential Revision: https://reviews.freebsd.org/D61128
(cherry picked from commit 915eb355d8fe8555f7a74c6db95bc3c02610a939)
tpm: crb: Correct the Pluton mailbox handshake
Pluton's REPLY register indicates readiness for a new notification, not
completion of the notification just sent. Wait for REPLY=1 before
ringing the mailbox, then wait for START=0 when a synchronous state
change needs acknowledgement.
Use a separate command notification callback that waits for mailbox
readiness but leaves command completion to the existing CRB_CTRL_START
polling. Bound readiness waits by TPM_TIMEOUT_C, including asynchronous
idle notifications, while retaining the command's execution timeout.
This resolves reported command timeouts on a Framework AMD laptop.
Tested by: olivier, tuexen
Sponsored by: BBOX.io
Differential Revision: https://reviews.freebsd.org/D61128
(cherry picked from commit 4995fd4bf2c61e30363e588c5b90d7fc9145bf5e)
ixgbe: Restore EEE exclusion for X550EM_X KR
X550EM_X KR devices do not support EEE and have no setup_eee operation.
The shared-code update restored the capability removed by d61b6a41dd30,
and the E610 EEE support subsequently added an unchecked call during
attach. Together these changes allow a NULL function pointer call when
attaching a KR device.
Remove the incorrect EEE capability and use the NULL-safe ixgbe_setup_eee()
wrapper when enabling EEE at attach.
Removing the unsupported capability also stops exposing eee_state and the
eee.tx_lpi_count and eee.rx_lpi_count sysctls on X550EM_X_KR devices.
Fixes: f72de14ea132 ("ixgbe: update if_ix and ixgbe api with ix-3.3.38 changes")
Fixes: 13ee84c591f8 ("ix(4): Add EEE support for E610 adapters")
Sponsored by: BBOX.io
(cherry picked from commit 4678f9d8dc1324da6c021dc9d376a4671e72ad97)
ixgbe: Guard E610 Link Default Override access
Reading Link Default Override uses the E610 Admin Command Interface,
whose mutex is initialized only on E610. Calling it on other adapters
can hang attach, as observed on X520.
Skip the read on non-E610 devices, leaving the cached policy invalid so
that the existing link-state guard also skips force-link commands.
Reviewed by: kgalazka
Fixes: 7868958f5c79 ("ix(4): Support Total Port Shutdown on E610")
Sponsored by: BBOX.io
Differential Revision: https://reviews.freebsd.org/D61144
(cherry picked from commit 2c6b01416f80462b393bbe70a38cea017325dea8)
ix(4): Support Total Port Shutdown on E610
Firmware controls the physical link state on E610 adapters, similarly to
X700 and E800 adapters. As a result, running "ifconfig down" does not
disable the physical link unless Total Port Shutdown is enabled.
Read the Link Default Override TLV from NVM to detect when Total
Port Shutdown was enabled for given port in system setup. In that
case, force the link down when the interface is stopped and restore
it during link configuration. Leave link state management unchanged
when the TLV is unavailable or the feature is not enabled.
Co-authored-by: Miłosz Linkiewicz <milosz.linkiewicz at intel.com>
Co-authored-by: Tomasz Lichwala <tomasz.lichwala at intel.com>
Signed-off-by: Krzysztof Galazka <krzysztof.galazka at intel.com>
Tested by: Mateusz Moga <mateusz.moga at intel.com>
Sponsored by: Intel Corporation
Differential Revision: https://reviews.freebsd.org/D60643
[2 lines not shown]
ixl(4): Enable building driver on ARM64
For consistency with other drivers enable building ixl
on ARM64 target.
Please be advised that it is only compile tested.
Intel will continue to test Ethernet drivers only on x86-64
platforms, and is not going to provide support for issues,
which cannot be reproduced in such environment.
Signed-off-by: Krzysztof Galazka <krzysztof.galazka at intel.com>
Suggested by: Dave Cottlehuber <dch at FreeBSD.org>
Reviewed by: manu
Approved by: kbowling (mentor)
Sponsored by: Intel Corporation
Differential Revision: https://reviews.freebsd.org/D54289
(cherry picked from commit a3d472219c5aa3c211371aebd2effbfade61cb5c)
Eliminate the (multiple) conditional branches based on fputype in the
m68k context switch path. Instead, the FPU save and restore blocks
begin with a BRA.W insn that branches around the FPU code, essentially
refleching FPU_NONE. Once the FPU is probed, these BRA.W insns are
patched with the displacement for the correct code fragment for the
detected FPU.
iavf: Honor negotiated VLAN offload capabilities
The driver advertised VLAN offload unconditionally, even when the PF
did not grant it, as observed with an E835 VF under Hyper-V. This
tells the stack to rely on hardware tag insertion and sends the PF
unsupported VLAN filter requests.
Advertise hardware VLAN tagging and filtering only when GET_VF_RESOURCES
grants the legacy VLAN capability. Do not allocate filter shadow entries
or send ADD_VLAN/DEL_VLAN requests without that capability. Retain VLAN
MTU and checksum/TSO support for software-tagged packets.
Keep advertised capabilities stable across resets, since existing VLAN
interfaces may already rely on them. If resource rediscovery removes
previously advertised VLAN offload, leave the VF stopped and require
reattachment rather than resume with a stale offload contract. A newly
granted capability is not exposed until reattach.
Sponsored by: BBOX.io
[2 lines not shown]