From patchwork Wed Aug 2 09:55:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Turko X-Patchwork-Id: 12991 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f41:0:b0:3e4:2afc:c1 with SMTP id v1csp341044vqx; Wed, 2 Aug 2023 03:02:34 -0700 (PDT) X-Google-Smtp-Source: APBJJlHRJs5nXimUoJdI+aBa5hzmXiIJaAmz3cc3CIr23V0JffAMSi3ioM4CU4ieGN4yXy0a+T52 X-Received: by 2002:a05:6000:1816:b0:317:6681:e426 with SMTP id m22-20020a056000181600b003176681e426mr4434238wrh.25.1690970554590; Wed, 02 Aug 2023 03:02:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690970554; cv=none; d=google.com; s=arc-20160816; b=YolKgaenpB9K5aX+6lMMMzkdmtGd5X+o2LWhslfmPcBO7t3XszbEcOETnhh5eUgboL pjJ0E7PvJu5MtNKJ246ik1MMD82En+KLDoWlQncsSjN58RQhv3tm1EM/fpZMT3Tb0HfG Vy+GNmw9bUb1xS4J0X2cYE3S7USkpcPG4/ijTufPUVI98ja7sKJp/a50kKXjXL8BW0ss vP5DjHvnPJ/AhLrdiCOtI2n18JiHVoTCFpxvhEuA5YnLnDx4+cOi7GGFKWFnkIVjnYtX jiBgZok7S1briSiThmR6yNNb0W1qvi1r92akunUNoGOeunYSBdgCulaAuxLfS/AIAonR ging== 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:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=qN0aRAMhVOtaXCKpBtw9l4jsU13tGi3IwTtY/vb7hMI=; fh=k/nQU4IX+jAQueq710KA8dCAcoPPe4cl6LpGj9WeH7w=; b=SR/Oup2+9J6wliDpVkyMnRdbFyEm7uWfA9Wb/6pyrTobMIIOyjW4sLEABHOD1BnxWL jc+cvubJXiDs0LRUcOmUbai2MEJ4cP5ZlK7IkgPKSYvmbnVqqrrNehZg7MIv6rxeaEtt lrxj6tuqFEdV2ldCRV4P6T9PzQ6BmzQ3/wlFfb9s156Sjj1VthAy3ZNvCDUZw0eNeHEX hDZeylZeLJqPICN0Hh/fRGbbFE0CGKmlluTxa82xBzS51us4LvIj4VcbHV+ZaLmtbFW8 ki16qoe+bADqDOEmhvBz0DqhDqgJ5riPS2eISISn9cD+UzooOBF4wnkV+gG1ysXbRzWw ZvYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=aOLZo3Od; 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 w20-20020aa7da54000000b0052257d1aafesi900355eds.14.2023.08.02.03.02.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 03:02:34 -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=aOLZo3Od; 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 DDC8A3858436 for ; Wed, 2 Aug 2023 10:01:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DDC8A3858436 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1690970492; bh=qN0aRAMhVOtaXCKpBtw9l4jsU13tGi3IwTtY/vb7hMI=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=aOLZo3OdvzAmYBOfIeqXgB2+P72TuBx3cmesfjdfeM3RCaRh/v8okqq67LiYOh1ff JswqE7xpLDPIK8rM8jZ2i1cOi4JMHZSIUM0byMQAU9eB+H/OW3yCG8BQWkCku5aRnP FE8wnxPk3yAPIqytD+2weKDPFBqeceYREO/FMJzU= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by sourceware.org (Postfix) with ESMTPS id 3323E3858D1E for ; Wed, 2 Aug 2023 10:00:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3323E3858D1E Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-31427ddd3fbso6086165f8f.0 for ; Wed, 02 Aug 2023 03:00:47 -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:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=qN0aRAMhVOtaXCKpBtw9l4jsU13tGi3IwTtY/vb7hMI=; b=QTzWlQ9SbgjFn564FMKXNo/RZKAgi43l/opQZd3GW+cC1DdMca5j71VEKsfHObksso kaXJ5jBNGozSRl81xpltbSJmgHJsESnJt8qhP+/sd3h2CNdjOCsBjqXkoI2kqp8nqxdN wRMDlWKlsPzptWw3TLiaC5h8W/YVqM94SLOrPzLiq93qzLfcXGK/C9fx1XLJNapC7/eJ rFHHDsY9WiKTCe39MwVIZ/WV7ksegN6PBKyk1FLIBhmOFitvLI3uU6BLXGEJbZl9FWZb VPigeAACr+Ev1tthp0MA2oMQfIliRcftCRXZbw09mXLBQ3K/vswWqk/w3Bs/z8qCjADS saGA== X-Gm-Message-State: ABy/qLbhO82O1zzVvlKwczpCxAHXOqb2ffFgmytVfotD0/E+JsUT0IHF +xRUWJXaD+t+ylyowtUsNUGWL6pnCC3OerpM X-Received: by 2002:a05:6000:12d2:b0:317:4bdc:6f34 with SMTP id l18-20020a05600012d200b003174bdc6f34mr4156054wrx.64.1690970445480; Wed, 02 Aug 2023 03:00:45 -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.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 03:00:45 -0700 (PDT) To: gcc-patches@gcc.gnu.org Cc: Andrzej Turko Subject: [PATCH 0/3 v2] genmatch: Speed up recompilation after changes to match.pd Date: Wed, 2 Aug 2023 11:55:24 +0200 Message-Id: <20230802095527.100830-1-andrzej.turko@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, 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: 1773111140485903246 X-GMAIL-MSGID: 1773111140485903246 The following reduces the number of object files that need to be rebuilt after match.pd has been modified. Right now a change to match.pd which adds/removes a line almost always forces recompilation of all files that genmatch generates from it. This is because of unnecessary changes to the generated .cc files: 1. Function names and ordering change as does the way the functions are distributed across multiple source files. 2. Code locations from match.pd are quoted directly (including line numbers) by logging fprintf calls. This patch addresses the those issues without changing the behaviour of the generated code. The first one is solved by making sure that minor changes to match.pd do not influence the order in which functions are generated. The second one by using a lookup table with line numbers. Now a change to a single function will trigger a rebuild of 4 object files (one with the function and the one with the lookup table both for gimple and generic) instead all of them (20 by default). For reference, this decreased the rebuild time with 48 threads from 3.5 minutes to 1.5 minutes on my machine. V2: * Placed the change in Makefile.in in the correct commit. * Used a separate logging function to reduce size of the executable. As for Richard Biener's remarks on executable size: 1. The previous version of the change increased the sizes of executables by 8-12 kB. 2. The current version (with an extra indirection step) did so by around 150 kB (I suspect that the reason for it may be adding an additional functions and its overhead, in which case the actual number of instructions may be smaller in this case). One can choose between those variants just by taking the third commit either from this or the previous version of the patch series. Note for reviewers: I do not have write access. Andrzej Turko (3): Support get_or_insert in ordered_hash_map genmatch: Reduce variability of generated code genmatch: Log line numbers indirectly gcc/Makefile.in | 4 +- gcc/genmatch.cc | 91 +++++++++++++++++++++++++++++------ gcc/ordered-hash-map-tests.cc | 19 ++++++-- gcc/ordered-hash-map.h | 26 ++++++++++ 4 files changed, 118 insertions(+), 22 deletions(-)