On Saturday 12 November 2005 14:35, Per Bothner wrote: > The internal SSA form might be something like: > > foo() > { > if (test) > { > int __attribute__((never_null)) *p_1 = > this_never_returns_NULL(); < ... use p without modifying it ... > <-- > p_1 never NULL here. } > else > { > int *p_2 = other_fn (); > < ... use p without modifying it ... > <-- p_2 may be NULL here. > } > int *p_3 = PHI(p_1, p_2); > ... more uses of p ...; > } > Well, I am not an FE person, so I don't much care how you convey the information into the optimizers.
From a user's perspective I see the obvious drawback that you've just forced me to edit a potentially large number of source files just to add the __attribute__((never_null)). The other approach just needs a single __attribute__ in the function declaration. Another problem I would have as a user is if you suddenly make 'int *' and 'int * __attribute__((non_null))' different/incompatible types. If I have a function that takes 'int *' as argument, I don't want to start adding tons of type casts to get around compiler warnings/errors. From an optimizer perspective, I fail to see how would your approach give me better information inside VRP. But since your approach seems to give me the same information, I don't much care how the FE implements this. If you decide to have type attributes, I'll use it. If you mark the function, I'll use it with the same effect.