summaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/InitUndef.cpp
AgeCommit message (Collapse)Author
2025-01-30[CodeGen] Use non-static Register::virtRegIndex() instead of static ↵Craig Topper
Register::virtReg2Index. NFC (#125031) These are the the ones where we already had a Register object being used. Some places are still using unsigned which I did not convert.
2025-01-14[CodeGen] Remove unused argument from getCoveringSubRegIndexes. NFC. (#122884)Jay Foad
2024-11-28Reland "[InitUndef] handleSubReg should skip artificial subregs. (#116248)"Sander de Smalen
This patch can now reland after 318c69de52b6 relanded #114827. This reverts commit 1683f84d289348ba6879635c4161979204f75230.
2024-11-22Revert "[InitUndef] handleSubReg should skip artificial subregs. (#116248)" ↵Vitaly Buka
(#117365) Maybe not needed but to avoid conflicts with #117307 Without revert of this one, but reverting #117307, the regenerated init-undef.mir became empty. This reverts commit be15fd5085680cc5ed9ec4f4f2258b504cdd55db.
2024-11-14[InitUndef] handleSubReg should skip artificial subregs. (#116248)Sander de Smalen
When enabling subreg liveness tracking for AArch64, this pass fails because it tries to get the register class for the artificial subreg `sub_32_hi` of a 64-bit GPR. It tries to create an INIT_UNDEF instruction for the top 32-bits of the 64-bit GPR, which are not directly addressable, so getSubRegisterClass() returns a nullptr, crashing this pass. It should instead just avoid trying to create the INIT_UNDEF instruction.
2024-09-19[InitUndef] Also handle inline asm (#108951)Nikita Popov
InitUndef should also handle early-clobber / undef conflicts in inline asm operands. Do this by iterating over all_defs() instead of defs(). The newly added ARM test was generating an "unpredictable STXP instruction, status is also a source" error prior to this change. Fixes https://github.com/llvm/llvm-project/issues/106380.
2024-09-16[InitUndef] Enable the InitUndef pass on non-AMDGPU targets (#108353)Nikita Popov
The InitUndef pass works around a register allocation issue, where undef operands can be allocated to the same register as early-clobber result operands. This may lead to ISA constraint violations, where certain input and output registers are not allowed to overlap. Originally this pass was implemented for RISCV, and then extended to ARM in #77770. I've since removed the target-specific parts of the pass in #106744 and #107885. This PR reduces the pass to use a single requiresDisjointEarlyClobberAndUndef() target hook and enables it by default. The hook is disabled for AMDGPU, because overlapping early-clobber and undef operands are known to be safe for that target, and we get significant codegen diffs otherwise. The motivating case is the one in arm64-ldxr-stxr.ll, where we were previously incorrectly allocating a stxp input and output to the same register.
2024-09-12[CodeGen] Clear InitUndef pass new register cache between pass runs (#90967)Joe Faulls
Multiple invocations of the pass could interfere with eachother, preventing some undefs being initialised. I found it very difficult to create a unit test for this due to it being dependent on particular allocations of a previous function. However, the bug can be observed here: https://godbolt.org/z/7xnMo41Gv with the creation of the illegal instruction `vnsrl.wi v9, v8, 0`
2024-09-12[InitUndef] Only compute DeadLaneDetector if subreg liveness enabled (NFC) ↵Nikita Popov
(#108279) InitUndef currently always computes DeadLaneDetector, but only actually uses it if subreg liveness is enabled for the target. Make the calculation optional to avoid an unnecessary compile-time impact for targets that don't enable subreg liveness.
2024-09-11[InitUndef] Don't use largest super class (#107885)Nikita Popov
The InitUndef pass currently uses the getLargestSuperClass() hook (which is only used by that pass) to chose the register to initialize. This was done to reduce the number of undef init pseudos needed, e.g. so that the vrnov0 regclass would use the same pseudo as v0. After #106744 we use a single generic pseudo, so this is no longer necessary.
2024-09-05[CodeGen] Add generic INIT_UNDEF pseudo (#106744)Nikita Popov
The InitUndef pass currently uses target-specific pseudo instructions, with one pseudo per register class. Instead, add a generic pseudo instruction, which can be used by all targets and register classes.
2024-09-02[CodeGen] Update a few places that were passing Register to ↵Craig Topper
raw_ostream::operator<< (#106877) These would implicitly cast the register to `unsigned`. Switch most of them to use printReg will give a more readable output. Change some others to use Register::id() so we can eventually remove the implicit cast to `unsigned`.
2024-06-14[CodeGen] Remove target SubRegLiveness flags (#95437)David Green
This removes the uses of target flags to disable subreg liveness, relying on the `-enable-subreg-liveness` flag instead. The `-enable-subreg-liveness` flag has been changed to take precedence over the subtarget if set, and one use of `Subtarget->enableSubRegLiveness()` has been changed to `MRI->subRegLivenessEnabled()` to make sure the option properly applies.
2024-02-26[CodeGen] [ARM] Make RISC-V Init Undef Pass Target Independent and add ↵Jack Styles
support for the ARM Architecture. (#77770) When using Greedy Register Allocation, there are times where early-clobber values are ignored, and assigned the same register. This is illeagal behaviour for these intructions. To get around this, using Pseudo instructions for early-clobber registers gives them a definition and allows Greedy to assign them to a different register. This then meets the ARM Architecture Reference Manual and matches the defined behaviour. This patch takes the existing RISC-V patch and makes it target independent, then adds support for the ARM Architecture. Doing this will ensure early-clobber restraints are followed when using the ARM Architecture. Making the pass target independent will also open up possibility that support other architectures can be added in the future.