From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by sourceware.org (Postfix) with ESMTPS id 8CC763857806 for ; Wed, 16 Mar 2022 12:59:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8CC763857806 Received: by mail-ej1-x62a.google.com with SMTP id bi12so4026730ejb.3 for ; Wed, 16 Mar 2022 05:59:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=j5fQDh2aqyFaGY6g9WbaPYN6fjiNJOEEpyXyarRmu+k=; b=itoLPYfyVqrt9STLgVbzN+APVF8XzWt6+sZjcRyIzet+PCfJtlNg69h9W5aEWAGwev wwUHC0Gqg5E9GI8zW8YNwHZGN4uhY5R4TeVwUsftkdTZ9CjpZxapS50ke+niJ959MpDe 8FWWwdQ0roohSJPlpqxfMipBls2SApGi5btqX1L4XcP02rQO/Z0HHyFs/znpN2zm1gND 0dycdLqjeVcGEvE07fpCNyXiOmLp8ZudsWztM4klv2/MTddsa1AkD1gYQbdN1seJ691l y6wSf0d1d1eHAwBHeI42jB54ZnF14xBEIVuVQhltDjqD/EPOAB2yuWrF8wuavJgRLhDc VM6Q== X-Gm-Message-State: AOAM5326RKI5RehAl/d6QbS0tJputF2aGxaWWHWobYxI7V3jqeU80lXp YvHkDYuyGDCug1rxQjO420w6ZHKxdzlXjyZMAho= X-Google-Smtp-Source: ABdhPJziSwdpJYnYyanu2DRcGxGTtsccRvx4CvVLFdEN/puebEJJnI09GRTgT6DtroWj8riV3IO1HbRnBhrMgGp55dU= X-Received: by 2002:a17:906:5d0f:b0:6db:8b63:e91 with SMTP id g15-20020a1709065d0f00b006db8b630e91mr24672961ejt.32.1647435566077; Wed, 16 Mar 2022 05:59:26 -0700 (PDT) MIME-Version: 1.0 References: <001a01d83931$8d6c5ee0$a8451ca0$@nextmovesoftware.com> In-Reply-To: <001a01d83931$8d6c5ee0$a8451ca0$@nextmovesoftware.com> From: Richard Biener Date: Wed, 16 Mar 2022 13:59:15 +0100 Message-ID: Subject: Re: [PATCH] Avoid generating unused labels in genmatch. To: Roger Sayle Cc: GCC Patches Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.7 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.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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-List-Received-Date: Wed, 16 Mar 2022 12:59:29 -0000 On Wed, Mar 16, 2022 at 1:31 PM Roger Sayle wrote: > > > This patch is the second of two changes to genmatch that don't affect > the executable code, but reduce the amount of debugging information > generated in stage3 of a build, but adhering more closely to GNU style > guidelines. > > This patch avoids generating "next_after_fail1:;" label statements > in genmatch, if this label is unused/never referenced as the target > of a goto. Because jumps to these labels are always forwards, we > know at the point the label is emitted whether it is used or not. > Because a debugger may set a breakpoint these labels, this increase > the size of g{imple,eneric}-match.o in a stage3 build. To save a > little extra space, I also shorten the label to "Lfail1:;" and only > increment the counter when necessary. This reduces the size of > gimple-match.o by 58K on x86_64-pc-linux-gnu. > > This patch has been tested on x86_64-pc-linux-gnu with make bootstrap > and make -k check with no new failures. Ok for mainline? I wonder if we could make this nicer by abstracting sth like class fail_label { fail_label (unsigned num); emit_goto () { fprintf (..., "goto L%u", num); used = true; } emit_label () { fprintf ("L%u:;\n", num); } unsigned num; bool used; }; or some better abstraction capturing all of the global state. > > > 2022-03-16 Roger Sayle > > gcc/ChangeLog > * gcc/genmatch.cc (fail_label_used): New global variable. > (expr::gen_transform): Set fail_label_used whenever a goto > FAIL_LABEL is generated. > (dt_simplify::gen_1): Clear fail_label_used when generating > a new (provisional) fail_label. Set fail_label used whenever > a goto fail_label is generated. Avoid emitting fail_label: > if fail_label_used is false, instead decrement fail_label_cnt. > > > Thanks in advance, > Roger > -- >