This is an archive of the discontinued LLVM Phabricator instance.

[AArch64][GlobalISel] Move the localizer to run before the legalizer, and always localize globals.
ClosedPublic

Authored by aemerson on Apr 3 2023, 4:24 PM.

Details

Summary

Our strategy for localizing globals in the entry block breaks down when we have
large functions with high register pressure, using lots of globals. When this
happens, our heuristics say that globals with many uses should not be localized,
leading us to cause excessive spills and stack usage. These situations are also
exacerbated by LTO which tends to generate large functions.

For now, moving to a strategy that's simpler and more akin to SelectionDAG
fixes these issues and makes our codegen more similar. This has an overall
neutral effect on size on CTMark, while showing slight improvements with -Os -flto
on benchmarks. For low level firmware software though we see big improvements.

The reason this is neutral, and not an improvement, is because we give up the
gains from CSE'ing globals in cases where we low register pressure. I think
this can be addressed in future with some better heuristics.

Diff Detail

Event Timeline

aemerson created this revision.Apr 3 2023, 4:24 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 3 2023, 4:24 PM
aemerson requested review of this revision.Apr 3 2023, 4:24 PM
paquette accepted this revision.Apr 3 2023, 4:36 PM

LGTM

This revision is now accepted and ready to land.Apr 3 2023, 4:36 PM
llvm/test/CodeGen/AArch64/GlobalISel/localizer-arm64-tti.ll