From patchwork Wed Dec 1 04:17:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 48320 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E0319385C405 for ; Wed, 1 Dec 2021 04:17:58 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from dog.elm.relay.mailchannels.net (dog.elm.relay.mailchannels.net [23.83.212.48]) by sourceware.org (Postfix) with ESMTPS id 033933858D28 for ; Wed, 1 Dec 2021 04:17:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 033933858D28 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gotplt.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gotplt.org X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id A5AB26C0D1E; Wed, 1 Dec 2021 04:17:39 +0000 (UTC) Received: from pdx1-sub0-mail-a305.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 2016B6C0A01; Wed, 1 Dec 2021 04:17:38 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from pdx1-sub0-mail-a305.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.114.196.229 (trex/6.4.3); Wed, 01 Dec 2021 04:17:39 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Stupid-Scare: 77c6c9de074e821c_1638332258929_3500443875 X-MC-Loop-Signature: 1638332258929:3225974171 X-MC-Ingress-Time: 1638332258928 Received: from rhbox.intra.reserved-bit.com (unknown [1.186.123.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: siddhesh@gotplt.org) by pdx1-sub0-mail-a305.dreamhost.com (Postfix) with ESMTPSA id 4J3m5X1BF7z1P; Tue, 30 Nov 2021 20:17:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gotplt.org; s=gotplt.org; t=1638332257; bh=UqOHCGOQNtWSpN8eTfLLH0xVyAg=; h=From:To:Cc:Subject:Date:Content-Type:Content-Transfer-Encoding; b=CEgUfhzYooy/W5XDSWsmHyFor79O/Btk+SYBjEcV0Ftk/Iyd+WW/An2vYrLC/APYX eh5JkqSdQRjiH9tmZkOqUEwtRNW7xSahJWXJhJ45Gim80nB7wMUdEd0PQPR7bsfrzL 6GBDA31SW6ekLb3Dy0ZN7AyyijmERo5z113VhQbs= From: Siddhesh Poyarekar To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/103456 - Record only successes from object_sizes_set Date: Wed, 1 Dec 2021 09:47:21 +0530 Message-Id: <20211201041721.3928134-1-siddhesh@gotplt.org> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Spam-Status: No, score=-3037.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_BL_SPAMCOP_NET, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, RCVD_IN_SBL, SPF_HELO_NONE, SPF_PASS, TXREP 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: , Cc: jakub@redhat.com Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Avoid overwriting osi->changed if object_sizes_set does not update the size, so that a previous success in the same pass is not overwritten. This fixes the bootstrap-ubsan build config, which was failing due to incorrect object size. Also completed a bootstrap on x86_64 which didn't show any new failures. gcc/ChangeLog: PR tree-optimization/103456 * tree-object-size.c (merge_object_sizes): Update osi->changed only if object_sizes_set succeeded. gcc/testsuite/ChangeLog: PR tree-optimization/103456 * gcc.dg/pr103456.c: New test. Co-authored-by: Martin Liška Signed-off-by: Siddhesh Poyarekar --- gcc/testsuite/gcc.dg/pr103456.c | 21 +++++++++++++++++++++ gcc/tree-object-size.c | 3 ++- 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/pr103456.c diff --git a/gcc/testsuite/gcc.dg/pr103456.c b/gcc/testsuite/gcc.dg/pr103456.c new file mode 100644 index 00000000000..20322fbaab1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr103456.c @@ -0,0 +1,21 @@ +/* PR tree-optimization/103456 */ +/* { dg-do compile } */ +/* { dg-options "-fsanitize=undefined -O -fdump-tree-objsz" } */ + +static char *multilib_options = "m64/m32"; + +void +used_arg_t (void) +{ + char *q = multilib_options; + for (;;) + { + while (*q) + q++; + while (__builtin_strchr (q, '_') == 0) + while (*q) + q++; + } +} + +/* { dg-final { scan-tree-dump-not "maximum object size 0" "objsz1" } } */ diff --git a/gcc/tree-object-size.c b/gcc/tree-object-size.c index 3780437ff91..b4881ef198f 100644 --- a/gcc/tree-object-size.c +++ b/gcc/tree-object-size.c @@ -854,7 +854,8 @@ merge_object_sizes (struct object_size_info *osi, tree dest, tree orig, orig_bytes = (offset > orig_bytes) ? HOST_WIDE_INT_0U : orig_bytes - offset; - osi->changed = object_sizes_set (osi, varno, orig_bytes); + if (object_sizes_set (osi, varno, orig_bytes)) + osi->changed = true; return bitmap_bit_p (osi->reexamine, SSA_NAME_VERSION (orig)); }