From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 109421 invoked by alias); 21 Nov 2019 09:21:24 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 109404 invoked by uid 89); 21 Nov 2019 09:21:24 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-2.7 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy=H*i:sk:0G82ivW, H*i:CAO9iq9GuMc, H*f:sk:h8W3FzF, H*i:sk:h8W3FzF X-HELO: mail-yb1-f174.google.com Received: from mail-yb1-f174.google.com (HELO mail-yb1-f174.google.com) (209.85.219.174) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 21 Nov 2019 09:21:23 +0000 Received: by mail-yb1-f174.google.com with SMTP id h23so1177538ybg.2; Thu, 21 Nov 2019 01:21:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=/714wEk9KwxLcwA/0Nnn/BKdGV0uNH+LvevJaKN5XDg=; b=dGNMLcJdx4iT6T/LUThEIgK1tZ6D8RPXTR0kKO9TBvzinKYSVzO0DCEgjT1EJTV0Yp NQA+pQNUgbytDKlvqX8nXI2d6DuRtHdGzxAMxtxOkCfzf0Izr9esXes9Ko8BxXY/SOBM JOUkMZHMO7jql4cJjYrpneyue+1g+8mJzSge/AYBFtzbJPZiycUvBnyaVqBMMDxqXilS 5ZaWOqM62TDPdoyLR3G0wCasXz+x49HMQl9FtoHDGci0U6vG4ZwsUOwpT07Y/JNc7lAK 0YloBHQL8TAy/biowN72BswYu7xDn7xBdJfG5ZCxWur+PhfrR9AAwHCQuXhbfj7ygSrF iZXg== MIME-Version: 1.0 References: <48286910-ebbb-10e4-488b-8c96e505375c@tkoenig.net> <43b9fcf0-f457-90a7-c807-4aebc65cb045@tkoenig.net> <2981fd67-007e-7327-8208-27e8fd18d9db@netcologne.de> <4e68f250-1e41-ac7c-dc64-88f91cdf183e@tkoenig.net> In-Reply-To: From: Janne Blomqvist Date: Thu, 21 Nov 2019 09:35:00 -0000 Message-ID: Subject: Re: [patch, fortran] Load scalar intent-in variables at the beginning of procedures To: =?UTF-8?Q?Thomas_K=C3=B6nig?= Cc: Thomas Koenig , Tobias Burnus , "fortran@gcc.gnu.org" , gcc-patches Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-SW-Source: 2019-11/txt/msg02076.txt.bz2 On Thu, Nov 21, 2019 at 12:31 AM Janne Blomqvist wrote: > > On Thu, Nov 21, 2019 at 12:18 AM Janne Blomqvist > wrote: > > > > On Wed, Nov 20, 2019 at 11:35 PM Thomas K=C3=B6nig wro= te: > > > (Why do we zero %eax > > > before each call? It should not be a variadic call right?) > > > > Not sure. Maybe some belt and suspenders thing? I guess someone better > > versed in ABI minutiae knows better. It's not Fortran-specific though, > > the C frontend does the same when calling a void function. > > Ah, scratch that, it is some varargs-thing, I had forgot that a C > function with no arguments or lacking a prototype is considered a > varargs. The code > > void foo(); > void bar(void); > > void testfoo() > { > foo(); > } > > void testbar() > { > bar(); > } > > void testunprototyped() > { > baz(); > } > > > generates code (elided scaffolding): > > testfoo: > xorl %eax, %eax > jmp foo > testbar: > jmp bar > testunprototyped: > xorl %eax, %eax > jmp baz > > > So probably this is due to the Fortran procedures lacking an interface > being considered varargs by the caller. Starts to smell like some > leftover from PR 87689? Thinking some more about it, I'm thinking we should leave it as is, even though it's a (small) code bloat. So Fortran calling a procedure with an implicit interface most closely resembles the C unprototyped function call. The problem is that we don't know much about the callee. What if a Fortran procedure calls a C varargs procedure? In the Fortran caller, we don't know whether the callee is varargs or not, but if we don't zero %eax all hell could break loose if it happened to be a varargs function. Yes, we could hide behind Fortran not supporting varargs, and it's all the users fault, but is it really worth it? I'd say no. (in some cases zeroing a register is used to tell the OoO hw to kill a dependency, so it can be beneficial for performance even if not strictly required for correctness) --=20 Janne Blomqvist