This is an archive of the discontinued LLVM Phabricator instance.

os_log: make buffer size an integer constant expression.
ClosedPublic

Authored by t.p.northover on Oct 22 2018, 10:37 AM.

Details

Reviewers
efriedma
Summary

The size of an os_log buffer is known at any stage of compilation, so making it a constant expression means that the common idiom of declaring a buffer for it won't result in a VLA. That allows the compiler to skip saving and restoring the stack pointer around such buffers.

There can be hundreds or even thousands of such calls, even in firmware projects, so the code size savings add up.

Diff Detail

Repository
rC Clang

Event Timeline

t.p.northover created this revision.Oct 22 2018, 10:37 AM
efriedma accepted this revision.Oct 29 2018, 1:00 PM
efriedma added subscribers: vsk, efriedma.

LGTM

This revision is now accepted and ready to land.Oct 29 2018, 1:00 PM
t.p.northover closed this revision.Nov 1 2018, 8:38 AM

Thanks Eli. I committed it as r345828, and then had to fixup some linker dependencies on other platforms, which took me a couple of tries (r345833 and r345835).

t.p.northover reopened this revision.Nov 1 2018, 9:40 AM

Turns out I neglected the layering between libclangAST and libclangAnalysis so I've reverted for now. For this to work I think we need to move the OSLog helpers into libclangAST. I'll put together a new patch and upload it.

This revision is now accepted and ready to land.Nov 1 2018, 9:40 AM

Same as previous patch except the OSLog helpers are moved to libclangAST to respect dependencies.

hiraditya closed this revision.Sep 29 2019, 9:16 AM
hiraditya added a subscriber: hiraditya.

closed in r345828, 314fbfa1c4c6665c54a220eefb10a6f23010a352

Herald added a project: Restricted Project. · View Herald TranscriptSep 29 2019, 9:16 AM