This is the mail archive of the
mailing list for the GCC project.
Re: Ada files now checked in
On Sun, 07 Oct 2001, Zack Weinberg wrote:
> Maybe you could change the warning message to "...used uninitialized
> here" or "at this point" or something like that? Just to be clear
> it's not the same old "somewhere in the function" message.
> I notice it says "_is_ used uninitialized". Does that mean you've
> eliminated the old false positive problems?
That's the intent. The new code still spews out false positives,
that's what I'm now working on.
The analysis depends on the computation of reaching definitions.
Prior to computing the SSA form, we insert ghost definitions for
every symbol in the entry basic block. After reaching
definitions, we traverse all the variable use references in the
function. For every use:
- if its only reaching definition is the ghost def, the variable
*is* used uninitialized.
- if one of its reaching definitions is the ghost def, the
variable *may be* used uninitialized.
That's a very simplified view that will give you lots of false
positives (variables with its address taken, global variables,
etc). I'm refining the criteria with each bootstrap.
Also, I'm about to add def-def chains to model non-killing
1: int a, b *p;
3: a = 4;
4: *p = 3;
5: b = a + 1;
The use of a at line 5 may be reached by the definitions of *p
and a at lines 4 and 3, respectively. But this part is nowhere
> How expensive is it to calculate these?>
The analysis itself is relatively cheap once you have computed
the SSA form and reaching definitions of the function. It's
roughly O(SxR) where S is the number of symbols and R the number
of symbol references in the function.
Computing the SSA form is not cheap, but can be improved.
Essentially you need to:
- Build the flowgraph. That's roughly linear in the number of
statement tree nodes.
- Find all the variable references in the function. Linear in
the total number of tree nodes.
- Compute the SSA form. This involves computing immediate
dominators and dominance frontiers. I believe the algorithms
we have in GCC are quite quick, but I haven't really looked.
Building the FUD chains is like O(SxNxE) (could be wrong, I'm
quoting from memory). There is a linear phi placing algorithm
which I plan to switch to.
I want to hook-up all the tree SSA passes to -ftime-report. That
will give us a better idea of how expensive this really is.
> It'd be nice if we could generate the warnings with
> optimization off; that's always been a wart.
Definitiely possible. We only need to make -Wuninitialized