[PATCH] Global merge on constants

Quentin Colombet qcolombet at apple.com
Tue Feb 26 17:24:47 PST 2013


Hi all,

You will find enclosed a patch that adds the support of constant variables for the generic global merge pass.
I've also attached a motivating example, test.c.

In that file there are several global variables accessed within the same function.
If all the variables are non-const, global merge generates one unique variable, which translates into one unique load in the assembly file.

clang -arch arm -O3 test.c -o - -S

If some are const (the example is very stupid), global merge does not merge anything and one load for each variable is issued, i.e., 3
clang -arch arm -O3 test.c -o - -S -DWITHCONST

If global merge had merged the constant globals, only 2 loads would have been issued. The patch allows to do that.

Although the patch is fairly simple, it was not done before because it seems it was breaking the EH processing (see comment in the original code).
Is it still true?

If yes, how could I reproduce that?

Note: that the patch disables by default the handling of global constants because the current heuristic may generate worse code. A tuning may be necessary, but it would be done as a second step

-Quentin


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130226/fb7e9e45/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: GlobalMergeOnConst.patch
Type: application/octet-stream
Size: 2279 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130226/fb7e9e45/attachment.obj>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130226/fb7e9e45/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.c
Type: application/octet-stream
Size: 380 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130226/fb7e9e45/attachment-0001.obj>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130226/fb7e9e45/attachment-0002.html>


More information about the llvm-commits mailing list