From patchwork Mon Aug 7 09:59:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Turko X-Patchwork-Id: 131780 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp1342534vqr; Mon, 7 Aug 2023 03:06:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHNHxXbWgK+lSyKbpLeVDbm4+GbPKKEwtCj6eL+RAiu16YyRp2+DHdxAnBsP+Opg6/2YjLl X-Received: by 2002:aa7:c7cf:0:b0:522:2ba9:6fce with SMTP id o15-20020aa7c7cf000000b005222ba96fcemr8177573eds.8.1691402795445; Mon, 07 Aug 2023 03:06:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691402795; cv=none; d=google.com; s=arc-20160816; b=lYnmvp4UScd6QJmtzCg+EtqaoOgRhsR0bKfExTA1Vo+UWKiDJFhBInkOMt0AXqC+r2 Ag8FCNUeRWtxeQeF7gEWBl5z6SsXzWOz6T0Dla7IgB34xFrMnBPqiolpNe0O3i/Avc+4 5vCEd/qwMB8ZJ1kCEgaW63fXVZrgeL+yLEJCZoOXFydiViJhg3NJ+xBVowPfcipF13lf 4vtN0289tl7WNLh+EvhnDXz6P0XAYHbim4NGD1ZHrxdQquZzejHOEkXX1RqCfKmWqiYK HtA7RNiVpE2Z0HV4FQTyIgs0i35jTMO3c0iSHniRzyOTqAPdEGTtA6QgNPM4Ek8envP3 uV6A== 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=Yo2ByyRkNEaDu9X7hI9WCxKxqBIoNDutgIrFEk/DvWs=; b=QFOjc5FKAQBbm9UZKnRLvuVemn54zjXBqcvSfkyI7KPczbHk1dQcHPk4pEYmkW9I3n rhZhSkPAF0cU4eIQ/bvKqzm6gyNynzZASpzmMB0XlExekSMpEr5sxciGN/2xPzBGYSWF sht0daUQzbhNP0eId/CNo4MKQNAVi3oqUtonoVwkBhooQVdtvdQEn2x+GkapboTF1i+A s0CBwrIfuuJUhWFnfGTZy3z/C1Vtjpo2BjxP2l/0AaBYeUNvxv0gkRAUgbY4ZPvNT64N NflG7j8xHQUmcQTrhnJ4C5wGho+B0FA5zFyWNP78Cw2T1oaCfAFjdFIYsFOYr2Fcuyrh ZVGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="JlG/uF/q"; 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 g25-20020a056402115900b005222d573a77si5670341edw.158.2023.08.07.03.06.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 03:06:35 -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="JlG/uF/q"; 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 269EA3857022 for ; Mon, 7 Aug 2023 10:05:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 269EA3857022 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1691402757; 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=JlG/uF/qzPcE5R9yDa9df7QlCjBjNxaHcHNGNqweChEDmwvl8+0sB+I3DtQWvEV+l MehhwmAG+3ELvqaiF2de2ijqUVSvHP6SlQqY9mNjz3q4bV0w2o/l01r5yup0H9lvH5 dA2wH1lvMTrIJb9k/Cb0kjssR0JTy8xvv97Tertk= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lj1-x22b.google.com (mail-lj1-x22b.google.com [IPv6:2a00:1450:4864:20::22b]) by sourceware.org (Postfix) with ESMTPS id F39403858412 for ; Mon, 7 Aug 2023 10:04:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F39403858412 Received: by mail-lj1-x22b.google.com with SMTP id 38308e7fff4ca-2ba1e9b1fa9so43116471fa.3 for ; Mon, 07 Aug 2023 03:04:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691402644; x=1692007444; 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=TF3Crl00ljHV6fCePyG8IllrGLgHwX0YAwabP2XRJH/2ggP06rYFgIW4MfqrmA7a22 5AYEazfiRnRTW/39/Dsg0SnhK33T0m16ZLitLr+/BtmRQ6VK3wHZA8BUYsk1CR5FOt8a GF+CDV81El5wxhEAqXlKqwWVxhxpFVAkx7cVbQhm6+C+gW1ZF5ECObHK8/2K9GgjTWqb CxWLQ2UOtihGCLevK+AplpPJels47v3DZl6o0EiHuu021UK6eJ4ku97/1tVyWasWYFgw WTGbICZUBm4ZNoIGQ9Tt/zLHV/V4FSf6rgIdD/VPDoUjPyetYi72XULNGcZt2csB//qG 0Vpw== X-Gm-Message-State: AOJu0YwB+LXOooj36Efb7SR2zos6x8Bt33fpqLl9l+8WHTPtZzhvkyqi 4s697N9gBrjSRCLLNJYlcUKdBwtnp2BUZopcbkM= X-Received: by 2002:a2e:9f16:0:b0:2b9:eb0f:c733 with SMTP id u22-20020a2e9f16000000b002b9eb0fc733mr6751275ljk.35.1691402644096; Mon, 07 Aug 2023 03:04:04 -0700 (PDT) Received: from amwld-aturko1.us.drwholdings.com ([149.14.21.6]) by smtp.gmail.com with ESMTPSA id la4-20020a170906ad8400b0099bd682f317sm4881305ejb.206.2023.08.07.03.04.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 03:04:03 -0700 (PDT) To: gcc-patches@gcc.gnu.org, Richard Biener Cc: Andrzej Turko Subject: [PATCH 2/3 v4] genmatch: Reduce variability of generated code Date: Mon, 7 Aug 2023 11:59:00 +0200 Message-Id: <20230807095901.267099-3-andrzej.turko@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230807095901.267099-1-andrzej.turko@gmail.com> References: <20230807095901.267099-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 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: 1773564377680953826 X-GMAIL-MSGID: 1773564377680953826 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