From patchwork Thu Oct 16 05:37:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Glisse X-Patchwork-Id: 400141 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 23E5E1400B6 for ; Thu, 16 Oct 2014 16:37:31 +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:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=OEYTWQVn5GErI8qi6LtGUupp8OiDf2mPYozY0/gm+Z4vrJxQzzfLT 9c6BJbaCx7UP39EY3z1f9bscjj0shX+is75+cIakDEACyoBf65So5ksKAaMQ4GtY SJMJE5Yr7ZyuFGOHvW39jI3BzBTNtz8lRgsN5jmJSazy05AwS8jG0w= 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:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=oRe8rS8ADVeJtMSSj1TMILPMIps=; b=OrHTE0+uEAQHjgAjhBSw R5Vc917TUcVSH4qpTZ8jAwnh48fb18VPfW1dzgzedwBZptj6gR0Fs7lp81hHoxoL pEig2ni02IwCaevhXgib3sfmT4wxE/DoFCTTnvwLUaqwgGyiI7im1eiuHdYZGMa3 6nAp7LDVtGtz66a8xao8Pd4= Received: (qmail 13473 invoked by alias); 16 Oct 2014 05:37:24 -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 13461 invoked by uid 89); 16 Oct 2014 05:37:23 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.0 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mail2-relais-roc.national.inria.fr Received: from mail2-relais-roc.national.inria.fr (HELO mail2-relais-roc.national.inria.fr) (192.134.164.83) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Thu, 16 Oct 2014 05:37:21 +0000 Received: from stedding.saclay.inria.fr (HELO stedding) ([193.55.250.194]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/AES128-SHA; 16 Oct 2014 07:37:18 +0200 Received: from glisse (helo=localhost) by stedding with local-esmtp (Exim 4.84) (envelope-from ) id 1XedkU-00087y-BS for gcc-patches@gcc.gnu.org; Thu, 16 Oct 2014 07:37:18 +0200 Date: Thu, 16 Oct 2014 07:37:18 +0200 (CEST) From: Marc Glisse To: gcc-patches@gcc.gnu.org Subject: NRV with address taken Message-ID: User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 Hello, the attached one-liner passed bootstrap+testsuite (really all languages) on x86_64-linux-gnu (I got an extra pass of unix/-m32: os but I assume that the failure with trunk was random). The current code is a bit weird: we bail out if either result or found is TREE_ADDRESSABLE, but then the variable replacement includes: TREE_ADDRESSABLE (result) |= TREE_ADDRESSABLE (found); (modified "recently", it was a plain assignment before) I mostly ran the testsuite to find a testcase showing why found should not have its address taken, so if someone wants to add one (or at least a comment in tree-nrv.c), that would be good. 2014-10-16 Marc Glisse * tree-nrv.c (pass_nrv::execute): Don't disable when address is taken. Index: gcc/tree-nrv.c =================================================================== --- gcc/tree-nrv.c (revision 216286) +++ gcc/tree-nrv.c (working copy) @@ -210,21 +210,20 @@ pass_nrv::execute (function *fun) return 0; } else found = rhs; /* The returned value must be a local automatic variable of the same type and alignment as the function's result. */ if (TREE_CODE (found) != VAR_DECL || TREE_THIS_VOLATILE (found) || !auto_var_in_fn_p (found, current_function_decl) - || TREE_ADDRESSABLE (found) || DECL_ALIGN (found) > DECL_ALIGN (result) || !useless_type_conversion_p (result_type, TREE_TYPE (found))) return 0; } else if (gimple_has_lhs (stmt)) { tree addr = get_base_address (gimple_get_lhs (stmt)); /* If there's any MODIFY of component of RESULT, then bail out. */