[llvm-commits] [llvm] r64352 - /llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp

Nick Lewycky nicholas at mxc.ca
Thu Feb 12 00:50:29 PST 2009


Duncan Sands wrote:
> Hi Nick,
> 
>> Don't mark all args to strtod and friends as nocapture.
> 
> if you're going to be that strict then you should eliminate
> sprintf and even printf (write pointer to file, read it in
> again elsewhere).  Or did I misunderstand what the problem
> with these is?

I'm going to guess that you misunderstood the problem.

Taking strtod as an example, it has:

double strtod(const char *nptr, char **endptr) {
   /* In a certain case, if (*nptr == 0) ... */
   *endptr = nptr;
}

and that's an escape. We can't mark nptr as "nocapture" since it can 
certainly be captured by being written through endptr.

printf and sprintf don't have that problem. If you write a pointer to a 
file, you're passing that pointer in an argument that isn't marked 
nocapture. We only mark the format string (and for sprintf, the output 
'str') as nocapture.

Nick




More information about the llvm-commits mailing list