[mlir][ArithToLLVM] Do not lower sitofp to unsupported float types (#230975)
The LLVM type converter maps float types with no LLVM equivalent (for
example
f8E4M3FN, f8E5M2 and f8E8M0FNU) to an integer of the same width. Unlike
`UIToFPOpLowering`, `FPToSIOpLowering` and `FPToUIOpLowering`,
`SIToFPOpLowering` did not set `FailOnUnsupportedFP`. As a result, it
produced an invalid op that the verifier rejects:
'llvm.sitofp' op result #0 must be floating point LLVM type or LLVM
dialect-compatible vector of floating point LLVM type, but got 'i8'
Reproducer (`mlir-opt --convert-arith-to-llvm`, or `--convert-to-llvm`):
%0 = arith.sitofp %arg0 : i32 to f8E4M3FN
Set `FailOnUnsupportedFP` so that the op stays unconverted, as the other
int/float conversions already do. Users can emulate the op first with
`arith-emulate-unsupported-floats`.
[5 lines not shown]
[CodeGen] Source-qualify hashes of module-local globals for GFM and outliner (#219938)
Global function merging and outliner compare hashes across modules. Some
globals are hashed by name, so two modules that each define a same-named
global with local linkage produce identical operand hashes although they
denote different storage. The hash collision caused both GFM and GFO to
make quite a few non-beneficial optimization decisions.
Add a `SourceQualifyLocalGlobals` option to IR `StructuralHash` and MIR
`stableHashValue`. When set, the name-based hash of a global with local
linkage is combined with the source file name of its module. The module
identifier itself is not suitable: the linker may name the module after
an unstable temporary LTO object file, which would make the supposedly
stable hash vary from run to run and between the generate and use
rounds. Content-based hashes are unchanged, so equivalent literals still
merge across modules.
The option defaults to off, so other users of `stableHashValue` and
`StructuralHash` keep their hashes.
[clang-tidy] Fix false positive in performance-no-automatic-move for captured variables (#231359)
performance-no-automatic-move matched any `return x` where `x` is a
const local
variable, without checking whether `x` is actually local to the function
doing
the return. Inside a lambda, a captured variable still points at the
enclosing
function's VarDecl, so `[&x] { return x; }` was diagnosed. But captured
variables
are never implicitly moved from (Sema bails on
refersToEnclosingVariableOrCapture()
before it looks at constness), so dropping the const still gives a copy.
Now we skip DeclRefExprs that refer to a capture, same as
UseStdMoveCheck. A const
local declared inside the lambda body is still diagnosed.
AI Usage: an AI assistant was used while working on this fix, and I went
[2 lines not shown]
[mlir][x86] Fix AMX loop carried accumulation (#231170)
Fixes the AMX contraction lowering of reduction loops whose accumulators
are carried in by an enclosing loop.
The values accumulated by the enclosing loop were dropped and replaced
with the initial accumulator, which produced wrong results.
Assisted-by: Claude
[clang][Serialization] Make directory dependencies absolute when read (#231319)
Directory dependencies under a module's base directory are stored
relative to it, and the reader's base directory isn't always absolute:
with relocation checks enabled it is taken from where header search
found the module, which is relative through a relative search path, and
with -fmodule-file-home-is-cwd there is none. These directories were
then read back relative, so `directory-deps` reported them relative and
they never matched the absolute paths a build system reports as
invalidated.
Canonicalize them when reading the same way they are when recorded.
Assisted-by: Claude Code: opus-5.5
[RISCV][GlobalISel] Mark manually selected FP comparisons as nofpexcept (#231360)
Like AArch64 (https://reviews.llvm.org/D115352), set `NoFPExcept` on the
FP compares built manually in `selectFPCompare`, matching what the
generated selector does for non-strict operations. This lets MachineCSE
combine identical compares.
This is safe because `selectFPCompare` only handles non-strict `G_FCMP`,
constrained comparison uses `G_STRICT_FCMP/G_STRICT_FCMPS`.
[KnownFPClass] Teach KnownFPClass that tanh(non-positive) = non-positive (#229752)
tanh is sign-preserving, so if the source is known to never be a
non-zero positive value (pinf, psub, pnorm), the result can never be a
positive subnormal or normal either. Zero is intentionally not ruled
out: tanh(+-0.0) = +-0.0, and a flushed subnormal may become +0.0 under
the positive-zero denormal modes.
Add Attributor tests for the new deduction, for the cases where it must
not fire (+inf, positive normal or positive subnormal still possible),
and for the dynamic and positive-zero denormal modes. Update the
existing tanh tests whose result is now stronger.
Fixes #229535
[llvm-objcopy] Stream ELF output to regular files
Write ELF output directly to seekable regular files instead of first allocating a buffer for the entire output. Keep buffered output for stdout and other non-seekable streams.
Use separate buffered and file-backed output implementations. Serialize regenerated metadata sequentially, seeking once per output range, and report sticky file errors after writing finishes. Truncate and extend seekable output up front so unwritten layout gaps read as zero without being materialized; explicitly overwrite only removed section contents within copied segments.
On a synthetic stamping-style ELF containing a 1 GiB payload, three warm-cache no-op copies had median peak RSS of 2,102,916 KiB before and 1,053,844 KiB after (49.9% lower). Median wall time improved from 1.06 s to 0.77 s, and the outputs were byte-identical.
Co-authored-by: Jeremy Braun <jtbraun at meta.com>
Co-authored-by: Fangrui Song <i at maskray.me>
Assisted-by: OpenAI Codex
[Support] Support seekable temporary output streams
Use raw_fd_stream for temporary outputs so callbacks can perform positioned writes and resize the destination. Add raw_fd_ostream::takeError and raw_fd_stream::resize, and return stream failures through Error while preserving an existing destination.
Co-authored-by: Jeremy Braun <jtbraun at meta.com>
Assisted-by: OpenAI Codex
[llvm-objcopy] Route section copies through writeSectionContents
Centralize section byte copies behind a virtual helper so ELF output can later target either a memory buffer or a seekable stream. Materialize SHT_SYMTAB_SHNDX entries using the target ELF word type to preserve output endianness.
Co-authored-by: Jeremy Braun <jtbraun at meta.com>
Assisted-by: OpenAI Codex
[BOLT][RISCV] Ignore alignment markers in linked binaries (#223994)
Skip `R_RISCV_ALIGN` when reading input relocations. It describes
padding used for linker relaxation rather than an address to relocate.
Since BOLT processes an already-linked binary, retained alignment
markers should not enter the ordinary relocation handling path.
[BOLT][RISCV] Emit PCREL_LO12 labels during size estimation (#224202)
BOLT skips instruction labels when emitting code for size estimation
with `EmitCodeOnly`. On RISC-V, however, `%pcrel_lo` fixups reference
labels on the corresponding `AUIPC` instructions. Omitting these labels
causes size estimation of entry patches to fail with **“ could not find
corresponding `%pcrel_hi` ”** when using `--force-patch`. Emit existing
RISC-V instruction labels in this mode so that PC-relative fixups can be
resolved.
[X86] Pin debug variable locations mode in pr228950.ll (#231278)
The CHECK lines in pr228950.ll assume instruction-referencing variable
locations, which is the x86_64 default. Under VarLoc-based
LiveDebugValues, llc emits a #DEBUG_VALUE comment between ldtilecfg and
tilezero, and the CHECK-NEXT fails.
Pass -experimental-debug-variable-locations=true so the test does not
depend on the default. This does not change upstream output.
rdar://189810853
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[RISCV][GlobalISel] Promote f16 to f32 for G_FCMP without Zfh (#231097)
Without Zfh, G_FCMP with f16 operands had no matching legalization rule,
so GlobalISel failed to legalize it.
This commit widen the operands to f32 instead, matching SelectionDAG,
which promotes f16 SETCC when Zfh is not available.
Godbolt link: https://godbolt.org/z/Y9P7Yqa8d
[RISCV][GlobalISel] Use Zfhmin for G_FCONSTANT s16 (#230723)
`fmv.h.x` is available with Zfhmin, and the selector already
materializes f16 constants through a GPR and `fmv.h.x`. SelectionDAG
handles f16 constants with Zfhmin, but GlobalISel would abort because
G_FCONSTANT s16 was only legal with Zfh.
SelectionDAG: https://godbolt.org/z/coMc7j3x9
GlobalISel: https://godbolt.org/z/MqzdG1r4v