public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-5275] Use 'location_hash' for 'seen_locations' in 'gcc/profile.c:branch_prob'
@ 2021-11-15 17:03 Thomas Schwinge
  0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2021-11-15 17:03 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:bcebd05720540e257b520737de6e087a328c1f8b

commit r12-5275-gbcebd05720540e257b520737de6e087a328c1f8b
Author: Thomas Schwinge <thomas@codesourcery.com>
Date:   Tue Aug 31 23:34:23 2021 +0200

    Use 'location_hash' for 'seen_locations' in 'gcc/profile.c:branch_prob'
    
    Follow-up to commit 102fcf94e625a2016a65829c73a42bd6c2420376
    "Fix GCOV CFG related issues": considering the current
    'int_hash <location_t, 0, 2>', per 'libcpp/include/line-map.h':
    
          Actual     | Value                         | Meaning
          -----------+-------------------------------+-------------------------------
          0x00000000 | UNKNOWN_LOCATION (gcc/input.h)| Unknown/invalid location.
          -----------+-------------------------------+-------------------------------
          0x00000001 | BUILTINS_LOCATION             | The location for declarations
                     |   (gcc/input.h)               | in "<built-in>"
          -----------+-------------------------------+-------------------------------
          0x00000002 | RESERVED_LOCATION_COUNT       | The first location to be
                     | (also                         | handed out, and the
                     |  ordmap[0]->start_location)   | first line in ordmap 0
    
    ... this currently uses value '0' ('UNKNOWN_LOCATION') as spare values for
    'Empty', and value '2' ('RESERVED_LOCATION_COUNT') as spare values for
    'Deleted', which is questionable?
    
    What actually does get put into 'seen_locations' is (mostly...)
    restricted/gated by '!RESERVED_LOCATION_P' (which is true unless
    'UNKNOWN_LOCATION' or 'BUILTINS_LOCATION'), thus we may simply use
    'location_hash'.
    
            gcc/
            * profile.c (branch_prob): Use 'location_hash' for
            'seen_locations'.

Diff:
---
 gcc/profile.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gcc/profile.c b/gcc/profile.c
index c33c833167f..d07002d265e 100644
--- a/gcc/profile.c
+++ b/gcc/profile.c
@@ -1375,7 +1375,7 @@ branch_prob (bool thunk)
       /* Initialize the output.  */
       output_location (&streamed_locations, NULL, 0, NULL, NULL);
 
-      hash_set<int_hash <location_t, 0, 2> > seen_locations;
+      hash_set<location_hash> seen_locations;
 
       FOR_EACH_BB_FN (bb, cfun)
 	{
@@ -1385,6 +1385,7 @@ branch_prob (bool thunk)
 	  if (bb == ENTRY_BLOCK_PTR_FOR_FN (cfun)->next_bb)
 	    {
 	      location_t loc = DECL_SOURCE_LOCATION (current_function_decl);
+	      gcc_checking_assert (!RESERVED_LOCATION_P (loc));
 	      seen_locations.add (loc);
 	      expanded_location curr_location = expand_location (loc);
 	      output_location (&streamed_locations, curr_location.file,


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-11-15 17:03 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-15 17:03 [gcc r12-5275] Use 'location_hash' for 'seen_locations' in 'gcc/profile.c:branch_prob' Thomas Schwinge

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).