diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -896,7 +896,7 @@ { PrettyStackTraceString CrashInfo("Per-function optimization"); - llvm::TimeTraceScope TimeScope("PerFunctionPasses", StringRef("")); + llvm::TimeTraceScope TimeScope("PerFunctionPasses"); PerFunctionPasses.doInitialization(); for (Function &F : *TheModule) @@ -907,13 +907,13 @@ { PrettyStackTraceString CrashInfo("Per-module optimization passes"); - llvm::TimeTraceScope TimeScope("PerModulePasses", StringRef("")); + llvm::TimeTraceScope TimeScope("PerModulePasses"); PerModulePasses.run(*TheModule); } { PrettyStackTraceString CrashInfo("Code generation"); - llvm::TimeTraceScope TimeScope("CodeGenPasses", StringRef("")); + llvm::TimeTraceScope TimeScope("CodeGenPasses"); CodeGenPasses.run(*TheModule); } @@ -1499,7 +1499,7 @@ BackendAction Action, std::unique_ptr OS) { - llvm::TimeTraceScope TimeScope("Backend", StringRef("")); + llvm::TimeTraceScope TimeScope("Backend"); std::unique_ptr EmptyModule; if (!CGOpts.ThinLTOIndexFile.empty()) { diff --git a/clang/lib/CodeGen/CodeGenAction.cpp b/clang/lib/CodeGen/CodeGenAction.cpp --- a/clang/lib/CodeGen/CodeGenAction.cpp +++ b/clang/lib/CodeGen/CodeGenAction.cpp @@ -249,7 +249,7 @@ void HandleTranslationUnit(ASTContext &C) override { { - llvm::TimeTraceScope TimeScope("Frontend", StringRef("")); + llvm::TimeTraceScope TimeScope("Frontend"); PrettyStackTraceString CrashInfo("Per-file LLVM IR generation"); if (FrontendTimesIsEnabled) { LLVMIRGenerationRefCount += 1; diff --git a/clang/lib/Parse/ParseAST.cpp b/clang/lib/Parse/ParseAST.cpp --- a/clang/lib/Parse/ParseAST.cpp +++ b/clang/lib/Parse/ParseAST.cpp @@ -151,7 +151,7 @@ bool HaveLexer = S.getPreprocessor().getCurrentLexer(); if (HaveLexer) { - llvm::TimeTraceScope TimeScope("Frontend", StringRef("")); + llvm::TimeTraceScope TimeScope("Frontend"); P.Initialize(); Parser::DeclGroupPtrTy ADecl; for (bool AtEOF = P.ParseFirstTopLevelDecl(ADecl); !AtEOF; diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp --- a/clang/lib/Sema/Sema.cpp +++ b/clang/lib/Sema/Sema.cpp @@ -924,8 +924,7 @@ } { - llvm::TimeTraceScope TimeScope("PerformPendingInstantiations", - StringRef("")); + llvm::TimeTraceScope TimeScope("PerformPendingInstantiations"); PerformPendingInstantiations(); } diff --git a/clang/lib/Serialization/GlobalModuleIndex.cpp b/clang/lib/Serialization/GlobalModuleIndex.cpp --- a/clang/lib/Serialization/GlobalModuleIndex.cpp +++ b/clang/lib/Serialization/GlobalModuleIndex.cpp @@ -134,7 +134,7 @@ "' failed: " + toString(std::move(Err))); }; - llvm::TimeTraceScope TimeScope("Module LoadIndex", StringRef("")); + llvm::TimeTraceScope TimeScope("Module LoadIndex"); // Read the global index. bool InGlobalIndexBlock = false; bool Done = false; @@ -770,7 +770,7 @@ } using namespace llvm; - llvm::TimeTraceScope TimeScope("Module WriteIndex", StringRef("")); + llvm::TimeTraceScope TimeScope("Module WriteIndex"); // Emit the file header. Stream.Emit((unsigned)'B', 8); diff --git a/clang/tools/driver/cc1_main.cpp b/clang/tools/driver/cc1_main.cpp --- a/clang/tools/driver/cc1_main.cpp +++ b/clang/tools/driver/cc1_main.cpp @@ -246,7 +246,7 @@ // Execute the frontend actions. { - llvm::TimeTraceScope TimeScope("ExecuteCompiler", StringRef("")); + llvm::TimeTraceScope TimeScope("ExecuteCompiler"); Success = ExecuteCompilerInvocation(Clang.get()); } diff --git a/llvm/include/llvm/Support/TimeProfiler.h b/llvm/include/llvm/Support/TimeProfiler.h --- a/llvm/include/llvm/Support/TimeProfiler.h +++ b/llvm/include/llvm/Support/TimeProfiler.h @@ -58,6 +58,10 @@ TimeTraceScope(TimeTraceScope &&) = delete; TimeTraceScope &operator=(TimeTraceScope &&) = delete; + TimeTraceScope(StringRef Name) { + if (TimeTraceProfilerInstance != nullptr) + timeTraceProfilerBegin(Name, StringRef("")); + } TimeTraceScope(StringRef Name, StringRef Detail) { if (TimeTraceProfilerInstance != nullptr) timeTraceProfilerBegin(Name, Detail); diff --git a/llvm/lib/Support/TimeProfiler.cpp b/llvm/lib/Support/TimeProfiler.cpp --- a/llvm/lib/Support/TimeProfiler.cpp +++ b/llvm/lib/Support/TimeProfiler.cpp @@ -123,7 +123,9 @@ J.attribute("ts", StartUs); J.attribute("dur", DurUs); J.attribute("name", E.Name); - J.attributeObject("args", [&] { J.attribute("detail", E.Detail); }); + if (!E.Detail.empty()) { + J.attributeObject("args", [&] { J.attribute("detail", E.Detail); }); + } }); }