[TypePromotion] Drop invalid nsw from promoted trunc-to-i1 conditions (#223637)
Fix a miscompile introduced in #216311. TypePromotion zero-extends the
operand of a trunc to i1. When doing so, drop nsw unless nuw is also
set, as the original operand might be all ones.
Preserve nuw because it remains valid when zero-extending. Preserve nuw
nsw as well, since it implies an all-zero operand when truncating to i1.
Alive2 proofs: https://alive2.llvm.org/ce/z/GHTZXg
[VPlan] Use frozen combined condition in early exit first-active-lane
Combined is used both to compute if an early exit was taken via VPInstruction::AnyOf, as well as the index of the early-exited lane in VPInstruction::FirstActiveLane.
Combined can have poison lanes past the exited lane, so the AnyOf uses freeze to prevent branching on poison. However FirstActiveLane on a vector with a poison lane is poison, so we need to also use the frozen version of Combined to prevent poison there.
[VPlan] Fix VPInstruction::AnyOf combine undoing freeze
There is an any-of combine for unrolled VPlans which does:
any-of (fcmp uno A, A), (fcmp uno B, B), ...-> any-of (fcmp uno A, B)
However any-of implicitly freezes each individual operand and this means we go from `freeze (fcmp uno A, A)` to `freeze (fcmp uno A, B)` which isn't sound: alive2.llvm.org/ce/z/UdQM7C
This causes miscompiles today with early exit loops, see the attached test case in single-early-exit-anyof-fold.ll.
This fixes it by explicitly modelling the freeze in VPlan. There are three places where we use AnyOf:
1) early exit loops: the freeze needs to be applied per-lane, so apply it to `(any-of (freeze (combined-conds-to-exit)))`
2) handleMaxMinNumReductions: If any lane of the reduction was poison in the scalar loop, the final result will be poison. We only need to freeze the result of AnyOf to prevent immediate UB when branching. Freezing individual operands blocks the any-of combine otherwise.
3) handleFindLastReductions: we need to freeze Cond itself since it's got multiple uses, but I plan on fixing this in a separate PR
[SelectionDAG] Soft promote the element operand of INSERT_VECTOR_ELT (#223612)
When f16/bf16 is soft promoted but a vector of that type is legal,
INSERT_VECTOR_ELT is left with a soft promoted i16 element operand.
SoftPromoteHalfOperand had no case for it and failed with "Do not know
how to soft promote this operator's operand!".
Legalize it like BUILD_VECTOR and the inverse EXTRACT_VECTOR_ELT:
bitcast
the vector to its integer counterpart, insert the promoted element there
and bitcast the result back. This also covers scalable vectors.
This is reachable on MIPS MSA and on RISC-V with Zvfhmin/Zvfbfmin but
without Zfhmin/Zfbfmin. X86, Hexagon and WebAssembly avoid it by custom
lowering INSERT_VECTOR_ELT on the scalar type; that still takes
precedence and can be removed separately.
Fixes https://github.com/llvm/llvm-project/issues/198104.
Assisted-by: Claude Code
[compiler-rt] Set FILEOS and FILETYPE in windows_version_resource.rc (#223387)
This is a follow-up to #216408 which added version info to runtime DLLs.
We have a test (in Crashpad) that expects the FILEOS and FILETYPE to be
set. I suppose it was getting default values from somewhere before, but
after #216408 it fails unless we set them explicitly.
CodeGen: Remove TargetOptions::EABIVersion
The field's only effect was gating the __aeabi_mem*[4|8] libcalls via the
IsEABI4/IsEABI5 predicates. That distinction is derivable from the triple's
environment, so replace the two predicates with a single
triple-derived IsEABIVersion and delete the field.
The clang -meabi option and clang::TargetOptions::EABIVersion are
retained (now codegen-inert); the llc/opt -meabi flag is removed. -meabi
now only takes effect on triples with a bare-EABI/GNU environment pair
(arm-none-eabi <-> gnueabi), which is the only case with a triple
representation.
Co-authored-by: Claude (Claude-Opus-4.8) <noreply at anthropic.com>
clang/ARM: Derive -pg mcount name from the triple environment (#220822)
For a glibc/gnueabi ARM and AArch64 targets, GCC's -pg instrumentation
always calls __gnu_mcount_nc (with the caller pushing LR, per the "nc"
no-LR-clobber ABI). clang only produced this when -meabi=gnu was passed
explicitly; a separate gnueabi triple wrongly called plain "mcount".
On ARM, glibc's EABI profiling entry point is __gnu_mcount_nc
(sysdeps/arm/arm-mcount.S, exported since GLIBC_2.8). It does provide
plain mcount/_mcount, but only as a legacy APCS compat alias
(__mcount_arm_compat, gated on GCC_COMPAT(4,3)/SHLIB_COMPAT)
that reads an APCS frame-pointer record rather than following the EABI push-LR
convention. Calling it from EABI -pg code is thus an ABI mismatch, not the intended
entry point.
Derive the GNU-vs-plain mcount name from the triple environment in
addition to the explicit -meabi=gnu, so a gnueabi target gets the correct
__gnu_mcount_nc call by default, matching GCC:
[5 lines not shown]
RegisterPressure: Remove dead defs correctly
When an instruction has overlapping register defs where only some carry the
dead flag (for example a dead super-register def alongside a live sub-register
def), the collector left the shared register units in both the live and dead def
sets. That produced a PressureDiff decrement with no matching increment and tripped
the "PSet overflow/underflow" assertion in getUpwardPressureDelta.
A register unit is dead if any def covering it is dead, regardless of operand
order. Reconcile by subtracting the dead defs from the live defs instead of the
reverse: removeRegLanes only clears the overlapping units, so a def keeps any
units a dead def does not cover.
Fixes #155807.
Fixes #149144.
Fixes #76416.
Fixes #205272.
Co-authored-by: XChy <xxs_chy at outlook.com>
Co-authored-by: Claude claude-opus-4.8 <noreply at anthropic.com>
18248 libzfs: uri_handlers are maximally confused
Reviewed by: Bill Sommerfeld <sommerfeld at hamachi.org>
Reviewed by: Gordon Ross <Gordon.W.Ross at gmail.com>
Approved by: Robert Mustacchi <rm+illumos at fingolfin.org>
Reland "[AArch64][GlobalISel] Add support for TLS for ELF" (#223443)
This relands #220236.
The original patch missed a case where TLS-related computations could be
localized into the middle of a call-frame adjustment sequence.
The fix prevents TLS variable localization on ELF, in the same way as on
Mach-O (see the second patch in this PR).
[clang][bytecode] Allocate records fields and bases via Program allocator (#223433)
They have the same lifetime as other things in `Program`. And we know
the number of things to allocate in advance, apart from some small
overallocations with explicitly specified virtual bases.
[VPlan] Use frozen combined condition in early exit first-active-lane
Combined is used both to compute if an early exit was taken via VPInstruction::AnyOf, as well as the index of the early-exited lane in VPInstruction::FirstActiveLane.
Combined can have poison lanes past the exited lane, so the AnyOf uses freeze to prevent branching on poison. However FirstActiveLane on a vector with a poison lane is poison, so we need to also use the frozen version of Combined to prevent poison there.
AMDGPU: Maintain LiveIntervals when removing blocks in SILowerControlFlow
removeMBBifRedundant removed a redundant block's instructions from the
LiveIntervals maps but not the block itself, leaving a stale idx2MBBMap entry
that crashed getMBBFromIndex in the verifier.
Add SlotIndexes::removeMBBFromMaps to drop the erased block's slot range, and
recompute the intervals that spanned it.
Co-authored-by: Claude claude-opus-4.8 <noreply at anthropic.com>
LICM: Drop -licm-force-thread-model-single in favor of the module flag
Now that the threading model is carried by the "thread-model" IR module flag,
the hidden -licm-force-thread-model-single override is redundant: a test can
select the single-threaded model by setting the module flag directly.
isThreadLocalObject reads only Module::getThreadModel.
Co-authored-by: Claude (Claude-Opus-4.8) <noreply at anthropic.com>
CodeGen: Replace TargetOptions::ThreadModel with module flag (#223157)
Migrate the threading-model consumers off TargetOptions::ThreadModel and
onto the "thread-model" module flag. The main user was ARM's pass config,
which is moved into AtomicExpand, which now performs the single-thread
expansion directly.
Few tests use the -thread-model flag, so delete it and migrate those
cases to use the module flag.
Co-authored-by: Claude (Claude-Opus-4.8) <noreply at anthropic.com>
Co-authored-by: Claude (Claude-Opus-4.8) <noreply at anthropic.com>
[flang] Delete a trailing CYCLE that is the last statement of its DO (#223399)
A CycleStmt at the end of the body of its own DoConstruct is a no-op:
branching to the EndDoStmt and falling through to it are the same thing.
Branch analysis nonetheless marks the DoConstruct unstructured, which
costs the structured form of the loop and the induction variable
semantics that later passes rely on.
Delete such a CycleStmt in the PFT. The statement must be unlabeled, so
that it is not itself a branch target, and it must name either no
construct or this one.