Actions

icon Post
text/html Subscribe
text/html Unsubscribe

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cxx-abi-dev] Revisiting Issue C-18: Result buffers


  • To: Cary Coutant <cary@xxxxxxxxxx>
  • Subject: Re: [cxx-abi-dev] Revisiting Issue C-18: Result buffers
  • From: Mark Mitchell <mark@xxxxxxxxxxxxxxxx>
  • Date: Wed, 04 May 2005 16:36:00 -0700

Cary Coutant wrote:
I was recently asked about Section 3.1.4 (Return Values) in the C++ ABI spec, where it states:

"... if the return value type has a non-trivial copy constructor or destructor, the caller allocates space for a temporary, and passes a pointer to the temporary as an implicit first parameter preceding both the this parameter and user parameters. The callee constructs the return value into this temporary. On Itanium, the pointer is passed in out0, different from other large class result buffer pointers, passed in r8."

The HP compiler follows this convention, but g++ on HP-UX does not, causing a binary incompatibility between the two compilers.

I dug up Issue C-18, which purports to have changed this convention to use r8, just as the base C ABI would, and as g++ does:

Yes, I distinctly remember lobbying to eliminate the special Itanium rule, and I remember the change being accepted. So, I belive the G++ behavior to be correct -- although you are of course correct that somehow the specification was never updated to reflect that. The change was made before the specification moved to our web site, so I really don't know what happened.

I have checked in the attached change. If anyone objects to that, please let me know.

What does the C++ ABI test suite check for?

Our testsuite doesn't check for particular registers; instead, it checks this constraint by calling a function from C++ and implementing it in C, with the pointer made explicit, and then checks that the value is really there. So, essentially, it checks for the G++ behavior, not the special Itanium behavior.

--
Mark Mitchell
CodeSourcery, LLC
mark@xxxxxxxxxxxxxxxx
(916) 791-8304
? diffs.txt
Index: abi.html
===================================================================
RCS file: /home/cvs/Repository/cxx-abi/abi.html,v
retrieving revision 1.81
diff -c -5 -p -r1.81 abi.html
*** abi.html	17 Feb 2005 20:36:57 -0000	1.81
--- abi.html	4 May 2005 23:34:31 -0000
*************** or destructor,
*** 2660,2672 ****
  the caller allocates space for a temporary,
  and passes a pointer to the temporary as an implicit
  first parameter
  preceding both the <code>this</code> parameter and user parameters.
  The callee constructs the return value into this temporary.
- On Itanium, the pointer is passed in <code>out0</code>,
- different from other large class result buffer pointers,
- passed in <code>r8</code>.
  
  <p>
  A result of an empty class type will be returned as though it were
  a struct containing a single char,
  i.e. <code>struct S { char c; };</code>.
--- 2660,2669 ----
*************** unwind table location.
*** 4957,4966 ****
--- 4954,4967 ----
  <p> <hr> <p>
  
  <p>This version of this document is $Revision: 1.81 $.  No special
  significance should be attached to the form of the revision number; it
  is simply a identifying number.</p>
+ 
+ <p>
+ <font color=blue>[050405]</font>
+ Remove use of <code>out0</code> for by-value return types on Itanium.
  
  <p>
  <font color=blue>[050211]</font>
  Reverse treatment of ambiguous arguments to __cxa_demangle (3.4).