From patchwork Wed Dec 1 08:31:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 1562085 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=gotplt.org header.i=@gotplt.org header.a=rsa-sha1 header.s=gotplt.org header.b=BQwDzi2l; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (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) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4J3slp613Mz9sR4 for ; Wed, 1 Dec 2021 19:32:37 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9625B3858029 for ; Wed, 1 Dec 2021 08:32:33 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from hamster.birch.relay.mailchannels.net (hamster.birch.relay.mailchannels.net [23.83.209.80]) by sourceware.org (Postfix) with ESMTPS id 072843858C60 for ; Wed, 1 Dec 2021 08:32:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 072843858C60 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 BF6836C1B6F; Wed, 1 Dec 2021 08:32:14 +0000 (UTC) Received: from pdx1-sub0-mail-a304.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id EF2116C1D29; Wed, 1 Dec 2021 08:32:13 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from pdx1-sub0-mail-a304.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.105.57.104 (trex/6.4.3); Wed, 01 Dec 2021 08:32:14 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Whimsical-Cellar: 7c307eb170616013_1638347534426_3951206079 X-MC-Loop-Signature: 1638347534420:3966553755 X-MC-Ingress-Time: 1638347534420 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-a304.dreamhost.com (Postfix) with ESMTPSA id 4J3slH4FfWz1v; Wed, 1 Dec 2021 00:32:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gotplt.org; s=gotplt.org; t=1638347533; bh=jRVgocqa34QfWC7n9D8wa03S8wk=; h=From:To:Cc:Subject:Date:Content-Type:Content-Transfer-Encoding; b=BQwDzi2lDkrpaKGmAHufXgGKlkNvMduKoGbGYvec3T+kIgJah9xlmthaPt8Xwd/o/ 0U6/223n6PsfSwEBnv99JxfxmbbVQKAsoZocXAF9VSvvEzZRcvyytzec9a9VsBTJBa WT9MXEHUNyw+XqrQxoVWWkUNDfYkr7eMcOdTjMEc= From: Siddhesh Poyarekar To: gcc-patches@gcc.gnu.org Subject: [COMMITTED] tree-optimization/103456 - Record only successes from object_sizes_set Date: Wed, 1 Dec 2021 14:01:59 +0530 Message-Id: <20211201083159.4044250-1-siddhesh@gotplt.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211201071836.GT2646553@tucnak> References: <20211201071836.GT2646553@tucnak> MIME-Version: 1.0 X-Spam-Status: No, score=-3039.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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+incoming=patchwork.ozlabs.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. 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/ubsan/pr103456.c: New test. Co-authored-by: Martin Liška Signed-off-by: Siddhesh Poyarekar --- gcc/testsuite/gcc.dg/ubsan/pr103456.c | 21 +++++++++++++++++++++ gcc/tree-object-size.c | 3 ++- 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/ubsan/pr103456.c diff --git a/gcc/testsuite/gcc.dg/ubsan/pr103456.c b/gcc/testsuite/gcc.dg/ubsan/pr103456.c new file mode 100644 index 00000000000..20322fbaab1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ubsan/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)); }