Page MenuHomePhabricator

[SPARC][clang] Enable frame pointer optimization by default
ClosedPublic

Authored by koakuma on Nov 22 2022, 4:40 PM.

Details

Summary

Enable frame pointer optimization by default to match it with other targets.
This brings a small reduction in generated binary sizes.

Fixes bug #48327 (https://github.com/llvm/llvm-project/issues/48327).

Diff Detail

Event Timeline

koakuma created this revision.Nov 22 2022, 4:40 PM
koakuma requested review of this revision.Nov 22 2022, 4:40 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 22 2022, 4:40 PM

Enable frame pointer optimization by default to match it with other targets.

I think we usually follow GCC instead of other targets.

I am unfamiliar with sparc. Can you show an example where -fomit-frame-pointer/-fno-omit-frame-pointer demonstrate a codegen difference? I tried some simple examples and cannot reproduce a difference.

It's somewhat unfortunate to add 6 RUN lines to test these sparc behaviors...

I think we usually follow GCC instead of other targets.

GCC enables it by default too, for example see https://godbolt.org/z/brPMKnM17
(That link also has comparison with clang with -fomit-frame-pointer/-fno-omit-frame-pointer)

I am unfamiliar with sparc. Can you show an example where -fomit-frame-pointer/-fno-omit-frame-pointer demonstrate a codegen difference? I tried some simple examples and cannot reproduce a difference.

Unfortunately on SPARC, due to the register window mechanics this optimization can only be done on leaf functions.
As for the concrete effects, it skips the save and restore instructions for register window management, which, among other things, does the saving/restoring of frame pointers, and changes the return instruction to retl (aka jmp %o7+8).

koakuma edited the summary of this revision. (Show Details)Nov 22 2022, 10:27 PM
arsenm accepted this revision.Nov 28 2022, 1:25 PM

LGTM. I still find it strange that by default clang explicitly disables an optimization that's the default for unattributed functions

This revision is now accepted and ready to land.Nov 28 2022, 1:25 PM
This revision was automatically updated to reflect the committed changes.