From: | ralph@inputplus.demon.co.uk (Ralph Corderoy) |
Newsgroups: | comp.compilers |
Date: | 20 Dec 2001 00:29:14 -0500 |
Organization: | InputPlus Ltd. |
References: | 01-12-050 <200112120335.fBC3ZMg01140@budgie.cs.uwa.edu.au> 01-12-065 |
Keywords: | optimize |
Posted-Date: | 20 Dec 2001 00:29:13 EST |
I said:
> An ANSI C compiler does know the semantics of strlen if the compiler
> writers have arranged for that to be the case. For instance, AIX's
> <string.h> #defines strlen to be __strlen which the compiler
> recognises as *the* standard strlen function.
Something I just found: Robert Morgan in _Building an Optimizing
Compiler_ says on page 25
Library routines are handled differently than other procedure
calls. If a library procedure is known to be a pure function it is
handled as if it were an operator. This allows the use of
identities involving the library routines. Other procedure calls
may be used in other parts of the analysis of the program, for
example, calls on malloc are known to return either a null pointer
or a pointer to a section of memory unreferenced in other parts of
the program.
strlen(s) is pure. So that just leaves determining modifying *t
doesn't touch s.
Ralph.
Return to the
comp.compilers page.
Search the
comp.compilers archives again.