public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Andrzej Turko <andrzej.turko@gmail.com>
To: gcc-patches@gcc.gnu.org
Cc: Andrzej Turko <andrzej.turko@gmail.com>
Subject: [PATCH 2/3] genmatch: Reduce variability of generated code
Date: Mon, 31 Jul 2023 13:03:45 +0200	[thread overview]
Message-ID: <20230731110346.174848-3-andrzej.turko@gmail.com> (raw)
In-Reply-To: <20230731110346.174848-1-andrzej.turko@gmail.com>

So far genmatch has been using an unordered map to store information about
functions to be generated. Since corresponding locations from match.pd were
used as keys in the map, even small changes to match.pd which caused
line number changes would change the order in which the functions are
generated. This would reshuffle the functions between the generated .cc files.
This way even a minimal modification to match.pd forces recompilation of all
object files originating from match.pd on rebuild.

This commit makes sure that functions are generated in the order of their
processing (in contrast to the random order based on hashes of their
locations in match.pd). This is done by replacing the unordered map with an
ordered one. This way small changes to match.pd does not cause function
renaming and reshuffling among generated source files.
Together with the subsequent change to logging fprintf calls, this
removes unnecessary changes to the files generated by genmatch allowing
for reuse of already built object files during rebuild. The aim is to
make editing of match.pd and subsequent testing easier.

Signed-off-by: Andrzej Turko <andrzej.turko@gmail.com>

gcc/ChangeLog:

	* genmatch.cc: Make sinfo map ordered.

Signed-off-by: Andrzej Turko <andrzej.turko@gmail.com>
---
 gcc/genmatch.cc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gcc/genmatch.cc b/gcc/genmatch.cc
index 2302f2a7ff0..1deca505603 100644
--- a/gcc/genmatch.cc
+++ b/gcc/genmatch.cc
@@ -29,6 +29,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "hash-table.h"
 #include "hash-set.h"
 #include "is-a.h"
+#include "ordered-hash-map.h"
 
 
 /* Stubs for GGC referenced through instantiations triggered by hash-map.  */
@@ -1684,7 +1685,7 @@ struct sinfo_hashmap_traits : simple_hashmap_traits<pointer_hash<dt_simplify>,
   template <typename T> static inline void remove (T &) {}
 };
 
-typedef hash_map<void * /* unused */, sinfo *, sinfo_hashmap_traits>
+typedef ordered_hash_map<void * /* unused */, sinfo *, sinfo_hashmap_traits>
   sinfo_map_t;
 
 /* Current simplifier ID we are processing during insertion into the
-- 
2.34.1


  parent reply	other threads:[~2023-07-31 11:05 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-31 11:03 [PATCH 0/3] genmatch: Speed up recompilation after changes to match.pd Andrzej Turko
2023-07-31 11:03 ` [PATCH 1/3] Support get_or_insert in ordered_hash_map Andrzej Turko
2023-07-31 13:38   ` Richard Biener
2023-07-31 11:03 ` Andrzej Turko [this message]
2023-07-31 13:40   ` [PATCH 2/3] genmatch: Reduce variability of generated code Richard Biener
2023-07-31 11:03 ` [PATCH 3/3] genmatch: Log line numbers indirectly Andrzej Turko
2023-07-31 13:48   ` Richard Biener
2023-08-03 14:31     ` Andrzej Turko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230731110346.174848-3-andrzej.turko@gmail.com \
    --to=andrzej.turko@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).