From patchwork Wed Dec 10 20:38:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 419855 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 5AE0B1400E7 for ; Thu, 11 Dec 2014 07:38:28 +1100 (AEDT) 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:date:message-id:subject:from:to:content-type; q= dns; s=default; b=C8advMgmJ4OZb3ycH3/+E+VbLk0443/M69FEOdKyqXzBu7 Sq0G1SbCW3vulwoCB0TfmHhHtIPrMNHECn0790ndqYoTAMxcikT3OT3lKZk+nZPY hYgCplhIirS7ETfcrXPDvszDR5vaJDobhNyZxs5IPBVTe8Dcpk5qdxkrUhw48= 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:date:message-id:subject:from:to:content-type; s= default; bh=ItgSxmepBNzoTJbfICezS52hJqw=; b=HT+0qmNk9gHkM0HGKoh1 L9jI3IJTsJc13I3ZSSGe7Zfe9dKrfwPoyn7+GdyLmYWg/sUvRAuIW+PmaMZAIDgv fpROtyrisFrnz0dsNTkStelvnH8O/N0HiunwZv+zqgXCCY13aFKKcbcaBUvqopu/ lkW0EFa8Rn9RnL8GXj+zKmw= Received: (qmail 19055 invoked by alias); 10 Dec 2014 20:38:20 -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 19045 invoked by uid 89); 10 Dec 2014 20:38:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-yh0-f47.google.com Received: from mail-yh0-f47.google.com (HELO mail-yh0-f47.google.com) (209.85.213.47) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Wed, 10 Dec 2014 20:38:17 +0000 Received: by mail-yh0-f47.google.com with SMTP id f73so1673001yha.20 for ; Wed, 10 Dec 2014 12:38:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to :content-type; bh=1vQkYAuYdRrAG4b7jYsOEZd2mzerCQkFCmfdnDarVlc=; b=K+ev5rvbEfsCdzEX86b7Row6QHj7/R28YYSdupGpWwtLnQkmQgPwhcM5bXJHyMqpqt Bs4KgljwV80ZI7F4FBmYO16Cvxra9hTQltBD6GrL0LONJ5GzeOvcA6mQREkCfsXsMD41 FuOpij8cGGWf6Mav0o5xVMpuhPf9eMf5Q+uDXT5/MYJVR/fuk0MT1kZ1BKTrYOV66rUx Dibs+Laa/pHgBAIate7iBRVQI83ObqoP/3/KfhcI+6olFmB2/IAyQMf2UlzPZKB10dbV 1D/oJgV5gkVwOJW8IbKwWY2ASDQP2SdbV8uAeXrMXjFZlLyIBnVCE5py0uIvQNQ+3mTV XHXA== X-Gm-Message-State: ALoCoQlnSSQKI0zgaf3PnzImvcJZTecpHulU4+S3/bW/+E11sKEFyEBA9fZRdkE/K2BjL8qFokoM MIME-Version: 1.0 X-Received: by 10.170.90.68 with SMTP id h65mr5552619yka.94.1418243895585; Wed, 10 Dec 2014 12:38:15 -0800 (PST) Received: by 10.170.57.196 with HTTP; Wed, 10 Dec 2014 12:38:15 -0800 (PST) Date: Wed, 10 Dec 2014 12:38:15 -0800 Message-ID: Subject: Go patch committed: Don't lower multi-valued arguments into temporaries From: Ian Lance Taylor To: gcc-patches , "gofrontend-dev@googlegroups.com" This patch from Chris Manghane fixes a compiler crash when lowering a multi-valued temporary (as in f(g()) when g returns multiple values). This is GCC PR 61316. Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline. Ian diff -r fc51bd51a948 go/expressions.cc --- a/go/expressions.cc Tue Dec 09 16:54:11 2014 -0800 +++ b/go/expressions.cc Wed Dec 10 11:40:53 2014 -0800 @@ -8525,6 +8525,7 @@ || fntype->is_builtin())) { Call_expression* call = this->args_->front()->call_expression(); + call->set_is_multi_value_arg(); Expression_list* args = new Expression_list; for (size_t i = 0; i < rc; ++i) args->push_back(Expression::make_call_result(call, i)); diff -r fc51bd51a948 go/expressions.h --- a/go/expressions.h Tue Dec 09 16:54:11 2014 -0800 +++ b/go/expressions.h Wed Dec 10 11:40:53 2014 -0800 @@ -1632,7 +1632,7 @@ fn_(fn), args_(args), type_(NULL), results_(NULL), call_(NULL), call_temp_(NULL), expected_result_count_(0), is_varargs_(is_varargs), varargs_are_lowered_(false), types_are_determined_(false), - is_deferred_(false), issued_error_(false) + is_deferred_(false), issued_error_(false), is_multi_value_arg_(false) { } // The function to call. @@ -1703,6 +1703,17 @@ bool issue_error(); + // Whether this call returns multiple results that are used as an + // multi-valued argument. + bool + is_multi_value_arg() const + { return this->is_multi_value_arg_; } + + // Note this call is used as a multi-valued argument. + void + set_is_multi_value_arg() + { this->is_multi_value_arg_ = true; } + protected: int do_traverse(Traverse*); @@ -1806,6 +1817,8 @@ // results and uses. This is to avoid producing multiple errors // when there are multiple Call_result_expressions. bool issued_error_; + // True if this call is used as an argument that returns multiple results. + bool is_multi_value_arg_; }; // An expression which represents a pointer to a function. diff -r fc51bd51a948 go/statements.cc --- a/go/statements.cc Tue Dec 09 16:54:11 2014 -0800 +++ b/go/statements.cc Wed Dec 10 11:40:53 2014 -0800 @@ -726,6 +726,17 @@ if ((*pexpr)->must_eval_in_order()) { + Call_expression* call = (*pexpr)->call_expression(); + if (call != NULL && call->is_multi_value_arg()) + { + // A call expression which returns multiple results as an argument + // to another call must be handled specially. We can't create a + // temporary because there is no type to give it. Instead, group + // the caller and this multi-valued call argument and use a temporary + // variable to hold them. + return TRAVERSE_SKIP_COMPONENTS; + } + Location loc = (*pexpr)->location(); Temporary_statement* temp = Statement::make_temporary(NULL, *pexpr, loc); this->block_->add_statement(temp);