<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </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 - [deadargelim] removes "this" from x86_thiscallcc"
   href="https://bugs.llvm.org/show_bug.cgi?id=43160">43160</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[deadargelim] removes "this" from x86_thiscallcc
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>8.0
          </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>Interprocedural Optimizations
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>CFSworks@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>This is very similar to <a class="bz_bug_link 
          bz_status_REOPENED "
   title="REOPENED - Invalid function signatures when inlining `this` into multiple parameters and there is inalloca parameters"
   href="show_bug.cgi?id=38487">bug 38487</a>; my test case in fact is slightly modified
from there.

In this case, I've modified the F::k function to avoid relying on the `this`
pointer. -deadargelim removes `this`, but leaves the calling convention set to
x86_thiscallcc, so the second argument (whatever that may be) ends up shoved
into ECX.

When combined with inalloca, the following fatal error is generated:

cannot use inalloca attribute on a register parameter


However, inalloca aside, removing `this` from any calling convention that
treats `this` specially does break that calling convention. The calling
convention should either be changed (to fastcc?) or the functions with these
special calling conventions should simply have their `this` pointer left alone.

// x.cpp
// clang++ -target i386-pc-windows-msvc -O3 -c x.cpp

struct Y
{
    int i; 
    Y();
    Y(const Y&);
};

void h(Y y);

namespace {
struct F {
    void k(Y y) {
        y.i = 0;
        h(y);
    }
};
}

void foo()
{
    F f;
    Y y;
    f.k(y);
}</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>