[PATCH] D57835: Fix -ftime-report with -x ir

Matt Arsenault via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 6 12:09:44 PST 2019


arsenm created this revision.
Herald added a subscriber: wdng.

This was only printing the clang frontend timer, and none of the
backend timers. Set the llvm global for enabling the backend time
report when creating the frontend timers, rather than in the
BackendConsumer constructor.

      

There's still something wrong with how the timers are managed though,
since the report seems to be printed twice for each one.


https://reviews.llvm.org/D57835

Files:
  lib/CodeGen/CodeGenAction.cpp
  lib/Frontend/CompilerInstance.cpp
  test/Frontend/ftime-report-bitcode.ll


Index: test/Frontend/ftime-report-bitcode.ll
===================================================================
--- /dev/null
+++ test/Frontend/ftime-report-bitcode.ll
@@ -0,0 +1,14 @@
+; RUN: %clang_cc1 -triple x86_64-apple-darwin10 -ftime-report -emit-obj -o /dev/null %s 2>&1 | FileCheck %s
+
+target triple ="x86_64-apple-darwin10"
+
+; Make sure the backend time reports are produced when compiling an IR
+; input
+
+; CHECK: Pass execution timing report
+; CHECK: LLVM IR Parsing
+; CHECK: Clang front-end time report
+
+define i32 @foo() {
+  ret i32 0
+}
Index: lib/Frontend/CompilerInstance.cpp
===================================================================
--- lib/Frontend/CompilerInstance.cpp
+++ lib/Frontend/CompilerInstance.cpp
@@ -941,8 +941,10 @@
        << " based upon " << BACKEND_PACKAGE_STRING
        << " default target " << llvm::sys::getDefaultTargetTriple() << "\n";
 
-  if (getFrontendOpts().ShowTimers)
+  if (getFrontendOpts().ShowTimers) {
+    llvm::TimePassesIsEnabled = true;
     createFrontendTimer();
+  }
 
   if (getFrontendOpts().ShowStats || !getFrontendOpts().StatsFile.empty())
     llvm::EnableStatistics(false);
Index: lib/CodeGen/CodeGenAction.cpp
===================================================================
--- lib/CodeGen/CodeGenAction.cpp
+++ lib/CodeGen/CodeGenAction.cpp
@@ -126,7 +126,6 @@
                                 CodeGenOpts, C, CoverageInfo)),
           LinkModules(std::move(LinkModules)) {
       FrontendTimesIsEnabled = TimePasses;
-      llvm::TimePassesIsEnabled = TimePasses;
     }
     llvm::Module *getModule() const { return Gen->GetModule(); }
     std::unique_ptr<llvm::Module> takeModule() {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57835.185611.patch
Type: text/x-patch
Size: 1685 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190206/a6692a06/attachment.bin>


More information about the cfe-commits mailing list