<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Hi all,<div><br></div><div>You will find enclosed a patch that adds the support of constant variables for the generic global merge pass.</div><div>I've also attached a motivating example, test.c.</div><div><br></div><div>In that file there are several global variables accessed within the same function.</div><div>If all the variables are non-const, global merge generates one unique variable, which translates into one unique load in the assembly file.</div><div><br></div><div>clang -arch arm -O3 test.c -o - -S</div><div><br></div><div>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</div><div>clang -arch arm -O3 test.c -o - -S -DWITHCONST</div><div><br></div><div>If global merge had merged the constant globals, only 2 loads would have been issued. The patch allows to do that.</div><div><br></div><div>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).</div><div>Is it still true?</div><div><br></div><div>If yes, how could I reproduce that?</div><div><br></div><div>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</div><div><br><div apple-content-edited="true">
<div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">-Quentin</div><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "></div></div></div></body></html>