[X86] Combine mask_beforefirst to (x - 1) & ~x in GPR
EVEX and libc use this pattern in strcpy etc. to set the bits before the lowest set bit. It works correctly for x=0 too, returning an all ones mask.
Because SSE/AVX/AVX2 promote vNi1 types, do this as a DAG combine before type legalization.
We need to restrict it to power of 2 types otherwise we hit a latent crash in combineToExtendBoolVectorInReg.
[VPlan] Use llvm.mask.beforefirst for computing early exit mask
This makes the cost more accurate and improves codegen for RISC-V. The codegen for an early exit loop with side effects then goes from:
.LBB0_3: # %vector.body
# =>This Inner Loop Header: Depth=1
vl1r.v v16, (a3)
vsetvli zero, zero, e8, m1, ta, ma
vmseq.vi v16, v16, 0
vfirst.m a7, v16
srli t0, a7, 63
czero.nez a7, a7, t0
czero.eqz t0, a1, t0
or a7, t0, a7
vsetvli zero, zero, e64, m8, ta, ma
vmsltu.vx v0, v8, a7
vle8.v v17, (a5), v0.t
vcpop.m t1, v16
vsetvli zero, zero, e8, m1, ta, ma
[20 lines not shown]
[clang] Normalize clang-cl options for host and device compilation (#228096)
clang-cl options such as `/O1`, `/O2`, and `/Ox` optimized host code in
HIP builds while leaving device code unoptimized. Translation of these
options, macro separators, and `/permissive` also depended on selecting
the MSVC toolchain.
Move this handling into a shared `ClangCLArgs` helper, selected by
`IsCLMode()`. Translate shared options before host/device filtering and
forwarded options afterward. Preserve explicit overrides, existing
GNU-mode MSVC compatibility, and the resolved host architecture for
frame-pointer options.
PassBuilder: Take LLVMContext for LibraryOptionsContext (#233150)
PassBuilder uses the PipelineTuningOptions' context, else the
TargetMachine's, else null, for which LibraryOptionsContext::get<T>
returns T::Global. A caller that sets neither, such as llvm-reduce,
silently gets the global values.
Take the LLVMContext whose library options the pipelines read as the
first constructor parameter instead, as StandardInstrumentations does,
and remove PipelineTuningOptions::LibraryOptions.
LLM-aided
[libc][docs] Rewrite remaining rst docs to md [2/2] (#233848)
Tracking issue:
[#201242](https://github.com/llvm/llvm-project/issues/201242)
See the [migration
guide](https://llvm.org/docs/SphinxQuickstartTemplate.html#markdown-migration-guidelines)
this is the second part of migrating the remaining libc utility READMEs
from rst to md
the content conversion is provided by this pr, following the rename in
the previous pr
Depends on #233817
the first commit is from the base pr (rename), the second commit
contains the content conversion
dsynth - Apply the "debug" directive to ports-mgmt/pkg
The debug directive was not being applied to ports-mgmt/pkg,
so we couldn't retain the mounts for debugging purposes when
explicitly building that target.
Adjust the (s4) string to recognize multiple flags, since fixing
this requires two flags to be passed in.
Reported-by: aly
[AMDGPU] Enable IAS in the AMDGPU backend (#85518)
Object emission already parses inline asm with AMDGPUAsmParser, so the
visible change is in textual output (llc, clang -S), where inline asm
is now parsed and printed in canonical form instead of being copied
through as written.
With the integrated assembler, MCAsmInfoELF's HasPreferredAlignment
makes AsmPrinter emit the preferred function alignment as .prefalign,
which lets small functions be aligned less than the instruction cache
line. Turn it off so that enabling the integrated assembler does not
change code layout. The existing function alignment tests cover this.
Update the tests whose inline asm cannot be written so that it prints
the same either way: v_nop_e64 is printed as v_nop, inline constants
are printed by value (0xbf000000 -> -0.5), constant expressions are
evaluated (0x40fffffff0 >> 32 -> 64) and a zero offset: is omitted.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[libc][cmake] Respect the configured optimization level for the Linux thread and TLS objects
The -O3 override on the Linux thread object dates from the old approach of
reading the thread arguments off the new thread's stack, which #225384
removed; the TLS objects copied the same pattern in #225418. Neither needs
it anymore, so drop the overrides and use the optimization level configured
by CMake.
Assisted-by: Claude
[libc][cmake] Respect the configured optimization level for tests (#234381)
Follow up to #126322 and #233964 for the test side: the math and stdfix
tests, `hash_test` and the MPFR/MPC wrappers still force `-O3`. Drop the
overrides so they use the optimization level configured by CMake like
the rest of the library.
Assisted-by: Claude
[XRay] Ignore debug instructions in instruction threshold (#219400)
Debug instructions currently contribute to `xray-instruction-threshold`,
so
enabling debug information can change whether a function is
instrumented.
Count raw machine instructions while excluding only debug instructions.
Using
the raw instruction range preserves the existing treatment of bundled
instructions and non-debug meta instructions.
The first commit records the existing behavior. The second applies the
fix and
updates the test expectations.
Fixes #219376
Assisted-by: OpenAI Codex 5.6 Sol, co-reviewed by Claude and Yongqiang
Tian.
ping: use CLOCK_REALTIME for ICMP Originate Timestamp
RFC 792 defines the ICMP Originate Timestamp field as milliseconds
since midnight UTC. However, ping(8) currently derives this value
from CLOCK_MONOTONIC, which represents time since an unspecified
starting point and is not related to UTC.
The issue was introduced by commit 1ad76f1b6047, which replaced
gettimeofday(2) with clock_gettime(CLOCK_MONOTONIC) for timekeeping
in ping(8).
Fix this by using CLOCK_REALTIME when generating the ICMP originate
timestamp.
Before:
$ ping -Mt -c1 127.0.0.1
ICMP_TSTAMP
PING 127.0.0.1 (127.0.0.1): 56 data bytes
[17 lines not shown]
ping: fix test timestamp_origin when tstamprepl is disabled
The timestamp_origin test sends an ICMP Timestamp Request (ping -Mt) and parses
the tso/tsr fields out of the reply.
When the sysctl net.inet.icmp.tstamprepl is 0, the kernel silently drops the
request, ping receives no reply, and the sed extraction yields an empty $tso.
The test then fails inside atf_check test -n "$tso" with the unhelpful message
Approved by: maxim
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D57287
(cherry picked from commit ff873565bc2c3e47fe1d070305aa851189ee8bcf)
[lldb] Fix SymbolFileDWARFTests link failure on Windows (#234441)
LLDB unit tests don't link clang libraries themselves, use
ObjCInterfaceDecl::getObjCRuntimeNameAsString() instead.
Assisted-by: Claude
Merge tag 'thermal-7.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull thermal control updates from Rafael Wysocki:
"These are mostly updates of thermal drivers including a new Exynos
ACPM thermal driver for Google GS101, new Renesas RZ/G3L thermal
sensor support, new Qualcomm MSM8952 TSENS support, new Qualcomm
PMAU0102 Master BandGap temperature monitor support in DT bindings,
and new rugged Panther Lake support in intel_tcc_cooling. Moreover,
the AN7583 driver is extended to register separate thermal zones for
bandgap, GbE and CPU (its DT bindings are updated accordingly).
There are also multiple fixes and assorted cleanups, as usual.
Specifics:
- Make the Intel powerclamp thermal driver reject invalid window_size
values, drop redundant clamp() from duration_set() in it, and
simplify 4 functions in it (Thorsten Blum)
[122 lines not shown]
Merge tag 'pm-7.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull power management updates from Rafael Wysocki:
"This time, the most visible part are the ACPI CPPC updates from
Christian Loehle, including CPPC cpufreq driver changes, even though
updates of cpufreq drivers proper are still the largest topic group.
However, the updates of cpufreq drivers depend on the ACPI CPPC
updates, so they should really be counted together and that is well
over 1/2 of the total commit count.
Interestingly enough, almost all of the updates included here are
fixes or cleanups, with some new feature support in the amd-pstate
cpufreq driver and IPQ9650 support in the qcom-nvmem cpufreq driver.
The runtime PM documentation improvements from Brian Norris can also
be mostly regarded as fixes, but a new kunit test goes along with
them.
Specifics:
[116 lines not shown]
[MachineScheduler] Fix stale read-undef flags when rescheduling physreg copies (#227897)
`GenericScheduler::reschedulePhysReg` can leave stale `read-undef` flags
when moving an already-scheduled COPY. This can be exposed most commonly
if a user introduces a large inline assembly section that can otherwise
limit the registers that are available to the compiler.
This addresses this bug in 2 steps:
1) Check for backends that can produce `read-undef` on subregisters in a
way that can meaningful move (e.g. has lane mask).
2) After a move regenerate the `read-undef` flags for just the region of
"movement" between the old/new location in the code.
You can find the motivating example here:
https://gist.github.com/njriasan/73a4b080e98cdb54bd0b59138bc5ad9c
ping: do a better job with what we received from the net, part 2
When we see a difference between the payload we sent and what we
received, we dump both but we were not prepared for the case when
the received payload is less than we sent. In this case we were trying
to dump more than needed.
Funny enough, 23 years ago I already fixed a similar issue here but
didn't pay attention to this small dumping loop.
Test written by jlduran.
Reviewed by: jlduran
MFC after: 1 month
Found with: Claude Code Sonnet 5
Differential Revision: https://reviews.freebsd.org/D59556
Differential Revision: https://reviews.freebsd.org/D59582
(cherry picked from commit 0b9434d707c71de7b1b62e400e6e780224f0384d)
ping: do a better job checking what we receive from the net
- zero out a buffer for the incoming icmp message that
we are about to parse
- for ICMP_MASKREPLY and ICMP_TSTAMPREPLY responses check their length
and warn and reject them if they are truncated
Without these checks a part of stack allocated struct icmp icp could
be printed out which seems low severity since we already dropped root
privileges by the time icp is allocated.
Reviewed by: glebius
MFC after: 1 month
Found with: Claude Code Sonnet 5
Differential Revision: https://reviews.freebsd.org/D59555
(cherry picked from commit aa6683207d189a0b58ccf8806bd9f8793914bc45)
PPC: Fold 64-bit zero-extending word load feeding extsw subregister (#211107)
A gprc LWZ/LWZX feeding EXTSW_32_64 is rewritten into a sign-extending
LWA/LWAX load. Extend the same fold to the 64-bit zero-extending word
loads LWZ8/LWZX8 when the EXTSW_32_64 reads their sub_32 subregister,
producing a single LWA/LWAX instead of a redundant lwz+extsw pair.
Co-authored-by: Claude (Opus 4.8) <noreply at anthropic.com>
[ThinLTO] Import locals with colliding GUIDs (#234247)
The ThinLTO importer treated a local already defined in the destination
as satisfying any reference with the same GUID. Distinct locals in
different modules can share a GUID when their source filenames and names
match. A needed definition was then skipped, tripping the export/import
consistency assertion for read-only variables.
Check the referencing module before skipping the import.
Assisted-by: OpenAI Codex