<div dir="ltr">I think lib/Transforms/Scalar/MemCpyOptimizer.cpp might be the right place for this, considering that most frontends will use memcpy for that copy anyway. It already has some logic for byval args.</div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Mar 5, 2015 at 3:51 PM, Mircea Trofin <span dir="ltr"><<a href="mailto:mtrofin@google.com" target="_blank">mtrofin@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello all,<div><br></div><div>I'm trying to find the pass that would convert from:</div><div><div><br></div><div><font face="monospace, monospace">define void @main(%struct* byval %ptr) {</font></div><div><font face="monospace, monospace">  %val = load %struct* %ptr</font></div><div><font face="monospace, monospace">  %val.ptr = alloca %struct</font></div><div><font face="monospace, monospace">  store %struct %val, %struct* %val.ptr</font></div><div><font face="monospace, monospace">  call void @extern_func(%struct* byval %val.ptr)</font></div><div><font face="monospace, monospace">  ret void</font></div><div><font face="monospace, monospace">}</font></div></div><div><br></div><div>to this:</div><div><div><font face="monospace, monospace">define void @main(%struct* byval %ptr) {</font></div><div><font face="monospace, monospace">  call void @extern_func(%struct* byval %ptr)</font></div><div><font face="monospace, monospace">  ret void</font></div><div><font face="monospace, monospace">}</font></div></div><div><br></div><div>First, am I missing something - would this be a correct optimization?</div><div><br></div><div>Thank you,</div><div>Mircea.</div></div>
<br>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
<br></blockquote></div><br></div>