-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[AMDGPU] Assert if stack grows downwards. #119888
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4041,17 +4041,15 @@ SDValue SITargetLowering::lowerDYNAMIC_STACKALLOCImpl(SDValue Op, | |
| Chain = SP.getValue(1); | ||
| MaybeAlign Alignment = cast<ConstantSDNode>(Tmp3)->getMaybeAlignValue(); | ||
| const TargetFrameLowering *TFL = Subtarget->getFrameLowering(); | ||
| unsigned Opc = | ||
| TFL->getStackGrowthDirection() == TargetFrameLowering::StackGrowsUp | ||
| ? ISD::ADD | ||
| : ISD::SUB; | ||
| assert(TFL->getStackGrowthDirection() == TargetFrameLowering::StackGrowsUp && | ||
| "Stack grows upwards for AMDGPU\n"); | ||
easyonaadit marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| SDValue ScaledSize = DAG.getNode( | ||
| ISD::SHL, dl, VT, Size, | ||
| DAG.getConstant(Subtarget->getWavefrontSizeLog2(), dl, MVT::i32)); | ||
|
|
||
| Align StackAlign = TFL->getStackAlign(); | ||
| Tmp1 = DAG.getNode(Opc, dl, VT, SP, ScaledSize); // Value | ||
| Tmp1 = DAG.getNode(ISD::ADD, dl, VT, SP, ScaledSize); // Value | ||
|
Contributor
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. (not related to this PR, but I thought it was worth reporting) If I'm reading correctly, the logic is broken for the case when the object alignment is greater than the stack alignment. Consider: The new address (32) is less than the previous value of the stack pointer (40). ADD
Contributor
Author
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. Hi,
This patch is actually just a part of fixing the logic flaw you pointed out. There is a fix in progress, you could follow it here:
Contributor
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. The default implementation is dead code for StackGrowsUp. I was going to fix it, but I couldn't add tests for the changes.
Contributor
Author
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. Other than scaling for wave size, the code changes in #119822 serve as a generic implementation for a growing up stack. And there are test cases along with it as well. Could this be replicated?
Contributor
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. The only other target that uses positive stack growth is NVPTX |
||
| if (Alignment && *Alignment > StackAlign) { | ||
| Tmp1 = DAG.getNode( | ||
| ISD::AND, dl, VT, Tmp1, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.