<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 - llvm doesn't generate inline sequence for load/store of unaligned atomic variable on x86_64"
href="https://bugs.llvm.org/show_bug.cgi?id=34347">34347</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>llvm doesn't generate inline sequence for load/store of unaligned atomic variable on x86_64
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</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>Common Code Generator Code
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>wmi@google.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>-------------------- 1.cc -----------------------
#include <atomic>
struct AM {
int f1;
int f2;
};
std::atomic<AM> ip3{AM()};
std::atomic<AM> ip4{AM()};
void foo() {
auto val = ip4.load(std::memory_order_relaxed);
ip3.store(val, std::memory_order_relaxed);
}
-------------------------------------------------
~/workarea/llvm-r309240/dbuild/bin/clang -O2 -std=c++11 -fno-exceptions -S 1.cc
.cfi_startproc
# BB#0: # %entry
pushq %rax
.Lcfi0:
.cfi_def_cfa_offset 16
movl $local_ip4, %edi
xorl %esi, %esi
callq __atomic_load_8
movl $local_ip3, %edi
xorl %edx, %edx
movq %rax, %rsi
popq %rax
jmp __atomic_store_8 # TAILCALL
.Lfunc_end0:
.size _Z3foov, .Lfunc_end0-_Z3foov
.cfi_endproc
g++ -O2 -std=c++11 -fno-exceptions -S 1.cc
.cfi_startproc
movq ip4(%rip), %rax
movq %rax, ip3(%rip)
ret
.cfi_endproc
If alignas(8) is added:
struct alignas(8) AM {
int f1;
int f2;
};
clang will generate inline sequence for the atomic accesses:
.cfi_startproc
movq ip4(%rip), %rax
movq %rax, ip3(%rip)
retq</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>