[LLVMdev] [RFC] New function attributes for errno-setting functions

Hal Finkel hfinkel at anl.gov
Fri Sep 13 14:18:39 PDT 2013

----- Original Message -----
> On 9/13/2013 3:37 PM, Hal Finkel wrote:
> >
> > No, I don't think so. If sqrt is not readnone or readonly, then it
> > should potentially alias whatever the errno macro actually expands
> > to (whether it is a global variable, and thread-local variable, a
> > function call, or whatever).
> I'm not sure about this. How about this:
> extern int BLAH;
> #define errno BLAH
> Then we have
>    int fd = open(...);
>    int saved_errno = BLAH;
>    double s = sqrt(var);
> If "sqrt" is "write-only-errno", how would we know that BLAH should
> be
> aliased with sqrt?  We don't to alias it with every global variable
> (that's what this proposal is trying to address).  We'd need a way to
> associate BLAH with errno, or else we're in the same place as we are
> now.

No, this is exactly what we do. It needs to be pessimistic in this sense. "write-only-errno" only helps to prove things about potential alising with pointers that we *know* can't be errno (like local stack allocations). Any global might be errno, so that can't count.


> -K
> --
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
> hosted by The Linux Foundation

Hal Finkel
Assistant Computational Scientist
Leadership Computing Facility
Argonne National Laboratory

More information about the llvm-dev mailing list