[SystemZ] Fix implicit defs of TRT and TRTR
TRANSLATE AND TEST and TRANSLATE AND TEST REVERSE store the function
byte in GR2 and the argument address in GR1, and never modify GR0.
Replace the incorrect R0L implicit def with R2L.
Assisted by: IBM Bob
[lldb] Compare the concrete frame index for inlining (#240963)
`StackFrameList::GetFrameWithConcreteFrameIndex` compared each frame's
index with the concrete frame index it was given. The search starts at
the frame with that index, so the first comparison always matched, and
the function returned the frame at that index instead of the first frame
with that concrete frame index. The two differ when there are inlined or
artificial frames below the frame.
The function now compares each frame's concrete frame index. It skips
the artificial frames for a tail call, which have the concrete frame
index of the next unwound frame and come before it. A scripted frame can
be artificial too, but it has a concrete frame index of its own, so it
still matches.
A concrete frame index is the unwinder's, so
`Thread::GetFrameWithConcreteFrameIndex` now searches the unwinder's
frame list. With a scripted frame provider loaded, the thread's frame
list is the provider's, and that list numbers its frames differently.
[2 lines not shown]
[X86] Silence GCC -Wfree-nonheap-object false positive in LowerShift (#245993)
GCC 13+ warns that `~APInt` calls delete[] on "an unallocated object" in
the GFNI shift lambda. `SmallVector::push_back(T&&)` passes the address
of the temporary APInt to the out-of-line grow path, so GCC can no
longer prove its BitWidth is <= 64 and considers the `delete[] U.pVal`
path with the constant still stored in the union.
The APInts are 64 bits wide, so that path is never taken. Construct them
in place with emplace_back so there is no temporary to destroy.
---------
Co-authored-by: Claude <noreply at anthropic.com>
[AMDGPU] Remove R600 usage from llvm tests. NFC
Second step of removing the R600 (TeraScale) tests:
* [x] clang, flang, lld tests (#245524)
* [x] llvm tests (this patch)
Tests that only cover R600 are deleted, including the tests of the
`llvm.r600.*` intrinsics. In tests shared with GCN, the r600 RUN lines
and their now unused EG, CM and R600 checks and comments are removed,
and autogenerated checks are regenerated. The R600 cases in the yaml,
TableGen, TargetParser, Triple and DataLayout upgrade tests are removed
too:
```
; RUN: llc -mtriple=amdgcn -mcpu=tahiti < %s | FileCheck -check-prefixes=SI,FUNC %s
; RUN: llc -mtriple=r600 -mcpu=redwood < %s | FileCheck -check-prefixes=EG,FUNC %s
; EG: LDS_READ_RET
-->
[8 lines not shown]
[CIR] Give the #cir.fenv parameters default values
The parameters of `#cir.fenv` were optional, and accessors substituted
a default for an absent one. The default floating-point environment
therefore had several spellings, such as `fenv<>`,
`fenv<except_mode = masked>` and the form CIRGen emits with all three
parameters, each a distinct attribute.
This makes the parameters default-valued: `tonearest`, `masked` and
`false`, the default floating-point environment. A parameter with its
default value is not printed, so each environment has one printed form
and `fenv<>` is the default one. A parameter spelled with its default
value still parses and gives the same attribute. An operation with
`fenv<>` is still constrained. Only an operation without the attribute
is not.
The default of `dynamic_rounding_mode` changes from `unknown` to
`tonearest`, in the documentation and in what the accessor returns for
an absent mode. Lowering already emitted `round.tonearest` for an
[9 lines not shown]
[CIR] Use one check for ignorable FP exceptions
Speculation and lowering each decided on their own whether a
constrained operation can ignore floating-point exceptions, and they
disagreed. An operation with `fenv<strict_except = false>` was
speculatable but lowered to `fpexcept.maytrap`, and one with masked but
strict exceptions was not speculatable but lowered to
`fpexcept.ignore`. `cir.vec.fcmp` never folded a constrained
comparison.
This adds `FenvAttr::canIgnoreExceptions()`, true when exceptions are
masked and not strict, and uses it in all three places:
- Speculation already used this condition and does not change.
- Lowering emits `fpexcept.ignore` when it holds, and otherwise
`fpexcept.strict` or `fpexcept.maytrap` by `strict_except`. Three
hand-written forms change: `fenv<strict_except = false>` goes from
maytrap to ignore, masked exceptions with `strict_except = true` from
ignore to strict, and unmasked or unknown exceptions without
[11 lines not shown]
[flang-rt][lit] Set dynamic library lookup path for shared runtime tests (#244114)
When the shared Fortran runtime (libflang_rt.runtime) is built, tests
that execute compiled binaries fail on macOS because the test RUN lines
only set LD_LIBRARY_PATH, which dyld ignores, and the test binaries do
not embed an LC_RPATH to the resource library directory.
This patch adopts the approach used in compiler-rt
(push_dynamic_library_lookup_path) to automatically set the appropriate
dynamic library lookup variable across platforms (DYLD_LIBRARY_PATH on
macOS, LD_LIBRARY_PATH on Linux, PATH on Windows, and LIBPATH on AIX).
Assisted-by: IBM Bob
[AggressiveInstCombine] Extend MulHigh fold for `or disjoint` (#228897)
`foldMulHigh` is excecuted after another fold, which folds `add` into
`or disjoint`. This can make `foldMulHigh` miss chances to fold.
Replacing `m_Add` into `m_AddLike` extends `foldMulHigh` so it can fold
more cases in `-O3` mode.
Notice that there are more cases in `foldMulHigh`. They may need to
replace `m_Add` too.
Fixes #221257.
RuntimeLibcalls: Add alignment to aligned memory helper arguments (#244724)
Add the alignment annotations to target specific memcpy-like functions.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[CIR] Give complex FP add/sub the fenv memory effects
cir.complex.fadd and cir.complex.fsub were Pure even with a constrained
fenv attribute, so they could be speculated or erased like unconstrained
ops. Derive them from CIR_FenvOp, as the other fenv ops are: constrained
ops read and write the FP environment and are only conditionally
speculatable, unconstrained ops stay effect-free.
Assisted-by: Claude Code (Opus 5.5).
[CIR] Handle integers wider than 64 bits in the vector constant folders
`cir::IntAttr::getUInt()` and `getSInt()` assert when the value needs
more than 64 bits. The folders of `cir.vec.cmp`, `cir.vec.ternary` and
`cir.vec.shuffle.dynamic` read constant elements through them, so they
asserted on a vector of `__int128` with such an element. C++ reaches
all three at -O0. The verifier of `cir.vec.shuffle` read its indices the
same way and asserted while parsing an index wider than 64 bits.
They now work on the `APInt` values:
- `cir.vec.cmp` compares the elements at their full width.
- `cir.vec.ternary` tests whether the condition element is zero.
- `cir.vec.shuffle.dynamic` masks the index before narrowing it.
- `cir.vec.shuffle` recognizes the -1 index by all of its bits being
set and range-checks the other indices without narrowing them.
Folds of integers up to 64 bits are unchanged.
Assisted-by: Claude Code (Fable 5.2).
[CIR] Lower constant vectors with undef, poison and zero elements
The `cir::ConstVectorAttr` verifier only checks the element types, so
`#cir.undef`, `#cir.poison` and `#cir.zero` are valid elements, and
`VecShuffleOp::fold` creates an undef element for a -1 index. The
lowering to the LLVM dialect handled int, float and bool elements and
hit an `llvm_unreachable` on anything else, so a
`__builtin_shufflevector` of two constant vectors with a -1 index
crashed `-fclangir -emit-llvm`.
A zero element is now a zero in the dense constant. An undef or poison
element also takes a zero there and is then replaced by an
`llvm.insertelement` of `llvm.mlir.undef` or `llvm.mlir.poison`.
`llvm.mlir.constant` cannot hold such an element itself: a dense
elements attribute holds only literals, and the translation to LLVM IR
accepts a per-element `LLVM::UndefAttr` or `LLVM::ZeroAttr` only in
struct and array constants and no `LLVM::PoisonAttr` at all. The
IRBuilder folds the insertions when the module is translated, in
function bodies and in global initializers, so the LLVM IR holds one
[4 lines not shown]
[CIR][NFC] Add a CIR_FenvOp base class (#245984)
Each operation with the fenv traits repeated them and the optional
`fenv` attribute in its own definition. This adds a `CIR_FenvOp` base
class that carries both, and the operations prepend their own arguments
to it. `CIR_FPBinaryOp` derives from `CIR_BinaryOp`, so it keeps the
traits and now appends its attributes to the `CIR_BinaryOp` arguments
instead of rebuilding the list. `cir.complex.fadd` and
`cir.complex.fsub` take the attribute without the traits and are not
changed here. The generated operation classes are unchanged.
Assisted-by: Claude Code (Fable 5.2).
[CIR] Mark LoweringPrepare init functions strictfp
Classic codegen's StartFunction makes a function that has no
FunctionDecl `strictfp` when the TU-wide default FP environment is
constrained: FP exceptions are not ignored or the rounding mode is
dynamic. That covers `_GLOBAL__sub_I_*`, `_GLOBAL__I_*`, the C++20
module initializer, `__cxx_global_var_init*`, `__cxx_global_array_dtor*`
and `__tls_init`. ClangIR marked only `__cxx_global_var_init*`, through
the `strictfp` attribute of its `cir.global`, so the other functions
and the calls in them were not `strictfp`.
LoweringPrepare creates these functions after CIRGen, so it reads the
TU-wide default from `#cir.lowering_options`. `no_trapping_math` already
records whether FP exceptions are ignored, and the new `rounding_math`
field mirrors `LangOptions::RoundingMath`. It is omitted when false, so
the module attribute prints as before without `-frounding-math`.
`buildRuntimeFunction` adds `strictfp` together with the other TU-wide
default function attributes. That needs no initializer to take the
attribute from, so it also covers a module initializer with nothing to
[3 lines not shown]
[CIR] Fix crashes in the complex constant folders
The folders of `cir.complex.real`, `cir.complex.imag` and
`cir.complex.create` asserted on constants that the `cir.const` verifier
accepts.
`cir.complex.real` and `cir.complex.imag` cast a constant operand to
`#cir.const_complex`. A complex constant can also be `#cir.zero`,
`#cir.undef` or `#cir.poison`. CIRGen emits `#cir.zero` for a
value-initialized complex, so clang crashed on `__real__ CI()`. A part
of `#cir.zero` now folds to the zero of the element type. The folders
leave an undef or poison operand alone.
`cir.complex.create` built a `#cir.const_complex` from any two constant
parts. The attribute holds int or float literals only, so its verifier
failed on a part that is undef, poison or a global view. The folder now
leaves such a create alone.
Assisted-by: Claude Code (Fable 5.2).
[lldb][Clike] Add ByteSizedType (#243814)
ByteSizedType is a mixin that adds a byte size to a Type. Type itself
only declares GetByteSize (returning "unknown" by default) because many
types derive their size from another type (arrays, typedefs, ...) or
from the target (pointers) and therefore don't need to store one. Types
with a size of their own, such as builtins, records and enums, will mix
this in.
An unknown size is stored as a UINT64_MAX sentinel instead of using
std::optional, which would need extra space for its flag.
assisted-by: claude
[lldb][Clike] Don't require TypeSystemClang for AppleObjCRuntimeV2 (#238961)
This makes this code compatible with TypeSystemClike. This is also code
that has no error handling aside from silently doing nothing, so I added
logging in case we fail to grab the TypeSystem.
[lldb][test] Add a new test for float types (Reland) (#238992)
This is a new modern test for float types that replaces the test logic
from `API/types` test that is about to be deleted.
This is #208451 but updated to also handle PDB.
See also #208402
assisted-by: claude
[lldb][Clike] Don't compare types using TSClang in ItaniumABIRuntime (#238958)
This won't work with TypeSystemClike. CompilerType has a generic API
that does the same without adding a dependency on TypeSystemClang.
NAS-145364 / 28.0.0-BETA.1 / middleware: strengthen path handling (#20280)
Paths that an unprivileged user may control are opened with safe_open,
safe_open_raw and safe_makedirs from truenas_os_pyutils, which refuse a
symlink anywhere in the path, and a FIFO, socket or device node before
opening it.
- rsync: create and chown ~/.ssh/known_hosts through symlink-refusing
fds; cap the known_hosts read at 4 MiB
- ssh-keyscan: pass "--" before the host
- user: read authorized_keys with safe_open, capped at 1 MiB; unlink it
through a symlink-free .ssh fd
- filesystem.mkdir: chmod, rmdir and listxattr through fds; compare .ssh
by component
- NFS: refuse export paths that exportfs would rewrite
- nvmet: a FILE namespace must be a symlink-free regular file in a data
pool
- SMB: path_suffix and dataset_naming_schema must stay beneath the share
- filesystem.set_zfs_attributes: callers without FULL_ADMIN are limited
[28 lines not shown]