Understanding and improving Clang -ftime-report | MaskRay

submited by
Style Pass
2025-01-13 07:00:04

Clang provides a few options to generate timing report. Among them, -ftime-report and -ftime-trace can be used to analyze the performance of Clang's internal passes.

The output consists of information about multiple timer groups. The last group spans the largest interval and encompasses timing data from other groups.

The "Clang front-end timer" timer measured the time spent in clang::FrontendAction::Execute, which includes lexing, parsing, semantic analysis, LLVM IR generation, optimization, and machine code generation. However, "Code Generation Time" and "LLVM IR Generation Time" belonged to the default timer group "Miscellaneous Ungrouped Timers". This caused confusion for many users. For example, https://aras-p.info/blog/2019/01/12/Investigating-compile-times-and-Clang-ftime-report/ elaborates on the issues.

The last group has been renamed and changed to cover a longer interval within the invocation. It provides timing information for four stages:

Leave a Comment