From patchwork Mon Oct 23 01:48:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 156632 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp1026447vqx; Sun, 22 Oct 2023 18:49:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHtIckZuYM//DuT+Fj5HwGeTPASY/hV5J86oaEYbEZHIdtWdo2duzLtmzkykAGIhm9gWU7g X-Received: by 2002:a05:622a:1b8e:b0:418:af7:e001 with SMTP id bp14-20020a05622a1b8e00b004180af7e001mr9149879qtb.41.1698025766086; Sun, 22 Oct 2023 18:49:26 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1698025766; cv=pass; d=google.com; s=arc-20160816; b=j5+xo+A8FigzPVK53fOhPi6CK6nbb1zo6R0tsmNN6lM27VFh77MMKK/S6zEU/C2NTp FdhC85YLjCcuowN0QPkeoV9Lhk/mANAFbZoBErwm5A4Uyq/MzQguSNqLu2R0lUmfb4W4 dxma8gpBWZDEbCk42wL4y3i1Ajv5FTXP2CnaUY6OYUWiDEi6Q10Dkv0TkdVFkwOCTkup yD5EGVfpDw3I5bkhwxmC50xgXvNy0lBXRdiA6Q9G/cO5CRdMQ6vhqoB8v/0TQ6dw/Lwl gpGFIBG9l2x1bW98W69CBfEnA2FG9Q5ZoRWc3RDI4DIyAnOxMmWzUTsUlpGZsEXVKJ9O W0wQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:to:subject:message-id:date:from :mime-version:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=lcgYOjchwOBzMza7kzHwi5KPxC+zSmynKv+ALtCto8I=; fh=sx1AF6BoRLLvWrm7PiL2RBt/kekZxFGoFwZKL1Ho560=; b=s5Ch+HXZ4bXs0j6/Gd4V+sNa9mGoftn8S2kHm5nDg8kVXPK3atlMehZXWV5jxUqsA7 S2VQ7QiW7auVdgKmipmJuDQ1JOJ6dPcCDe5FmfOmTMTTCnGCSXE+KGGtLCDfZqA8jSly iUVb8vj1i/MSmD9D+Q01D2SEpabDp1QhagsUNy8TX+IP2B8pZirHI1ZoyAJXCPT5q0Al AdmNHQlyB3HiaY9pmESqrb9mqiiIh/XoBvjP+wpuGxEjjsXqG4FzvvPAVH3Dl31lWAb8 xuLDUjJrbLpgpPRc629wkYzs/DfwIiB0CSaPGGUrhmI4ymhnvRiH1C3jFmxMVxiR5KiQ FMNA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@golang-org.20230601.gappssmtp.com header.s=20230601 header.b=1rQG43co; arc=pass (i=1); 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=fail (p=NONE sp=NONE dis=NONE) header.from=golang.org Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id w13-20020ac87e8d000000b00417cfd588cesi4761925qtj.766.2023.10.22.18.49.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Oct 2023 18:49:26 -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=@golang-org.20230601.gappssmtp.com header.s=20230601 header.b=1rQG43co; arc=pass (i=1); 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=fail (p=NONE sp=NONE dis=NONE) header.from=golang.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D57E13857703 for ; Mon, 23 Oct 2023 01:49:25 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-yb1-xb32.google.com (mail-yb1-xb32.google.com [IPv6:2607:f8b0:4864:20::b32]) by sourceware.org (Postfix) with ESMTPS id A99FE3858CDB for ; Mon, 23 Oct 2023 01:48:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A99FE3858CDB Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=golang.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=golang.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A99FE3858CDB Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::b32 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698025741; cv=none; b=ionY2JlvJXGva7Km+Oixm1wPH52cIeYcJEHN2do4ZZQ8mO6HK6ooOkGPza0GBpIOgQuqv7dYBPLc1nUW2GjzMMeBhnAPtmC5RCMNUE6xpA72p349rFJKdvw6VYLYJkb3UWpM3o8+H0IeBxBA3NPxBITeChCPMm60DLn+T6BHo5c= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698025741; c=relaxed/simple; bh=rU0lOfE+s+ydWJmdt7ZKdlFbruvx2NSPT+ZUKTpim24=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=wGv2uiDLIxq77+MbrnvlnOWcwE+zNdK0UdZSUPDSqQUQ9Ctz/lTFzZt+8KJDUB7/cWxRc+n434qRZSIWREsynAT2K6BMMcW58+5lie8yTU+XJ3PWs12vsXjkMDmL4LmU49Tq4b+X01Svvv5OhbYl6JKRCOkIhHQaXZG11txS01E= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-yb1-xb32.google.com with SMTP id 3f1490d57ef6-d9ad67058fcso2670152276.1 for ; Sun, 22 Oct 2023 18:48:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=golang-org.20230601.gappssmtp.com; s=20230601; t=1698025739; x=1698630539; darn=gcc.gnu.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=lcgYOjchwOBzMza7kzHwi5KPxC+zSmynKv+ALtCto8I=; b=1rQG43coX4hLgJgTtqak2scLvF17E2UNp+2Rr9ZY4JkmZc++Xo2/zvw9mLo+eBV9ds 26y7UEhAZcv9taJOY7cDX038TrTVCR/H8zKittQG404KlEJR2tZFSW8XPVIu/0W61DM3 08lXttkrPG+sF4D44fu2EN2r9po3bKuWmBiHxWIvhr4DwLvd2XsJaxh6qInzaCQwnIFV Eb8Vo8a/6ZP6bRBXAimqk3AWU9ASqRmGsWnx+nlyT/ON8smHoSk+ITebLQyG4M8gQazp JRjFOytvAzyHZ4T1i5AyLiGayXndxIzPZN4ZQWxUDMI6Zkw7zTZciOOdLHQnABDLvQO2 BR1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698025739; x=1698630539; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=lcgYOjchwOBzMza7kzHwi5KPxC+zSmynKv+ALtCto8I=; b=Sp5gQHZnFblLH3Ulg+8UArLydOaZ25yLMRatumyqwkTsw7y/n8iJjSrnbdnTWzHUon /LB5LRF12hEBQs35u4kEMxNh89XbqXMdeV/LGibkHax00YOdIcG/dz2sve/AApisniaR HhDXfuRinlhHKdK2HKlFaJj87mZrnMWLT3FrcjeFgCV3zMkA469prVU2TxWnSTBRL2zK DcPJOjRzYotDnQAKiqUtQA3gZfFWBYLYNKa6zYpb7sPnqJunbyd41K8dq9/qlny8zqeM Tda4uwH8nZ3FwYsTnMDp6mSwn+Sm0nwbGGXBbz07V2lH5/x4WtO9TvsA/HpuF0nCbPx5 JBcQ== X-Gm-Message-State: AOJu0Yw6oJfsCUv35UA81t1OiDFK1YrPSf2jWJf01smtG+lj6hZlERdS ObnvlmiQ0a8845w/ZdjPgNwdM1QedcqHV52CFUDnQE4Ia0JNW9wJ2r0= X-Received: by 2002:a25:428e:0:b0:d90:c424:53ee with SMTP id p136-20020a25428e000000b00d90c42453eemr8391749yba.9.1698025738842; Sun, 22 Oct 2023 18:48:58 -0700 (PDT) MIME-Version: 1.0 From: Ian Lance Taylor Date: Sun, 22 Oct 2023 18:48:48 -0700 Message-ID: Subject: Go patch committed: Remove the traverse_assignments code To: gcc-patches , gofrontend-dev X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780509065625859560 X-GMAIL-MSGID: 1780509065625859560 This patch to the Go frontend removes the traverse_assignments support. The last caller was removed in https://go.dev/cl/18261 in 2016. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian a6e74b0b3316f3f0b2096d6a175c31bed58ae4ed diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index d31fb336e41..398d2671b64 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -75b08794cb1485c955d13784c53a89174764af55 +c201fa2a684ada551ca9a0825a3075a0a69498de The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/gcc/go/gofrontend/statements.cc b/gcc/go/gofrontend/statements.cc index b43f1393e33..91c7627a0e3 100644 --- a/gcc/go/gofrontend/statements.cc +++ b/gcc/go/gofrontend/statements.cc @@ -64,16 +64,6 @@ Statement::traverse_contents(Traverse* traverse) return this->do_traverse(traverse); } -// Traverse assignments. - -bool -Statement::traverse_assignments(Traverse_assignments* tassign) -{ - if (this->classification_ == STATEMENT_ERROR) - return false; - return this->do_traverse_assignments(tassign); -} - // Traverse an expression in a statement. This is a helper function // for child classes. @@ -288,17 +278,6 @@ Variable_declaration_statement::do_traverse(Traverse*) return TRAVERSE_CONTINUE; } -// Traverse the assignments in a variable declaration. Note that this -// traversal is different from the usual traversal. - -bool -Variable_declaration_statement::do_traverse_assignments( - Traverse_assignments* tassign) -{ - tassign->initialize_variable(this->var_); - return true; -} - // Lower the variable's initialization expression. Statement* @@ -510,17 +489,6 @@ Temporary_statement::do_traverse(Traverse* traverse) return this->traverse_expression(traverse, &this->init_); } -// Traverse assignments. - -bool -Temporary_statement::do_traverse_assignments(Traverse_assignments* tassign) -{ - if (this->init_ == NULL) - return false; - tassign->value(&this->init_, true, true); - return true; -} - // Determine types. void @@ -889,13 +857,6 @@ Assignment_statement::do_traverse(Traverse* traverse) return this->traverse_expression(traverse, &this->rhs_); } -bool -Assignment_statement::do_traverse_assignments(Traverse_assignments* tassign) -{ - tassign->assignment(&this->lhs_, &this->rhs_); - return true; -} - // Lower an assignment to a map index expression to a runtime function // call. Mark some slice assignments as not requiring a write barrier. @@ -1212,10 +1173,6 @@ class Assignment_operation_statement : public Statement int do_traverse(Traverse*); - bool - do_traverse_assignments(Traverse_assignments*) - { go_unreachable(); } - Statement* do_lower(Gogo*, Named_object*, Block*, Statement_inserter*); @@ -1365,10 +1322,6 @@ class Tuple_assignment_statement : public Statement int do_traverse(Traverse* traverse); - bool - do_traverse_assignments(Traverse_assignments*) - { go_unreachable(); } - Statement* do_lower(Gogo*, Named_object*, Block*, Statement_inserter*); @@ -1511,10 +1464,6 @@ public: int do_traverse(Traverse* traverse); - bool - do_traverse_assignments(Traverse_assignments*) - { go_unreachable(); } - Statement* do_lower(Gogo*, Named_object*, Block*, Statement_inserter*); @@ -1719,10 +1668,6 @@ class Tuple_receive_assignment_statement : public Statement int do_traverse(Traverse* traverse); - bool - do_traverse_assignments(Traverse_assignments*) - { go_unreachable(); } - Statement* do_lower(Gogo*, Named_object*, Block*, Statement_inserter*); @@ -1862,10 +1807,6 @@ class Tuple_type_guard_assignment_statement : public Statement int do_traverse(Traverse*); - bool - do_traverse_assignments(Traverse_assignments*) - { go_unreachable(); } - Statement* do_lower(Gogo*, Named_object*, Block*, Statement_inserter*); @@ -2277,10 +2218,6 @@ class Inc_dec_statement : public Statement do_traverse(Traverse* traverse) { return this->traverse_expression(traverse, &this->expr_); } - bool - do_traverse_assignments(Traverse_assignments*) - { go_unreachable(); } - Statement* do_lower(Gogo*, Named_object*, Block*, Statement_inserter*); @@ -2412,18 +2349,6 @@ Thunk_statement::do_traverse(Traverse* traverse) return this->traverse_expression(traverse, &this->call_); } -// We implement traverse_assignment for a thunk statement because it -// effectively copies the function call. - -bool -Thunk_statement::do_traverse_assignments(Traverse_assignments* tassign) -{ - Expression* fn = this->call_->call_expression()->fn(); - Expression* fn2 = fn; - tassign->value(&fn2, true, false); - return true; -} - // Determine types in a thunk statement. void @@ -3148,23 +3073,6 @@ Statement::make_defer_statement(Call_expression* call, // Class Return_statement. -// Traverse assignments. We treat each return value as a top level -// RHS in an expression. - -bool -Return_statement::do_traverse_assignments(Traverse_assignments* tassign) -{ - Expression_list* vals = this->vals_; - if (vals != NULL) - { - for (Expression_list::iterator p = vals->begin(); - p != vals->end(); - ++p) - tassign->value(&*p, true, true); - } - return true; -} - // Lower a return statement. If we are returning a function call // which returns multiple values which match the current function, // split up the call's results. If the return statement lists diff --git a/gcc/go/gofrontend/statements.h b/gcc/go/gofrontend/statements.h index 9ef63cb9a61..5fac01b916e 100644 --- a/gcc/go/gofrontend/statements.h +++ b/gcc/go/gofrontend/statements.h @@ -55,42 +55,6 @@ class Bstatement; class Bvariable; class Ast_dump_context; -// This class is used to traverse assignments made by a statement -// which makes assignments. - -class Traverse_assignments -{ - public: - Traverse_assignments() - { } - - virtual ~Traverse_assignments() - { } - - // This is called for a variable initialization. - virtual void - initialize_variable(Named_object*) = 0; - - // This is called for each assignment made by the statement. PLHS - // points to the left hand side, and PRHS points to the right hand - // side. PRHS may be NULL if there is no associated expression, as - // in the bool set by a non-blocking receive. - virtual void - assignment(Expression** plhs, Expression** prhs) = 0; - - // This is called for each expression which is not passed to the - // assignment function. This is used for some of the statements - // which assign two values, for which there is no expression which - // describes the value. For ++ and -- the value is passed to both - // the assignment method and the rhs method. IS_STORED is true if - // this value is being stored directly. It is false if the value is - // computed but not stored. IS_LOCAL is true if the value is being - // stored in a local variable or this is being called by a return - // statement. - virtual void - value(Expression**, bool is_stored, bool is_local) = 0; -}; - // A single statement. class Statement @@ -292,13 +256,6 @@ class Statement int traverse_contents(Traverse*); - // If this statement assigns some values, it calls a function for - // each value to which this statement assigns a value, and returns - // true. If this statement does not assign any values, it returns - // false. - bool - traverse_assignments(Traverse_assignments* tassign); - // Lower a statement. This is called immediately after parsing to // simplify statements for further processing. It returns the same // Statement or a new one. FUNCTION is the function containing this @@ -486,12 +443,6 @@ class Statement virtual int do_traverse(Traverse*) = 0; - // Implemented by child class: traverse assignments. Any statement - // which includes an assignment should implement this. - virtual bool - do_traverse_assignments(Traverse_assignments*) - { return false; } - // Implemented by the child class: lower this statement to a simpler // one. virtual Statement* @@ -633,9 +584,6 @@ class Assignment_statement : public Statement int do_traverse(Traverse* traverse); - bool - do_traverse_assignments(Traverse_assignments*); - virtual Statement* do_lower(Gogo*, Named_object*, Block*, Statement_inserter*); @@ -753,9 +701,6 @@ class Temporary_statement : public Statement int do_traverse(Traverse*); - bool - do_traverse_assignments(Traverse_assignments*); - void do_determine_types(Gogo*); @@ -820,9 +765,6 @@ class Variable_declaration_statement : public Statement int do_traverse(Traverse*); - bool - do_traverse_assignments(Traverse_assignments*); - Statement* do_lower(Gogo*, Named_object*, Block*, Statement_inserter*); @@ -869,9 +811,6 @@ class Return_statement : public Statement do_traverse(Traverse* traverse) { return this->traverse_expression_list(traverse, this->vals_); } - bool - do_traverse_assignments(Traverse_assignments*); - Statement* do_lower(Gogo*, Named_object*, Block*, Statement_inserter*); @@ -1383,9 +1322,6 @@ class Thunk_statement : public Statement int do_traverse(Traverse* traverse); - bool - do_traverse_assignments(Traverse_assignments*); - void do_determine_types(Gogo*); @@ -1719,10 +1655,6 @@ class For_statement : public Statement int do_traverse(Traverse*); - bool - do_traverse_assignments(Traverse_assignments*) - { go_unreachable(); } - Statement* do_lower(Gogo*, Named_object*, Block*, Statement_inserter*); @@ -1783,10 +1715,6 @@ class For_range_statement : public Statement int do_traverse(Traverse*); - bool - do_traverse_assignments(Traverse_assignments*) - { go_unreachable(); } - Statement* do_lower(Gogo*, Named_object*, Block*, Statement_inserter*);