[InstCombine] Fix invalid returned attribute on memset (#235490)
This pr fixes the problem in InstCombine where the memset with returned
attribute changes into llvm intrinsc memset call which is invalid
because the original memset function returns a pointer and its first
marked argument is returned atrribute however the problem is llvm.memset
returns void .when atrributes are merged from old to new call ,returned
attribute still attached to pinter arguement .
This results in Invalid LLVM error and causes to report incompatible
arguement .
Changes made :
Updated mergeAttributesAndFlags in SimplifyLibCalls.cpp to remove the
returned parameter attribute when the new call returns void.
Added a regression test in memset-returned.ll to verify that InstCombine
simplifies the memset call without preserving the invalid attribute.
---------
Co-authored-by: jayadevthamatam <jayadevthamatam at gmail.com>
[libcxxabi] fix -Wunused-private-field (#241575)
-Wunused-private-field will soon be able to flag fields in instantiated
class templates. Land this in preparation.
The lone new instance is only defined when BUILDING_CXA_GUARD is
defined.
Link: #237374
[Matrix] Implement matrix support for the `mad` intrinsic (#239357)
Closes #184510.
This PR implements the matrix api for `mad` and adds matrix codegen
tests and matrix sema tests. Matrix backend tests were not added because
no DirectX or SPIRV backend changes were made.
Assisted-by: Claude Opus 5.5
[SandboxVec][Scheduler] Fix IR in unit test (#241656)
The unittest forms a scheduling bundle of stores S0 and S1. But there
used to be a dependency S0->S1, which is not allowed in a bundle. This
patch removes the dependency by changing the store address pointers.
[MLIR][NVVM] Add support for .s8.s4 types in nvvm.ldmatrix (#241153)
This patch adds support for the `.s8.s4` types for the `ldmatrix` instruction with the `.m8n16` shape, introduced in PTX ISA 9.4. The source data is a sequence of signed 4-bit elements that are expanded to signed 8-bit values during the load.
PTX ISA Reference: https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#warp-level-matrix-instructions-ldmatrix
Assisted by: Claude (Opus 5.5)
[flang] Track character temporary lifetimes for safe stack placement
Dynamic character expression buffers could grow the stack on every
iteration of an unstructured loop because their lifetimes were hidden
from allocation placement. Emit hlfir.destroy for them, add an explicit
cleanup region to hlfir.yield_element, and preserve both through array
constructor lowering, elemental inlining, WHERE lowering and
bufferization, which now allocates these buffers with fir.allocmem.
When such an allocation cannot be hoisted out of the loop, reclaim its
stack space with one stacksave/stackrestore pair per block. Allocation
placement then keeps these temporaries on the stack in every mode,
including offload regions (except under -fdynamic-heap-array).
[flang] Address review comments on character temporary lifetimes
- stack-arrays: accept blocks with properly nested stacksave/stackrestore
pairs, such as the ones around calls with a runtime-length result, as
long as the allocations made inside a pair are freed before its end.
These allocations then reuse that pair.
Document that the block scope makes the peak stack the sum of the
promoted allocations.
- Only create a cleanup region from the current statement context scope,
so that array constructors do not get empty cleanup regions that block
elemental inlining.
- Always allocate kind conversion buffers on the heap and let allocation
placement move them to the stack, so that constant-length ones are
hoisted out of loops.
- Canonicalize away the hlfir.concat, hlfir.char_trim, hlfir.set_length
and hlfir.char_extremum results whose only uses are hlfir.destroy, such
as the SET_LENGTH bypassed by structure constructor lowering.
- Do not let hlfir.associate take over the storage of an hlfir.no_reassoc
operand that has other uses.
- Use %flang_fc1 in the new Fortran tests.
[AMDGPU] Disable local reassignment for GPUs with many registers (#239760)
Local reassignment during register allocation eviction is very expensive
when there are a large number of registers. For kernels with large
register pressure, compile-time time can exceed 10 minutes.
This PR disables local reassignment for GPUs with a large number of
VGPRs.
Creating this PR while waiting for performance results.
[Support] Pass tool options to parseCommandLineOptions (#240009)
Add a `parseCommandLineOptions` overload that takes the libraries a tool
opts in to. Replace the global state `RegisterMCToolOptions` with
`mc::getToolOptions` and `codegen::getToolOptions`, which tools pass
where they parse, including lld's `-mllvm`, gold's `-plugin-opt`, and
libLTO's debug options.
`RegisterCodeGenFlags` no longer registers the MC options.
clang-linker-wrapper does not pass the MC options, so it now rejects
them in `-mllvm` and `--offload-opt`, which it forwards to the device
and host link steps. Its wrapper module uses the module's own context
instead of the user's `-mllvm`, as discussed on #233513.
`LibraryOptionsContext` records the library that parsed each argument,
so `assign`, which runs on each ThinLTO backend thread, replays without
looking up the registry.
LLM-aided
[libc][docs] Generate implementation status dashboard (#241945)
The top-level headers/index.md page currently renders a plain static
list of header names without indicating overall C23 or POSIX.1-2024
coverage or per-header completion across the library.
Replace static headers/index.md with docgen.py --index (invoked by the
CMake libc-docgen-index target) to generate top-level C23, POSIX.1-2024,
and symbol-category completeness cards alongside colour-coded progress
rows for every catalogued header, while hiding top-of-page source links
on the aggregated index page in conf.py.
Assisted-by: Automated tooling, human reviewed.
[X86] Fix bf16 VBROADCAST lowering and selection without AVX512BW+VLX
Broadcasts of bf16 vectors only have isel patterns with AVX512BW+VLX,
so AVX2 targets without them (e.g. znver3) fail with "Cannot select".
Add v8bf16/v16bf16 VPBROADCASTW patterns for AVX2, mirroring the f16
ones. In combineTargetShuffle, only apply the broadcast(bitcast(src))
and vbroadcast(bitcast(vbroadcast(src))) folds if the new broadcast type
is legal, since v16bf16 can be illegal when v8bf16 is legal.
Assisted-by: Antigravity
[X86] Add bf16 broadcast tests (NFC) (#240804)
Add tests for bf16 vector splats that end up as X86ISD::VBROADCAST or
X86ISD::VBROADCAST_LOAD of a bf16 vector type:
- values live across basic blocks
- volatile loads
- loads whose other uses are simplified away after legalization
- broadcasts of v8bf16 values that are bitcast to vXi16/vXi32
Only the default target (SSE2) and -mattr=+avx512bw,+avx512vl are tested
for now. AVX2 targets without AVX512BW+VLX crash on all of these: they
fail to select the bf16 broadcast, or form an illegal v16bf16 broadcast
after type legalization. The follow-up fix adds RUN lines for them.
Assisted-by: Antigravity
[ThinLTO] Import source modules in module hash order (#241455)
The ThinLTO cache key orders the import list by module hash and leaves
out the module paths, but FunctionImporter imports from the source
modules in path order. The IRMover appends imported globals and named
metadata such as llvm.linker.options in import order, so linking the
same bitcode under different file names could produce the same cache
key with different objects, e.g. a different LC_LINKER_OPTION order.
Import from the source modules in module hash order to match the key.
[ConstraintElim] A signed sum of operands with opposite signs cannot wrap (#235159)
If one operand is known non-negative and the other non-positive, the
signed sum is between them, so it cannot overflow.
https://alive2.llvm.org/ce/z/ZF5Yqr
[ConstraintElim] Split signed min/max across their operands when checking a compare
The existing constraint systems only record the bounds that hold for both
operands of a min/max (smax(a, b) >= a and >= b, smin(a, b) <= a and <= b). The
other direction is a disjunction, which cannot be recorded as a fact. When a
compare of signed decompositions involves a min/max result, split it into its
operands: the decomposition is monotonic in that result, so it is the max or min
of its values on each side, and the relation holds for all or for either side
respectively.
https://alive2.llvm.org/ce/z/zsGkJ-
[ConstraintElim] Prove sadd/ssub.with.overflow cannot overflow from the exact sum
Decompose the operands and show that the sum lies in the range of the type. This
handles patterns like A + (B - A), as well as sums involving signed min/max
results, which are split across their respective operands using monotonicity
(for example start + smax(end - start - 1, 0) <= end).
https://alive2.llvm.org/ce/z/ze8LCk
[llubi] Handle fast math flags on call instructions (#239458)
Otherwise we end up directly propagating the values when we otherwise
should be rewriting to poison.
Fixes #235737
[offload] Add OpenACC Offload Kind (#239432)
Add the new OFK_OpenACC to the OffloadKind enum to represent device code
generated by OpenACC compilation. The __tgt_acc_register_lib function
will be implemented by the offload/libacctarget runtime.
Assisted-by: Claude
---------
Co-authored-by: Yury Plyakhin <yury.plyakhin at intel.com>
[mlir][tosa] Fix empty profiles and extensions in #tosa.target_env (#241574)
- Make `profiles` and `extensions` optional array parameters and update
the assembly format to parse `[]` when either list is empty.
- Add a round-trip test for `--tosa-attach-target` with the default
options.
Fixes #236938
FunctionAttrs: Skip computing initializes if an exit is reachable without writes
inferInitializes computes the ranges initialized by every block in post
order when the argument is written outside the entry block. These are
empty for the entry block if a path from it reaches an exit without
passing through a block that writes the argument, which is the case for
most arguments. Check for such a path first. NFC.
Exact instructions (callgrind) of opt -passes='default<O3>':
sqlite3 -0.13%
consumer-typeset -0.50% (z08.c)
SPASS -0.07% (cnf.c)
The CTMark build changes by O3 -0.01%, ThinLTO -0.02% (sqlite3 -0.05%,
-0.06%).
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>