forked from rust-lang/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 38
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
Dynamic stack frame size support #26
Merged
alessandrod
merged 4 commits into
anza-xyz:solana-rustc/13.0-2021-08-08
from
alessandrod:dynamic-frames
Mar 8, 2022
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
af98455
[SOL] Variable size stack frames
dmakarov c7abbcd
[SOL] Tag SBF files setting e_flags to EF_SBF_V2 in ELF headers
alessandrod 3c9b7c0
[SOL] modify the stack pointer only if the stack isn't empty
alessandrod 8110fd3
[SOL] Add sbfv2 target cpu and the dynamic-frames feature
alessandrod File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,22 +52,11 @@ static void WarnSize(int Offset, MachineFunction &MF, DebugLoc& DL) | |
OldMF = &(MF.getFunction()); | ||
int MaxOffset = -1 * BPFRegisterInfo::FrameLength; | ||
if (Offset <= MaxOffset) { | ||
if (MF.getSubtarget<BPFSubtarget>().isSolana()) { | ||
dbgs() << "Error:"; | ||
if (DL) { | ||
dbgs() << " "; | ||
DL.print(dbgs()); | ||
} | ||
dbgs() << " Function " << MF.getFunction().getName() << " Stack offset of " << -Offset | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't we want to keep displaying this message for fixed solana stack frames? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yup nice catch, fixed |
||
<< " exceeded max offset of " << -MaxOffset << " by " | ||
<< MaxOffset - Offset << " bytes, please minimize large stack variables\n"; | ||
} else { | ||
DiagnosticInfoUnsupported DiagStackSize(MF.getFunction(), | ||
"BPF stack limit of 512 bytes is exceeded. " | ||
"Please move large on stack variables into BPF per-cpu array map.\n", | ||
DL); | ||
MF.getFunction().getContext().diagnose(DiagStackSize); | ||
} | ||
DiagnosticInfoUnsupported DiagStackSize(MF.getFunction(), | ||
"BPF stack limit of 512 bytes is exceeded. " | ||
"Please move large on stack variables into BPF per-cpu array map.\n", | ||
DL); | ||
MF.getFunction().getContext().diagnose(DiagStackSize); | ||
} | ||
} | ||
|
||
|
@@ -102,7 +91,9 @@ void BPFRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II, | |
if (MI.getOpcode() == BPF::MOV_rr) { | ||
int Offset = MF.getFrameInfo().getObjectOffset(FrameIndex); | ||
|
||
WarnSize(Offset, MF, DL); | ||
if (!MF.getSubtarget<BPFSubtarget>().getHasDynamicFrames()) { | ||
WarnSize(Offset, MF, DL); | ||
} | ||
MI.getOperand(i).ChangeToRegister(FrameReg, false); | ||
Register reg = MI.getOperand(i - 1).getReg(); | ||
BuildMI(MBB, ++II, DL, TII.get(BPF::ADD_ri), reg) | ||
|
@@ -117,7 +108,9 @@ void BPFRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II, | |
if (!isInt<32>(Offset)) | ||
llvm_unreachable("bug in frame offset"); | ||
|
||
WarnSize(Offset, MF, DL); | ||
if (!MF.getSubtarget<BPFSubtarget>().getHasDynamicFrames()) { | ||
WarnSize(Offset, MF, DL); | ||
} | ||
|
||
if (MI.getOpcode() == BPF::FI_ri) { | ||
// architecture does not really support FI_ri, replace it with | ||
|
This file contains 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
This file contains 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
This file contains 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
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.
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.
Is the total stack size known to llvm or does it allow overflow expecting the runtime to catch it?
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.
It can't be known statically and the runtime needs to handle overflows anyway for hand rolled code