Hal Finkel
2013-Sep-17 19:43 UTC
[LLVMdev] [RFC] New function attributes for errno-setting functions
----- Original Message -----> On 9/12/2013 7:44 PM, Hal Finkel wrote: > > > > 1. 'writes-only-errno' > > 2. 'errno-ignored' > > Do we really need the first one? We already know which standard > functions could potentially set errno, and we know which standard > functions don't modify any other storage (other than that which is > passed via parameters). I think it's safe to assume that standard > functions can be recognized by name, since the standard prohibits > user > objects to use a predefined name.I agree that we could put a list into LLVM instead of adding attributes in the frontend. We need to be a little careful that -fno-builtin is passed to the backend in this case.> > We could have an attribute like "side-effects-ignored" indicating > that > whatever modifications the given function makes, nobody will read > them > (at least not without an intervening store). This would include > errno, > but could also be used in more general contexts.That would depend on how this attribute was used; it could only be used by a pass that did actually understand what those side effects were (like the loop vectorizer understanding that, if errno is ignored, then vectorizing cos() is legal). I don't object to making the name generic, but I want to make sure that we're all on the same page regarding what it means. Thanks, Hal> > -K > > > -- > 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 > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >-- Hal Finkel Assistant Computational Scientist Leadership Computing Facility Argonne National Laboratory
Krzysztof Parzyszek
2013-Sep-17 20:23 UTC
[LLVMdev] [RFC] New function attributes for errno-setting functions
On 9/17/2013 2:43 PM, Hal Finkel wrote:> > That would depend on how this attribute was used; it could only be used by a pass that did actually understand what those side effects were (like the loop vectorizer understanding that, if errno is ignored, then vectorizing cos() is legal). I don't object to making the name generic, but I want to make sure that we're all on the same page regarding what it means.In some cases the exact nature of the side effects wouldn't need to be known. For example, if the side-effects are known to be ignored, a call to such a function could be eliminated as dead code. Also, the "errno-ignored" or equivalent attribute brings up this question: given this code x = cos(y); // assume "errno-ignored" z = global; is it safe to infer that "global" is not errno? In other words, could this attribute be used to refine alias information with respect to errno? -K -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
Hal Finkel
2013-Sep-17 20:45 UTC
[LLVMdev] [RFC] New function attributes for errno-setting functions
----- Original Message -----> On 9/17/2013 2:43 PM, Hal Finkel wrote: > > > > That would depend on how this attribute was used; it could only be > > used by a pass that did actually understand what those side > > effects were (like the loop vectorizer understanding that, if > > errno is ignored, then vectorizing cos() is legal). I don't object > > to making the name generic, but I want to make sure that we're all > > on the same page regarding what it means. > > In some cases the exact nature of the side effects wouldn't need to > be > known. For example, if the side-effects are known to be ignored, a > call > to such a function could be eliminated as dead code. >Good point.> > Also, the "errno-ignored" or equivalent attribute brings up this > question: > given this code > x = cos(y); // assume "errno-ignored" > z = global; > is it safe to infer that "global" is not errno?Unfortunately, I fear that the answer is no; at least, not without some further target-specific information. In general, any global could be errno. On the other hand, if we know that we're on Darwin, or using glibc, or whatever, then we could likely say something more. -Hal> In other words, > could > this attribute be used to refine alias information with respect to > errno? > > -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
Seemingly Similar Threads
- [LLVMdev] [RFC] New function attributes for errno-setting functions
- [LLVMdev] [RFC] New function attributes for errno-setting functions
- [LLVMdev] [RFC] New function attributes for errno-setting functions
- [LLVMdev] [RFC] New function attributes for errno-setting functions
- [LLVMdev] [RFC] New function attributes for errno-setting functions