<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 --- - Optimized code contains illegal movaps instruction when using aligned attribute in typedef"
href="https://llvm.org/bugs/show_bug.cgi?id=28410">28410</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Optimized code contains illegal movaps instruction when using aligned attribute in typedef
</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>Linux
</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>C++
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>lukasz.czyz@intel.com
</td>
</tr>
<tr>
<th>CC</th>
<td>dgregor@apple.com, llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>clang generates MOVAPS instruction with wrongly aligned operand (resulting in
SEGFAULT) when compiling following code with optimizations enabled (-O2):
#include <stdint.h>
struct Foo
{
uint32_t data[ 13 ];
};
typedef __attribute__((aligned(16))) Foo FooDef;
int counter;
struct Bar
{
FooDef array[4];
};
__attribute__ ((noinline)) void do_sth(FooDef* foo)
{
counter += ((char*)foo)[0];
}
int main()
{
Bar* bar = new Bar();
FooDef tmp = {{0}};
for (int i = 0; i < 4; i++)
{
FooDef *foo = &bar->array[i];
*foo = tmp;
do_sth(foo);
}
return 0;
}
Explanation: aligned(16) attribute is ignored when determining sizeof(FooDef)
(so sizeof(FooDef) == 52, not 64). At the other hand optimizer assumes that the
given alignment holds for all elements of bar->array which is not true due to
sizeof(FooDef) not aligned to 16 bytes.</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>