[LLVMdev] [RFC] New function attributes for errno-setting functions
hfinkel at anl.gov
Fri Sep 13 12:23:04 PDT 2013
----- Original Message -----
> On 9/12/2013 7:44 PM, Hal Finkel wrote:
> > To fix this problem, I think that we need to stop treating errno as
> > some arbitrary external state, and model is explicitly.
> In such case it would make sense to know when "errno" is read. This
> we could detect whether it's actually used, whether or not the
> -fno-math-errno (or some generic -fno-xyz-errno) was specified.
> is that errno (referenced explicitly) may be a macro that expands to
> some system-specific function call.
I agree, and this is exactly the problem: It is really hard, as far as I understand, to figure out what 'errno' actually is. On the other hand, the frontend has more information on this, at least in theory, and maybe it could communicate it to the backend somehow. Maybe the easiest way would be to insert an intrinsic @llvm.errno.read() whenever errno (as a source token) appears in the source as an rvalue (and do some similar thing when it appears as a lvalue). Thoughts?
> On that note, what would be really nice is if a function could have
> "mod/use" sets attached to it, which would specify what external
> this function can reference. I'm not sure how that could be
> in the current IR though.
We could attach this as metadata currently. In terms of extending the IR, we might be able to add 'implicit' function parameters similar to what we do for MIs.
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
> hosted by The Linux Foundation
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
Assistant Computational Scientist
Leadership Computing Facility
Argonne National Laboratory
More information about the llvm-dev