From patchwork Mon Aug 7 09:58:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Turko X-Patchwork-Id: 13224 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp1341959vqr; Mon, 7 Aug 2023 03:05:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFCxal9WJjbF+bjCcwVwOr5HpQ7GAF4uG0tD/9qjC+Cbtx8jt1vAtDNWfPED3N16e5MMt24 X-Received: by 2002:a17:907:77d6:b0:997:bb66:3ce with SMTP id kz22-20020a17090777d600b00997bb6603cemr9339735ejc.7.1691402724532; Mon, 07 Aug 2023 03:05:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691402724; cv=none; d=google.com; s=arc-20160816; b=amrxNUiFayXayfGGTCYuPom0810oQ9HpgEPMp4RBLHxHjSfO8bVziaMEtvpaceWx2o pcMqMWMv9UaIhOMJyfUjy3H1RC4f+Cnk3d+PE+oX0tSl4L5wbC7eMFaOWp4ao/BaXGhL 2/xfPPAk3ihxn0y5qdlVmBQyLAn7WCGs7DWtCwVd5Tx9XatOovAN8Js9fuA7srSF50so ZpC+9SejdWVWG8jvgXf6FysqvEDQuudVjit3RE1+iuiPqYu+zIgssvY25ZvM1Bp3IbaH WTYxz8FcxxwMzO0Ee7umuSXa2UxLWkK321OPN/1PfPTgyEN5iUYXrMFCFsJggEqVORoG x3GQ== 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=3BaX7bgfAsDAL0tmg6ZSQzzA3ADZhq/8UrBdxtOAiz0=; fh=Yo2ByyRkNEaDu9X7hI9WCxKxqBIoNDutgIrFEk/DvWs=; b=kemnInAysID6G0PV2umSXNw7WcpddenEQd5bw59l5I3gao3yYRbDsg4Y/5Wcct9ug0 rbkurf5VfsAk4vgW2NH+LoUNgzrZz4jnQfknly1W8TnGc7W5oZgHUtoWXbhId+fRkf8K Ht6DP9saeS1WwLhjkIWKAmarfMvCOtOp7Em2eZ5oTgbB9r6OWDbpYFXtHDNny/2aYeTX EQe8M5BTX1hURVnvN/ba/6TwU0X3YgpI8CJuyj2nh33MuqzLTAjCElzfE1wFh2E18MKl VAy/g8fWr9EKfVaL8PFlKNhRuITnJ3FP32wLvZhP8ptB5hweoo8adlfO9khONy7KYNWJ j70g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=lHEct6Mi; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id t19-20020a170906269300b0098df1cbe2aesi181282ejc.1008.2023.08.07.03.05.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 03:05:24 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=lHEct6Mi; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 B47F63856244 for ; Mon, 7 Aug 2023 10:04:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B47F63856244 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1691402698; bh=3BaX7bgfAsDAL0tmg6ZSQzzA3ADZhq/8UrBdxtOAiz0=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=lHEct6Mi+ap66EF5Z8/SuCZm737TFQk+5io+4KJDIC1U4CsGo28bCx7yrT0VSQkVI 0+cbLlSeKAvJcWmtR5UDkoF3G53da8TdRqRzOOPDeDQQ+hH8eM6A4LnyRTU5e+hH5B B4h717U2phWF8O4GYKpPJxtSaw4vA646S3RtBn8E= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by sourceware.org (Postfix) with ESMTPS id C3BB83858D28 for ; Mon, 7 Aug 2023 10:04:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C3BB83858D28 Received: by mail-ej1-x62b.google.com with SMTP id a640c23a62f3a-99cdb0fd093so92046166b.1 for ; Mon, 07 Aug 2023 03:04:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691402643; x=1692007443; 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=3BaX7bgfAsDAL0tmg6ZSQzzA3ADZhq/8UrBdxtOAiz0=; b=RIIlUeqcD9mzMKmDjPt08cMsOwAmoOc0ASE+1YZmQS5PdV/sTxW+ksr31la7yPwrpp 5qsS46Q1kuMZCG476YTNdRhk4680VIXaCtp0YAvvWax5DYDALd365sF0Xf3fELR+nvE3 7kncssVjJGJYzC311I4ErrHIAzSrfAaA1GTOwaupl66TzhNDyYOByevm86J5Xc8bJMGv rHfbVWVa+e4lyQmgVlA3vHYAgF4sLZWwhmJV0vhqfv1oUOVbQXSAC9gmF5nZr2eUNSB6 e8ZjHfjsm21ErI43B/Z9sjoFCsMGccDI7UUd8L0wDShq6bcMN8xFygDo9mNsxxsdePzH JHeA== X-Gm-Message-State: AOJu0YzDQTVHuJSwV2TIaOmMqejlPoo11EcEegdr8EtbOCYF/VMz+ogA 8Fr7gvcHdbalfl60MaN3Bckxzs1usS5SnXfrbkk= X-Received: by 2002:a17:906:8a53:b0:991:cd1f:e67a with SMTP id gx19-20020a1709068a5300b00991cd1fe67amr7685514ejc.29.1691402642948; Mon, 07 Aug 2023 03:04:02 -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.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 03:04:02 -0700 (PDT) To: gcc-patches@gcc.gnu.org, Richard Biener Cc: Andrzej Turko Subject: [PATCH 0/3 v4] genmatch: Speed up recompilation after changes to match.pd Date: Mon, 7 Aug 2023 11:58:58 +0200 Message-Id: <20230807095901.267099-1-andrzej.turko@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-6.1 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 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: 1773564303209478187 X-GMAIL-MSGID: 1773564303209478187 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. V3: * Fix a bug from 'genmatch: Log line numbers indirectly', which was introduced in V2. V4: * Remove duplicate line numbers in the lookup table. * Do not define dump_log functions if they are not called. 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 | 98 +++++++++++++++++++++++++++++------ gcc/ordered-hash-map-tests.cc | 19 +++++-- gcc/ordered-hash-map.h | 26 ++++++++++ 4 files changed, 125 insertions(+), 22 deletions(-)