On 10/02/14 08:46, Jason Merrill wrote:
On 10/01/2014 05:31 PM, Aldy Hernandez wrote:
+ for (tree t = level->names; t; t = TREE_CHAIN(t))
+ if (TREE_CODE (t) != TYPE_DECL
+ && TREE_CODE (t) != PARM_DECL
+ && !DECL_IS_BUILTIN (t))
+ debug_hooks->early_global_decl (t);
What does this do for templates? I think we don't want to send a
template off to early_global_decl, but rather walk through its
specializations and emit them.
Hmm, I'll look into this.
Why do you need to check for PARM_DECL? There shouldn't be any
PARM_DECL at namespace scope.
Why do you want to skip TYPE_DECL? I think we should leave the decision
about whether to emit a typedef to the debugging back end.
Actually, I think we/I need to rethink this whole globals thing.
Currently we're early dumping global *_DECLs, and hoping dwarf2out
recursion will also pick up types and any derivatives from the *_DECLs,
but taking a closer look I've noticed a lot of things are not being
dumped early.
For instance:
foo()
{
typedef int ITYPE;
ITYPE var = 5;
}
For the above code, var's DIE gets outputted _after_ the compilation
proper has been run here:
if (! declaration && outer_scope && TREE_CODE (outer_scope) != ERROR_MARK
&& (!DECL_STRUCT_FUNCTION (decl)
|| DECL_STRUCT_FUNCTION (decl)->gimple_df))
...
...
decls_for_scope (outer_scope, subr_die, 0);
I think we should be outputting DIEs for locals at the end of parsing,
so my patch going through level->names IMO is wrong. We should be
dumping all *_DECLs created by the FE, not just globally scoped ones.
This means that we'll need to clean up unreachable/unused DIEs after the
flow graph has been built.
Another example currently not being dumped early is...
function()
{
class Local {
public:
void loc_foo (void) { }
};
Local l;
l.loc_foo ();
}
...since loc_foo() is not in level->names. Again, this seems like an
argument for early dumping all *_DECLs directly from
rest_of_decl_compilation() (as you've hinted) and then cleaning up
unused DIEs after we have flow information.
Does this seem reasonable?
Aldy