This is an archive of the discontinued LLVM Phabricator instance.

[libc] add compile option for printf arg type array
ClosedPublic

Authored by michaelrj on Aug 16 2022, 2:05 PM.

Details

Summary

This patch allows for adjusting the size of the array that printf uses
to track the types of arguments in index mode. This is useful for
optimizing the tradeoff between memory usage and performance.

Diff Detail

Event Timeline

michaelrj created this revision.Aug 16 2022, 2:05 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptAug 16 2022, 2:05 PM
michaelrj requested review of this revision.Aug 16 2022, 2:05 PM
sivachandra added inline comments.Aug 17 2022, 12:04 AM
libc/src/stdio/printf_core/parser.h
51

Normally, config params like this are all put in one single .h file, say in this printf_parser_config.h:

#ifndef LLVM_LIBC_PRINTF_INDEX_ARR_LEN
// Explain what this param is about.
#define LLVM_LIBC_PRINTF_INDEX_ARR_LEN 128
#endif

Include printf_parser_config.h in parser.h. Not sure if we really want a separate config file for the parser, may be just a printf_config.h file is sufficient.

michaelrj updated this revision to Diff 454967.Aug 23 2022, 2:47 PM
michaelrj marked an inline comment as done.

move the config into a separate file.

sivachandra accepted this revision.Aug 25 2022, 2:59 PM
sivachandra added inline comments.
libc/src/stdio/printf_core/printf_config.h
17 ↗(On Diff #455281)

Nit: Give an example of what that "severity" will look like.

This revision is now accepted and ready to land.Aug 25 2022, 2:59 PM
michaelrj marked an inline comment as done.

add description of how the index array being too small effects runtime.

This revision was landed with ongoing or failed builds.Aug 26 2022, 11:38 AM
This revision was automatically updated to reflect the committed changes.