Don't merge two constants if we care about the address of both.
authorRafael Espindola <rafael.espindola@gmail.com>
Sun, 16 Jan 2011 17:05:09 +0000 (17:05 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Sun, 16 Jan 2011 17:05:09 +0000 (17:05 +0000)
commitd6e5cbc84226ad4a62e8847f1babecf86089d415
tree0e8e4f6a7fbc025297e832fa4c2b84461d0e88f0
parent1ed26acc58a13f125bc9e1d5e5aa22fd479654ff
Don't merge two constants if we care about the address of both.

This fixes the original testcase in PR8927. It also causes a clang
binary built with a patched clang to increase in size by 0.21%.

We can probably get some of the size back by writing a pass that
detects that a global never has its pointer compared and adds
unnamed_addr to it (maybe extend global opt). It is also possible that
there are some other cases clang could add unnamed_addr to.

I will investigate extending globalopt next.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123584 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/IPO/ConstantMerge.cpp
test/Transforms/ConstantMerge/2011-01-15-EitherOrder.ll
test/Transforms/ConstantMerge/merge-both.ll [new file with mode: 0644]
test/Transforms/ConstantMerge/unnamed-addr.ll [new file with mode: 0644]