On 7/7/24 9:29 AM, Nathaniel Shead wrote:
Bootstrapped and regtested on x86_64-pc-linux-gnu, OK for trunk?
Or should I include a testcase? I haven't reduced one from using the
full contents of C++23 <iostream> yet but I can do so if you prefer.
Would adding -ftime-report to the pr99166 test reproduce the issue?
-- >8 --
While lazy loading, instantiation of pendings can sometimes recursively
perform name lookup and begin further lazy loading. When using the
'-ftime-report' functionality this causes ICEs as we could start an
already-running timer for the importing.
This patch fixes the issue by using the 'timevar_cond*' API instead to
support such recursive calls.
PR c++/115165
gcc/cp/ChangeLog:
* module.cc (lazy_load_binding): Use 'timevar_cond*' APIs.
(lazy_load_pendings): Likewise.
Signed-off-by: Nathaniel Shead <nathanielosh...@gmail.com>
---
gcc/cp/module.cc | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
index dc5d046f04d..fec1b7e58df 100644
--- a/gcc/cp/module.cc
+++ b/gcc/cp/module.cc
@@ -19564,7 +19564,7 @@ lazy_load_binding (unsigned mod, tree ns, tree id,
binding_slot *mslot)
{
int count = errorcount + warningcount;
- timevar_start (TV_MODULE_IMPORT);
+ bool timer_running = timevar_cond_start (TV_MODULE_IMPORT);
/* Make sure lazy loading from a template context behaves as if
from a non-template context. */
@@ -19594,7 +19594,7 @@ lazy_load_binding (unsigned mod, tree ns, tree id,
binding_slot *mslot)
function_depth--;
- timevar_stop (TV_MODULE_IMPORT);
+ timevar_cond_stop (TV_MODULE_IMPORT, timer_running);
if (!ok)
fatal_error (input_location,
@@ -19633,7 +19633,7 @@ lazy_load_pendings (tree decl)
int count = errorcount + warningcount;
- timevar_start (TV_MODULE_IMPORT);
+ bool timer_running = timevar_cond_start (TV_MODULE_IMPORT);
bool ok = !recursive_lazy ();
if (ok)
{
@@ -19667,7 +19667,7 @@ lazy_load_pendings (tree decl)
function_depth--;
}
- timevar_stop (TV_MODULE_IMPORT);
+ timevar_cond_stop (TV_MODULE_IMPORT, timer_running);
if (!ok)
fatal_error (input_location, "failed to load pendings for %<%E%s%E%>",