<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Win64 MS ABI: Classes with non-trivial dtors and trivial copy ctors are passed in registers"
   href="http://llvm.org/bugs/show_bug.cgi?id=19640">19640</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Win64 MS ABI: Classes with non-trivial dtors and trivial copy ctors are passed in registers
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>LLVM Codegen
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>rnk@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>consider:
struct S {
  S(int a) : a(a) {}
  ~S() {}
  int a;
};
void foo(S s);
int main() {
  foo(S(42));
}

foo's parameter is passed in ecx on x64.  However, Clang doesn't consider this
type to be "trivially copyable", so we try to pass it indirectly.

If we pass the parameter in registers, then the object is reconstituted on the
other side with a new address, which can be observed.  Therefore we cannot copy
elide this argument.  We have to construct the temporary in the caller's frame,
destroy the temporary after the call, *and* the callee will destroy its copy at
the end of foo.

If the parameter is passed in memory, it receives the same treatment: a
temporary is constructed in the caller, its bytes are copied into the argument
slot, and it is destroyed in the caller and callee.  It is possible to use
inalloca to copy elide when the argument is in memory, but it is potentially
hostile to optimization.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>