From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 63657 invoked by alias); 6 Jan 2020 15:19:41 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 63649 invoked by uid 89); 6 Jan 2020 15:19:41 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-0.0 required=5.0 tests=BAYES_40,SPF_PASS autolearn=ham version=3.3.1 spammy=H*F:D*fr, hall, Hall, persuade 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 ESMTP; Mon, 06 Jan 2020 15:19:39 +0000 Received: from aaubervilliers-653-1-91-224.w83-200.abo.wanadoo.fr (HELO stedding) ([83.200.98.224]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Jan 2020 16:19:36 +0100 Date: Mon, 06 Jan 2020 15:19:00 -0000 From: Marc Glisse Reply-To: gcc-help@gcc.gnu.org To: Chris Hall cc: gcc-help@gcc.gnu.org Subject: Re: Function returning struct on x86_64 (at least) In-Reply-To: <6ca4e3d5-46ea-ef7e-080c-11da70f0b9d8@gmch.uk> Message-ID: References: <20190418190754.GH8599@gate.crashing.org> <4b1f3ec6-8df9-7707-8d75-af6a84774b74@gmch.uk> <042a6858-a5a5-c842-e29f-ca45fbe14912@gmch.uk> <6ca4e3d5-46ea-ef7e-080c-11da70f0b9d8@gmch.uk> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed X-SW-Source: 2020-01/txt/msg00017.txt.bz2 On Mon, 6 Jan 2020, Chris Hall wrote: [description of NRVO] > Is there any way in which I can persuade the compiler that a function > returning a struct does not need to worry about preserving the value of the > final destination (ie the struct at %rdi) ? Compile the file as C++ instead of C. Not that it would be forbidden in C, but the optimization happens to be in the C++ front-end. There is also an optimization pass called nrv, but it does trigger that often. -- Marc Glisse