From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by sourceware.org (Postfix) with ESMTPS id CE1633870886 for ; Wed, 16 Mar 2022 13:00:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CE1633870886 Received: by mail-ed1-x52b.google.com with SMTP id w4so2602153edc.7 for ; Wed, 16 Mar 2022 06:00:20 -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=GBGkkaivSFCyR+1ojh823CexyBOJCsEDeAHoFcm6Mg4=; b=atzJKD1tBMyaUPbVspifyKrwuBC1H47O5h7liPJEf6+eRFGl2GPiqC/315hZpWB5Xa iu9NnrOc/8t53ZrVTALp4DUr2T1cRefwX5OkOd0wT025SIh6M4Y019ds+rQPKJDqxbmu Wa14sP+OsJeItw6PvbP7rmnCQ7+rSdpBzHXcO6NtvEYOQ6SlSPwSIdeXublIoZl9LkbQ CJikfgJRZ+6fS6kcVKzgYAf9dSKCOJctMrG4J/+sBz/lFtdp4JhFXaPcqXw/GKIPif/X /pQKDU42Nr72jjcmEEA2S9s0Q6Z6eFY5j9bNg65g70vVuI7tqpwB7s3Sus2EjZqXTOS6 ipcg== X-Gm-Message-State: AOAM531ulrn6JpBq2GILe8IoGE6EZNldgE0GvL6kAz08gvf4bx2obH/N 49G73h8h81QRZWkzuGV28934sCQr/Z4jvxIjZUxs/vEwPPQ= X-Google-Smtp-Source: ABdhPJwZQKQEem4hUamRMgqauYtQfNKh1NyrObtOcsBuuoYRj207GJ/l2aE0YpFSgzGMCVC7p5pcTV8WYwxAyPmcd0g= X-Received: by 2002:a05:6402:2682:b0:416:cee9:53db with SMTP id w2-20020a056402268200b00416cee953dbmr24650219edd.194.1647435619620; Wed, 16 Mar 2022 06:00:19 -0700 (PDT) MIME-Version: 1.0 References: <001a01d83931$8d6c5ee0$a8451ca0$@nextmovesoftware.com> In-Reply-To: From: Richard Biener Date: Wed, 16 Mar 2022 14:00:08 +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.3 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 13:00:22 -0000 On Wed, Mar 16, 2022 at 1:59 PM Richard Biener wrote: > > 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. Btw, the unused labels were one reason for having gimple-match.o-warn = -Wno-unused generic-match.o-warn = -Wno-unused maybe that's then no longer needed. > > > > > > 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 > > -- > >