summaryrefslogtreecommitdiff
path: root/llvm/lib/Target/PowerPC/PPCFrameLowering.cpp
AgeCommit message (Collapse)Author
2025-11-10CodeGen: Remove TRI arguments from stack load/store hooks (#158240)Matt Arsenault
This is directly available in TargetInstrInfo
2025-09-23[MIR] Support save/restore points with independent sets of registers (#119358)Elizaveta Noskova
This patch adds the MIR parsing and serialization support for save and restore points with subsets of callee saved registers. That is, it syntactically allows a function to contain two or more distinct sub-regions in which distinct subsets of registers are spilled/filled as callee save. This is useful if e.g. one of the CSRs isn't modified in one of the sub-regions, but is in the other(s). Support for actually using this capability in code generation is still forthcoming. This patch is the next logical step for multiple save/restore points support. All points are now stored in DenseMap from MBB to vector of CalleeSavedInfo. Shrink-Wrap points split Part 4. RFC: https://discourse.llvm.org/t/shrink-wrap-save-restore-points-splitting/83581 Part 1: https://github.com/llvm/llvm-project/pull/117862 (landed) Part 2: https://github.com/llvm/llvm-project/pull/119355 (landed) Part 3: https://github.com/llvm/llvm-project/pull/119357 (landed) Part 5: https://github.com/llvm/llvm-project/pull/119359 (likely to be further split)
2025-08-12[llvm] Support multiple save/restore points in mir (#119357)Elizaveta Noskova
Currently mir supports only one save and one restore point specification: ``` savePoint: '%bb.1' restorePoint: '%bb.2' ``` This patch provide possibility to have multiple save and multiple restore points in mir: ``` savePoints: - point: '%bb.1' restorePoints: - point: '%bb.2' ``` Shrink-Wrap points split Part 3. RFC: https://discourse.llvm.org/t/shrink-wrap-save-restore-points-splitting/83581 Part 1: https://github.com/llvm/llvm-project/pull/117862 Part 2: https://github.com/llvm/llvm-project/pull/119355 Part 4: https://github.com/llvm/llvm-project/pull/119358 Part 5: https://github.com/llvm/llvm-project/pull/119359
2025-06-28[PowerPC] Use range-based for loops (NFC) (#146221)Kazu Hirata
2025-03-18[PowerPC] Avoid repeated hash lookups (NFC) (#131724)Kazu Hirata
Co-authored-by: Nikita Popov <github@npopov.com>
2025-03-16[PowerPC] Avoid repeated hash lookups (NFC) (#131498)Kazu Hirata
2025-02-20[FrameLowering] Use MCRegister instead of Register in CalleeSavedInfo. NFC ↵Craig Topper
(#128095) Callee saved registers should always be phyiscal registers. They are often passed directly to other functions that take MCRegister like getMinimalPhysRegClass or TargetRegisterClass::contains. Unfortunately, sometimes the MCRegister is compared to a Register which gave an ambiguous comparison error when the MCRegister is on the LHS. Adding a MCRegister==Register comparison operator created more ambiguous comparison errors elsewhere. These cases were usually comparing against a base or frame pointer register that is a physical register in a Register. For those I added an explicit conversion of Register to MCRegister to fix the error.
2025-02-18[PowerPC] Used named subreg indices instead of hardcoded numbers. NFC (#127671)Craig Topper
2025-02-18[PowerPC] Use MCRegister. NFCCraig Topper
2025-01-22[PowerPC] Fix saving of Link Register when using ROP Protect (#123101)Stefan Pintilie
An optimization was added that tries to move the uses of the mflr instruction away from the instruction itself. However, this doesn't work when we are using the hashst instruction because that instruction needs to be run before the stack frame is obtained. This patch disables moving instructions away from the mflr in the case where ROP protection is being used. --------- Co-authored-by: Lei Huang <lei@ca.ibm.com>
2025-01-14[llvm] Mark scavenging spill-slots as *spilled* stack objects. (#122673)Guy David
This seems like an oversight when copying code from other backends.
2024-11-04[PowerPC] Utilize getReservedRegs to find asm clobberable registers. (#107863)zhijian lin
This patch utilizes getReservedRegs() to find asm clobberable registers. And to make the result of getReservedRegs() accurate, this patch implements the todo, which is to make r2 allocatable on AIX for some leaf functions.
2024-10-18[llvm] Consistently respect `naked` fn attribute in ↵Alex Rønne Petersen
`TargetFrameLowering::hasFP()` (#106014) Some targets (e.g. PPC and Hexagon) already did this. I think it's best to do this consistently so that frontend authors don't run into inconsistent results when they emit `naked` functions. For example, in Zig, we had to change our emit code to also set `frame-pointer=none` to get reliable results across targets. Note: I don't have commit access.
2024-09-03[PowerPC] Use DenseMap::operator[] (NFC) (#107044)Kazu Hirata
2024-08-07[PPC][AIX] Save/restore r31 when using base pointer (#100182)Zaara Syeda
When the base pointer r30 is used to hold the stack pointer, r30 is spilled in the prologue. On AIX registers are saved from highest to lowest, so r31 also needs to be saved. Fixes https://github.com/llvm/llvm-project/issues/96411
2024-07-19CodeGen: Avoid some references to MachineFunction's getMMI (#99652)Matt Arsenault
MachineFunction's probably should not include a backreference to the owning MachineModuleInfo. Most of these references were used just to query the MCContext, which MachineFunction already directly stores. Other contexts are using it to query the LLVMContext, which can already be accessed through the IR function reference.
2024-06-20[PowerPC] use r1 as the frame pointer when there is dynamic allocaChen Zheng
On PPC, when there is dynamic alloca, only r1 points to the backchain.
2024-06-07[PowerPC] return correct frame address for frameaddress intrinsicChen Zheng
2024-05-07[PowerPC] Spill non-volatile registers required for traceback table (#71115)Maryam Moghadas
On AIX we need to spill all [rfv]N-[rfv]31 when a function clobbers [rfv]N so that the traceback table contains accurate information.
2024-04-15[NFC] Refactor looping over recomputeLiveIns into function (#88040)Kai Nacke
https://github.com/llvm/llvm-project/pull/79940 put calls to recomputeLiveIns into a loop, to repeatedly call the function until the computation converges. However, this repeats a lot of code. This changes moves the loop into a function to simplify the handling. Note that this changes the order in which recomputeLiveIns is called. For example, ``` bool anyChange = false; do { anyChange = recomputeLiveIns(*ExitMBB) || recomputeLiveIns(*LoopMBB); } while (anyChange); ``` only begins to recompute the live-ins for LoopMBB after the computation for ExitMBB has converged. With this change, all basic blocks have a recomputation of the live-ins for each loop iteration. This can result in less or more calls, depending on the situation.
2024-03-21[PowerPC] Clang format (NFC).Christudasan Devadasan
2024-03-02[PowerPC] provide CFI for ELF32 to unwind cr2, cr3, cr4 (#83098)George Koehler
Delete the code that skips the CFI for the condition register on ELF32. The code checked !MustSaveCR, which happened only when Subtarget.is32BitELFABI(), where spillCalleeSavedRegisters is spilling cr in a different way. The spill was missing CFI. After deleting this code, a spill of cr2 to cr4 gets CFI in the same way as a spill of r14 to r31. Fixes #83094
2024-01-30Refactor recomputeLiveIns to converge on added MachineBasicBlocks (#79940)Oskar Wirga
This is a fix for the regression seen in https://github.com/llvm/llvm-project/pull/79498 > Currently, the way that recomputeLiveIns works is that it will recompute the livein registers for that MachineBasicBlock but it matters what order you call recomputeLiveIn which can result in incorrect register allocations down the line. Now we do not recompute the entire CFG but we do ensure that the newly added MBB do reach convergence.
2024-01-26Revert "Refactor recomputeLiveIns to operate on whole CFG (#79498)"Nikita Popov
This reverts commit 59bf60519fc30d9d36c86abd83093b068f6b1e4b. Introduces a major compile-time regression.
2024-01-26Refactor recomputeLiveIns to operate on whole CFG (#79498)Oskar Wirga
Currently, the way that recomputeLiveIns works is that it will recompute the livein registers for that MachineBasicBlock but it matters what order you call recomputeLiveIn which can result in incorrect register allocations down the line. This PR fixes that by simply recomputing the liveins for the entire CFG until convergence is achieved. This makes it harder to introduce subtle bugs which alter liveness.
2023-12-01[llvm][PowerPC] Correct handling of spill slots for SPE when ↵David Spickett
EXPENSIVE_CHECKS is enabled (#73940) This was modifying a container as it iterated it, which tripped a check in libstdc++'s debug checks. Instead, just assign to the item via the reference we already have. This fixes the following expensive checks failures on my machine: LLVM :: CodeGen/PowerPC/fp-strict.ll LLVM :: CodeGen/PowerPC/pr55463.ll LLVM :: CodeGen/PowerPC/register-pressure.ll LLVM :: CodeGen/PowerPC/spe.ll Which are some of the tests noted by #68594.
2023-11-08[RegScavenger] Simplify state tracking for backwards scavenging (#71202)Jay Foad
Track the live register state immediately before, instead of after, MBBI. This makes it simple to track the state at the start or end of a basic block without a separate (and poorly named) Tracking flag. This changes the API of the backward(MachineBasicBlock::iterator I) method, which now recedes to the state just before, instead of just after, *I. Some clients are simplified by this change. There is one small functional change shown in the lit tests where multiple spilled registers all need to be reloaded before the same instruction. The reloads will now be inserted in the opposite order. This should not affect correctness.
2023-09-08[PEI][PowerPC] Fix false alarm of stack size limit (#65559)bzEq
PPC64 allows stack size up to ((2^63)-1) bytes. Currently llc reports ``` warning: stack frame size (4294967568) exceeds limit (4294967295) in function 'main' ``` if the stack allocated is larger than 4G.
2023-07-23[PowerPC/SPE] powerpcspe load and store instruction hasKishan Parmar
8-bit offset instead of 16-bit unlike other load/store instructions. so if stack grows any further than 8-bit, create one emergency slot for spilling.
2023-06-21PowerPC/SPE: Add phony registers for high halves of SPE SuperRegsKishan Parmar
The intent of this patch is to make upper halves of SPE SuperRegs(s0,..,s31) as artificial regs, similar to how X86 has done it. And emit store /reload instructions for the required halves. PR : https://github.com/llvm/llvm-project/issues/57307 Reviewed By: jhibbits Differential Revision: https://reviews.llvm.org/D152437
2023-05-23[PowerPC] Avoid RegScavenger::forward in PPCFrameLoweringJay Foad
RegScavenger::backward is preferred because it does not rely on accurate kill flags. Differential Revision: https://reviews.llvm.org/D150558
2023-04-15[Target] Use range-based for loops (NFC)Kazu Hirata
2022-12-17[CodeGen] Additional Register argument to ↵Christudasan Devadasan
storeRegToStackSlot/loadRegFromStackSlot With D134950, targets get notified when a virtual register is created and/or cloned. Targets can do the needful with the delegate callback. AMDGPU propagates the virtual register flags maintained in the target file itself. They are useful to identify a certain type of machine operands while inserting spill stores and reloads. Since RegAllocFast spills the physical register itself, there is no way its virtual register can be mapped back to retrieve the flags. It can be solved by passing the virtual register as an additional argument. This argument has no use when the spill interfaces are called during the greedy allocator or even the PrologEpilogInserter and can pass a null register in such cases. Reviewed By: arsenm Differential Revision: https://reviews.llvm.org/D138656
2022-11-22[PowerPC] store the LR before stack update for big offsets.Chen Zheng
For case that LROffset + FrameSize can not be encoded to the LR store instruction, we have to store the LR before the stack update.
2022-11-14[PowerPC] make expensive mflr be away from its user in the function prologueChen Zheng
mflr is kind of expensive on Power version smaller than 10, so we should schedule the store for the mflr's def away from mflr. In epilogue, the expensive mtlr has no user for its def, so it doesn't matter that the load and the mtlr are back-to-back. Reviewed By: RolandF Differential Revision: https://reviews.llvm.org/D137423
2022-09-08[llvm] Use std::size instead of llvm::array_lengthofJoe Loser
LLVM contains a helpful function for getting the size of a C-style array: `llvm::array_lengthof`. This is useful prior to C++17, but not as helpful for C++17 or later: `std::size` already has support for C-style arrays. Change call sites to use `std::size` instead. Differential Revision: https://reviews.llvm.org/D133429
2022-06-06[PowerPC] Support huge frame size for PPC64Kai Luo
Support allocation of huge stack frame(>2g) on PPC64. For ELFv2 ABI on Linux, quoted from the spec 2.2.3.1 General Stack Frame Requirements > There is no maximum stack frame size defined. On AIX, XL allows such huge frame. Reviewed By: #powerpc, nemanjai Differential Revision: https://reviews.llvm.org/D107886
2022-06-05[llvm] Convert for_each to range-based for loops (NFC)Kazu Hirata
2022-03-16Cleanup codegen includesserge-sans-paille
This is a (fixed) recommit of https://reviews.llvm.org/D121169 after: 1061034926 before: 1063332844 Discourse thread: https://discourse.llvm.org/t/include-what-you-use-include-cleanup Differential Revision: https://reviews.llvm.org/D121681
2022-03-15[PowerPC][P10] Add Vector pair calling conventionStefan Pintilie
Add the calling convention for the vector pair registers. These registers overlap with the vector registers. Part of an original patch by: Lei Huang Reviewed By: nemanjai, #powerpc Differential Revision: https://reviews.llvm.org/D117225
2022-03-10Revert "Cleanup codegen includes"Nico Weber
This reverts commit 7f230feeeac8a67b335f52bd2e900a05c6098f20. Breaks CodeGenCUDA/link-device-bitcode.cu in check-clang, and many LLVM tests, see comments on https://reviews.llvm.org/D121169
2022-03-10Cleanup codegen includesserge-sans-paille
after: 1061034926 before: 1063332844 Differential Revision: https://reviews.llvm.org/D121169
2022-01-26Revert "Rename llvm::array_lengthof into llvm::size to match std::size from ↵Benjamin Kramer
C++17" This reverts commit ef8206320769ad31422a803a0d6de6077fd231d2. - It conflicts with the existing llvm::size in STLExtras, which will now never be called. - Calling it without llvm:: breaks C++17 compat
2022-01-26Rename llvm::array_lengthof into llvm::size to match std::size from C++17serge-sans-paille
As a conquence move llvm::array_lengthof from STLExtras.h to STLForwardCompat.h (which is included by STLExtras.h so no build breakage expected).
2022-01-19[NFC] Use Register instead of unsignedJim Lin
2022-01-05[PowerPC] Add support for ROP protection for 32 bit.Stefan Pintilie
Add support for Return Oriented Programming (ROP) protection for 32 bit. This patch also adds a testing for AIX on both 64 and 32 bit. Reviewed By: amyk Differential Revision: https://reviews.llvm.org/D111362
2021-11-22[llvm] Use range-based for loops (NFC)Kazu Hirata
2021-11-21[llvm] Use range-based for loops (NFC)Kazu Hirata
2021-08-23[PowerPC] Use int64_t to represent stack object offset and frame sizeKai Luo
This is the first step to enable PPC64 support huge frame size(>2G). Also fix an assertion error for frame size, i.e.,`int x; !isInt<32>(x);` should be always evaluated false, so the guard code for frame size is impossible to hit. Reviewed By: jsji Differential Revision: https://reviews.llvm.org/D107435
2021-06-09[PowerPC] Make sure the first probe is full size or is the last probe when ↵Kai Luo
stack is realigned When `-fstack-clash-protection` is enabled and stack has to be realigned, some parts of redzone is written prior the probe, so probe might overwrite content already written in redzone. To avoid it, we have to make sure the first probe is at full probe size or is the last probe so that we can skip redzone. It also fixes violation of ABI under PPC where `r1` isn't updated atomically. This fixes https://bugs.llvm.org/show_bug.cgi?id=49903. Reviewed By: jsji Differential Revision: https://reviews.llvm.org/D100290