<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 - standard library APIs missing noalias on rvalue references"
href="https://bugs.llvm.org/show_bug.cgi?id=48238">48238</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>standard library APIs missing noalias on rvalue references
</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>C++
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>gonzalobg88@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>According to the wording and notes in [res.on.arguments]/1.3, standard library
APIs taking rvalue references arguments can assume that these do not alias.
When looking at: <a href="https://godbolt.org/z/G8ejKb">https://godbolt.org/z/G8ejKb</a>
#include <utility>
int fails(int* p) {
int&& i = std::move(std::move(*p));
return i;
}
int works(int * __restrict p) {
return *p;
}
the last call to `std::move` in "fails" takes an rvalue reference, and its
argument should be `noalias`, which LLVM attributor pass should be able to
propagate up to `p`.
However, the generated IR is missing no-alias.
I don't think the standard guarantees that rvalue references are always no
alias, but the standard library does guarantee that for all its APIs.
The simplest solution I can imagine would be to add a [[__std_lib_api__]]
builtin attribute that adds `noalias` to all rvalue reference arguments of a
function. We'd need to implement the argument, and add it to libc++.
Richard, Eric, thoughts?
To me this wording looks extremely powerful, but from
<a href="https://cplusplus.github.io/LWG/issue1204">https://cplusplus.github.io/LWG/issue1204</a> I don't know if this is intended or
not.</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>