This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] PR libgcc/83112, Fix warnings on libgcc float128-ifunc.c
- From: Michael Meissner <meissner at linux dot vnet dot ibm dot com>
- To: Segher Boessenkool <segher at kernel dot crashing dot org>
- Cc: Michael Meissner <meissner at linux dot vnet dot ibm dot com>, Martin Sebor <msebor at gmail dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>, David Edelsohn <dje dot gcc at gmail dot com>, Bill Schmidt <wschmidt at linux dot vnet dot ibm dot com>
- Date: Tue, 12 Dec 2017 16:56:36 -0500
- Subject: Re: [PATCH] PR libgcc/83112, Fix warnings on libgcc float128-ifunc.c
- Authentication-results: sourceware.org; auth=none
- References: <20171127192131.GA15914@ibm-tiger.the-meissners.org> <aabb7e7e-4678-f4a4-9240-6587438a0aeb@gmail.com> <20171127234009.GA28990@ibm-tiger.the-meissners.org> <20171130024250.GX10515@gate.crashing.org> <20171130205425.GA11524@ibm-tiger.the-meissners.org> <20171201054022.GA5348@ibm-tiger.the-meissners.org> <20171201235355.GL10515@gate.crashing.org> <20171211205750.GA16210@ibm-tiger.the-meissners.org> <20171212170455.GT10515@gate.crashing.org>
On Tue, Dec 12, 2017 at 11:04:55AM -0600, Segher Boessenkool wrote:
> On Mon, Dec 11, 2017 at 03:57:51PM -0500, Michael Meissner wrote:
> > > > +extern KCtype __divkc3 (KFtype, KFtype, KFtype, KFtype);
> > > > +
> > > > KCtype
> > > > __divkc3 (KFtype a, KFtype b, KFtype c, KFtype d)
> > > > {
> > >
> > > How does this warn? -Wmissing-declarations? Should this declaration be
> > > in a header then?
> >
> > The compiler creates the call to __mulkc3 and __divkc3, and internally it has
> > the appropriate prototype like it does for all built-in functions (in this
> > case, returning an _Float128 _Complex type, and taking 4 _Float128 arguments).
> >
> > So before adding ifunc support, we never noticed it didn't have a prototype,
> > because the compiler already has a prototype.
>
> I still don't get it. A function definition is also a declaration.
>
> Something very non-intuitive is happening?
GCC has the following function declarations built-in:
extern _Float128 _Complex __mulkc3 (_Float128, _Float128, _Float128, _Float128);
extern _Float128 _Complex __divkc3 (_Float128, _Float128, _Float128, _Float128);
Before the patch, _mulkc3.c looked like:
_Float128 _Complex
__mulkc3 (_Float128 a, _Float128 b, _Float128 c, _Float128 d)
{
// ...
}
Now, with ifunc handling it gets compiled in three separate files:
First in a file compiled with -mno-float128-hardware:
_Float128 _Complex
__mulkc3_sw (_Float128 a, _Float128 b, _Float128 c, _Float128 d)
{
// ...
}
Second in a file compiled with -mfloat128-hardware:
_Float128 _Complex
__mulkc3_hw (_Float128 a, _Float128 b, _Float128 c, _Float128 d)
{
// ...
}
And third as the ifunc handler:
#define SW_OR_HW(SW, HW) (__builtin_cpu_supports ("ieee128") ? HW : SW)
static __typeof__ (__mulkc3_sw) *
__mulkc3_resolve (void)
{
return SW_OR_HW (__mulkc3_sw, __mulkc3_hw);
}
_Float128 _Complex __mulkc3 (Float128, _Float128, _Float128, _Float128)
__attribute__ ((__ifunc__ ("__mulkc3_resolve")));
As Andreas points out, the option -Wmissing-prototypes complains if a global
function is compliled without prototypes for C/Objective C.
Before the patch, the internal definition within the compiler meant that that
__mulkc3 would not get the warning. Now with separate ifunc handlers, both
__mulkc3_sw and __mulkc3_hw got warnings.
--
Michael Meissner, IBM
IBM, M/S 2506R, 550 King Street, Littleton, MA 01460-6245, USA
email: meissner@linux.vnet.ibm.com, phone: +1 (978) 899-4797