From patchwork Wed Aug 2 09:55:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Turko X-Patchwork-Id: 129736 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f41:0:b0:3e4:2afc:c1 with SMTP id v1csp341156vqx; Wed, 2 Aug 2023 03:02:45 -0700 (PDT) X-Google-Smtp-Source: APBJJlG1SzZjSwBO+8kolzvq2TsDaEdz175HCQiolIJIJojZsBzF0zMUy55olTOHfj8J/eIzCEsz X-Received: by 2002:a17:907:75d1:b0:993:f15f:efbe with SMTP id jl17-20020a17090775d100b00993f15fefbemr4285087ejc.5.1690970564823; Wed, 02 Aug 2023 03:02:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690970564; cv=none; d=google.com; s=arc-20160816; b=Us2E22DLUmCBva1Rz2aqbiNW3PGIoTZtoKtJPsBub8GVEA1sOzFeBKSYkVBJ9qfcqt 8/vZak5fuYGvIFuV1dSI7+1+kNvqTtt9R5y4mEQU9/W2A0CFi7GHVGdd7wdRkF5A+PTX lf8aFuS1iyXPfYL7PBwuzH3eHlm59HDZJgk4HPlzKChv5J7VrEAoqV5+vkCAk2O0234w GqIZn7FME0iG6ifgOi3hg2egQadQNJ0vV3+TqE7P9MSXIb/YmZ/cBB3xrP18wNgrD4d2 Tpp68zLW0vOrHgGPyguYxmHl+Zl7UX8hlJLDQUdoWYZVfduRdiVVO3QZzwt1u0P7Mk9x QTGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=4ONfezsU+Y6Ocii25Q8nJtKgEUDTkvb/+sIK43Mafxs=; fh=k/nQU4IX+jAQueq710KA8dCAcoPPe4cl6LpGj9WeH7w=; b=eNTuJT7h3PkqgLz1O8C6KFrpavGObWcf5W/DGowqMzMJ72mVJWvlqzxE9Pve18VzZ6 gU94V0zUobSh7DH8yVlcgBe1Qn+pH1+e09S5RaeWmwZSMkRKim9OZ2T4/SqnLAE5+Tdt fdEor7VSB0zkownL3DcroIBq/hL56uWBrcSo+VxTOw467QVL8GmbDlqQeyi241H5CqOS zJD2ropVqZmUyGTuEyuZGMaXpJzpKE/59/NUd2lcT8ybvmAI4FdxzmaaaZGdn96JK0JK qv8dWeQgqCg3Y/UQifEwgU77zbfnsFtbxD87C9ggTUuaAEC9UdzQ/noJYGvLvL2WXLW6 6uZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=s92YE7be; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id um9-20020a170906cf8900b00992d6fa3b33si9688274ejb.440.2023.08.02.03.02.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 03:02:44 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=s92YE7be; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 176FB3853D06 for ; Wed, 2 Aug 2023 10:01:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 176FB3853D06 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1690970495; bh=4ONfezsU+Y6Ocii25Q8nJtKgEUDTkvb/+sIK43Mafxs=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=s92YE7bedc+mO8Scy4nLSAa0KOljFsuEKbuiS/4JoWo5HdpBFVhsDfbyOdjFIFyPd hANxIiYEpAUwoT3Wtq+yaGUHmEpMEu+4ObzzkulMFeMj6Z0FmNH0if1040Du/cKPVr x7aLN74k6teLHTbZ5sGV45r690bME4SPTy2eFKic= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by sourceware.org (Postfix) with ESMTPS id 3A9113858D39 for ; Wed, 2 Aug 2023 10:00:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3A9113858D39 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-31781e15a0cso5677837f8f.3 for ; Wed, 02 Aug 2023 03:00:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690970446; x=1691575246; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4ONfezsU+Y6Ocii25Q8nJtKgEUDTkvb/+sIK43Mafxs=; b=L9Q2Z0TSEa2Iet2ERqIw3h3hf3jvmkcdsYVFn2Kr/L04T+sA+hZO0apKHdq2F+icHZ 9iL6rB1mu5S4dQyp8YwtofOCjYWidynm83Y8tL/FSh0sanqvlbOvCNsgkUna7zRHH5hP 4HNiHp7pYWzRQ5U0yfTISXBn/aD6GV0cFuti/jk43C+7Q9FCqDW3g/Q3L1KVLixiFX2U oZ9UIrCq4XgQxFQVArM5R8pSvsct1/+vWoYWe9/SsuosiDrWb8VLkcxmiqE20CXXPjPi 7yCtR8OuGeY5uH5nBcQqvxH7rST4PFh2PSLuzwHTvBiDyyK8hrb50bOQ87SghD1+ps00 BuOg== X-Gm-Message-State: ABy/qLY1VN5frNpVuro8DMf8FtxNzbIC3UTMUiILJUIaCt0Bh5wZ/Cgw pin5tRKbvZqX30q3/Yvm1vc3xJCbRxgZnkZX X-Received: by 2002:a5d:6904:0:b0:317:61d8:3c83 with SMTP id t4-20020a5d6904000000b0031761d83c83mr4297974wru.3.1690970446600; Wed, 02 Aug 2023 03:00:46 -0700 (PDT) Received: from amwld-aturko1.us.drwholdings.com ([149.14.21.6]) by smtp.gmail.com with ESMTPSA id s1-20020a5d4ec1000000b003063db8f45bsm18544560wrv.23.2023.08.02.03.00.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 03:00:46 -0700 (PDT) To: gcc-patches@gcc.gnu.org Cc: Andrzej Turko Subject: [PATCH 2/3 v2] genmatch: Reduce variability of generated code Date: Wed, 2 Aug 2023 11:55:26 +0200 Message-Id: <20230802095527.100830-3-andrzej.turko@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230802095527.100830-1-andrzej.turko@gmail.com> References: <20230802095527.100830-1-andrzej.turko@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Andrzej Turko via Gcc-patches From: Andrzej Turko Reply-To: Andrzej Turko Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773111151030291641 X-GMAIL-MSGID: 1773111151030291641 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 gcc/ChangeLog: * genmatch.cc: Make sinfo map ordered. * Makefile.in: Require the ordered map header for genmatch.o. --- gcc/Makefile.in | 4 ++-- gcc/genmatch.cc | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/gcc/Makefile.in b/gcc/Makefile.in index e99628cec07..2429128cbf2 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -3004,8 +3004,8 @@ build/genhooks.o : genhooks.cc $(TARGET_DEF) $(C_TARGET_DEF) \ $(COMMON_TARGET_DEF) $(D_TARGET_DEF) $(BCONFIG_H) $(SYSTEM_H) errors.h build/genmddump.o : genmddump.cc $(RTL_BASE_H) $(BCONFIG_H) $(SYSTEM_H) \ $(CORETYPES_H) $(GTM_H) errors.h $(READ_MD_H) $(GENSUPPORT_H) -build/genmatch.o : genmatch.cc $(BCONFIG_H) $(SYSTEM_H) \ - $(CORETYPES_H) errors.h $(HASH_TABLE_H) hash-map.h $(GGC_H) is-a.h \ +build/genmatch.o : genmatch.cc $(BCONFIG_H) $(SYSTEM_H) $(CORETYPES_H) \ + errors.h $(HASH_TABLE_H) hash-map.h $(GGC_H) is-a.h ordered-hash-map.h \ tree.def builtins.def internal-fn.def case-cfn-macros.h $(CPPLIB_H) build/gencfn-macros.o : gencfn-macros.cc $(BCONFIG_H) $(SYSTEM_H) \ $(CORETYPES_H) errors.h $(HASH_TABLE_H) hash-set.h builtins.def \ 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, template static inline void remove (T &) {} }; -typedef hash_map +typedef ordered_hash_map sinfo_map_t; /* Current simplifier ID we are processing during insertion into the