On 2 March 2018 at 22:18, Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx> wrote: > On Fri, Mar 02, 2018 at 09:06:21PM +0000, Dibyendu Majumdar wrote: >> On 2 March 2018 at 20:48, Luc Van Oostenryck >> <luc.vanoostenryck@xxxxxxxxx> wrote: >> >> But overall, I feel that we don't really care about sizes that are not >> >> 'register' size - do we? In reality we probably only care about 8, 16, >> >> 32, 64 bits. >> > >> > Even is 'pseudo' holds for 'pseudo-register' they are used for any 'values'. >> Not sure I understood this point - I was suggesting that we only set >> pseudo value size when it makes sense to do so. > > I meant that I think that it would be dangerous to special-case > pseudos with register-size and non-register-size (we're by dangerous > I mostly mean 'add unneeded complexity'). > It's a fuzzy concept anyway and target specific while there is no need > to be target specific. > I wasn't talking about pseudos in general - only pseudos of type PSEUDO_VAL. For such a size that is bigger than 64-bits makes no sense - do you agree? >> >> However, that still leaves a question in my mind: >> >> >> >> a) Is it okay to assign a value 0 to uninitialized vars? >> > >> > As explained here above, it's OK but it's just a compiler choice >> > for something UB (and certainly not worse than any other). >> > >> >> b) If size is not present or is 0 - does that mean that the CSE logic >> >> will consider all these equivalent? That doesn't sound right to me. >> > >> > Sure, unless you special case it in CSE. >> >> I was wondering if the source of the bugs related to uninitialized var >> and CSE is this that the CSE doesn't know the value came from garbage. > > Once we choose to give value 0 to otherwise unintialized vars, it's > no more garbage than anything else. It's something very sane to do > for a 'robust compiler'. > I would prefer that the compiler a) doesn't try to CSE values that are garbage, and b) it is better to know something is garbage than assign a value 0. Latter makes the CSE do unexpected things I think. In fact on detecting that a garbage value is being used somewhere the compiler should simply stop trying to CSE. In my project, the LLVM backend will stop compiling as soon as it sees a VOID pseudo. >> >> I don't really understand how the CSE handles these but maybe - if you >> >> agree with above then CSE should ignore any pseudo value that is size >> >> 0? >> > >> > Currently, a size of zero is used for erroneous code, like incomplete >> > type and things like that (-1/~0 is also used for that). In such >> > situations CSE make no sense anyway, we just want to continue parsing >> > and give the best possible diagnostic for the remaining of the code. >> > >> >> I didn't follow - size 0 is used for pseudo values? > > Sorry, when I said 'size' I meant 'size of the underlying type' while > you were talking about the size given to the pseudo. Again - I am not talking about pseudos in general - only those of PSEUDO_VAL type. > > But my answer would be 'yes for pseudos coming from errors', 'no for > pseudo from variables we're not sure if they will be used only after > having received a value', 'why special case at this level? it would > be better to use consistently a special kind of value for erroneous > things (VOID is used for this but also used for other things which > doesn't help)'. > So for un-initialized vars we should not be creating a value pseudo with 0 - is that what you are saying? Regards Dibyendu -- To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html