with reference to the following:

  struct data {
    data (long v) : m_data (v) {}
    data (const data&) {}
    long  m_data;
  };

  data foo (data v) {
    return v;
  }

my reading of the x86_64 ABI (v .98, sept 2006) on page 17 is that
data should have class MEMORY when passed as argument to function foo.
This because it has a non-trivial copy constructor 
(it is not implicitely declared).

But GCC 4.1.1 and a more recent version from svn give (for foo):

  .globl _Z3foo4data
          .type   _Z3foo4data, @function
  _Z3foo4data:
  .LFB8:
          movq    %rdi, %rax
          ret
  .LFE8:

[so v is passed in a register]

The gimple dump (from the svn version) is:

  data::data(long int) (this, v)
  {
    this->m_data = v;
  }


  data::data(const data&) (this, D.2481)
  {

  }


  data foo(data) (v)
  {
    struct data & D.2509;

    D.2509 = <retval>;
    __comp_ctor  (D.2509, v);
    return <retval>;
  }

which seems to confirm v in a register.

So the question is whether my reading of the ABI is wrong (and why).
Thanks a lot and best regards,

       Maurizio



Reply via email to