From patchwork Tue Jul 10 00:55:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 941776 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-481255-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=golang.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="S7WXkhFK"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=golang-org.20150623.gappssmtp.com header.i=@golang-org.20150623.gappssmtp.com header.b="SR7jIzpI"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41PkK41zC5z9rxs for ; Tue, 10 Jul 2018 10:55:50 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=TOUrHLYNFNUJ+FkfeTQ76JQNeyADerQHqghRxiw735s0mg 2RDKseL6tnNPa1GYRC0PdaR1MBXfoTOj7u0PxyHhWpTb2OHgq77sZYgxPUYWtwtN 3iEKcK+o+bE+xkJtxjVZIpt3k52WPHQepBloRG5WvG9LTcXqActf3tMKkeKkY= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=FpwNco64aEDH3ydIPZItJossNGw=; b=S7WXkhFKJsepHOpXvC9d bRZIyz2ZYn9Sm4sYSnG73sGAdXtxzaux9XXQeDpbnCG31xsBCEBfXcYLutm97xEN fna7i8mt9mh95IwDHaDNxWsOBVUX8fnn8cQWzy+yzTbi6oIpewypxJw3D8cegON2 Uf9eocR3kGOWZmdeO72+2zw= Received: (qmail 71182 invoked by alias); 10 Jul 2018 00:55:43 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 71167 invoked by uid 89); 10 Jul 2018 00:55:42 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-10.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=HTo:D*googlegroups.com, H*Ad:D*googlegroups.com, ian, Expression X-HELO: mail-lf0-f46.google.com Received: from mail-lf0-f46.google.com (HELO mail-lf0-f46.google.com) (209.85.215.46) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 10 Jul 2018 00:55:40 +0000 Received: by mail-lf0-f46.google.com with SMTP id b22-v6so4347990lfa.3 for ; Mon, 09 Jul 2018 17:55:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=golang-org.20150623.gappssmtp.com; s=20150623; h=mime-version:from:date:message-id:subject:to; bh=MbDVgMiBRnU8zrXdaG7h24TpJYsCTd6tV8PyYjP3Id0=; b=SR7jIzpIWJTSkU3eMOF3lAVg9ya5K9TGF/wSdgvwCHvniyjZntPU7MX8yoTOvFeWcm LYHoF/rKiLTI/gsLwUiUW3okTB+d9c6SumFsEhlH9WhNEGDN2EpCN/2sQ/FZKbHC3wm3 6DK7g3XnCf7MyUaWuqzPUZ8tY9F8/czsfRSbkRhuPWcB/0j+vupa9epfzVQmhQsQcx32 PMXhEXbnyFQtWX0VP7KOR2TLfo6021oxdf6EVQ2olO5qyxYWU37FU+XJTL1EkKltbO8+ rgRk95GF5QGgltaLdVeQTPr68z57YeADvuTQh3N7X4Jh/FvPcWXyDoOAso5XnocoL0JA xhiA== MIME-Version: 1.0 Received: by 2002:ab3:1d07:0:0:0:0:0 with HTTP; Mon, 9 Jul 2018 17:55:36 -0700 (PDT) From: Ian Lance Taylor Date: Mon, 9 Jul 2018 17:55:36 -0700 Message-ID: Subject: Go patch committed: Fix double evaluation when using interface field expression To: gcc-patches , gofrontend-dev@googlegroups.com This patch to the Go frontend by Cherry Zhang fixes the compiler to avoid a double evaluation of an interface field expression. In Interface_field_reference_expression, the interface expression is used in two places, so a temporary variable is used. Previously, we used a Set_and_use_temporary_expression, which, when evaluated twice, causes double evaluation of the underlying expression. Fix by setting the temporary once and use Temporary_reference_expression instead. This fixes https://golang.org/issue/26248. The test case for this is in https://golang.org/cl/122757. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian Index: gcc/go/gofrontend/MERGE =================================================================== --- gcc/go/gofrontend/MERGE (revision 262313) +++ gcc/go/gofrontend/MERGE (working copy) @@ -1,4 +1,4 @@ -94738979a3422e845acf358a766aabf8b9275d43 +8ad67a72a4fa59efffc891e73ecf10020e3c565d The first line of this file holds the git revision number of the last merge done from the gofrontend repository. Index: gcc/go/gofrontend/expressions.cc =================================================================== --- gcc/go/gofrontend/expressions.cc (revision 262312) +++ gcc/go/gofrontend/expressions.cc (working copy) @@ -11886,10 +11886,9 @@ Interface_field_reference_expression::do if (!this->expr_->is_variable()) { Temporary_statement* temp = - Statement::make_temporary(this->expr_->type(), NULL, this->location()); + Statement::make_temporary(NULL, this->expr_, this->location()); inserter->insert(temp); - this->expr_ = Expression::make_set_and_use_temporary(temp, this->expr_, - this->location()); + this->expr_ = Expression::make_temporary_reference(temp, this->location()); } return this; }