<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><span class="vcard"><a class="email" href="mailto:dblaikie@gmail.com" title="David Blaikie <dblaikie@gmail.com>"> <span class="fn">David Blaikie</span></a>
</span> changed
<a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED WORKSFORME - Replace pass by const reference with pass by value"
href="https://bugs.llvm.org/show_bug.cgi?id=38666">bug 38666</a>
<br>
<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>What</th>
<th>Removed</th>
<th>Added</th>
</tr>
<tr>
<td style="text-align:right;">CC</td>
<td>
</td>
<td>dblaikie@gmail.com
</td>
</tr>
<tr>
<td style="text-align:right;">Resolution</td>
<td>---
</td>
<td>WORKSFORME
</td>
</tr>
<tr>
<td style="text-align:right;">Status</td>
<td>NEW
</td>
<td>RESOLVED
</td>
</tr></table>
<p>
<div>
<b><a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED WORKSFORME - Replace pass by const reference with pass by value"
href="https://bugs.llvm.org/show_bug.cgi?id=38666#c1">Comment # 1</a>
on <a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED WORKSFORME - Replace pass by const reference with pass by value"
href="https://bugs.llvm.org/show_bug.cgi?id=38666">bug 38666</a>
from <span class="vcard"><a class="email" href="mailto:dblaikie@gmail.com" title="David Blaikie <dblaikie@gmail.com>"> <span class="fn">David Blaikie</span></a>
</span></b>
<pre>LLVM already performs this optimization (if you're curious about which
optimizations LLVM performs, asking on llvm-dev might be more suitable than
filing bugs) where possible:
$ cat arg_promo.cpp
void f1(int);
static __attribute__((noinline)) void f2(const int &a) { f1(a); }
void f3(int a) { f2(a); }
$ clang++-tot arg_promo.cpp -emit-llvm -S && cat arg_promo.ll | grep
define.*f2
define internal void @_ZL2f2RKi(i32* dereferenceable(4) %a) #0 {
$ clang++-tot arg_promo.cpp -emit-llvm -S -O3 && cat arg_promo.ll | grep
define.*f2
define internal fastcc void @_ZL2f2RKi(i32 %a.val) unnamed_addr #1 {
It cannot be performed on externally visible functions because it changes the
way the calling code works - and is contingent on the implementation of the
function, so only when both the implementation and all callers are visible/can
be changed, can the optimization be performed. (otherwise the function might be
modified, but a caller could still end up trying to pass a reference, etc)</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>