[LLVMdev] Optimizing out redundant alloca involving byval params

Reid Kleckner rnk at google.com
Thu Mar 5 16:21:53 PST 2015


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.

On Thu, Mar 5, 2015 at 3:51 PM, Mircea Trofin <mtrofin at google.com> wrote:

> Hello all,
>
> I'm trying to find the pass that would convert from:
>
> define void @main(%struct* byval %ptr) {
>   %val = load %struct* %ptr
>   %val.ptr = alloca %struct
>   store %struct %val, %struct* %val.ptr
>   call void @extern_func(%struct* byval %val.ptr)
>   ret void
> }
>
> to this:
> define void @main(%struct* byval %ptr) {
>   call void @extern_func(%struct* byval %ptr)
>   ret void
> }
>
> First, am I missing something - would this be a correct optimization?
>
> Thank you,
> Mircea.
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150305/c0a460a6/attachment.html>


More information about the llvm-dev mailing list