-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[GlobalIsel] Avoid aligning alloca size. #132064
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
base: main
Are you sure you want to change the base?
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 |
---|---|---|
|
@@ -114,7 +114,7 @@ define void @f5() { | |
; CHECK-NEXT: lgr %r11, %r15 | ||
; CHECK-NEXT: .cfi_def_cfa_register %r11 | ||
; CHECK-NEXT: lgr %r1, %r15 | ||
; CHECK-NEXT: aghi %r1, -128 | ||
; CHECK-NEXT: aghi %r1, -124 | ||
; CHECK-NEXT: la %r2, 280(%r1) | ||
; CHECK-NEXT: nill %r2, 65408 | ||
; CHECK-NEXT: lgr %r15, %r1 | ||
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. This looks clearly wrong. The sequence 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. Off hand I am surprised my change has kicked in for this test since it is a static alloca:
I expected this return to be reached but it is not. I will investigate further and get back once I understand the issue. 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. isStackRealignable() is false on SystemZ, so it's treated as a dynamic allocation. 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. I see that
With my change, we get 4 + (128 - 8) which is 124. It makes sense that we would want Do you think it is reasonable to add the code rounding the alloca size up to the nearest I think the SPARC backend has the same behavior. 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. I'm not convinced that isStackRealignable() is relevant here. That only changes the behavior for overaligned allocas with compile-time constant sizes. For a non-constant size, we'd still have the same problem even if isStackRealignable() were true. I think the core issue may rather be the assumption whether (or not) the result of a But on other targets, like s390x, these are two different values - on s390x at the very bottom of the stack there is an ABI mandated area for outgoing arguments and a register save area, which is preserved even across dynamic allocations. In this case the dynamic allocation result in two new values: a new stack pointer (which must respect the stack alignment) and a result pointer (which must respect the alloca alignment requirement). I don't have a strong opinion on whether the alignment code should generated by common code or the target back-end. However, the interface should be clearly defined - specifically, what if any assumptions the back-end implementation of lowering
If this is no longer correct, the documentation needs to be updated (and existing code that may have relied on that documentation should be reviewed). 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.
Agreed I think the property I am looking for is something like: whether the target uses the stack pointer as the result of
Makes sense, thanks for the explanation.
Agreed I would need to update this documentation and audit existing uses. That may be too much effort for this change. GlobalISel uses an opcode called
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. I'm not really familiar with the GlobalISel side of things, sorry - we don't support this on SystemZ at the moment. 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. I removed the change to |
||
|
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.
@aemerson does this change seem reasonable to you?