[llvm-dev] Optimize placement of llvm.lifetime.start/end
David Blaikie via llvm-dev
llvm-dev at lists.llvm.org
Mon Oct 29 08:04:20 PDT 2018
Sounds like a potential optimization LLVM could perform, sure.
On Mon, Oct 29, 2018 at 12:12 AM Markus Lavin via llvm-dev <
llvm-dev at lists.llvm.org> wrote:
> Does (or should) LLVM make any attempt to optimize the placement of
> llvm.lifetime.start and llvm.lifetime.end intrinsics?
> Considering the example below (where the pointer argument to function bar
> ends up being marked as nocapture in IR) the stack usage is twice of what
> would be necessary since the lifetime markers for mem1 and mem2 indicate
> that they are both live at the same time. The markers seem to remain where
> they were placed by clang while I naively expected that opt would try to
> adjust them to allow for better stack coloring.
>
> #define LEN 512
>
> void bar(__attribute__((noescape)) int *p) ;
>
> int foo(void)
> {
> int sum1 = 0, sum2 = 0;
>
> int mem1[LEN];
> bar(mem1);
> for (int i = 0; i < LEN; i++)
> sum1 += mem1[i];
>
> int mem2[LEN];
> bar(mem2);
> for (int i = 0; i < LEN; i++)
> sum2 += mem2[i];
>
> return sum1 + sum2;
> }
>
> -Markus
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20181029/83bba7ea/attachment.html>
More information about the llvm-dev
mailing list