-
Notifications
You must be signed in to change notification settings - Fork 14.4k
[LoongArch] Strengthen stack size estimation for LSX/LASX extension #146455
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tangaac
wants to merge
1
commit into
llvm:main
Choose a base branch
from
tangaac:spill-register
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+350
−345
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@llvm/pr-subscribers-backend-loongarch Author: None (tangaac) ChangesFull diff: https://github.com/llvm/llvm-project/pull/146455.diff 2 Files Affected:
diff --git a/llvm/lib/Target/LoongArch/LoongArchRegisterInfo.cpp b/llvm/lib/Target/LoongArch/LoongArchRegisterInfo.cpp
index 47fce37ce59f6..b3a6ca9acad63 100644
--- a/llvm/lib/Target/LoongArch/LoongArchRegisterInfo.cpp
+++ b/llvm/lib/Target/LoongArch/LoongArchRegisterInfo.cpp
@@ -29,7 +29,6 @@ using namespace llvm;
#define GET_REGINFO_TARGET_DESC
#include "LoongArchGenRegisterInfo.inc"
-
LoongArchRegisterInfo::LoongArchRegisterInfo(unsigned HwMode)
: LoongArchGenRegisterInfo(LoongArch::R1, /*DwarfFlavour*/ 0,
/*EHFlavor*/ 0,
@@ -254,3 +253,15 @@ bool LoongArchRegisterInfo::canRealignStack(const MachineFunction &MF) const {
// reserve it.
return MRI->canReserveReg(LoongArchABI::getBPReg());
}
+
+bool LoongArchRegisterInfo::saveScavengerRegister(
+ MachineBasicBlock &MBB, MachineBasicBlock::iterator I,
+ MachineBasicBlock::iterator &UseMI, const TargetRegisterClass *RC,
+ Register Reg) const {
+
+ DebugLoc DL;
+ const TargetInstrInfo &TII = *MBB.getParent()->getSubtarget().getInstrInfo();
+ TII.copyPhysReg(MBB, I, DL, LoongArch::R12, Reg, true);
+ TII.copyPhysReg(MBB, UseMI, DL, Reg, LoongArch::R12, true);
+ return true;
+}
\ No newline at end of file
diff --git a/llvm/lib/Target/LoongArch/LoongArchRegisterInfo.h b/llvm/lib/Target/LoongArch/LoongArchRegisterInfo.h
index d1e40254c2972..e9e7ee930f7f6 100644
--- a/llvm/lib/Target/LoongArch/LoongArchRegisterInfo.h
+++ b/llvm/lib/Target/LoongArch/LoongArchRegisterInfo.h
@@ -52,6 +52,11 @@ struct LoongArchRegisterInfo : public LoongArchGenRegisterInfo {
return true;
}
bool canRealignStack(const MachineFunction &MF) const override;
+ bool saveScavengerRegister(MachineBasicBlock &MBB,
+ MachineBasicBlock::iterator I,
+ MachineBasicBlock::iterator &UseMI,
+ const TargetRegisterClass *RC,
+ Register Reg) const override;
};
} // end namespace llvm
|
heiher
reviewed
Jul 8, 2025
@@ -158,7 +158,12 @@ void LoongArchFrameLowering::processFunctionBeforeFrameFinalized( | |||
// estimateStackSize has been observed to under-estimate the final stack | |||
// size, so give ourselves wiggle-room by checking for stack size | |||
// representable an 11-bit signed field rather than 12-bits. | |||
if (!isInt<11>(MFI.estimateStackSize(MF))) | |||
// For [x]vstelm.{b/h/w/d} memory instructions with 8 imm offset, 7-bit | |||
// signed field is fine. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a test case for this?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This patch is to add an emergency spill slot when ran out of registers.
PR #139201 introduces
vstelm
instructions with only 8-bit imm offset,it causes no spill slot to store the spill registers.