[Mesa-dev] [PATCH v2] nv30: Add unused attribute to function nv40_fp_bra.

Francisco Jerez currojerez at riseup.net
Sat Mar 7 13:13:41 PST 2015


Matt Turner <mattst88 at gmail.com> writes:

> On Sat, Mar 7, 2015 at 12:54 PM, Francisco Jerez <currojerez at riseup.net> wrote:
>> Matt Turner <mattst88 at gmail.com> writes:
>>
>>> On Fri, Mar 6, 2015 at 11:43 PM, Vinson Lee <vlee at freedesktop.org> wrote:
>>>> Silences GCC unused-function warning.
>>>>
>>>> nv30/nvfx_fragprog.c:333:1: warning: ‘nv40_fp_bra’ defined but not used [-Wunused-function]
>>>>  nv40_fp_bra(struct nvfx_fpc *fpc, unsigned target)
>>>>  ^
>>>>
>>>> Signed-off-by: Vinson Lee <vlee at freedesktop.org>
>>>> ---
>>>>  src/gallium/drivers/nouveau/nv30/nvfx_fragprog.c | 2 +-
>>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>>
>>>> diff --git a/src/gallium/drivers/nouveau/nv30/nvfx_fragprog.c b/src/gallium/drivers/nouveau/nv30/nvfx_fragprog.c
>>>> index 6600997..abd51c8 100644
>>>> --- a/src/gallium/drivers/nouveau/nv30/nvfx_fragprog.c
>>>> +++ b/src/gallium/drivers/nouveau/nv30/nvfx_fragprog.c
>>>> @@ -329,7 +329,7 @@ nv40_fp_rep(struct nvfx_fpc *fpc, unsigned count, unsigned target)
>>>>  }
>>>>
>>>>  /* warning: this only works forward, and probably only if not inside any IF */
>>>> -static void
>>>> +static __attribute__((unused)) void
>>>
>>> Doing this means gcc can't actually eliminate the function.
>>>
>>> I think your only option, if we want to keep the code but still let
>>> gcc eliminate the function, is to #if 0 it/comment it out.
>>
>> I don't think that's right, __attribute__((unused)) doesn't prevent gcc
>> From eliminating a function, maybe you're confusing it with
>> __attribute__((used))?
>
> I don't know.
>
> This commit uses ((unused)) as well, with apparently the intention of
> keeping the function around.
>
> commit 27b6ef7ecaa60ce192ec74eef2245c25ed4e703b
> Author: Kenneth Graunke <kenneth at whitecape.org>
> Date:   Fri Feb 6 00:36:26 2015 -0800
>
>     i965: Add a function to disassemble an instruction from the 4 dwords.

I don't think that guarantees that gcc will keep the function around,
From [1]:

| unused
|    This attribute, attached to a function, means that the function is
|    meant to be possibly unused. GCC does not produce a warning for
|    this function.

So AFAICT it's only meant to suppress the warning.  OTOH:

| used
|    This attribute, attached to a function, means that code must be
|    emitted for the function even if it appears that the function is
|    not referenced. This is useful, for example, when the function is
|    referenced only in inline assembly.

[1] https://gcc.gnu.org/onlinedocs/gcc-4.9.2/gcc/Function-Attributes.html#Function-Attributes
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 212 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20150307/759f2159/attachment.sig>


More information about the mesa-dev mailing list