[SPIRV] Use 32-bit pointers for the logical spirv triple (#239347)
Vulkan modules declare `Int64` for HLSL shaders that use only 32-bit
integers. This fails Vulkan validation unless the device enables
`shaderInt64` (`VUID-VkShaderModuleCreateInfo-pCode-08740`). For
example, reading `S::b` from a `ConstantBuffer<S>` with `struct S {
float a, b; }` produces an access chain whose index is a 64-bit constant
1.
In logical SPIR-V, an access chain index should be a 32-bit integer. The
`spirv` data layout has no `p` entry, so pointers and the GEP index type
default to 64 bits.
This gives the `spirv` triple `p:32:32`. Main changes:
- Clang's `SPIRVTargetInfo` gets 32-bit pointers, so subscripts stay
`i32` and resource handles take 4 bytes, as on DXIL.
- `SPIRVEmitIntrinsics` creates literal access chain indices in the
index type instead of `i64`, truncates wider indices, and wraps constant
[21 lines not shown]
[CIR] Improve a couple of NYI diagnostics (#244742)
This change adds an NYI diagnostic for block pointer callees and
improves the information for the general fallback diagnostic in
CIRGenFunction::emitLValue.
This produces a more specific diagnostic for the missing functionality
reported in https://github.com/llvm/llvm-project/issues/243877
[SandboxIR][SandboxVec][PassManager] Check and fix pass return values (#236183)
This patch implements a verifier for the pass return value, i.e., if
it's false only when the pass does not modify the IR.
To accomplish this we introduce basic hashing for the IR building
blocks, like Instructions, BasicBlocks, Functions etc. Then in the pass
manager we get the IR hash before we ran the pass and compare it against
the hash after the pass has completed.
These new checks exposed issues with the return values of a few passes,
which are also fixed by the patch.
[VPlan] Use getPlainCFGMiddleBlock in vp_rpo_plain_cfg_loop_body (NFC). (#245287)
Look up the middle block via getPlainCFGMiddleBlock, instead of assuming
it is the latch's first successor.
PR: https://github.com/llvm/llvm-project/pull/245287
[MISched] Allow memop clustering in the presence of memory dependencies (#239320)
Relax the conditions under which we cluster memops to include situations
where a pair of adjacent memops are related by a single memory
dependency. This reduces the impact of enabling store sequencing by
allowing sequencing stores to be clustered with other stores in their
frontier. Interestingly, this also impacts a number of existing RISCV
and AMDGPU tests, presumably on the basis that some existing DAG
mutations are already inserting ordering edges between memops that would
otherwise form clusterable pairs.
[Clang][Sema] Add fortify warnings for getlogin_r, ttyname_r, ptsname_r, and confstr (#244704)
Add `-Wfortify-source` compile-time bounds checking for the POSIX
functions `getlogin_r`, `ttyname_r`, `ptsname_r`, and `confstr`.
- Register `getlogin_r`, `ttyname_r`, `confstr`
(`GNULibBuiltin<"unistd.h">`), and `ptsname_r`
(`GNULibBuiltin<"stdlib.h">`) in `Builtins.td`. `NoThrow` is set on
`confstr` and omitted on `getlogin_r`, `ttyname_r`, and `ptsname_r`
since `getlogin_r`/`ttyname_r`/`ptsname` are POSIX cancellation points.
- Diagnose size arguments exceeding the destination buffer size in
`Sema::checkFortifiedBuiltinMemoryFunction` with
`warn_fortify_source_size_mismatch`.
- Add Sema tests covering direct calls, `confstr(name, 0, 0)`, `-1`
sizes, `diagnose_as_builtin` wrappers, C++ non-`extern "C"` lookalikes,
and strict `-std=c99` non-GNU mode, and update `ReleaseNotes.md`.
Part of #142230
Assisted-by: Gemini
[flang][hlfir] Optimize MINLOC/MAXLOC with equality mask (#211722)
When the mask is an element-wise integer equality comparison against a
loop-invariant scalar (e.g. MASK = A == val), tracking the
minimum/maximum value throughout the reduction loop is redundant — every
unmasked element is identical to val, so the first match is the result
regardless of its value.
This is the second part of the optimization enabled by #186916, which
relaxed InlineElementals to inline the mask hlfir.elemental at its
hlfir.apply site inside the generated reduction loop.
The [coords, minval, isFirst] accumulator is replaced with [coords,
isFirst], turning the loop into a short-circuiting find-first locator.
The arith.andi %mask_val, %isFirst guard ensures subsequent masked
elements are skipped once the first match is recorded.
[mlir][spirv] Support OCP microscaling floating-point formats (#238282)
Add SPV_EXT_ocp_microscaling_types support for FP4 E2M1, FP6 E2M3 and
E3M2, and FP8 E8M0 using the corresponding MLIR builtin float types.
Add the capabilities and FP encodings, OpBitcastExtractEXT, type
availability and storage checks, and SPIR-V binary import/export for the
floating-point types and constants. Preserve supported native types
during conversion and reject unsupported sub-byte emulation.
Cover IR verification, capability inference, conversion, and binary
round trips. MXINT8 support is left to a follow-up change.
SPIR-V extension specification:
https://github.khronos.org/SPIRV-Registry/extensions/EXT/SPV_EXT_ocp_microscaling_types.html
Signed-off-by: Davide Grohmann <davide.grohmann at arm.com>
[Hexagon][NFC] Move GlobalScheduler alias check to HexagonInstrInfo (#245213)
Move the alias check used by the GlobalScheduler pull-up into
HexagonInstrInfo::areMemAccessesDependent, next to
areMemAccessesTriviallyDisjoint, so it can be queried like other
instruction properties. No functional change.
Assisted by AI
Co-authored-by: Fateme Hosseini <fhossein at qti.qualcomm.com>
[BinaryFormat][MachO] Give HeaderFileType a fixed uint32_t underlying type (#245285)
Fixes 565b6e9af598 (#244575). Under UBSan (-fsanitize=enum), yaml2obj
-DFILETYPE=0x1000 in MachO/filetype.yaml triggers an illegal instruction
because HeaderFileType has no fixed underlying type.
[MLIR][NFC] Remove check for negative value for unsigned integer. (#245164)
`index` is declared as `size_t` and hence can never be a negative.
Remove the redundant check in the if statement for checking if `index`
is negative.
Signed-off-by: Hardik Kumar <hardikxk at gmail.com>
[X86] Remove unused getCondFromCFCMov and getCondFromCCMP (NFC) (#244119)
The last uses were removed on May 20, 2024 in commit
758e1199f6dbcddc0a8d425753c56a42507dd313.
Assisted-by: Antigravity
[SimplifyCFG] Give a select from branch folding the weights of its condition
performBranchToCommonDestFolding() folds `br c1` and `br c2` with a
common successor into a branch on `select c1, c2, false` or
`select c1, true, c2`. Since #154426, it gives the select the weights
of the merged branch, which are those of `c1 && c2` or `c1 || c2`.
The weights of a select are those of its condition, `c1`: PGO
instrumentation and LowerExpectIntrinsic set them that way, and
CodeGenPrepare and JumpThreading copy them to a branch on the
condition when they turn the select into a branch. The other fold
that creates these selects, SimplifyCondBranchToCondBranch(), already
gives the select the weights of the first branch.
For example, with `c1` true half of the time and `c2` 1% of the time,
the select gets weights 50:9950, and CodeGenPrepare turns it into
`br c1` with these weights.
Give the select the weights of the first branch before the fold. If
[16 lines not shown]
[SystemZ] Declare command line options in TableGen (#244983)
Move the cl::opt options into SystemZOptions.td. SystemZTargetMachine
holds `const SystemZOptions &CLOpts`, and SystemZSubtarget copies it.
-argext-abi-check becomes a BoolOrDefault, since an explicit
-argext-abi-check=false overrides TargetOptions::VerifyArgABICompliance.
Renames without an alias, as the old spellings are generic or unused:
```
-generic-sched -> -systemz-generic-sched
-procres-cost-lim -> -systemz-procres-cost-lim
```
LLM-aided
[AMDGPU] Constant fold fixed cluster dims (#235076)
## Reasoning
When cluster dims are known at kernel compile time, we can constant
fold.
Currently cluster dims are never constant folded even when the size is
known, leading to unnecessary extra register consumption.
## Changelog
Add cluster dim constant folding pass for cluster intrinsics
### llm disclosure
llms were used to assist in putting together this PR
---------
Co-authored-by: Matt Arsenault <arsenm2 at gmail.com>
Co-authored-by: Ryan Mitchell <Ryan.Mitchell at amd.com>
[libc] Enable baremetal Armv8-M hard FP premerge job (#243424)
This patch enables a new premerge CI job to build and test for baremetal
Armv8-M Mainline with hardware floating-point ABI.
[libc] Add run capabilities to baremetal Armv8-M.Main hard FP CMake cache file (#243422)
Create a new CMake cache file in a dedicated Arm-specific folder for
testing configurations. This specific testing configuration is for
Armv8-M Mainline with hardware floating-point ABI.
All the configurations are based on what Arm Toolchain for Embedded uses
for its downstream testing, and are known to work.