From patchwork Tue May 2 15:19:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 89403 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp695739vqo; Tue, 2 May 2023 08:20:06 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6u9Fhjc6sfjNiqsyPrcAtWK5DYY7GND9vPDum4zGn19e/58o8t7S+Sz7bP7ODAveYr/WY8 X-Received: by 2002:a50:fb8d:0:b0:50b:c49b:61d1 with SMTP id e13-20020a50fb8d000000b0050bc49b61d1mr5883549edq.24.1683040805839; Tue, 02 May 2023 08:20:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683040805; cv=none; d=google.com; s=arc-20160816; b=hpQwln/S/bxms0W+fUYsy3KqJSutiZzLi7XtYcH/5rlMc31YxeH4ssHQu/6kXqKn5J AuCqjvnP62IKV1bo+NQI2tiV0Wvfxx66c2Mgueo2rnVsIe3zqANqu4GFcHfovjhGQcfU kYjlCliUGqW8ZA//EQ/HlPe50LqXNSLg+hlRmi/c7YjqdnkZnyWtSKU1EyRY+T5CJ8BJ OEgD+vL4w1vecvoHPW7z6wEIeKhEGvbON6UCjIOXX2b1U0eJOFvFv805GAYASo09Z/Pr UibM2a6rvEkt+/xpAFsb2/l7+0lCkh8tZXL1uRVMw+prDULev0La9QC5NyQOPPCWl+SY QNqA== 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-disposition:mime-version:message-id:subject:cc:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=AMi3/AtoG2HQc2NWMZ2qle3HdHf14pgjWzTAuq6QicM=; b=mBPVpqkkhT4rvyKxcC7JLGCVqZVMqnor6lNLfFHSeMJ5wfsfUlmAVZfqybJAhu59as xx9mSGs0HKzOyWZ9iakssjAR3/orcQp4trxnSW3qJZWNcsr+5bqSaN1EsmSNbHxPnflw fGk3mhfWvc/kitedrAyaaUnd0T0fzLg5uk4AXU6ZwWg58jLYyx7WZgXO4e/ZVWt2arW4 fsgDk+ZedCIapPiWtKDzoS8d/Est/XgnzTZVQY+TVqUXyeCuR5UGeZdh/rAFJ+/6I6yq 8Bke4cz227hRQVaATjHAp7r3eW5Jp5bQf7uwbHUWt5+ObnEnYGtiajiG1hF/XcSLuA3X H0sA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Ms914rvi; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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. [8.43.85.97]) by mx.google.com with ESMTPS id n14-20020aa7c68e000000b0050491f11f08si24067056edq.35.2023.05.02.08.20.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 May 2023 08:20:05 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Ms914rvi; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 B8E353858D28 for ; Tue, 2 May 2023 15:20:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B8E353858D28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1683040804; bh=AMi3/AtoG2HQc2NWMZ2qle3HdHf14pgjWzTAuq6QicM=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=Ms914rviH3nYhe6ygJOUVEuYAnS2P03ZDcHAgdVJ63NZ50b1sFHeGUEcA9OEyG0TR r++6U9q5oHeuHDZtEaCH/sC7W4se6oWeKoCm9RP6bpH4rvib7OxA5wZ10Zb5bMxaUN gJ88KQa1tlA64Jxcbv+j4upk8R22dpR8IheORS8g= 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 810F03858D1E for ; Tue, 2 May 2023 15:19:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 810F03858D1E 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-501-Y7IS0Ru9NUKL2qqS96SUtw-1; Tue, 02 May 2023 11:19:14 -0400 X-MC-Unique: Y7IS0Ru9NUKL2qqS96SUtw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A806685A588 for ; Tue, 2 May 2023 15:19:14 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.194.156]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 63B26C15BAD; Tue, 2 May 2023 15:19:14 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 342FJCkM3172038 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 2 May 2023 17:19:12 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 342FJBAR3172037; Tue, 2 May 2023 17:19:11 +0200 Date: Tue, 2 May 2023 17:19:11 +0200 To: Jason Merrill Cc: gcc-patches@gcc.gnu.org, Patrick Palka Subject: [PATCH] c++: Fix up VEC_INIT_EXPR gimplification after r12-7069 Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no 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: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek 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?1764796196051101659?= X-GMAIL-MSGID: =?utf-8?q?1764796196051101659?= Hi! During patch backporting, I've noticed that while most cp_walk_tree calls with cp_fold_r callback callers were changed from &pset to cp_fold_data &data, the VEC_INIT_EXPR gimplifications has not, so it still passes just address of a hash_set and so if during the folding we ever touch data->flags, we use uninitialized data there. The following patch changes it to do the same thing as cp_fold_function because the VEC_INIT_EXPR gimplifications will happen on function bodies only. Ok for trunk if it passes bootstrap/regtest? 2023-05-02 Jakub Jelinek * cp-gimplify.cc (cp_fold_data): Move definition earlier. (cp_gimplify_expr): Pass address of ff_genericize | ff_mce_false constructed data rather than &pset to cp_walk_tree with cp_fold_r. Jakub --- gcc/cp/cp-gimplify.cc.jj 2023-03-16 22:01:02.295090975 +0100 +++ gcc/cp/cp-gimplify.cc 2023-05-02 17:05:03.079652427 +0200 @@ -57,6 +57,13 @@ enum fold_flags { using fold_flags_t = int; +struct cp_fold_data +{ + hash_set pset; + fold_flags_t flags; + cp_fold_data (fold_flags_t flags): flags (flags) {} +}; + /* Forward declarations. */ static tree cp_genericize_r (tree *, int *, void *); @@ -505,8 +512,8 @@ cp_gimplify_expr (tree *expr_p, gimple_s *expr_p = expand_vec_init_expr (NULL_TREE, *expr_p, tf_warning_or_error); - hash_set pset; - cp_walk_tree (expr_p, cp_fold_r, &pset, NULL); + cp_fold_data data (ff_genericize | ff_mce_false); + cp_walk_tree (expr_p, cp_fold_r, &data, NULL); cp_genericize_tree (expr_p, false); copy_if_shared (expr_p); ret = GS_OK; @@ -1029,13 +1036,6 @@ struct cp_genericize_data in fold-const, we need to perform this before transformation to GIMPLE-form. */ -struct cp_fold_data -{ - hash_set pset; - fold_flags_t flags; - cp_fold_data (fold_flags_t flags): flags (flags) {} -}; - static tree cp_fold_r (tree *stmt_p, int *walk_subtrees, void *data_) {