This is an archive of the discontinued LLVM Phabricator instance.

[GlobalOpt] Localize some globals that have non-instruction users
ClosedPublic

Authored by jmolloy on Nov 19 2015, 6:43 AM.

Details

Summary

We currently bail out of global localization if the global has non-instruction users. However, often these can be simple bitcasts or constant-GEPs, which we can easily turn into instructions before localizing. Be a bit more aggressive.

Diff Detail

Repository
rL LLVM

Event Timeline

jmolloy updated this revision to Diff 40638.Nov 19 2015, 6:43 AM
jmolloy retitled this revision from to [GlobalOpt] Localize some globals that have non-instruction users.
jmolloy updated this object.
jmolloy added reviewers: mehdi_amini, dexonsmith.
jmolloy set the repository for this revision to rL LLVM.
jmolloy added a subscriber: llvm-commits.
mehdi_amini accepted this revision.Nov 19 2015, 8:02 AM
mehdi_amini edited edge metadata.

LGTM with some comments.

lib/Transforms/IPO/GlobalOpt.cpp
1845

Nit: A common pattern is to put UUsers out of the loop and call clear at the end of each iteration. So that if you cross the limit of 4 multiple times you won't pay the dynamic allocation (and the copy) again.

1849

Minor suggestion: I'd rather read assert(isa<Instruction>) before cast<Instruction>

test/Transforms/GlobalOpt/localize-constexpr.ll
9

The last check is spurious. The next CHECK-LABEL should be enough I think.

This revision is now accepted and ready to land.Nov 19 2015, 8:02 AM