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

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 8 16:31:45 PST 2017


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?

-fmerge-all-constants has exactly the same meaning in clang and gcc.  And it's generally beneficial for both codesize and performance, so turning it off to pursue performance is a bad idea.

I would suggest finding some other approach to solve your issue later in the optimization pipeline, preferably in a manner which is sensitive to register pressure.  Maybe put the code in ConstantHoisting?  You don't lose any useful information by promoting the alloca to a global constant; you can easily recreate it later.


https://reviews.llvm.org/D30759





More information about the llvm-commits mailing list