This is an archive of the discontinued LLVM Phabricator instance.

[GlobalOpt] Allow constant globals to be SRA'd
ClosedPublic

Authored by jmolloy on Nov 16 2015, 3:35 AM.

Details

Summary

The current logic assumes that any constant global will never be SRA'd. I presume this is because normally constant globals can be pushed into their uses and deleted. However, that sometimes can't happen (which is where you really want SRA, so the elements that can be eliminated, are!).

There seems to be no reason why we can't SRA constants too, so let's do it.

Diff Detail

Repository
rL LLVM

Event Timeline

jmolloy updated this revision to Diff 40270.Nov 16 2015, 3:35 AM
jmolloy retitled this revision from to [GlobalOpt] Allow constant globals to be SRA'd.
jmolloy updated this object.
jmolloy set the repository for this revision to rL LLVM.
jmolloy added a subscriber: llvm-commits.
mehdi_amini added inline comments.Nov 16 2015, 8:01 AM
test/Transforms/GlobalOpt/globalsra.ll
31

It is strange that we can store to a constant?

jmolloy added inline comments.Nov 16 2015, 8:18 AM
test/Transforms/GlobalOpt/globalsra.ll
31

What Danny said - also, these tests are carbon copies of the existing ones above, they just operate on a constant instead of a global.

mehdi_amini accepted this revision.Dec 11 2015, 2:57 PM
mehdi_amini edited edge metadata.

LGTM, thanks.

This revision is now accepted and ready to land.Dec 11 2015, 2:57 PM

Is it to be landed?

jmolloy closed this revision.Apr 25 2016, 3:54 AM

Hi Mehdi,

Sorry for the delay on this. Committed in r267393.

James