<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 --- - [MS ABI] Bad interaction between inalloca call and expanded memcpy"
   href="http://llvm.org/bugs/show_bug.cgi?id=19012">19012</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[MS ABI] Bad interaction between inalloca call and expanded memcpy
          </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>-New Bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>hans@chromium.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu, rnk@google.com
          </td>
        </tr>

        <tr>
          <th>Blocks</th>
          <td>12477, 18887
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The following program crashes when built with clang-cl:

(If the #if 1 is changed to #if 0, it doesn't crash. For some reason that
causes us not to expand the memcpy.)

struct Ptr {
  ~Ptr() {}
  int *ptr;
};

#if 1
struct Arr {
  struct {
    struct {
      char name[54];
    } mailbox;
    int texture_target;
    int sync_point;
  } mailbox_holder;
  void *shared_memory;
  struct shared_memory_size {
    int width;
    int height;
  } memory_size;
};
#else
struct Arr {
  char x[76];
};
#endif

void f(Ptr) {}

void g(Arr *a, Arr *b, Ptr *p) {
  *a = *b; // memcpy, possibly expanded to rep movs, clobbering esi
  f(*p);   // inalloca call, causing chkstk, not expecting clobbered esi
};

int main() {
  Ptr p = {};
  Arr a = {}, b = {};
  g(&a, &b, &p);
  return 0;
}

(Reduced from Chromium's cc::CopyOutputResult::TakeTexture.)</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>