svn commit: r335278 - head/bin/pwd

Bruce Evans brde at optusnet.com.au
Sun Jun 17 06:54:55 UTC 2018


On Sun, 17 Jun 2018, Eitan Adler wrote:

> Log:
>  pwd: mark usage as dead
>
> Modified:
>  head/bin/pwd/pwd.c
>
> Modified: head/bin/pwd/pwd.c
> ==============================================================================
> --- head/bin/pwd/pwd.c	Sun Jun 17 03:33:29 2018	(r335277)
> +++ head/bin/pwd/pwd.c	Sun Jun 17 05:14:50 2018	(r335278)
> @@ -95,7 +95,7 @@ main(int argc, char *argv[])
> 	exit(0);
> }
>
> -void
> +void __dead2
> usage(void)
> {

I asked you to back out a previous addition of __dead2 about 20 additions
of it ago.

__dead2 here has no effect.  The compiler can see that usage() doesn't
return if it understands __dead2 at all, since usage() ends with exit()
which is declared as __dead2.

If __dead2 were added in a place where the addition is not complete
nonsense, that is in the forward declaration of the function, then it
would have an effect in compilers that don't implement -funit-at-a-time.
Then since usage() is called before it is defined, compilers that don't
parse the whole file before generating any code would have to consider
the function as possibly returning for some of the calls to it unless
the forward declaration tells them otherwise.  However, -funit-at-a-time
can't even be turned off for clang.  -funit-at-time is merely the
default for gcc starting with -O2, and can be turned off.  Detecting
functions that don't return is a trivial part of inlining.

See my old mail about this for more details.

Bruce


More information about the svn-src-all mailing list