This patch is a enhancement of D74516.
The previous implementation of time tracing in NewPassManager is direct but messive.
The key codes are like the demo below:
/// Runs the function pass across every function in the module. PreservedAnalyses run(LazyCallGraph::SCC &C, CGSCCAnalysisManager &AM, LazyCallGraph &CG, CGSCCUpdateResult &UR) { /// ... PreservedAnalyses PassPA; { TimeTraceScope TimeScope(Pass.name()); PassPA = Pass.run(F, FAM); } /// ... }
It can be bothered to judge where should we add the tracing codes by hands.
With the PassInstrumentation framework, we can easily add Before/After callback
functions to add time tracing codes.
Thus, the implementation of that can be clearer than before by this mechanism.
Further more, we need not to add time tracing codes by hands when new types of PassManager are added.
Through this improved method, the time tracing results of pass execution time now are approximately equal to the previous one.
Demo:
{ // ... (Previous) "dur": 31, "name": "Total AnnotationRemarksPass", // ... }, { // ... (Now) "dur": 50, "name": "Total AnnotationRemarksPass", // ... }, { // ... (Previous) "dur": 840, "name": "Total AlwaysInlinerPass", // ... }, { // ... (Now) "dur": 725, "name": "Total AlwaysInlinerPass", // ... }
Could we use /// here to get better doxygen appearances?