Skip to content

Commit 4f2104c

Browse files
committed
make -ftime-trace also trace time spent creating debug info
Differential Revision: https://reviews.llvm.org/D69750
1 parent 5fb1782 commit 4f2104c

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

clang/lib/CodeGen/CGDebugInfo.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
#include "llvm/Support/FileSystem.h"
4747
#include "llvm/Support/MD5.h"
4848
#include "llvm/Support/Path.h"
49+
#include "llvm/Support/TimeProfiler.h"
4950
using namespace clang;
5051
using namespace clang::CodeGen;
5152

@@ -2968,6 +2969,13 @@ llvm::DIType *CGDebugInfo::getOrCreateType(QualType Ty, llvm::DIFile *Unit) {
29682969
if (Ty.isNull())
29692970
return nullptr;
29702971

2972+
llvm::TimeTraceScope TimeScope("DebugType", [&]() {
2973+
std::string Name;
2974+
llvm::raw_string_ostream OS(Name);
2975+
Ty.print(OS, getPrintingPolicy());
2976+
return Name;
2977+
});
2978+
29712979
// Unwrap the type as needed for debug information.
29722980
Ty = UnwrapTypeForDebugInfo(Ty, CGM.getContext());
29732981

@@ -3686,6 +3694,15 @@ void CGDebugInfo::EmitFunctionDecl(GlobalDecl GD, SourceLocation Loc,
36863694
if (!D)
36873695
return;
36883696

3697+
llvm::TimeTraceScope TimeScope("DebugFunction", [&]() {
3698+
std::string Name;
3699+
llvm::raw_string_ostream OS(Name);
3700+
if (const NamedDecl *ND = dyn_cast<NamedDecl>(D))
3701+
ND->getNameForDiagnostic(OS, getPrintingPolicy(),
3702+
/*Qualified=*/true);
3703+
return Name;
3704+
});
3705+
36893706
llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero;
36903707
llvm::DIFile *Unit = getOrCreateFile(Loc);
36913708
bool IsDeclForCallSite = Fn ? true : false;
@@ -4406,6 +4423,14 @@ void CGDebugInfo::EmitGlobalVariable(llvm::GlobalVariable *Var,
44064423
if (D->hasAttr<NoDebugAttr>())
44074424
return;
44084425

4426+
llvm::TimeTraceScope TimeScope("DebugGlobalVariable", [&]() {
4427+
std::string Name;
4428+
llvm::raw_string_ostream OS(Name);
4429+
D->getNameForDiagnostic(OS, getPrintingPolicy(),
4430+
/*Qualified=*/true);
4431+
return Name;
4432+
});
4433+
44094434
// If we already created a DIGlobalVariable for this declaration, just attach
44104435
// it to the llvm::GlobalVariable.
44114436
auto Cached = DeclCache.find(D->getCanonicalDecl());
@@ -4466,6 +4491,14 @@ void CGDebugInfo::EmitGlobalVariable(const ValueDecl *VD, const APValue &Init) {
44664491
assert(DebugKind >= codegenoptions::LimitedDebugInfo);
44674492
if (VD->hasAttr<NoDebugAttr>())
44684493
return;
4494+
llvm::TimeTraceScope TimeScope("DebugConstGlobalVariable", [&]() {
4495+
std::string Name;
4496+
llvm::raw_string_ostream OS(Name);
4497+
VD->getNameForDiagnostic(OS, getPrintingPolicy(),
4498+
/*Qualified=*/true);
4499+
return Name;
4500+
});
4501+
44694502
auto Align = getDeclAlignIfRequired(VD, CGM.getContext());
44704503
// Create the descriptor for the variable.
44714504
llvm::DIFile *Unit = getOrCreateFile(VD->getLocation());

0 commit comments

Comments
 (0)