From patchwork Wed Dec 22 15:11:01 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 76417 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]) by ozlabs.org (Postfix) with SMTP id 9F08AB6EF2 for ; Thu, 23 Dec 2010 02:11:23 +1100 (EST) Received: (qmail 11530 invoked by alias); 22 Dec 2010 15:11:20 -0000 Received: (qmail 11515 invoked by uid 22791); 22 Dec 2010 15:11:19 -0000 X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, SPF_HELO_PASS, T_RP_MATCHES_RCVD, T_TVD_MIME_NO_HEADERS X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (74.125.121.67) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 22 Dec 2010 15:11:11 +0000 Received: from hpaq1.eem.corp.google.com (hpaq1.eem.corp.google.com [172.25.149.1]) by smtp-out.google.com with ESMTP id oBMFB8wF002021 for ; Wed, 22 Dec 2010 07:11:08 -0800 Received: from pvg6 (pvg6.prod.google.com [10.241.210.134]) by hpaq1.eem.corp.google.com with ESMTP id oBMFB7jh010380 for ; Wed, 22 Dec 2010 07:11:07 -0800 Received: by pvg6 with SMTP id 6so1649842pvg.37 for ; Wed, 22 Dec 2010 07:11:06 -0800 (PST) Received: by 10.142.246.8 with SMTP id t8mr5561876wfh.404.1293030666590; Wed, 22 Dec 2010 07:11:06 -0800 (PST) Received: from coign.google.com ([67.218.105.75]) by mx.google.com with ESMTPS id b11sm9250731wff.21.2010.12.22.07.11.04 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 22 Dec 2010 07:11:06 -0800 (PST) From: Ian Lance Taylor To: gcc-patches@gcc.gnu.org, gofrontend-dev@googlegroups.com Subject: Go patch committed: Fix named results when cloning Date: Wed, 22 Dec 2010 07:11:01 -0800 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 X-System-Of-Record: true X-IsSubscribed: yes 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 This patch to the Go frontend fixes the handling of named result variables when cloning a function which calls recover. The compiler was failing to updating the backpointer from the named result variable to the function. Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline. Ian diff -r bf3edc9b2487 go/gogo.cc --- a/go/gogo.cc Tue Dec 21 22:32:27 2010 -0800 +++ b/go/gogo.cc Wed Dec 22 07:06:02 2010 -0800 @@ -2177,6 +2177,10 @@ Convert_recover convert_recover(can_recover_no); new_func->traverse(&convert_recover); + // Update the function pointers in any named results. + new_func->update_named_result_variables(); + orig_func->update_named_result_variables(); + return TRAVERSE_CONTINUE; } @@ -2505,6 +2509,21 @@ } } +// Update the named result variables when cloning a function which +// calls recover. + +void +Function::update_named_result_variables() +{ + if (this->named_results_ == NULL) + return; + + for (Named_results::iterator p = this->named_results_->begin(); + p != this->named_results_->end(); + ++p) + (*p)->result_var_value()->set_function(this); +} + // Return the closure variable, creating it if necessary. Named_object* diff -r bf3edc9b2487 go/gogo.h --- a/go/gogo.h Tue Dec 21 22:32:27 2010 -0800 +++ b/go/gogo.h Wed Dec 22 07:06:02 2010 -0800 @@ -787,6 +787,11 @@ void create_named_result_variables(Gogo*); + // Update the named result variables when cloning a function which + // calls recover. + void + update_named_result_variables(); + // Add a new field to the closure variable. void add_closure_field(Named_object* var, source_location loc) @@ -1318,6 +1323,12 @@ is_in_heap() const { return this->is_address_taken_; } + // Set the function. This is used when cloning functions which call + // recover. + void + set_function(Function* function) + { this->function_ = function; } + private: // Type of result variable. Type* type_;