From patchwork Mon May 1 21:51:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Polacek X-Patchwork-Id: 89185 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp198793vqo; Mon, 1 May 2023 14:52:07 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6+03OEubR0vmsg7f4fcLszHQ5fyfSBWGYK/z5dyQcShpd959n+VaZbVw/ofqGBO9bOKNBB X-Received: by 2002:a05:6402:1e90:b0:4ea:a9b0:a518 with SMTP id f16-20020a0564021e9000b004eaa9b0a518mr7400196edf.17.1682977926840; Mon, 01 May 2023 14:52:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682977926; cv=none; d=google.com; s=arc-20160816; b=Eq/pDFU0N5s1twzdDqzXXTC2sh2QrJA7b7YTgQH5My9GegHaJKutXm+nM/Nyyigf+m 60PGu98zUoI7UXcQajbGgztpY299rCTft/SOigy/Mj9lRR+7z2MsURjkPKRnGWfeA+Yb JhfkgWs7lXP+1Ud0ieE50okuo/edXrZKLGPA30ZG3QdB61ZnmHPdT9PrdUhD9p3hLBhR cUmW+2mJ2Lq0GiiQwSGFXq6E6AEAbc74o/GkScLcD595f9isBTm9sWo8ekNPRoPH+mp1 jZKi3ydyP90LuKr5OWysGWvPV2LSMOzCHdD7GvXWsZXo0Dy8pVcDGYyRFCEsag+poR+5 DtHQ== 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:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=AtOgJReKkBt7Cf2LbamIVkbn8bCCaAz2sf1WJembMGQ=; b=vkAt43GlGX8s/MUfcKm8TOifdvTyjQ6J9iotpm/+uVEAsx5HYyapn7j5v+hXuxHmRI nO8YIs8eMBxx2dB9LK/GBtG5ZPdc4M/UGy7PHBAVVi/7IreAuJVNNIe1Z8OuGQ+PWTB+ rk/MEq5qWAbbrdpXROnrz/ovqo7nzfQypciO6NeJ3kXhYrblpME8YvVpahaq6+Di+USb teSLZuzLx+kTxEDh8XoU+fij8R6EWkycJyRIhcbZ2FhqcA1VA/Xvh0VkOPlMLqterbu6 e7NRT5Fk6Bpo8IPrJFsVM8HOFnMdRwBWYN8zTNwvOiPZhaFiwRkNsyt8Hm7Bk8FFCJ/D RmcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=xAtwx8pz; 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 sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id r23-20020a056402035700b00506addaaabasi21154296edw.64.2023.05.01.14.52.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 May 2023 14:52:06 -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=xAtwx8pz; 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 423A23858425 for ; Mon, 1 May 2023 21:52:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 423A23858425 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1682977924; bh=AtOgJReKkBt7Cf2LbamIVkbn8bCCaAz2sf1WJembMGQ=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=xAtwx8pztDFqMmfci2vIgdUKR6RcQFQAIANpNoHwRL81295KelRl7hl6i66Mm3AA9 Li9bh7NiABcqXkml98hZSVamncWheVDxFlERxa5bSAr7I8LoVI03odcR3zEyzc+AcR nqQOdIdXBTNdL1nkxU7XoAInx/uX4nXL2LCq4HzY= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 52AFB3858D1E for ; Mon, 1 May 2023 21:51:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 52AFB3858D1E Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-171-Us9DtaCiNoOk75cTMVbl8Q-1; Mon, 01 May 2023 17:51:17 -0400 X-MC-Unique: Us9DtaCiNoOk75cTMVbl8Q-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 53205811E7D for ; Mon, 1 May 2023 21:51:17 +0000 (UTC) Received: from pdp-11.lan (unknown [10.22.10.66]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3D3AF40B3EDA for ; Mon, 1 May 2023 21:51:17 +0000 (UTC) To: GCC Patches Subject: [pushed] ubsan: ubsan_maybe_instrument_array_ref tweak Date: Mon, 1 May 2023 17:51:12 -0400 Message-Id: <20230501215112.432409-1-polacek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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: Marek Polacek via Gcc-patches From: Marek Polacek Reply-To: Marek Polacek Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764730262608737114?= X-GMAIL-MSGID: =?utf-8?q?1764730262608737114?= In we discussed that the copy_node in ubsan_maybe_instrument_array_ref is redundant, but also that it'd be best to postpone the optimization to GCC 14. So I'm making that change now. Tested x86_64-pc-linux-gnu, applying to trunk. gcc/c-family/ChangeLog: * c-ubsan.cc (ubsan_maybe_instrument_array_ref): Don't copy_node. --- gcc/c-family/c-ubsan.cc | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) base-commit: 07c52d1eec9671af92b7ce977b469f13a87887ad diff --git a/gcc/c-family/c-ubsan.cc b/gcc/c-family/c-ubsan.cc index c3ae515306c..cfb7cbf389c 100644 --- a/gcc/c-family/c-ubsan.cc +++ b/gcc/c-family/c-ubsan.cc @@ -505,12 +505,8 @@ ubsan_maybe_instrument_array_ref (tree *expr_p, bool ignore_off_by_one) tree e = ubsan_instrument_bounds (EXPR_LOCATION (*expr_p), op0, &op1, ignore_off_by_one); if (e != NULL_TREE) - { - tree t = copy_node (*expr_p); - TREE_OPERAND (t, 1) = build2 (COMPOUND_EXPR, TREE_TYPE (op1), - e, op1); - *expr_p = t; - } + TREE_OPERAND (*expr_p, 1) = build2 (COMPOUND_EXPR, TREE_TYPE (op1), + e, op1); } }