This is an archive of the discontinued LLVM Phabricator instance.

[PPC] PPC32/Darwin ABI info
Needs ReviewPublic

Authored by kparzysz on May 24 2017, 8:40 AM.

Details

Summary

Use the default implementation of EmitVAArg instead of the SVR4 one. This is meant to address PR33108.

The motivating testcase:

void foo() {
  __builtin_va_list va;
  __builtin_va_arg(va, int);
}

Compiling with clang -target powerpc-unknown-macosx -S test.c results in a crash.

Diff Detail

Repository
rL LLVM

Event Timeline

kparzysz created this revision.May 24 2017, 8:40 AM
kparzysz updated this revision to Diff 100105.May 24 2017, 8:52 AM

Add implementation of EmitVAArg and explicitly call emitVoidPtrVAArg in it.

kparzysz updated this revision to Diff 100720.May 30 2017, 9:14 AM
kparzysz retitled this revision from [PPC] First approximation of PPC32/Darwin ABI info to [PPC] PPC32/Darwin ABI info.
kparzysz edited the summary of this revision. (Show Details)

This patch corrects the ABI alignment issues for arguments of size greater than 4: all types except vector and aggregates will be aligned at 4-byte boundary in the parameter area. Vectors and aggregates will follow their natural alignment.

Ping. The bug reporter has verified that this patch fixes the problem.

nemanjai edited edge metadata.Jun 20 2017, 2:37 PM
nemanjai added subscribers: iains, echristo.

I'm not sure how much expertise there is for PPC32-Darwin. Perhaps @iains might be able to offer some insight here. Also, @echristo might have a thing or two to say in this regard.

iains added a comment.Jun 22 2017, 1:57 AM

This seems like a reasonable start, and is a step forward.
For the VAArgs, this will be self-consistent, but to be compliant with the system ABI, I think you'll need to account the different padding rules for small aggregates, as per pp14 of "Mac_OS_X_ABI_Function_Calls". Specifically, 1 and 2 byte aggregates are right-aligned and padded on the left, but sizes 3 and above are left-aligned and padded on the right.

I have a more complete ABIInfo implementation, but it needs forward-porting to trunk. Will let you know when that's done.

Great! Thanks.

@iains - I have interest in resolving this issue, and also a couple of other lingering bugs in the PPC32Darwin ABI realm. If you have your WIP available anywhere, I'd be happy to have a go at bringing it up to current.

@iains - I have interest in resolving this issue, and also a couple of other lingering bugs in the PPC32Darwin ABI realm. If you have your WIP available anywhere, I'd be happy to have a go at bringing it up to current.

A decision was made a while ago to remove Darwin support from the PPC back end. This was decided due to very little use of the code and essentially no maintenance being done on it. I think that support was already turned off in ToT with the plan to slowly rip out the code over the next couple of releases. So I believe that any improvements you plan to make it will need to be done on an older release out of tree unless you can make a compelling case for keeping this support in LLVM. Tagging some of the interested parties (@kbarton @hfinkel @echristo).

Since that's my understanding too - I am (slowly) bringing my patches forward to 7.0 - at the moment testing the MC layer changes on powerpc-darwin9 (looking reasonable, as an assembler for GCC, so far). When things are "ready" (at least not broken as far as I can tell) - will push them to my github (iains).

I think the parting comment was that if /when it's coherent enough to warrant re-inclusion (or there are enough developer cycles to maintain it)... then that could be discussed.

I saw that idea floated but didn't see that it was accepted. I don't know exactly how much interest there is in darwin PPC. There are new tickets about Darwin PPC within the past few months. I see plenty of questions about it on the MacPorts boards.

I have clang/llvm-5.0 and clang/llvm-3.8 running now on 10.5 PPC with a 98% pass on the test suite. I use it to build things on a daily basis. The compiler_rt build is messy still, otherwise I would push it to MacPorts now.

AFAICT, darwin PPC is missing only support for non-default exceptions (there is a ticket about that), and this va_args thing. Everything else seems to be working and intact.

I have the patch in this ticket already incorporated in my builds.

I found the relevant recent discussions on the mailing list, and the commits from August that started the Darwin PPC withdrawal from the source.

I have this patch in my local folder of llvm/darwinppc fixes. I suppose this ticket might be closed then?