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

Paweł Bylica via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 30 01:05:46 PDT 2026


https://github.com/chfast updated https://github.com/llvm/llvm-project/pull/193717

>From 3038010221472b7fe8f9d140ba4dcf2db9806a31 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pawe=C5=82=20Bylica?= <pawel at hepcolgum.band>
Date: Thu, 23 Apr 2026 13:21:10 +0200
Subject: [PATCH] [clang][unittests] Fix flaky PerformPendingInstantiations
 nesting in TimeProfilerTest
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

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.
---
 clang/unittests/Support/TimeProfilerTest.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

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