From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 40784 invoked by alias); 16 Dec 2018 16:13:26 -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 40765 invoked by uid 89); 16 Dec 2018 16:13:25 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=implications, thumb X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 16 Dec 2018 16:13:23 +0000 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 681F380F6D; Sun, 16 Dec 2018 16:13:22 +0000 (UTC) Received: from localhost.localdomain (ovpn-112-24.rdu2.redhat.com [10.10.112.24]) by smtp.corp.redhat.com (Postfix) with ESMTP id B6CB81057076; Sun, 16 Dec 2018 16:13:20 +0000 (UTC) Subject: Re: [PATCH v4][C][ADA] use function descriptors instead of trampolines in C To: "Uecker, Martin" , "msebor@gmail.com" , "joseph@codesourcery.com" Cc: "gcc-patches@gcc.gnu.org" , "ebotcazou@adacore.com" References: <1534005653.22677.9.camel@med.uni-goettingen.de> <1534609978.14596.2.camel@med.uni-goettingen.de> <1534774021.5798.6.camel@med.uni-goettingen.de> <1534832264.15600.1.camel@med.uni-goettingen.de> <1534918133.4891.5.camel@med.uni-goettingen.de> <1541364511.30044.4.camel@med.uni-goettingen.de> <1544638361.17067.3.camel@med.uni-goettingen.de> <70f4a7b4-3741-52db-e362-699ef310a3b3@redhat.com> <1544781926.10326.8.camel@med.uni-goettingen.de> <17025085-3d47-0b16-c9d3-fec8d1ae9f39@redhat.com> <56b1e591-4d32-672f-6a30-11a9a0b167b7@gmail.com> <1544967934.14155.1.camel@med.uni-goettingen.de> From: Jeff Law Openpgp: preference=signencrypt Message-ID: Date: Sun, 16 Dec 2018 16:13:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.1 MIME-Version: 1.0 In-Reply-To: <1544967934.14155.1.camel@med.uni-goettingen.de> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-IsSubscribed: yes X-SW-Source: 2018-12/txt/msg01176.txt.bz2 On 12/16/18 6:45 AM, Uecker, Martin wrote: > Am Freitag, den 14.12.2018, 18:20 -0700 schrieb Martin Sebor: >> On 12/14/18 4:36 PM, Jeff Law wrote: >>> On 12/14/18 3:05 AM, Uecker, Martin wrote: >>>> >>>> Am Donnerstag, den 13.12.2018, 16:35 -0700 schrieb Jeff Law: >>>>> On 12/12/18 11:12 AM, Uecker, Martin wrote: >>>> >>>> ... >>>>>>>> diff --git a/gcc/c/c-objc-common.h b/gcc/c/c-objc-common.h >>>>>>>> index 78e768c2366..ef039560eb9 100644 >>>>>>>> --- a/gcc/c/c-objc-common.h >>>>>>>> +++ b/gcc/c/c-objc-common.h >>>>>>>> @@ -110,4 +110,7 @@ along with GCC; see the file COPYING3.  If >>>>>>>> not see >>>>>>>>    >>>>>>>>   #undef LANG_HOOKS_TREE_INLINING_VAR_MOD_TYPE_P >>>>>>>>   #define LANG_HOOKS_TREE_INLINING_VAR_MOD_TYPE_P c_vla_unspec_p >>>>>>>> + >>>>>>>> +#undef LANG_HOOKS_CUSTOM_FUNCTION_DESCRIPTORS >>>>>>>> +#define LANG_HOOKS_CUSTOM_FUNCTION_DESCRIPTORS true >>>>>>>>   #endif /* GCC_C_OBJC_COMMON */ >>>>>>> >>>>>>> I wonder if we even need the lang hook anymore.  ISTM that a >>>>>>> front-end >>>>>>> that wants to use the function descriptors can just set >>>>>>> FUNC_ADDR_BY_DESCRIPTOR and we'd use the function descriptor, >>>>>>> else we'll >>>>>>> use the trampoline.  Thoughts? >>>>>> >>>>>> The lang hook also affects the minimum alignment for function >>>>>> pointers via the FUNCTION_ALIGNMENT macro (gcc/default.h). This >>>>>> does >>>>>> not appear to change the default alignment on any architecture, but >>>>>> it causes a failure in i386/gcc.target/i386/attr-aligned.c when >>>>>> requesting a smaller alignment which is then silently ignored. >>>>> >>>>> Ugh.  I didn't see that. >>>> >>>> The test is new (2019-11-29 Martin Sebor), but one could >>>> argue that we could simply remove this specific test as 'aligned' >>>> is only required to increase alignment. Martin? >>> >>> The test is meant to test that we do the right thing consistently.  If >>> we're failing with your patch, then that needs to be addressed. >> >> I haven't been paying attention here and so I don't know how the test >> fails after the change.  It's meant to verify that attribute aligned >> successfully reduces the alignment of functions that have not been >> previously declared with one all the way down to the supported minimum >> (which is 1 on i386).  I agree with Jeff that removing the test would >> not be right unless the failure is due to some bad assumptions on my >> part.  If it's the built-in that fails that could be due to a bug in >> it (it's very new). > > There is a choice to be made:  > > Either we activate the lang hook for C, then the minimum alignment for > functions on is not 1 anymore, because we need one bit to identify the  > descriptors.  From a correcntess point of view, this is OK as 'alignas' > is only required to increase alignment. It is also not really regression > in my opinion, as it is nowhere documented that one can reduce alignment > to '1'. The test also has just been added a couple of days ago (if I am > not mistaken). For these reasons, I think it would be OK to remove the test. > > The other option is to decide that having an alignment of only '1' > is a valuable feature and should be preserved on those platforms which > support it. I have no idea what this could be good for, but maybe > there are use cases.  In this case, it makes of course sense to keep > the test. We should then remove the lang hook (as it could never be > activated for most languages) and instead live with the fact that > '-fno-trampoline' and using alignof(1) on functions are simply > incompatible. A warning could be added if the compiler sees > alignof(1) when -fno-trampoline is active. There's certainly targets where 1 byte function alignment is important from a code space perspective -- it's likely that function descriptors will never be supported on those targets. It's also important to remember that not every target which uses function descriptors uses the LSB. On some targets the LSB may switch between modes (arm vs thumb for example). So on those targets the use of descriptors may imply an even larger minimum alignment. Ultimately using function descriptors is an ABI breaking choice and we might declare that function descriptors imply higher function alignments. The ABI implications also likely mean that function descriptors aren't likely going to achieve widespread use. Sigh. jeff