-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[CodeGen] Get stack alignment from TargetFrameLowering #105477
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 all commits
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 |
---|---|---|
|
@@ -9133,9 +9133,10 @@ LegalizerHelper::lowerMemcpy(MachineInstr &MI, Register Dst, Register Src, | |
// Don't promote to an alignment that would require dynamic stack | ||
// realignment. | ||
const TargetRegisterInfo *TRI = MF.getSubtarget().getRegisterInfo(); | ||
if (!TRI->hasStackRealignment(MF)) | ||
while (NewAlign > Alignment && DL.exceedsNaturalStackAlignment(NewAlign)) | ||
NewAlign = NewAlign.previous(); | ||
if (!TRI->hasStackRealignment(MF)) { | ||
const TargetFrameLowering *TFL = MF.getSubtarget().getFrameLowering(); | ||
NewAlign = std::min(NewAlign, std::max(Alignment, TFL->getStackAlign())); | ||
} | ||
|
||
if (NewAlign > Alignment) { | ||
Alignment = NewAlign; | ||
|
@@ -9241,9 +9242,10 @@ LegalizerHelper::lowerMemmove(MachineInstr &MI, Register Dst, Register Src, | |
// Don't promote to an alignment that would require dynamic stack | ||
// realignment. | ||
const TargetRegisterInfo *TRI = MF.getSubtarget().getRegisterInfo(); | ||
if (!TRI->hasStackRealignment(MF)) | ||
while (NewAlign > Alignment && DL.exceedsNaturalStackAlignment(NewAlign)) | ||
NewAlign = NewAlign.previous(); | ||
if (NewAlign > Alignment && !TRI->hasStackRealignment(MF)) { | ||
const TargetFrameLowering *TFL = MF.getSubtarget().getFrameLowering(); | ||
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. Can we assert that the TFL value is the same as the datalayout? Preferably we wouldn't have 2, and only have the DL one? 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 don't like having two of them either, but AIUI the one from DataLayout is more of a heuristic. 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 TFL one is also another fixed constant, just set in a different place 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.
It appears they values are different on AMDGPU. Data layout string specifies "S32" (4 bytes), but TFL value is 16 bytes. I couldn't conclude if this is intended or an oversight. 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. It's not intended. I don't know what the DataLayout one is even used for, it should change to match 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 DataLayout one is used in similar scenarios, but in middle end passes. I.e. when promoting alloca alignment. |
||
NewAlign = std::min(NewAlign, TFL->getStackAlign()); | ||
} | ||
|
||
if (NewAlign > Alignment) { | ||
Alignment = NewAlign; | ||
|
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.
There is a lot of code duplication. Why not move this code into a function and use it everywhere?
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.
Thanks for the suggestion. I'll try to find a common place, or maybe you can suggest one?