<html>
    <head>
      <base href="https://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 --- - Compiler not properly honoring alignment when calling trivial default copy constructor"
   href="https://llvm.org/bugs/show_bug.cgi?id=24982">24982</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Compiler not properly honoring alignment when calling trivial default copy constructor
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>trunk
          </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>douglas_yung@playstation.sony.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>After change r246985, the compiler started to emit calls to memcpy that do not
take into account the alignment requirements of the target. Consider the
following code:

/***********/
struct C { float a; float b; float c; float d; } __attribute__((aligned(16)));

typedef C C4 __attribute__((aligned(4)));

C4 c4 = {0.0,1.0,1.0,0.0};

C test4() {
  return c4;
}
/***********/

Prior to change r246985, the compiler generated the following IR for the call
to memcpy:

call void @llvm.memcpy.p0i8.p0i8.i64(i8* %0, i8* bitcast (%struct.C* @c4 to
i8*), i64 16, i32 16,i1 false)

In this case, note the alignment parameter "i32 16" which is what the target
requires.

However, following the change in r246985 up to the most recent build I have
(r248770), the compiler is now generating an incorrect value for the alignment
for the memcpy call which only seems to take into account the source alignment.
The new IR is the following:

call void @llvm.memcpy.p0i8.p0i8.i64(i8* %0, i8* bitcast (%struct.C* @c4 to
i8*), i64 16, i32 4, i1 false)

Note that the alignment parameter is now 4 instead of 16 as it was previously.</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>