]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[auto-profile] Improve handling of timestamp merging.
authorPrathamesh Kulkarni <prathameshk@nvidia.com>
Wed, 8 Apr 2026 05:56:12 +0000 (05:56 +0000)
committerPrathamesh Kulkarni <prathameshk@nvidia.com>
Wed, 8 Apr 2026 05:57:59 +0000 (05:57 +0000)
The following condition:
if (other->timestamp() < timestamp())
  set_timestamp (other->timetamp())

would set timestamp() to 0 if other->timestamp() was zero effectively
dropping the symbol from time-profile based reordering.
The patch fixes this by ensuring other->timestamp() is greater than zero.

Also, handles the case when timestamp() is zero but other->timestamp() is non-zero.

gcc/ChangeLog:
* auto-profile.cc (function_instance::merge): Set other->timestamp() if it's
lesser than timestamp() and greater than zero or if timestamp() is zero.

Signed-off-by: Prathamesh Kulkarni <prathameshk@nvidia.com>
gcc/auto-profile.cc

index 34f863a773108f5fa9c4d165a7a61b3642dac258..f4562d7f2f98d8468dd684774d5943cf09f90f76 100644 (file)
@@ -1372,7 +1372,9 @@ function_instance::merge (function_instance *other,
     head_count_ += other->head_count_;
 
   /* While merging timestamps, set the one that occurs earlier.  */
-  if (other->timestamp () < timestamp ())
+  if (timestamp () == 0
+      || (other->timestamp () > 0
+         && other->timestamp () < timestamp ()))
     set_timestamp (other->timestamp ());
 
   bool changed = true;