Issue 125429
Summary [maybe missed optimizaton] Suboptimal assembly with constexpr non-static VS static variable
Labels new issue
Assignees
Reporter chrooti
    Looking at the following example on Godbolt: https://www.godbolt.org/z/cMoojqsd3

the assembly generated is optimal: to call writev one lea and three movs are emitted. If the static specifier is removed from the definition of `vecs` the assembly degenerates into a bunch of `movaps` that copy the `.data` section entries into the stack before passing a pointer to it. 

Given that string literal are supposed to live in static storage and the the Iovecs are just pointers to them whether they are `static` or not probably should not make any difference to the generated asm output.
Notably in the IR output `@__const.main.vecs` switches from `internal` linkage in the optimal "static" case to `private unnamed_addr` in the "non-static" one, which seems both correct _and_ the eventual source of the possibly missed optimization.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to