Skip to content

Commit 83eb8ae

Browse files
atetubouMaskRay
authored andcommitted
Use timeTraceAsyncProfilerBegin for Source span (#83961)
This fixes incorrect trace for #56554. This shows trace like https://ui.perfetto.dev/#!/?s=aa809778dc50f2b155b062317fa18bbe2bb2fb9175e6282add8121c7c178214e for the case shown in #83236. #83778 is preparing PR. Fix #56554
1 parent c48aa78 commit 83eb8ae

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

clang/lib/Sema/Sema.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ namespace sema {
135135
class SemaPPCallbacks : public PPCallbacks {
136136
Sema *S = nullptr;
137137
llvm::SmallVector<SourceLocation, 8> IncludeStack;
138+
llvm::SmallVector<llvm::TimeTraceProfilerEntry *, 8> ProfilerStack;
138139

139140
public:
140141
void set(Sema &S) { this->S = &S; }
@@ -153,8 +154,8 @@ class SemaPPCallbacks : public PPCallbacks {
153154
if (IncludeLoc.isValid()) {
154155
if (llvm::timeTraceProfilerEnabled()) {
155156
OptionalFileEntryRef FE = SM.getFileEntryRefForID(SM.getFileID(Loc));
156-
llvm::timeTraceProfilerBegin("Source", FE ? FE->getName()
157-
: StringRef("<unknown>"));
157+
ProfilerStack.push_back(llvm::timeTraceAsyncProfilerBegin(
158+
"Source", FE ? FE->getName() : StringRef("<unknown>")));
158159
}
159160

160161
IncludeStack.push_back(IncludeLoc);
@@ -167,7 +168,7 @@ class SemaPPCallbacks : public PPCallbacks {
167168
case ExitFile:
168169
if (!IncludeStack.empty()) {
169170
if (llvm::timeTraceProfilerEnabled())
170-
llvm::timeTraceProfilerEnd();
171+
llvm::timeTraceProfilerEnd(ProfilerStack.pop_back_val());
171172

172173
S->DiagnoseNonDefaultPragmaAlignPack(
173174
Sema::PragmaAlignPackDiagnoseKind::ChangedStateAtExit,

0 commit comments

Comments
 (0)