[PATCH] pr13012: Support -fpcc-struct-return for x86-32

Arthur O'Dwyer arthur.j.odwyer at gmail.com
Fri Jun 7 14:12:53 PDT 2013


On Fri, Jun 7, 2013 at 1:58 PM, John McCall <rjmccall at apple.com> wrote:
> On Jun 7, 2013, at 12:07 PM, Arthur O'Dwyer <arthur.j.odwyer at gmail.com> wrote:
>> On Wed, Jun 5, 2013 at 1:23 PM, Arthur O'Dwyer
>> <arthur.j.odwyer at gmail.com> wrote:
>>>
>>>  This is my first post to cfe-commits, so my apologies if I get
>>> something wrong.
>>> A while back I filed an issue on Bugzilla requesting support for
>>> -fpcc-struct-return:
>>> http://llvm.org/bugs/show_bug.cgi?id=13012
>>>
>>> Recently I wrote a real patch [...] I believe I don't have the necessary
>>> credentials to commit the patch anyway, so basically I'm looking for
>>> a patron to adopt this patch. :)
>>>
>>> To observe what the patch does:
>>>  echo "struct S {int i;} foo() {return (struct S){42};}" >foo.c
>>>  clang -m32 -O3 -fomit-frame-pointer foo.c -S -o reg.s
>>>  clang -m32 -O3 -fomit-frame-pointer foo.c -S -o pcc.s -fpcc-struct-return
>>>  diff reg.s pcc.s
>>
>> Ping? Any takers? Any comments at all?
>
> I would really like to avoid adding support for all these little ABI-tweaking
> options, and frankly, unless you're just being unassuming, it doesn't sound
> like this is all that important to you.

I do tend to be unassuming. Would yelling about it help? ;) It's
important to my employer, in that the only alternative we're aware of
is for us to maintain our own little Clang fork in perpetuity. If
there's a better alternative, I'd like to hear it.

For example, maybe it would be more acceptable to add a new target
triple specifically for "x86-32 Linux with pcc struct returns"?
Philosophically, I vastly prefer to add the -fpcc-struct-return option
so that *everybody* can get the benefit, no matter what platform
they're on (and in a GCC-compatible way).

> ABI-changing options are also a Real Big Hammer for things like making
> a couple assembly stubs have a slightly simpler CC.

In our case it's not "a couple assembly stubs", it's an entire
application program written in Objective-C; and we need it to use the
pcc calling convention so that we can link it against dynamic
libraries that use the pcc calling convention. We need a hammer big
enough to change the CC across the entire program. On GCC, that hammer
is named "-fpcc-struct-return", and it works like this.

–Arthur




More information about the cfe-commits mailing list