[PATCH] D30759: With PIE on x86_64, keep hot local arrays on the stack

Sriraman Tallam via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 8 15:35:16 PST 2017


On Wed, Mar 8, 2017 at 3:10 PM, Eli Friedman via Phabricator
<reviews at reviews.llvm.org> wrote:
> efriedma added a comment.
>
> In theory, the C/C++ standards require behavior equivalent to -fno-merge-all-constants.  In practice, code doesn't actually depend on that, so we made the decision many years ago to turn on -fmerge-all-constants by default.

Understood.  Does it seem reasonable/useful to fix this along the
lines of GCC, -fmerge-constants and -fmerge-all-constants where the
latter applies to const arrays and a warning that this is happening
when the latter option is used?

>
> Anyway, you don't really want the behavior of the optimizer to depend on whether the constant array is marked "static"; it probably doesn't reflect the user's intent in any useful way.
>
> ----
>
> I'm sort of surprised you didn't mention register pressure at all in your explanation.

Yes!, my mistake.  The benchmarks I looked at did not seem to suffer
from it but if the lea is done early and hoisted then one register is
taken up. If they are done together, I guess the register used to
store the final value can also be used to store the pointer from the
previous lea. With the array on the stack, there is no such problem.

>
> https://reviews.llvm.org/D30759
>
>
>


More information about the llvm-commits mailing list