This is an archive of the discontinued LLVM Phabricator instance.

[PowerPC] Enable sret arguments.
ClosedPublic

Authored by sfertile on Dec 13 2019, 7:04 PM.

Details

Summary

Removes the fatal error for sret arguments and adds lit testing.

Diff Detail

Event Timeline

sfertile created this revision.Dec 13 2019, 7:04 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 13 2019, 7:04 PM
llvm/test/CodeGen/PowerPC/aix-sret-param.ll
37

What is the cause of this alignment value?

So it doesn't look like we need to add any special handling for struct returns on AIX? I had a quick look and none of the other PPC targets seem to have anything.

So it doesn't look like we need to add any special handling for struct returns on AIX? I had a quick look and none of the other PPC targets seem to have anything.

By the time we get the IR in this form from the front-end, we shouldn't need special handling here. We know the front-end does not represent complex types in an ideal way for AIX here.

sfertile marked an inline comment as done.Dec 16 2019, 9:49 AM

So it doesn't look like we need to add any special handling for struct returns on AIX? I had a quick look and none of the other PPC targets seem to have anything.

By the time we get the IR in this form from the front-end, we shouldn't need special handling here. We know the front-end does not represent complex types in an ideal way for AIX here.

We added the fatal_error in the previous patch in order to keep the patch as small and focused as possible. For back-end implementation everything should just work: we allocate a frame index for the object on the stack and pass a pointer to the frame-object as the argument. At that point its simply another pointer argument. As Hubert mentions though there is front-end (clang/CodeGen) work that is needed for generating the correct IR for AIX argument passing.

llvm/test/CodeGen/PowerPC/aix-sret-param.ll
37

Frame object alignment smaller then 8 gets promoted ... but I'm not exactly sure why 8 as opposed to 4 or 16. I'll figure out where the 8 comes from.

We added the fatal_error in the previous patch in order to keep the patch as small and focused as possible. For back-end implementation everything should just work: we allocate a frame index for the object on the stack and pass a pointer to the frame-object as the argument. At that point its simply another pointer argument. As Hubert mentions though there is front-end (clang/CodeGen) work that is needed for generating the correct IR for AIX argument passing.

I don't know what happens in the case where the front-end doesn't handle some cases correctly but the back-end does. Is there a danger in enabling this in the back-end knowing we don't get correct IR for complex types for AIX? Is there an error in the front-end for those before we get to this step?

llvm/test/CodeGen/PowerPC/aix-sret-param.ll
1–3

Do we need '-verify-machineinstrs` in these tests?

I don't know what happens in the case where the front-end doesn't handle some cases correctly but the back-end does. Is there a danger in enabling this in the back-end knowing we don't get correct IR for complex types for AIX? Is there an error in the front-end for those before we get to this step?

There's no error from the front-end. In terms of continuous delivery, this leads to silently bad code that could lead to incorrect output or crashes at runtime.

sfertile marked 2 inline comments as done.Dec 17 2019, 10:14 AM
sfertile added inline comments.
llvm/test/CodeGen/PowerPC/aix-sret-param.ll
1–3

Yes, good call.

37

When determining the alignment of the frame object we consider 3 different alignments and take the maximum of those. The three alignments are

  1. The preferred aggregate alignment which is 8 by default: here
  2. The alignment from the StructLayout object.
  3. The alignment on the alloca instruction.

So any alignment less then 8 will get promoted to 8 when creating the frame object.

llvm/test/CodeGen/PowerPC/aix-sret-param.ll
37

Got it. Thanks for looking into this.

sfertile updated this revision to Diff 234941.Dec 20 2019, 11:58 AM

Rebased and added '-verify-machineinstrs` to the run commands.

sfertile marked 4 inline comments as done.Dec 20 2019, 12:08 PM

I don't know what happens in the case where the front-end doesn't handle some cases correctly but the back-end does. Is there a danger in enabling this in the back-end knowing we don't get correct IR for complex types for AIX? Is there an error in the front-end for those before we get to this step?

There's no error from the front-end. In terms of continuous delivery, this leads to silently bad code that could lead to incorrect output or crashes at runtime.

I think if the front-end AIX support was further along then a patch like this should be deferred until we fixed (and verified) the IR the front-end generates for sret arguments. With how clang/CodeGen is going through the SVR4 targets for AIX its safe to consider any Clang AIX support as extremely experimental right now, and the back-end implementation shouldn't be held up based on Clang support for the target.

llvm/test/CodeGen/PowerPC/aix-sret-param.ll
37

np.

@sfertile, I'm not seeing the change to the test to add -verify-machineinstrs. Perhaps you have a newer version to upload?

sfertile updated this revision to Diff 234993.Dec 20 2019, 5:15 PM
sfertile marked an inline comment as done.

Uploaded wrong diff last time.

I think if the front-end AIX support was further along then a patch like this should be deferred until we fixed (and verified) the IR the front-end generates for sret arguments. With how clang/CodeGen is going through the SVR4 targets for AIX its safe to consider any Clang AIX support as extremely experimental right now, and the back-end implementation shouldn't be held up based on Clang support for the target.

Sounds reasonable. This patch LGTM.

This revision is now accepted and ready to land.Dec 20 2019, 6:28 PM
This revision was automatically updated to reflect the committed changes.