]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gcov: Only consider pure locations in line mapping
authorJørgen Kvalsvik <j@lambda.is>
Wed, 5 Nov 2025 19:15:50 +0000 (20:15 +0100)
committerJørgen Kvalsvik <j@lambda.is>
Fri, 30 Jan 2026 10:20:57 +0000 (11:20 +0100)
Fixes a regression introduced I bisected to this commit:

commit 385d9937f0e23cbf9c62f0b2553a33ff70e56ecf
Author: Jan Hubicka <hubicka@ucw.cz>
Date:   Fri Jul 11 13:01:13 2025 +0200
    Rewrite assign_discriminators

That patch adds discriminators to edge->goto_locus which will map to
the right source location, but breaks the equality comparison used in
the hash set.

Fixes these tests:

gcc/testsuite/gcc.misc-tests/gcov-pr83813.c
gcc/testsuite/gcc.misc-tests/gcov-pr84758.c
gcc/testsuite/gcc.misc-tests/gcov-pr85332.c
gcc/testsuite/gcc.misc-tests/gcov-pr85372.c

PR gcov-profile/121084
PR gcov-profile/121123
PR gcov-profile/121409

gcc/ChangeLog:

* profile.cc (branch_prob): Record seen_locations without
discriminators.

gcc/profile.cc

index 21e33b985dc4793acb6f5c5175ea1020d4644e60..17841fc723a051539ff5ed6c9f462bc5f246f011 100644 (file)
@@ -1554,7 +1554,7 @@ branch_prob (bool thunk)
              location_t loc = DECL_SOURCE_LOCATION (current_function_decl);
              if (!RESERVED_LOCATION_P (loc))
                {
-                 seen_locations.add (loc);
+                 seen_locations.add (get_pure_location (loc));
                  expanded_location curr_location = expand_location (loc);
                  output_location (&streamed_locations, curr_location.file,
                                   MAX (1, curr_location.line), &offset, bb);
@@ -1567,7 +1567,7 @@ branch_prob (bool thunk)
              location_t loc = gimple_location (stmt);
              if (!RESERVED_LOCATION_P (loc))
                {
-                 seen_locations.add (loc);
+                 seen_locations.add (get_pure_location (loc));
                  output_location (&streamed_locations, gimple_filename (stmt),
                                   MAX (1, gimple_lineno (stmt)), &offset, bb);
                }
@@ -1580,7 +1580,7 @@ branch_prob (bool thunk)
          if (single_succ_p (bb)
              && (loc = single_succ_edge (bb)->goto_locus)
              && !RESERVED_LOCATION_P (loc)
-             && !seen_locations.contains (loc))
+             && !seen_locations.contains (get_pure_location (loc)))
            {
              expanded_location curr_location = expand_location (loc);
              output_location (&streamed_locations, curr_location.file,