283465 Commits

Author SHA1 Message Date
Vitaly Buka
a3093e56fc [NFC][llvm-mt] Move XmlDeleter declaration 2025-02-23 22:38:32 -08:00
Craig Topper
6053ca004a
[MC][CodeGen] Move FirstStackSlot and VirtualRegFlag from MCRegister to Register. NFC (#128444)
These concepts don't exist for MCRegister.

I think there is a need for virtual registers in MCRegister for NVPTX,
SPIR-V and WebAssembly, but those should not be confused with Register's
virtual register. I will try to make a separate proposal for that with a
real interface.
2025-02-23 19:56:49 -08:00
Craig Topper
03610af3d5 [RISCV] Remove Inst bits from Pseudo tablegen class. NFC
Pseudods shouldn't have encoding information so these bits should
never be used.
2025-02-23 15:08:55 -08:00
Dmitry Nechitaev
14f33c6bc1
[llvm-objcopy][mach-o] Fix section finding logic for object files (#127604)
Fix section finding logic for object files.
As by product, make --update-section functional when the input is an object file.

This PR fixes #127495
2025-02-23 11:17:58 -08:00
Fangrui Song
78bac7f0a6 [MC] Remove unneeded getMemtagAttr() 2025-02-23 10:56:59 -08:00
Florian Hahn
65e44b4301 [LV] Add tests with deref assumptions and non-constant sizes. 2025-02-23 18:21:22 +00:00
Fangrui Song
34387fc63b
[AsmPrinter] Simplify $local after D131429. NFC
setType is unneeded (and AsmPrinter tries not to modify symbols).
AsmPrinter. MCSA_ELF_TypeFunction is available on all
targets using getSymbolPreferLocal.

Pull Request: https://github.com/llvm/llvm-project/pull/128138
2025-02-23 10:19:27 -08:00
Kazu Hirata
303825d2ab
[Analysis] Avoid repeated hash lookups (NFC) (#128394) 2025-02-23 08:47:02 -08:00
Veera
9d1fbbd2b9
[SROA][NFC] Remove Unused Parameter in promoteAllocas() (#128382)
Removing it because `Function &F` is not used by `promoteAllocas()`.
2025-02-23 11:17:43 -05:00
Robert Imschweiler
cafad2b75a
[AMDGPU] Add verification for amdgcn.init.exec.from.input (#128172)
Check that the input register is an inreg argument to the parent
function. (See the comment in `IntrinsicsAMDGPU.td`.)

This LLVM defect was identified via the AMD Fuzzing project.

---------

Co-authored-by: Matt Arsenault <arsenm2@gmail.com>
2025-02-23 10:42:31 -05:00
Florian Hahn
72791fef6d [VPlan] Remove unused buildPlainCFG from unit tests (NFC).
Also clarify the name of buildHCFG -> buildVPlan.
2025-02-23 13:38:42 +00:00
Jonas Hahnfeld
9e82ee5274
[Support] Remove AlignedCharArrayUnion from Expected and ErrorOr, NFCI. (#127407)
They were instantiated with only a single type and union-members
themselves. By putting the types directly into a union, they are still
left uninitialized by default.
2025-02-23 12:34:44 +01:00
Florian Hahn
b72bbfc293 [VPlan] Remove fixHeaderPhis (NFC).
Removes unneeded code after https://github.com/llvm/llvm-project/pull/124432.
2025-02-23 10:51:20 +00:00
Yingwei Zheng
2071ea24a2
[LVI] Skip self loops in solveBlockValueNonLocal (#127763)
We cannot infer more information from backedges in
`solveBlockValueNonLocal`. However, since DT is unavailable in LVI,
there is not a precise way to check whether a BB edge is a backedge.
This patch only skips self loops to unblock the range analysis.

The motivating case is extracted from
https://github.com/llvm/llvm-project/pull/127663.

Compile-time impact is high:
https://llvm-compile-time-tracker.com/compare.php?from=84ddda58c870681dd12ed765e9d59d5e00567f94&to=af032f1351358f2f5b5d9f4e87c5601c23b9bd37&stat=instructions:u
2025-02-23 17:52:38 +08:00
Yeaseen
96c723374a
[llvm] Remove br i1 undef from some llvm/test/CodeGen tests (#128272) 2025-02-23 09:23:33 +00:00
Yingwei Zheng
2ebc69a521
[InstCombine] Add support for GEPs in simplifyNonNullOperand (#128365)
Alive2: https://alive2.llvm.org/ce/z/2KE8zG
2025-02-23 17:19:31 +08:00
Kazu Hirata
929d70a38d
[llvm-jitlink] Avoid repeated hash lookups (NFC) (#128399) 2025-02-23 01:05:13 -08:00
Kazu Hirata
fb19bddbc5
[SPIRV] Avoid repeated hash lookups (NFC) (#128398) 2025-02-23 01:04:11 -08:00
Kazu Hirata
9dd8c14443
[IR] Avoid repeated map lookups (NFC) (#128396) 2025-02-23 01:03:46 -08:00
Kazu Hirata
b0d1c51a17
[DebugInfo] Avoid repeated hash lookups (NFC) (#128395) 2025-02-23 01:03:22 -08:00
Lang Hames
33f2686bed [llvm-jitlink] Only use candidate library extensions during library search.
While processing library link options that check search paths (-lx, -hidden-lx,
etc.) we shouldn't generate candidate paths with extensions that are invalid
for the option being visited (e.g. -hidden-lx only applies to archives, so we
shouldn't generate candidates with `.so` extensions).

Note: Candidate extensions should probably be further filtered based on the OS
of the executing process. This patch is a step in the right direction though.
2025-02-23 18:16:10 +11:00
Lang Hames
21939c4c2e [ORC] Fix type name in comments. NFC. 2025-02-23 18:16:10 +11:00
Craig Topper
4efad490af [WebAssembly] Use Register instead of unsigned. NFC 2025-02-22 22:45:06 -08:00
Craig Topper
b38d472055 [ARM] Prevent converting a virtual register to MCRegister. NFC 2025-02-22 22:27:14 -08:00
Craig Topper
228dbd254a [RegAllocGreedy] Use MCRegister instead of Register for functions that return a physical register.
The callers of these functions return the value as an MCRegister
so this removes some casts from Register to MCRegister.
2025-02-22 21:39:25 -08:00
Craig Topper
57b445862d
[LiveRegUnits] Use MCRegister instead of MCPhysReg in interface. NFC (#128232) 2025-02-22 21:20:45 -08:00
Craig Topper
a26fd0b75f
[LivePhysReg] Fix off by 1 error in an assert. NFC (#128379)
Reg should not be equal to the number of registers.
2025-02-22 21:13:46 -08:00
Kazu Hirata
0963f0d645
[AMDGPU] Avoid repeated hash lookups (NFC) (#128393) 2025-02-22 21:03:23 -08:00
Yingwei Zheng
dbd219aef4
[DAGCombiner][X86] Correctly clean up high bits in combinei64TruncSrlAdd (#128353)
A counterexample for original implementation:
https://alive2.llvm.org/ce/z/7ieYLg
This patch uses zext instead of anyext to fix the original issue.
BTW, we should keep low `64 - shamt` bits instead of `shamt - 32`:
https://alive2.llvm.org/ce/z/ruQP_Z
Some codes are simplified to avoid confusion.
Proof: https://alive2.llvm.org/ce/z/z_jdHD

Closes https://github.com/llvm/llvm-project/issues/128309.
2025-02-23 12:57:45 +08:00
Matt Arsenault
ccad5e7744
AMDGPU: Respect amdgpu-no-agpr in functions and with calls (#128147)
Remove the MIR scan to detect whether AGPRs are used or not,
and the special case for callable functions. This behavior was
confusing, and not overridable. The amdgpu-no-agpr attribute was
intended to avoid this imprecise heuristic for how many AGPRs to
allocate. It was also too confusing to make this interact with
the pending amdgpu-num-agpr replacement for amdgpu-no-agpr.

Also adds an xfail-ish test where the register allocator asserts
after allocation fails which I ran into.

Future work should reintroduce a more refined MIR scan to estimate
AGPR pressure for how to split AGPRs and VGPRs.
2025-02-23 09:00:37 +07:00
Craig Topper
0bd66c4194 [RegAllocGreedy] Remove unnecessary conversion from MCRegister to Register. NFC 2025-02-22 16:20:19 -08:00
Craig Topper
6fe780ce63 [RegAllocGreedy] Use Register() instead of 0 for invalid Register. NFC 2025-02-22 16:20:19 -08:00
Vitaly Buka
50b0669e84
Revert "[X86] combineBROADCAST_LOAD - merge across chains" (#128380)
Reverts llvm/llvm-project#128209

Introduces "AddressSanitizer: use-after-poison".
2025-02-22 16:15:41 -08:00
Craig Topper
bac6e7b651
[RISCV][VLOpt] Put vmclr/vmset back in the RISCVVPseudo table. (#128293)
This allows them to be supported by the VLOptimizer.
2025-02-22 15:30:35 -08:00
Philip Reames
a7d578dcce [RISCV][TTI] Avoid complicated fallthrough in getShuffleCost [nfc]
Just making the control flow easier to follow.
2025-02-22 15:16:59 -08:00
Philip Reames
f5f55ade3a [RISCV][TTI] Common a check in getShufleCost [nfc]
None of the vector costings apply if we're scalarizing.  Pull that check
into an early guard instead.
2025-02-22 15:00:18 -08:00
Craig Topper
9b7bf1fdd3 [RISCV] Set the SEW field in the VPseudoTiedBinaryRoundingMode.
Noticed some oddities in the InversePseudo table. TIED pseudos are
in there but sorted differently than their non-TIED version. I think
we always check non-zero SEW first which should hit the non-tied version.

I'm working on a larger patch to remove _MASK and _TIED from the
InversePseudo table.
2025-02-22 14:36:50 -08:00
Florian Hahn
0859df4e42 [VPlan] Use operands from initial VPInstructions directly (NFC).
Use operands from VPInstructions directly during recipe creation.

Follow-up as discussed and planned after
https://github.com/llvm/llvm-project/pull/124432.
2025-02-22 22:34:35 +00:00
Justin Bogner
f404047ab2
[DirectX][OpLowering] Simplify named struct handling (#128247)
This removes "replaceFunctionWithNamedStructOp" and folds its
functionality into "replaceFunctionWithOp". It turns out we were
overcomplicating things and this is trivial to handle generically.

Fixes #113192
2025-02-22 12:33:09 -08:00
Fangrui Song
75bb25b682 [Xtensa] Use asMCReg after #128095 2025-02-22 11:48:01 -08:00
Craig Topper
9e8d11d2df
[X86] Check that the type is integer before calling isUnsignedIntSetCC in combineExtSetcc. (#128263)
SETULT can be an unsigned less than integer compare or a unordered less
than FP compare. We need to check the VT to distinguish them.

Fixes on of the issues from #128237.
2025-02-22 10:10:51 -08:00
ur4t
62c78919c6
[CMake] Fix some breakages when using ninja multi config (#65451)
When using multi-config generator to build `libLLVM.so` like `cmake -G
'Ninja Multi-Config' -Sllvm -B/tmp/out/ninja-multi
-DCMAKE_CONFIGURATION_TYPES='Debug;Release' -DLLVM_LINK_LLVM_DYLIB=on
-DLLVM_TARGETS_TO_BUILD=host && cmake --build /tmp/out/ninja-multi
--config Debug`, `lld` complains `error: cannot find version script
/tmp/out/ninja-multi/Debug/lib/tools/llvm-shlib/simple_version_script.map`.

This patch adds multi-config compatibility when configuring
`simple_version_script.map`.

Fixes #63800.


When using multi-config generator, clang's headers is not copied to
proper directories, which is fixed as well.
2025-02-22 09:52:53 -08:00
Florian Hahn
30f44c9627 [VPlan] Set values for non-header phis at construction. (NFC)
Update HCFG builder to set the incoming values directly at construction
for non-header phis.

Simplification/clarification as suggested independently in
https://github.com/llvm/llvm-project/pull/126388.
2025-02-22 17:27:10 +00:00
Simon Pilgrim
e21a1737f3
[X86] combineBROADCAST_LOAD - merge across chains (#128209)
Remove the restriction when reusing wider BROADCAST_LOAD nodes that both nodes couldn't have uses of their load chains - use makeEquivalentMemoryOrdering to merge the chains instead.
2025-02-22 15:59:25 +00:00
Teresa Johnson
eb92157399
[MemProf] Add ability to export or highlight only a portion of graph (#128255)
To simplify debugging and analysis, particularly for very large
applications with large graphs, this patch adds support for either
highlighting a single context id or allocation's context ids, and/or
only exporting the nodes/edges for a single context id or allocation's
context ids. When highlighting, the specified nodes and edges are a
brighter color and larger.

This can be controlled by the new -memprof-dot-scope={all,alloc,context}
flag which controls how much to export, along with two companion flags:
	-memprof-dot-alloc-id=ID
	-memprof-dot-context-id=ID
These two are interpreted differently depending on the value of
-memprof-dot-scope (where "all" is the default).

If exporting all, one of the above flags can optionally be passed to
highlight the nodes/edges for the given context id or allocation's
context ids.

If exporting alloc scope, an alloc id must be provided. A context id can
optionally be provided to highlight that context.

If exporting context scope, a context id must be provided.

The ids to use can be obtained either by looking at the full graph, or a
context id can be identified from the -memprof-report-hinted-sizes
output after PR128188 is merged.
2025-02-22 05:42:46 -08:00
Teresa Johnson
9d6f2647de
[MemProf] Print internal context id when reporting bytes hinted (#128188)
During the whole program reporting of contexts when hinted byte
reporting is enabled via -memprof-report-hinted-sizes, also print the
internal context id. This is useful for debugging, as well as for
guiding the dot file dumping with some upcoming changes that will
accept a context id to focus the graph on a context of interest.
2025-02-22 05:42:28 -08:00
Phoebe Wang
fa64a210b8
[X86][FP16] Adding lowerings for FP16 ISD::LRINT and ISD::LLRINT (#127382)
Address comment in #126477
2025-02-22 21:17:26 +08:00
Luke Lau
e23ab73335
[VPlan] Don't convert widen recipes to VP intrinsics in EVL transform (#127180)
This is a copy of #126177, since it was automatically and permanently
closed because I messed up the source branch on my remote

This patch proposes to avoid converting widening recipes to VP
intrinsics during the EVL transform.

IIUC we initially did this to avoid `vl` toggles on RISC-V. However we
now have the RISCVVLOptimizer pass which mostly makes this redundant.

Emitting regular IR instead of VP intrinsics allows more generic
optimisations, both in the middle end and DAGCombiner, and we generally
have better patterns in the RISC-V backend for non-VP nodes. Sticking to
regular IR instructions is likely a lot less work than reimplementing
all of these optimisations for VP intrinsics, and on SPEC CPU 2017 we get
noticeably better code generation.
2025-02-22 19:38:11 +08:00
Florian Hahn
b74413bf91 [VPlan] Use VPSingleDef instead of VPValue in HCFG builder (NFC).
Use VPSingleDef to remove unneeded casts to a recipe type.
2025-02-22 11:15:37 +00:00
Mikhail Gudim
f5d153ef26
[VectorCombine] Fold binary op of reductions. (#121567)
Replace binary of of two reductions with one reduction of the binary op
applied to vectors. For example:

```
%v0_red = tail call i32 @llvm.vector.reduce.add.v16i32(<16 x i32> %v0)
%v1_red = tail call i32 @llvm.vector.reduce.add.v16i32(<16 x i32> %v1)
%res = add i32 %v0_red, %v1_red
```
gets transformed to:

```
%1 = add <16 x i32> %v0, %v1
%res = call i32 @llvm.vector.reduce.add.v16i32(<16 x i32> %1)
```
2025-02-22 06:11:33 -05:00