[llvm-bugs] [Bug 38666] Replace pass by const reference with pass by value
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Aug 22 09:51:43 PDT 2018
https://bugs.llvm.org/show_bug.cgi?id=38666
David Blaikie <dblaikie at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |dblaikie at gmail.com
Resolution|--- |WORKSFORME
Status|NEW |RESOLVED
--- Comment #1 from David Blaikie <dblaikie at gmail.com> ---
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)
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180822/eb45280c/attachment.html>
More information about the llvm-bugs
mailing list