Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(623)

Issue 8479017: Add a compatibility function attribute (and flag) for nacl-gcc to (Closed)

Created:
9 years, 1 month ago by jvoung - send to chromium...
Modified:
9 years, 1 month ago
Reviewers:
khim, Roland McGrath
CC:
native-client-reviews_googlegroups.com, noelallen_use_chromium, robertm, pnacl-team_google.com
Base URL:
http://git.chromium.org/native_client/nacl-gcc.git@master
Visibility:
Public.

Description

Add a compatibility function attribute (and flag) for nacl-gcc to be ABI compatible with llvm/PNaCl. Due to the fact that llvm bitcode loses information about the original source, (unions, alignment) it is hard to match the ABI (see notes for known issues: https://docs.google.com/a/google.com/document/d/1P3WrT_LHwN20gbs75LnHuMrbd804fSdSHKGK7Q3B20k/edit?hl=en_US#bookmark=id.sb20hms96tga). Thus, for now, we make an attribute (and flag) to pass and return structures and unions on the stack. Vectors and scalars can still use registers. This is calling convention is easy to match. With this nacl-gcc is calling convention compatible with pnacl. If at some point in the future we get richer type information in bitcode we could do without this. ***** Example uses of the attribute: typedef struct {int x; float y; } s1; typedef void (__attribute__((pnaclcall)) *pnacl_fp)(int, s1, int); typedef s1 (__attribute__((pnaclcall)) *pnacl_ret_fp)(int, int) ; extern void foo(int x, s1 y, int z); __attribute__((pnaclcall)) void bar(int x, s1 y, int z) { foo(x, y, z); if (x > 0) bar(x - 1, y, z); } void bar_fp_casted(void) { s1 s = { 80, 81.0f }; void (__attribute__((pnaclcall)) *temp_fp)(int, s1, int) ; temp_fp = (pnacl_fp)&foo; (*temp_fp)(79, s, 82); } void bar_fp_casted2(void) { s1 s = { 80, 81.0f }; void (*temp_fp)(int, s1, int) = &foo; (*(pnacl_fp)temp_fp)(79, s, 82); } ***** BUG= http://code.google.com/p/nativeclient/issues/detail?id=1819 BUG= http://code.google.com/p/nativeclient/issues/detail?id=2413 TEST= http://codereview.chromium.org/8502006/ and toolchain trybots Committed: http://git.chromium.org/gitweb?p=native_client/nacl-gcc.git;a=commit;h=82ea71e

Patch Set 1 #

Patch Set 2 : remove debug printf #

Patch Set 3 : Hack for propagating attributes from a function pointer, when determining how structs are returned. #

Patch Set 4 : indent #

Patch Set 5 : Fix var-args #

Total comments: 10

Patch Set 6 : style changes #

Patch Set 7 : more spacing #

Patch Set 8 : braces #

Patch Set 9 : period #

Unified diffs Side-by-side diffs Delta from patch set Stats (+103 lines, -22 lines) Patch
M gcc/config/i386/i386.h View 1 2 3 4 5 6 7 8 2 chunks +3 lines, -0 lines 0 comments Download
M gcc/config/i386/i386.c View 24 chunks +70 lines, -22 lines 0 comments Download
M gcc/config/i386/nacl.opt View 1 chunk +5 lines, -0 lines 0 comments Download
M gcc/function.c View 1 2 3 4 5 2 chunks +25 lines, -0 lines 0 comments Download

Messages

Total messages: 7 (0 generated)
jvoung - send to chromium...
9 years, 1 month ago (2011-11-07 17:38:07 UTC) #1
jvoung - send to chromium...
ah.. hold on, I broke something in the normal case
9 years, 1 month ago (2011-11-08 19:02:07 UTC) #2
jvoung - send to chromium...
ok, PTAL. Fixed the previously mentioned bug, and function pointer attribs work for influencing the ...
9 years, 1 month ago (2011-11-08 22:31:18 UTC) #3
Roland McGrath
I've given some style nits, but not covered all the places where there were style ...
9 years, 1 month ago (2011-11-09 01:02:58 UTC) #4
jvoung - send to chromium...
http://codereview.chromium.org/8479017/diff/10001/gcc/config/i386/i386.c File gcc/config/i386/i386.c (right): http://codereview.chromium.org/8479017/diff/10001/gcc/config/i386/i386.c#newcode4263 gcc/config/i386/i386.c:4263: + /* Usually x86-64 does not have attributes so ...
9 years, 1 month ago (2011-11-09 21:02:03 UTC) #5
jvoung - send to chromium...
Trybots are green w/ these style changes. On 2011/11/09 21:02:03, jvoung wrote: > http://codereview.chromium.org/8479017/diff/10001/gcc/config/i386/i386.c > ...
9 years, 1 month ago (2011-11-10 22:59:57 UTC) #6
sehr (please use chromium)
9 years, 1 month ago (2011-11-14 17:13:59 UTC) #7
All,

This issue needs to be resolved for pnacl to enter dogfood.  Please give Jan a
review as soon as you can.

David

On 2011/11/10 22:59:57, jvoung wrote:
> Trybots are green w/ these style changes.
> 
> On 2011/11/09 21:02:03, jvoung wrote:
> > http://codereview.chromium.org/8479017/diff/10001/gcc/config/i386/i386.c
> > File gcc/config/i386/i386.c (right):
> > 
> >
>
http://codereview.chromium.org/8479017/diff/10001/gcc/config/i386/i386.c#newc...
> > gcc/config/i386/i386.c:4263: +      /* Usually x86-64 does not have
attributes
> > so they warn here, but
> > On 2011/11/09 01:02:58, Roland McGrath wrote:
> > > This is GNU code, so use GNU style:
> > >   /* Comment
> > >      second line.  */
> > > Never but braces on a line with something else.
> > > 
> > > Since your case returns, you don't need to move the other cases into an
else
> > > clause.  Avoiding that keeps the diff smaller and avoids indentation-only
> > > changes to upstream code.
> > 
> > Done.
> > 
> >
>
http://codereview.chromium.org/8479017/diff/10001/gcc/config/i386/i386.c#newc...
> > gcc/config/i386/i386.c:4702: +/* Return true if the function is decorated
with
> a
> > pnaclcall attribute. */
> > On 2011/11/09 01:02:58, Roland McGrath wrote:
> > > GNU style here: Two spaces after period, brace style.
> > 
> > Done.
> > 
> >
>
http://codereview.chromium.org/8479017/diff/10001/gcc/config/i386/i386.c#newc...
> > gcc/config/i386/i386.c:4704: +  if (fntype && lookup_attribute ("pnaclcall",
> > On 2011/11/09 01:02:58, Roland McGrath wrote:
> > > Don't need an if to return a boolean.
> > 
> > Done.
> > 
> >
>
http://codereview.chromium.org/8479017/diff/10001/gcc/config/i386/i386.c#newc...
> > gcc/config/i386/i386.c:4802: +  if (TARGET_64BIT) {
> > On 2011/11/09 01:02:58, Roland McGrath wrote:
> > > GNU style: no braces for a single line consequent.
> > 
> > Done.
> > 
> >
>
http://codereview.chromium.org/8479017/diff/10001/gcc/config/i386/i386.c#newc...
> > gcc/config/i386/i386.c:30218: +  { "pnaclcall", 0, 0, false, true, true,
> > ix86_handle_cconv_attribute },
> > On 2011/11/09 01:02:58, Roland McGrath wrote:
> > > This could be upstreamable with a different attribute name, maybe
> "stackparm"?
> > > or "aggregates_on_stack"?
> > 
> > That's a good point... maybe revisit this later?

Powered by Google App Engine
This is Rietveld 408576698