Re: [PATCH] bitops: simplify generic bit finding functions

Al Viro
2008-04-27T21:02:48Z

On Sun, Apr 27, 2008 at 01:38:34PM -0700, Linus Torvalds wrote:

> It happens because the warning is done as part of constant expression
> evaluation, but then the expression isn't actually *used*, so when we
> optimize it away - at a later date - it's too late to undo the warning.
>
> I don't rightly know how to fix it. We do want to do the constant
> evaluation early (since all the optimizations that may then make it a
> non-issue depends on constants being constants!), but in order to not
> output the warning we'd have to turn the constant into a "constant with
> warning 'xyz' if used".
>
> Which we have no support for in sparse yet.

It's not even a constant, really... What we need is
* don't fold further if that sucker would be evaluated (i.e. 0 && <...>
is folded, 0 & <...> is not)
* don't consider an integer constant expression with value 0 for
purposes of null pointer constant handling
* emit corresponding insn in linearize_expression() when we run into
such sucker.
* somewhere around the call of vrfy_flow() walk through insns in
remaining bb (we'd done dead code elimination already) and spew postponed
warning on each such insn. Probably. Assuming that I'm not entirely
confused about what's going on in that area - which is quite possible.

Folks, could somebody familiar with the backend comment on the last part?