diff --git a/llvm/include/llvm/IR/PassManager.h b/llvm/include/llvm/IR/PassManager.h --- a/llvm/include/llvm/IR/PassManager.h +++ b/llvm/include/llvm/IR/PassManager.h @@ -46,6 +46,7 @@ #include "llvm/IR/PassInstrumentation.h" #include "llvm/IR/PassManagerInternal.h" #include "llvm/Support/Debug.h" +#include "llvm/Support/TimeProfiler.h" #include "llvm/Support/TypeName.h" #include "llvm/Support/raw_ostream.h" #include @@ -512,6 +513,8 @@ if (!PI.runBeforePass(*P, IR)) continue; + llvm::TimeTraceScope PassScope("RunPass", P->name()); + PreservedAnalyses PassPA = P->run(IR, AM, ExtraArgs...); // Call onto PassInstrumentation's AfterPass callbacks immediately after @@ -1290,6 +1293,8 @@ FunctionAnalysisManager &FAM = AM.getResult(M).getManager(); + llvm::TimeTraceScope ModuleScope("OptModule", M.getName()); + // Request PassInstrumentation from analysis manager, will use it to run // instrumenting callbacks for the passes later. PassInstrumentation PI = AM.getResult(M); @@ -1304,6 +1309,9 @@ // false). if (!PI.runBeforePass(Pass, F)) continue; + + llvm::TimeTraceScope FunctionScope("OptFunction", F.getName()); + PreservedAnalyses PassPA = Pass.run(F, FAM); PI.runAfterPass(Pass, F);