[clang] 1862fd2 - [clang][unittests] Fix flaky PerformPendingInstantiations nesting in TimeProfilerTest (#193717)

via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 30 04:15:41 PDT 2026


Author: Paweł Bylica
Date: 2026-04-30T13:15:36+02:00
New Revision: 1862fd21d631599c658b8ae39d3bcb379f0d5f4c

URL: https://github.com/llvm/llvm-project/commit/1862fd21d631599c658b8ae39d3bcb379f0d5f4c
DIFF: https://github.com/llvm/llvm-project/commit/1862fd21d631599c658b8ae39d3bcb379f0d5f4c.diff

LOG: [clang][unittests] Fix flaky PerformPendingInstantiations nesting in TimeProfilerTest (#193717)

buildTraceGraph already compensates for timer rounding that makes
PerformPendingInstantiations appear to be inside the previous event, but
only when it is nested exactly one level deep. The aarch64-darwin
buildbot produced three-level nesting for ConstantEvaluationC99, which
slipped through the normalization and broke the expected trace output.

Keep popping while PerformPendingInstantiations looks nested—we know it
is always a top-level event in these tests—instead of stopping at the
single-level case.

Followup to https://github.com/llvm/llvm-project/pull/138613.

Added: 
    

Modified: 
    clang/unittests/Support/TimeProfilerTest.cpp

Removed: 
    


################################################################################
diff  --git a/clang/unittests/Support/TimeProfilerTest.cpp b/clang/unittests/Support/TimeProfilerTest.cpp
index 84e9dc232be75..4433445c5e27f 100644
--- a/clang/unittests/Support/TimeProfilerTest.cpp
+++ b/clang/unittests/Support/TimeProfilerTest.cpp
@@ -155,10 +155,10 @@ std::string buildTraceGraph(StringRef Json) {
 
       // Presumably due to timer rounding, PerformPendingInstantiations often
       // appear to be within the timer interval of the immediately previous
-      // event group. We always know these events occur at level 1, not level 2,
-      // in our tests, so pop an event in that case.
+      // event group. We always know these events occur at level 1 in our
+      // tests, so keep popping until the stack is back at the root.
       if (InsideCurrentEvent && Event.Name == "PerformPendingInstantiations" &&
-          EventStack.size() == 2) {
+          EventStack.size() >= 2) {
         InsideCurrentEvent = false;
       }
 


        


More information about the cfe-commits mailing list