<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 - Invalid code generation for win32/32bit windows target"
href="https://bugs.llvm.org/show_bug.cgi?id=44395">44395</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Invalid code generation for win32/32bit windows target
</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>enhancement
</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>zamazan4ik@tut.by
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>clang(trunk) with -m32 on windows (win32 target) generates wrong code for the
following code ( <a href="https://godbolt.org/z/RKzU5M">https://godbolt.org/z/RKzU5M</a> )
#include <vector>
#include <functional>
#include <emmintrin.h>
struct Id { unsigned handle; };
struct QueryView { __m128 val; unsigned i; };
extern void perform_query(std::function<void(QueryView &)>);
template<typename BT> void foo ( QueryView &qv, const BT & block)
{
block( Id{qv.i}, _mm_setzero_ps() );
}
template<typename BT> void bar ( const BT & block)
{
perform_query([&](QueryView& qv) { block(qv.val); });
}
void external_call ( QueryView & qv ) {
{
foo(qv, [&](Id id, const __m128 two)->void{ bar([&](__m128 &
arg)->void{arg = two;});});
}}
the body of function std::function capture will (reasonably) make aligned read
on argument of __m128 type
While unaligned_stack_store will store __m128 register on stack unaligned,
tightly with Id structure.
This results in crash during runtime (unaligned load).
LLVM code (relevant part)
%3 = alloca inalloca <{ %struct.Id, <4 x float> }>, align 4
Assembly disasm (relevant part):
push eax
sub esp, 16
mov eax, esp
xorps xmm0, xmm0
mov dword ptr [eax], ecx
movups xmmword ptr [eax + 4], xmm0 #unaligned!
Possible fix: <a href="https://reviews.llvm.org/D71915">https://reviews.llvm.org/D71915</a></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>