60139 Commits

Author SHA1 Message Date
paperchalice
ce86ff105b
[GlobalISel] Remove UnsafeFPMath references (#146319)
This is the GlobalISel part to remove `UnsafeFPMath` flag in CodeGen
pipeline.
2025-07-29 12:11:52 +08:00
Shoreshen
a5deb59dfe
[AMDGPU] Add NoaliasAddrSpace to AAMDnodes (#149247)
This is the following PR of
https://github.com/llvm/llvm-project/pull/136553 which calculate
NoaliasAddrSpace.

This PR carries the info calculated into MIR by adding it into AAMDnodes
2025-07-29 10:10:06 +08:00
paperchalice
21836f4a49
[SelectionDAG] Remove UnsafeFPMath in LegalizeDAG (#146316)
These global flags hinder further improvements like [[RFC] Honor pragmas
with
-ffp-contract=fast](https://discourse.llvm.org/t/rfc-honor-pragmas-with-ffp-contract-fast)
and pass concurrency support. Remove them incrementally.
2025-07-29 08:41:21 +08:00
Mahé
379949d79f
[BPF] Visit nested map array during BTF generation (#150608)
Fixes missing inner map struct type definitions [^1]. We should visit
the type of nested array of maps like we do for global maps. This patch
adds a boolean to convey the information to visitTypeEntry and
visitDerivedType that the pointee is a map definition and should be
treated as such.

It ressembles and works with commit 0d21c956a5c1 ("[BPF] Handle nested
wrapper structs in BPF map definition traversal (#144097)") which
focused on directly nested wrapper structs.

Before that patch, this ARRAY_OF_MAPS definition would lead to the BTF
information include the 'missing_type' as "FWD 'missing_type'
fwd_kind=struct":

	struct missing_type { uint64_t foo; };
	struct {
		__uint(type, BPF_MAP_TYPE_ARRAY_OF_MAPS);
		[...]
		__array(
			values, struct {
				[...]
				__type(value, struct missing_type);
			});
	} map SEC(".maps");

Which lead to errors while trying to load the map:

libbpf: map 'outer_map.inner': can't determine value size for type [N]:
-22.

To solve this issue, users had to use the struct in a dummy variable or
in a dummy function for the BTF to be generated correctly [^2].

[^1]: https://lore.kernel.org/netdev/aH_cGvgC20iD8qs9@gmail.com/T/#u
[^2]:
https://github.com/cilium/ebpf/discussions/1658#discussioncomment-12491339

---------

Signed-off-by: Mahe Tardy <mahe.tardy@gmail.com>
Co-authored-by: Eduard Zingerman <eddyz87@gmail.com>
2025-07-28 13:45:15 -07:00
Prabhu Rajasekaran
c46336b396
Reapply "[llvm] Add CalleeTypeIds field to CallSiteInfo" (#150335) (#150990)
This reverts commit 05e08cdb3e576cc0887d1507ebd2f756460c7db7.
Adding the missing -mtriple flags in MIR/X86 test files which caused
these tests to fail which was the reason for reverting the patch.
2025-07-28 13:34:26 -07:00
Philip Reames
82ad67b138
[RISCV] Rewrite vlseg tests to avoid riscv.tuple.extract [nfc] (#151003)
Motivated by https://github.com/llvm/llvm-project/pull/150049, we can
directly return the tuple instead of extracting one segment.

(I wrote a quick script to rewrite these; this wasn't done by hand.)
2025-07-28 11:26:20 -07:00
Alex MacLean
35693daa70
[NVPTX] Fix v2i8 call lowering, use generic ld/st nodes for call params (#146930) 2025-07-28 10:41:51 -07:00
Jasmine Tang
522ac23609
[WebAssembly] Add pattern for relaxed nmadd (#150684)
Following footstep of https://github.com/llvm/llvm-project/pull/147487
(support for madd), this PR adds support for nmadd.

https://github.com/llvm/llvm-project/issues/55932 tracks this
2025-07-28 10:20:04 -07:00
Ellis Hoag
819f020b28
Use F.hasOptSize() instead of checking optsize directly (#147348) 2025-07-28 08:38:52 -07:00
Matt Arsenault
a496a985d9
AMDGPU: Remove -stress-regalloc arguments from mfma selection tests (#150890)
I'm not really sure what the point of these was, but they originated
in the base support commit for gfx942 mfma support. These don't impact
the selection at all, so don't belong in this test. These were causing
allocation failure depending on whether or not the AGPR or VGPR form
was used.
2025-07-29 00:30:01 +09:00
Matt Arsenault
6fb8e58565
AMDGPU: Disable AGPR allocation in VGPR MFMA tests (#150873) 2025-07-29 00:26:24 +09:00
Pierre van Houtryve
a6532c2ada
[AMDGPU][gfx12] Clean-up implementation of waits before SCOPE_SYS stores (#150587)
We can do it all in finalizeStore if we ensure it always sees the
stores.
For that, I needed to fix a hidden bug where finalizeStore wouldn't see
all stores
because sometimes the iterator got out-of-sync and didn't point to the
store anymore.

This also removes the waits before volatile LDS stores which never
needed it, that was a bug until now.
2025-07-28 15:38:46 +02:00
Florian Hahn
6ccc9e559d
[AArch64] Add taildup test with computed gotos.
Add a test case showing missed optimizations from early taildup with
computed gotos for https://github.com/llvm/llvm-project/pull/150911.
2025-07-28 13:26:51 +01:00
Simon Pilgrim
5452c3888c [AMDGPU] Regenerate add/sub overflow tests
Add GFX10/11 test coverage to match saddo.ll
2025-07-28 12:51:21 +01:00
Matt Arsenault
51194a4ae2
AMDGPU: Fix test to stop pipeline after VGPR allocation (#150809)
This test seems to have been incorrectly updated after
ac0f64f06d67a93817ccd9a3c529ad40920115c9. Previously it
was testing the state after VGPR allocation; after the content
was updated for the "greedy,1" which now does not correspend
to the VGPR allocation. The spills implied by the test name
aren't present (they also appear to still be missing for gfx90a).
2025-07-28 18:43:57 +09:00
Pierre van Houtryve
2ad4e93ded
[AMDGPU][gfx1250] Use SCOPE_SE for stores that may hit scratch (#150586) 2025-07-28 11:40:56 +02:00
Florian Hahn
cad5328b00
[X86] Add late tail duplication tests with computed gotos.
Add a new test for post-regalloc tail duplication with computed gotos to
complement llvm/test/CodeGen/X86/tail-dup-computed-goto.mir.
2025-07-28 09:37:16 +01:00
Nikita Popov
525090e83c
Revert "[MIPS]Fix QNaNs in the MIPS legacy NaN encodings" (#150773)
Reverts llvm/llvm-project#139829.

We can't just randomly change the value of constants during lowering.

Fixes https://github.com/llvm/llvm-project/issues/149295.
2025-07-28 10:36:40 +02:00
Matt Arsenault
72b77c193f
AMDGPU: Avoid contraction in wwm allocation failure message (#150888) 2025-07-28 17:11:28 +09:00
Nikita Popov
fe0dbe0f29
[CodeGen] More consistently expand float ops by default (#150597)
These float operations were expanded for scalar f32/f64/f128, but not
for f16 and more problematically, not for vectors. A small subset of
them was separately set to expand for vectors.

Change these to always expand by default, and adjust targets to mark
these as legal where necessary instead.

This is a much safer default, and avoids unnecessary legalization
failures because a target failed to manually mark them as expand.

Fixes https://github.com/llvm/llvm-project/issues/110753.
Fixes https://github.com/llvm/llvm-project/issues/121390.
2025-07-28 09:46:00 +02:00
David Green
376326c660 [AArch64] Update some tests to use a more common check prefix. NFC
I'm just trying to more consistently use CHECK-SD and CHECK-GI.
2025-07-28 08:26:48 +01:00
Haohai Wen
07d396b6f5
[COFF] Set .llvmbc and .llvmcmd to metadata section (#150879)
Those are metadata sections for ELF but was not properly set for COFF.
2025-07-28 15:25:13 +08:00
Vikram Hegde
495774d6d5
Revert "[CodeGen][NPM] Stitch up loop passes in codegen pipeline" (#150883)
Reverts llvm/llvm-project#148114

will update with fixed PR.
2025-07-28 11:28:00 +05:30
Vikram Hegde
d35bf478a8
[CodeGen][NPM] Stitch up loop passes in codegen pipeline (#148114)
same as https://github.com/llvm/llvm-project/pull/133050

Co-authored-by : Oke, Akshat
<[Akshat.Oke@amd.com](mailto:Akshat.Oke@amd.com)>
2025-07-28 11:13:44 +05:30
ZhaoQi
80e0d41677
[LoongArch] Custom legalizing build_vector with same constant elements (#150584) 2025-07-28 09:50:35 +08:00
yingopq
778fb76e63
[Mips] Fix wrong ELF FP ABI info when inline asm was empty (#146457)
When Mips process emitStartOfAsmFile and updateABIInfo, it did not know
the real value of IsSoftFloat and STI.useSoftFloat(). And when inline
asm instruction was empty, Mips did not process asm parser, so it would
not do TS.updateABIInfo(STI) again and at this time the value of
IsSoftFloat is correct.

Fix #135283.
2025-07-28 09:07:51 +08:00
Mahesh-Attarde
bca80a00e7
[X86][GlobalISel] Add test for IS_FP_CLASS (#148816)
Test for PR https://github.com/llvm/llvm-project/pull/148801
2025-07-28 00:39:23 +02:00
Matt Arsenault
1c6e75cb98 AMDGPU: Fix test with broken checks
This was broken in 6118a254ff9acb4b54a6bdb952c088a792b679af

update_llc_test_checks behavior in the conflict case is dangerous
and terrible; it silently deletes all checks and inserts the unused
check prefixes at the bottom.
2025-07-27 10:31:54 +09:00
Philip Reames
f65b329d70 [IA] Fix a bug introduced by a recent refactoring
I had dropped the check for which intrinsics were supported.  This is
a quick fix to get tree back into an unbroken state, a cleaner change
may follow.
2025-07-26 11:46:15 -07:00
Fangrui Song
b22e22ebfa MC: Allocate initial fragment and define section symbol in changeSection
Reland #150574 with a MCStreamer::changeSection change:
In Mach-O, DWARF sections use Begin as a temporary label, requiring a label
definition, unlike section symbols in other file formats.
(Tested by dec978036ef1037753e7de5b78c978e71c49217b)

---

13a79bbfe583e1d8cc85d241b580907260065eb8 (2017) introduced fragment
creation in MCContext for createELFSectionImpl, which was inappropriate.
Fragments should only be created when using MCSteramer, not during
`MCContext::get*Section` calls.
`initMachOMCObjectFileInfo` defines multiple sections, some of which may
not be used by the code generator. This caused symbol names matching
these sections to be incorrectly marked as undefined (see
https://reviews.llvm.org/D55173).

The fragment code was later replicated in other file formats, such as
WebAssembly (see https://reviews.llvm.org/D46561), XCOFF, and GOFF.

This patch fixes the problem by moving initial fragment allocation from
MCContext::createSection to MCStreamer::changeSection.
While MCContext still creates a section symbol, the symbol is not
attached to the initial fragment. In addition,

* Move `emitLabel`/`setFragment` from `switchSection*` and
  overridden changeSection to `MCObjectStreamer::changeSection` for
  consistency.
* De-virtualize `switchSectionNoPrint`.
* test/CodeGen/XCore/section-name.ll now passes. XCore doesn't support
  MCObjectStreamer. I don't think the MCAsmStreamer output behavior
  change matters.

Pull Request: https://github.com/llvm/llvm-project/pull/150574
2025-07-26 00:05:10 -07:00
ZhaoQi
f2a4cc1dd0
[LoongArch] Avoid expanding build_vector containing insertion of undef elements (#150377) 2025-07-26 14:24:39 +08:00
Matt Arsenault
5f3eea7ef2
AMDGPU: Fix not folding splat immediate into VGPR MFMA src2 (#150628) 2025-07-26 13:54:49 +09:00
dyung
cb37916a25
Revert "MC: Allocate initial fragment and define section symbol in changeSection" (#150736)
Reverts llvm/llvm-project#150574

This is causing a test failure on AArch64 MacOS bots:
https://lab.llvm.org/buildbot/#/builders/190/builds/24187
2025-07-25 20:21:59 -07:00
Matt Arsenault
3f8a05893f
AMDGPU: Add a few mfma test with immediate splat src2 (#150627) 2025-07-26 11:58:54 +09:00
Matt Arsenault
110692b5cc
Mips: Add frexp intrinsic test (#148677) 2025-07-26 11:20:44 +09:00
Matt Arsenault
1461a1c3b8
DAG: Emit an error if trying to legalize read/write register with illegal types (#145197)
This is a starting point to have better legalization failure diagnostics
2025-07-26 10:54:59 +09:00
Matt Arsenault
a4bbfd532e
Mips: Add some llvm.sincos tests (#147465)
I guessed at some basic triples. Mips is also missing
tests for the basic sin and cos calls too.
2025-07-26 10:48:23 +09:00
Matt Arsenault
e4d5969d71
AMDGPU: Add tests with forced selection of mfmas to VGPR form (#150626)
Add some run lines to existing tests with VGPR selection enabled.
2025-07-26 09:45:59 +09:00
Hood Chatham
15b03687ff
[WebAssembly,clang] Add __builtin_wasm_test_function_pointer_signature (#150201)
Tests if the runtime type of the function pointer matches the static
type. If this returns false, calling the function pointer will trap.
Uses `@llvm.wasm.ref.test.func` added in #147486.

Also adds a "gc" wasm feature to gate the use of the ref.test
instruction.
2025-07-25 16:52:39 -07:00
Jeffrey Byrnes
6118a254ff
[AMDGPU] Allocate AVRegClass last (#146606)
This changes the RC priorities such that AVRegClass is the least
prioritized. These registers are less constrained than the VRegClass and
ARegClass as they can be either agpr or vgpr. Thus, assigning them last
removes unnecessary constraints from VRegClass and ARegClass
assignments, and allows the RA to make smarter decisions about whether
to use vgpr / agpr for AVRegClass.

We only have 5 bits for RC priorities, and we still want to prioritize
larger RCs over smaller ones. Since this new prioritization uses the 5th
bit for AVRegClass vs ARegClass / VRegClass, we only have 4 bits to
encode the size priorities. Previously, each RC with a distinct size,
had a distinct priority. However, this PR groups together multiple sizes
to the same priority. Currently, this will have no effect on
prioritization in practice because we only have one actually defined RC
per group per vector register type.

For example, a register class with 15 or 16 32bit registers will have
the same size priority (14). However, we only have VReg_512 (VReg_480
doesn't exist), so only one actual RC in VRegClass has this priority.
Similarly, we give register class with 17-32+ 32 bit registers a size
priority of 15, but we only have VReg_1024.

The effect of this PR is to prioritize first the vector register type
(VReg & Areg have top priority, then AVReg), with the size of the
register class having second priority.

Passes PSDB.

---------

Co-authored-by: Matt Arsenault <Matthew.Arsenault@amd.com>
2025-07-25 13:46:41 -07:00
Vigneshwar Jayakumar
56ae79a6ab
reland "[StructurizeCFG] Hoist and simplify zero-cost incoming else p… (#149744)
…hi values (#139605)"

This relands commit b11523b494b with the fix for llvm-buildbot failures
"clang-hip-vega20" and "openmp-offload-amdgpu-runtime-2". The reland
prevents hoisting the phi node which fixes the issue.

Original PR description:

The order of if and else blocks can introduce unnecessary VGPR copies.
Consider the case of an if-else block where the incoming phi from the
'Else block' only contains zero-cost instructions, and the 'Then' block
modifies some value. There would be no interference when coalescing
because only one value is live at any point before structurization.
However, in the structurized CFG, the Then value is live at 'Else' block
due to the path if→flow→else, leading to additional VGPR copies.

This patch addresses the issue by:
- Identifying PHI nodes with zero-cost incoming values from the Else
block and hoisting those values to the nearest common dominator of the
Then and Else blocks.
- Updating Flow PHI nodes by replacing poison entries (on the if→flow
edge) with the correct hoisted values.
2025-07-25 15:23:45 -05:00
Jasmine Tang
8e6a05d471
[WebAssembly] Added vectorized version of fexp10 to the supported list (#150564)
Fixes https://github.com/llvm/llvm-project/issues/117200.

The default behavior in TargetLoweringBase is only scalar floats on fexp
are supported by default, not the vectorized version. This PR adds
`ISD::FEXP10` to the supported list.
2025-07-25 12:30:59 -07:00
Changpeng Fang
400ce1a3d3
[AMDGPU] Support AMDGPUClamp for bf16 on gfx1250 (#150663)
Scalar version uses V_MAX_BF16_PSEUDO which is expanded to V_PK_MAX_BF16
with unused high bits. If V_PK_MAX_BF16 is produced directly instead
that creates problem with folding of the clamp into other scalar
instructions due to incompatible clamp bits.

FIXME-TRUE16: enable bf16 clamp with true16

---------

Co-authored-by: Stanislav Mekhanoshin <Stanislav.Mekhanoshin@amd.com>
2025-07-25 12:13:06 -07:00
Philip Reames
6564bf6a5e [RISCV] Rewrite tests to preserve test intent and simplify
Cleaning up tests in advance of pr #150049.
2025-07-25 12:01:32 -07:00
Helena Kotas
f169af3ba7
[HLSL] Fix detection of overlapping binding with unbounded array (#150547)
Fixes #150534
2025-07-25 09:41:20 -07:00
Matt Arsenault
74502168c4
AMDGPU: Convert some mfma tests to generated checks (#150607) 2025-07-25 23:42:53 +09:00
Jonathan Cohen
81bbe98abf
Revert "[AArch64][Machine-Combiner] Split gather patterns into neon regs to multiple vectors (#142941)" (#150505)
Reverting due to reported miscompiles, will reland once it is fixed.
2025-07-25 14:09:23 +01:00
Matt Arsenault
2b1ce25e21
AMDGPU: Fix -amdgpu-mfma-vgpr-form flag on gfx908 (#150599)
This should be ignored since there are no VGPR forms. This
makes it possible to flip the default for the flag to true.
2025-07-25 19:49:56 +09:00
Nikita Popov
129a35454c [WebAssemblyOptimizeReturned] Skip lifetime intrinsic uses
Replacing an alloca with a call result in a lifetime intrinsic
will cause a verifier error.

Fixes https://github.com/llvm/llvm-project/issues/150498.
2025-07-25 12:12:26 +02:00
Anatoly Trosinenko
6e04e1e164
[AArch64][PAC] Introduce AArch64::PAC pseudo instruction (#146488)
Introduce a pseudo instruction carrying address and immediate modifiers
as separate operands to be selected instead of a pair of `MOVKXi` and
`PAC[ID][AB]` . The new pseudo instruction is expanded in AsmPrinter, so
that `MOVKXi` is emitted immediately before `PAC[ID][AB]`. This way, an
attacker cannot control the immediate modifier used to sign
the value, even if address modifier can be substituted.

To simplify the instruction selection, select `AArch64::PAC` pseudo
using TableGen pattern and post-process its `$AddrDisc` operand by
custom inserter hook - this eliminates duplication of the logic for
DAGISel and GlobalISel. Furthermore, this improves cross-BB analysis in
case of DAGISel.
2025-07-25 13:10:37 +03:00