[PATCH] D69750: make -ftime-trace also trace time spent creating debug info
This revision was automatically updated to reflect the committed changes. Closed by commit rG4f2104c5adbc: make -ftime-trace also trace time spent creating debug info (authored by llunak). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D69750/new/ https://reviews.llvm.org/D69750 Files: clang/lib/CodeGen/CGDebugInfo.cpp Index: clang/lib/CodeGen/CGDebugInfo.cpp === --- clang/lib/CodeGen/CGDebugInfo.cpp +++ clang/lib/CodeGen/CGDebugInfo.cpp @@ -46,6 +46,7 @@ #include "llvm/Support/FileSystem.h" #include "llvm/Support/MD5.h" #include "llvm/Support/Path.h" +#include "llvm/Support/TimeProfiler.h" using namespace clang; using namespace clang::CodeGen; @@ -2968,6 +2969,13 @@ if (Ty.isNull()) return nullptr; + llvm::TimeTraceScope TimeScope("DebugType", [&]() { +std::string Name; +llvm::raw_string_ostream OS(Name); +Ty.print(OS, getPrintingPolicy()); +return Name; + }); + // Unwrap the type as needed for debug information. Ty = UnwrapTypeForDebugInfo(Ty, CGM.getContext()); @@ -3686,6 +3694,15 @@ if (!D) return; + llvm::TimeTraceScope TimeScope("DebugFunction", [&]() { +std::string Name; +llvm::raw_string_ostream OS(Name); +if (const NamedDecl *ND = dyn_cast(D)) + ND->getNameForDiagnostic(OS, getPrintingPolicy(), + /*Qualified=*/true); +return Name; + }); + llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero; llvm::DIFile *Unit = getOrCreateFile(Loc); bool IsDeclForCallSite = Fn ? true : false; @@ -4406,6 +4423,14 @@ if (D->hasAttr()) return; + llvm::TimeTraceScope TimeScope("DebugGlobalVariable", [&]() { +std::string Name; +llvm::raw_string_ostream OS(Name); +D->getNameForDiagnostic(OS, getPrintingPolicy(), +/*Qualified=*/true); +return Name; + }); + // If we already created a DIGlobalVariable for this declaration, just attach // it to the llvm::GlobalVariable. auto Cached = DeclCache.find(D->getCanonicalDecl()); @@ -4466,6 +4491,14 @@ assert(DebugKind >= codegenoptions::LimitedDebugInfo); if (VD->hasAttr()) return; + llvm::TimeTraceScope TimeScope("DebugConstGlobalVariable", [&]() { +std::string Name; +llvm::raw_string_ostream OS(Name); +VD->getNameForDiagnostic(OS, getPrintingPolicy(), + /*Qualified=*/true); +return Name; + }); + auto Align = getDeclAlignIfRequired(VD, CGM.getContext()); // Create the descriptor for the variable. llvm::DIFile *Unit = getOrCreateFile(VD->getLocation()); Index: clang/lib/CodeGen/CGDebugInfo.cpp === --- clang/lib/CodeGen/CGDebugInfo.cpp +++ clang/lib/CodeGen/CGDebugInfo.cpp @@ -46,6 +46,7 @@ #include "llvm/Support/FileSystem.h" #include "llvm/Support/MD5.h" #include "llvm/Support/Path.h" +#include "llvm/Support/TimeProfiler.h" using namespace clang; using namespace clang::CodeGen; @@ -2968,6 +2969,13 @@ if (Ty.isNull()) return nullptr; + llvm::TimeTraceScope TimeScope("DebugType", [&]() { +std::string Name; +llvm::raw_string_ostream OS(Name); +Ty.print(OS, getPrintingPolicy()); +return Name; + }); + // Unwrap the type as needed for debug information. Ty = UnwrapTypeForDebugInfo(Ty, CGM.getContext()); @@ -3686,6 +3694,15 @@ if (!D) return; + llvm::TimeTraceScope TimeScope("DebugFunction", [&]() { +std::string Name; +llvm::raw_string_ostream OS(Name); +if (const NamedDecl *ND = dyn_cast(D)) + ND->getNameForDiagnostic(OS, getPrintingPolicy(), + /*Qualified=*/true); +return Name; + }); + llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero; llvm::DIFile *Unit = getOrCreateFile(Loc); bool IsDeclForCallSite = Fn ? true : false; @@ -4406,6 +4423,14 @@ if (D->hasAttr()) return; + llvm::TimeTraceScope TimeScope("DebugGlobalVariable", [&]() { +std::string Name; +llvm::raw_string_ostream OS(Name); +D->getNameForDiagnostic(OS, getPrintingPolicy(), +/*Qualified=*/true); +return Name; + }); + // If we already created a DIGlobalVariable for this declaration, just attach // it to the llvm::GlobalVariable. auto Cached = DeclCache.find(D->getCanonicalDecl()); @@ -4466,6 +4491,14 @@ assert(DebugKind >= codegenoptions::LimitedDebugInfo); if (VD->hasAttr()) return; + llvm::TimeTraceScope TimeScope("DebugConstGlobalVariable", [&]() { +std::string Name; +llvm::raw_string_ostream OS(Name); +VD->getNameForDiagnostic(OS, getPrintingPolicy(), + /*Qualified=*/true); +return Name; + }); + auto Align = getDeclAlignIfRequired(VD, CGM.getContext()); // Create the descriptor for the variable. llvm::DIFile *Unit = getOrCreateFile(VD->getLocation()); ___
[PATCH] D69750: make -ftime-trace also trace time spent creating debug info
anton-afanasyev accepted this revision. anton-afanasyev added a comment. This revision is now accepted and ready to land. LGTM, thanks! Repository: rC Clang CHANGES SINCE LAST ACTION https://reviews.llvm.org/D69750/new/ https://reviews.llvm.org/D69750 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D69750: make -ftime-trace also trace time spent creating debug info
llunak created this revision. llunak added a reviewer: anton-afanasyev. llunak added a project: clang. Herald added subscribers: cfe-commits, aprantl. In debug builds a noticeable time can be spent generating debug info, so make -ftime-trace track that too. Repository: rC Clang https://reviews.llvm.org/D69750 Files: clang/lib/CodeGen/CGDebugInfo.cpp Index: clang/lib/CodeGen/CGDebugInfo.cpp === --- clang/lib/CodeGen/CGDebugInfo.cpp +++ clang/lib/CodeGen/CGDebugInfo.cpp @@ -46,6 +46,7 @@ #include "llvm/Support/FileSystem.h" #include "llvm/Support/MD5.h" #include "llvm/Support/Path.h" +#include "llvm/Support/TimeProfiler.h" using namespace clang; using namespace clang::CodeGen; @@ -2946,6 +2947,13 @@ if (Ty.isNull()) return nullptr; + llvm::TimeTraceScope TimeScope("DebugType", [&]() { +std::string Name; +llvm::raw_string_ostream OS(Name); +Ty.print(OS, getPrintingPolicy()); +return Name; + }); + // Unwrap the type as needed for debug information. Ty = UnwrapTypeForDebugInfo(Ty, CGM.getContext()); @@ -3664,6 +3672,15 @@ if (!D) return; + llvm::TimeTraceScope TimeScope("DebugFunction", [&]() { +std::string Name; +llvm::raw_string_ostream OS(Name); +if (const NamedDecl *ND = dyn_cast(D)) + ND->getNameForDiagnostic(OS, getPrintingPolicy(), + /*Qualified=*/true); +return Name; + }); + llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero; llvm::DIFile *Unit = getOrCreateFile(Loc); bool IsDeclForCallSite = Fn ? true : false; @@ -4384,6 +4401,14 @@ if (D->hasAttr()) return; + llvm::TimeTraceScope TimeScope("DebugGlobalVariable", [&]() { +std::string Name; +llvm::raw_string_ostream OS(Name); +D->getNameForDiagnostic(OS, getPrintingPolicy(), +/*Qualified=*/true); +return Name; + }); + // If we already created a DIGlobalVariable for this declaration, just attach // it to the llvm::GlobalVariable. auto Cached = DeclCache.find(D->getCanonicalDecl()); @@ -,6 +4469,14 @@ assert(DebugKind >= codegenoptions::LimitedDebugInfo); if (VD->hasAttr()) return; + llvm::TimeTraceScope TimeScope("DebugConstGlobalVariable", [&]() { +std::string Name; +llvm::raw_string_ostream OS(Name); +VD->getNameForDiagnostic(OS, getPrintingPolicy(), + /*Qualified=*/true); +return Name; + }); + auto Align = getDeclAlignIfRequired(VD, CGM.getContext()); // Create the descriptor for the variable. llvm::DIFile *Unit = getOrCreateFile(VD->getLocation()); Index: clang/lib/CodeGen/CGDebugInfo.cpp === --- clang/lib/CodeGen/CGDebugInfo.cpp +++ clang/lib/CodeGen/CGDebugInfo.cpp @@ -46,6 +46,7 @@ #include "llvm/Support/FileSystem.h" #include "llvm/Support/MD5.h" #include "llvm/Support/Path.h" +#include "llvm/Support/TimeProfiler.h" using namespace clang; using namespace clang::CodeGen; @@ -2946,6 +2947,13 @@ if (Ty.isNull()) return nullptr; + llvm::TimeTraceScope TimeScope("DebugType", [&]() { +std::string Name; +llvm::raw_string_ostream OS(Name); +Ty.print(OS, getPrintingPolicy()); +return Name; + }); + // Unwrap the type as needed for debug information. Ty = UnwrapTypeForDebugInfo(Ty, CGM.getContext()); @@ -3664,6 +3672,15 @@ if (!D) return; + llvm::TimeTraceScope TimeScope("DebugFunction", [&]() { +std::string Name; +llvm::raw_string_ostream OS(Name); +if (const NamedDecl *ND = dyn_cast(D)) + ND->getNameForDiagnostic(OS, getPrintingPolicy(), + /*Qualified=*/true); +return Name; + }); + llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero; llvm::DIFile *Unit = getOrCreateFile(Loc); bool IsDeclForCallSite = Fn ? true : false; @@ -4384,6 +4401,14 @@ if (D->hasAttr()) return; + llvm::TimeTraceScope TimeScope("DebugGlobalVariable", [&]() { +std::string Name; +llvm::raw_string_ostream OS(Name); +D->getNameForDiagnostic(OS, getPrintingPolicy(), +/*Qualified=*/true); +return Name; + }); + // If we already created a DIGlobalVariable for this declaration, just attach // it to the llvm::GlobalVariable. auto Cached = DeclCache.find(D->getCanonicalDecl()); @@ -,6 +4469,14 @@ assert(DebugKind >= codegenoptions::LimitedDebugInfo); if (VD->hasAttr()) return; + llvm::TimeTraceScope TimeScope("DebugConstGlobalVariable", [&]() { +std::string Name; +llvm::raw_string_ostream OS(Name); +VD->getNameForDiagnostic(OS, getPrintingPolicy(), + /*Qualified=*/true); +return Name; + }); + auto Align = getDeclAlignIfRequired(VD, CGM.getContext()); // Create the descriptor for the variable. llvm::DIFile *Unit = getOrCreateFile(VD->getLocation()); _