diff --git a/tools/ClangPlugin.cpp b/tools/ClangPlugin.cpp index cc8cd6ec5..1cdf242c4 100644 --- a/tools/ClangPlugin.cpp +++ b/tools/ClangPlugin.cpp @@ -101,15 +101,9 @@ namespace clad { }; CladPlugin::CladPlugin(CompilerInstance& CI, DifferentiationOptions& DO) - : m_CI(CI), m_DO(DO), m_HasRuntime(false), m_TG("Clad timers", "Timers for clad funcs"){ + : m_CI(CI), m_DO(DO), m_HasRuntime(false), + m_TG("Clad timers", "Timers for clad funcs") { #if CLANG_VERSION_MAJOR > 8 - const clang::CommentOptions::BlockCommandNamesTy cmdargs = m_CI.getCodeGenOpts().CommandLineArgs; - for(const std::string &arg: cmdargs){ - if(arg == "-ftime-report") { - m_PrintTimings = true; - break; - } - } FrontendOptions& Opts = CI.getFrontendOpts(); // Find the path to clad. llvm::StringRef CladSoPath; @@ -166,7 +160,8 @@ namespace clad { m_PendingInstantiationsInFlight = false; } // Necessary to prevent separate timing reports due to expired timers - llvm::Timer dummy("Dummy timer", "Prevent premature printing of timings", m_TG); + llvm::Timer dummy("Dummy timer", "Prevent premature printing of timings", + m_TG); for (DiffRequest& request : requests) ProcessDiffRequest(request); return true; // Happiness @@ -247,19 +242,16 @@ namespace clad { } else { // Only time the function when it is first encountered llvm::Timer tm("Clad timer", request.BaseFunctionName, m_TG); - if(m_PrintTimings && !tm.isRunning()){ + if (m_CI.getCodeGenOpts().TimePasses && !tm.isRunning()) tm.startTimer(); - } auto deriveResult = m_DerivativeBuilder->Derive(request); DerivativeDecl = deriveResult.derivative; OverloadedDerivativeDecl = deriveResult.overload; - if(m_PrintTimings && tm.isRunning()){ + if (tm.isRunning()) tm.stopTimer(); - } } } - if (DerivativeDecl) { if (!alreadyDerived) { m_DFC.Add( diff --git a/tools/ClangPlugin.h b/tools/ClangPlugin.h index 888a3f6e4..97d4b0123 100644 --- a/tools/ClangPlugin.h +++ b/tools/ClangPlugin.h @@ -19,8 +19,8 @@ #include "clang/Basic/Version.h" #include "clang/Frontend/FrontendPluginRegistry.h" -#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/SmallVector.h" #include "llvm/Support/Timer.h" namespace clang { @@ -90,7 +90,6 @@ namespace clad { bool m_HasRuntime = false; bool m_PendingInstantiationsInFlight = false; bool m_HandleTopLevelDeclInternal = false; - bool m_PrintTimings = false; llvm::TimerGroup m_TG; DerivedFnCollector m_DFC; public: