lebedev.ri added inline comments.

================
Comment at: cfe/trunk/lib/CodeGen/BackendUtil.cpp:1426-1431
   EmitAssemblyHelper AsmHelper(Diags, HeaderOpts, CGOpts, TOpts, LOpts, M);
 
   if (CGOpts.ExperimentalNewPassManager)
     AsmHelper.EmitAssemblyWithNewPassManager(Action, std::move(OS));
   else
     AsmHelper.EmitAssembly(Action, std::move(OS));
----------------
anton-afanasyev wrote:
> lebedev.ri wrote:
> > anton-afanasyev wrote:
> > > lebedev.ri wrote:
> > > > anton-afanasyev wrote:
> > > > > anton-afanasyev wrote:
> > > > > > lebedev.ri wrote:
> > > > > > > This isn't covered by any timer; if you look in `BackendUtil.cpp`,
> > > > > > > `EmitAssemblyHelper` actually has `CodeGenerationTime("codegen", 
> > > > > > > "Code Generation Time")` timer.
> > > > > > Thanks, I'm to add it.
> > > > > Hmm, I've figured out this isn't needed: such new timer mostly 
> > > > > coincides with "Backend" timer (above). Legacy `Timer 
> > > > > CodeGenerationTime(...)` is bad example of doing right timing.
> > > > "Mostly coincides" may not be the best way to approach fine-grained 
> > > > timings, i think? :)
> > > > 
> > > > I have noticed this because when i looked at the produced time flame 
> > > > graph,
> > > > there's large section in the end that is covered only by `"Backend"` 
> > > > timer,
> > > > but nothing else. Now, i'm not going to say whether or not that extra 
> > > > section
> > > > should or should not be within `"Backend"` timer, but it certainly 
> > > > should *also*
> > > > be within `"codegen"` timer. Or is there no codegen time spent there?
> > > > {F10062322}
> > > > {F10062316}
> > > "Mostly coincides" here means "identical" I believe, the difference is 
> > > auxiliary stuff.
> > > Please look at `clang::EmitBackendOutput()`, `"Backend"` timer is outer 
> > > for `"codegen"` one.
> > Then we are talking about different things using the same name.
> > There are two distinct codegen steps:
> > 1. clang AST -> LLVM IR codegen
> > (after that, all the opt passes run)
> > 2. LLVM IR -> final assembly. This happens after all the opt middle-end 
> > passes.
> > 
> > Those are *different* codegen's.
> Yes, and step 1 is named as "CodeGen Function" whereas step 2 is named just 
> "Backend".
Aha. So this is what i //expected// to see, apparently: 
{F10063128} {F10063119}
```
diff --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 71ae8fd4fb0..d89d12612f8 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -910,6 +910,7 @@ void EmitAssemblyHelper::EmitAssembly(BackendAction Action,
 
   {
     PrettyStackTraceString CrashInfo("Code generation");
+    llvm::TimeTraceScope TimeScope("BackendCodegen", StringRef(""));
     CodeGenPasses.run(*TheModule);
   }
```

But that actually brings me to another question - what about 
`PrettyStackTraceString CrashInfo("Per-function optimization");`?
Should that be wrapped into some section, too?
I'm less certain here.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58675/new/

https://reviews.llvm.org/D58675



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to