[SLP]Combine fmuladd for the nodes of the gathered slices
The fadd/fsub nodes from the vectorized gathers were never combined with
their fmul operands, while their scalars were costed as fused.
It overestimated the vector cost of such trees.
Reviewers:
Pull Request: https://github.com/llvm/llvm-project/pull/232361
[CIR] Extract DynLib build/link fixes from #221291 (#232330)
The review from #221291 finally got me to see that we failed a few
things with Dynlib. This extracts the changes from that review so that
they are separate from the main one, so we can merge that patch with
this on main eventually.
[libc] Add support for writing to wchar_t in printf_core/ converter functions. (#230246)
This is part of the ongoing work toward implementing wide-character
printf functions.
* A `CharT` template type parameter is added where appropriate to the
converter functions.
* The converter_test cases are extended to `TYPED_TEST`s covering both
`char` and `wchar_t`.
* Some new test cases are added for character and string conversion.
* As a part of this change `BasicFormatSection<T>` is renamed back to
simply `FormatSection<T>`. (It was renamed in #222988 with
`FormatSection` becoming an alias mainly to keep from changing a lot of
lines in converter_test twice.)
Assisted-by: Automated tooling, human reviewed.
[CIR][OpenMP] Add support for the OpenMP 'for' directive
This patch adds support for wsloop in ClangIR: the `for` directive and its
combined forms `parallel for` and `target parallel for`. This is lowered to an
omp.wsloop + omp.loop_nest, nested utilizing the existing queue-based
decomposition.
Assisted-by: Cursor / Claude Sonnet 5 High
AArch64: Move the Windows trap after noreturn calls into the AsmPrinter
With Windows unwind info, the unwinder finds the function or funclet
for a frame from its return address, so a call must not be the last
instruction of one.
This was hackily handled by overwriting TrapUnreachable in the
TargetMachine constructor which inserts traps after every
unreachable. X86 handles the same problem by padding calls in the
AsmPrinter, so do the same here: emit a trap only after a noreturn
call that would end a function or funclet. This addresses the FIXME
about eliding the trap when the next instruction is in the same
region, so noreturn calls in the middle of a function no longer get a
trap.
This removes one of the last obstacles to removing ExceptionModel from
TargetOptions.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[X86][LoongArch]Fix ODR violation in CostKindCosts
Both targets defined a global CostKindCosts with different field
orders. Without inlining, the linker merged the inline operator[],
swapping X86 throughput and latency costs.
Assisted-by: Cursor
Reviewers:
Pull Request: https://github.com/llvm/llvm-project/pull/232356
[lldb] Let the host platform write to pipes
`Platform::WriteFile` on the host platform could not write to a pipe: it
goes to `FileCache::WriteFile`, which seeks to the offset before
writing, and a pipe refuses the seek with ESPIPE. The offset means
nothing for a pipe, so `FileCache::WriteFile` now writes at the pipe's
end when the seek fails that way.
This is the host-side counterpart of #232045, which does the same for
lldb-server's `vFile:pwrite`. With both, writing to a pipe through a
platform works the same whether the platform is the host or a remote
one. Downstream, NVIDIA's GPU support writes a byte to a pipe in the
debugged process through the target's platform, to ask the CUDA driver
to attach.
The new FileCacheTest opens a named pipe through `FileCache`, writes to
it at a nonzero offset, and reads back exactly the bytes sent. Without
the fix, the write fails with ESPIPE. The test is POSIX-only, since
named pipes are files only there.
[lldb] Fix a statusline deadlock when flushing the process (#231719)
Since #188377, Process::Flush calls Debugger::FlushStatusLine, which
takes the statusline mutex. Process::Flush may run under the target API
mutex, while a statusline redraw holds the statusline mutex and then
waits on the API mutex, resulting in a deadlock.
For example, this happens when a scripted command runs "target modules
load" through SBDebugger::HandleCommand while a progress event redraws
the statusline.
Make FlushStatusLine set an atomic flag instead, and have the next
redraw clear the cached frame under the statusline mutex. This keeps the
stale frame protection without the risk of lock inversion.
rdar://189958732
[Windows] FlushViewOfFile() for sparse files before unmap (#231823)
The issue has been described here
https://github.com/swiftlang/llvm-project/issues/12605 We have
reproduced this issue on x86_64 too running 2000 processes
simultaneously. It is hard to create a stable test for this patch. The
problem is specific to sparse files on NTFS. There is no problem on
ReFS.
I think using sparse files increases fragmentation and reduces
performance. It might be worth considering moving away from sparse
files.
[flang][OpenMP] Improve diagnosing invalid operators in DECLARE_REDUCTION
Move the check out of the common MakeNameFromOperator function and
into OmpStructureChecker. Remove the no longer needed SemanticsContext
parameter in MakeNameFromOperator.
This will allow reusing at least some parts of the the name-mangling
code in DECLARE_INDUCTION.
[AArch64] Combine non-extending partial.reduce.fadd into fma (#230120)
Using partial reductions as the default (#228481) results in some
regressions, in particular for imagick from spec2017. The cause in that
case is a lack of combining fmul and fadd into fmla, since the fadd was
still part of the intrinsic at that point.
This PR makes sure that the partial_reduce_fmla ISD node is constructed
with the same flags that the intrinsic had, copies flags to the nodes
generating when expanding during vector op legalization, then performs a
target DAG combine for the FADD_P and FMUL_P AArch64ISD nodes.
[Offload] Allow 0 to be returned for `MEMORY_CLOCK_RATE` (#232265)
For integrated Intel GPUs, level zero APIs will return 0. It's not easy
to fetch dram's clock rate, so we just accept 0 as valid result of the
test.
AMDGPU: Don't look up ConstantData in the constant access cache (#232283)
AAAMDAttributes checks the constant operands of all instructions for
address space casts and LDS globals that need the queue pointer or
flat scratch initialization, looking each of them up in a cache. Skip
the lookup for trivial constants which have no operands.
Instructions spent in amdgpu-attributor:
rocPRIM test_device_scan, gfx942: 1429M -> 1419M (-0.7%)
Blender Cycles HIP kernel, gfx1100: 507M -> 506M (-0.2%)
rocPRIM 16 tests, full LTO, closed world: 5283M -> 5263M (-0.4%)
The effect is magnified with other pending compile time improvements.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[flang] Move reduction name mangling code to Semantics/tools
Gather all the mangling/demangling code in one place.
Also remove MangledIntrinsicOperatorReductionName that was only there
to expose MakeNameFromOperator, whose declaration was not in include/.
One remaining issue is emitting a diagnostic specific to DECLARE
REDUCTION in MakeNameFromOperator.
[VPlan] Don't fold fcmp uno of different types. (#232324)
The combine (fcmp uno X, X) | (fcmp uno Y, Y) -> fcmp uno X, Y did not
check that X and Y have the same type, e.g. when checking for NaNs in
both a float and a double min/max reduction, creating an invalid fcmp
and crashing. Only apply it if the types match.
DebugInfo: Fix contradictory dead flags in MIR tests (#232326)
Remove the duplicate implicit-def dead $pc from Hexagon L4_return, and
drop the dead flag from sub-register defs that also have a live
super-register implicit-def. These will fail a future verifier rule.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[TableGen] Count errors reported via PrintError(const char *, ...) (#232271)
This overload called SrcMgr.PrintMessage directly instead of going
through PrintMessage, so it did not increment ErrorsPrinted. The lexer
uses it for several diagnostics, so e.g. an unterminated #ifdef printed
two errors followed by "1 errors.".
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply at anthropic.com>
[Offload][Omp] Remove OmpABIVersion from PluginInterface (#232337)
Move the ABI version check for host kernels from the host plugin to
libomptarget. This allows to remove the field from the KernelLaunchArgs
in the PluginInterface.
Assisted by Claude.
[flang][OpenACC] Hoist firstprivate loads of guarded optional variables (#231996)
`ACCOptimizeFirstprivateMap` did not optimize optional variables,
because loading an absent optional on the host is unsafe. When the
`acc.firstprivate_map` is in the then region of a `fir.if` on the
presence of the same variable, the variable is known to be present:
hoist its loads and fold the presence checks of the mapped value to
true.
[AMDGPU][NewInsertWaitcnt] Event Tracker (2/2)
See #226970 for context and history regarding this patch.
This is intended to begin review as a 1-1 equivalent of #226970 with only one change: a "Drain"
test that Claude added and I found useful, so I left it in.
Builds upon the previous patch to include the functionality needed to import
events from predecessor basic blocks into a basic block, so a MBB can be aware of
previous state.
This adds the "height" system, which is necessary to preserve chronology across control-flow edges,
especially in asymmetrical diamonds, alongside a way to import predecessor state via a `enterBlock`
function.
Assisted-by: AI Coding Assistants for basic boilerplate/research/etc. - no logic was written by LLMs except some unit tests.
[AMDGPU] Reserve addrspace 19 for downstream use (#232092)
Add RESERVED_ADDRESS_SPACE_19 to AMDGPUAS, following the existing
reservations for address spaces 10, 11, 14, and 16-18. Address spaces
above MAX_AMDGPU_ADDRESS are already treated conservatively (global-like
in isFlatGlobalAddrSpace, may-alias in addrspacesMayAlias), so no
behavior changes; this only documents the number as taken so upstream
does not later assign it.
Codegen for addrspace(19) is already covered by
llvm/test/CodeGen/AMDGPU/nullptr.ll.
NFC
Assisted-by: Claude Code:claude-opus-5[1m]
[AMDGPU][NewInsertWaitcnt] Event Tracker (1/2)
See #226970 for context and history regarding this patch.
Adds the basic infrastructure needed to track in-flight records for each InstCounterType.
This is not a full functional replacement of SIInsertWaitcnts::WaitcntBrackets and it does not
aim to be one, as we'd like to break up its functionality into multiple different pieces.
This patch only contains the functionality needed for tracking events in one block, without importing events from previous blocks.
Assisted-by: Claude Opus 5.5
After requests to split the patch, I used Claude to help me create this patch which is a subset of #226970 with all functionality pertaining to importing incoming events removed.