(1) The available program storage region of the red zone to compilers is 288 bytes rather than 244 bytes (both for ABI V1.9 and ABI V2).
(2) The formula for negative number alignment calculation should be y = x & ~(n-1) rather than y = (x + (n-1)) & ~(n-1).
Details
Diff Detail
Event Timeline
test/CodeGen/PowerPC/tailcall1-64.ll | ||
---|---|---|
2 | Does this change relate to frame lowering? |
test/CodeGen/PowerPC/tailcall1-64.ll | ||
---|---|---|
2 | This test case is modified to make sure the changes above don't regress the TCO. |
lib/Target/PowerPC/PPCFrameLowering.cpp | ||
---|---|---|
1877 | How are we testing this change? |
Address the comments from Nemanja and Stefan.
Add one test case to test the alignment calculation change.
So... I believe if we make this change as-is then we've dropped Darwin support. Darwin had a 224-byte red zone. I'm in favor of doing that, but I don't think we should just do it subtly like this. I'd add a check for Darwin for now (to keep the 224). Then we can rip it out with the rest of Darwin support when we do that.
lib/Target/PowerPC/PPCFrameLowering.cpp | ||
---|---|---|
1873 | Please add parens here (x + (n-1)) & (n-1). |
(1) Refactor the messy red zone guard conditions to make it more readable.
(2) Differentiate the red zone behavior for DarwinABI and Non-DarwinABI (SVR4ABI).
(3) Address comments from Hal.
lib/Target/PowerPC/PPCFrameLowering.cpp | ||
---|---|---|
471 | How about adding a function Subtarget.getAvailableRedZoneSize(), which returns 288 only when icPPC64 && isSVR4ABI and 224 otherwise? |
lib/Target/PowerPC/PPCFrameLowering.cpp | ||
---|---|---|
471 | I understand why you want to add that function, but if you look at the logic (!Subtarget.isPPC64()) && (FrameSize == 0) can not nicely fit into that refactor. If everything can be fit into the getAvailableRedZoneSize() function and we just use | |
1877 | I added one new test cases to test the alignment calculation change. |
lib/Target/PowerPC/PPCFrameLowering.cpp | ||
---|---|---|
471 | isSVR4ABI && isPPC64 -> return 288 isSVR4ABI && !isPPC64 -> return 0 other -> return 224 Is this representing the above conditions? (since FrameSize is unsigned FrameSize == 0 and FrameSize <= 0 is same.) |
LGTM. Just some minor updates in the comments.
lib/Target/PowerPC/PPCSubtarget.h | ||
---|---|---|
277 ↗ | (On Diff #105796) | Please change the Non-DarwinABI to SVR4ABI. |
test/CodeGen/PowerPC/ppc-redzone-alignment-bug.ll | ||
3 | Can you please replace "this issue" with the specific Review that is being fixed? | |
11 | Again, instead of "the fix" specify the review this is being done under. |
How about adding a function Subtarget.getAvailableRedZoneSize(), which returns 288 only when icPPC64 && isSVR4ABI and 224 otherwise?