the following patch fixes an ICE for me when LTO building Firefox at
-O3 -g. The problem is that at one spot we use decl_function_context
as a predicate whether to use TREE_CONTEXT rather than using it's
result which can be determined in a much more elaborate way. In my
particular case TREE_CONTEXT is a type, not a function decl and
lookup_decl_die chokes on that, when it is fed the function result,
all seems fine.
Bootstrapped and tested on x86_64-linux. OK for trunk?
Also, I have not actually tried it but I suppose we'll be hitting this
problem with 4.7 as well. OK for the branch once 4.7.0 is out?
2012-03-07 Martin Jambor <mjam...@suse.cz>
* dwarf2out.c (dwarf2out_decl): Use result of decl_function_context
rather than DECL_CONTEXT.
@@ -19830,6 +19830,7 @@ void
dwarf2out_decl (tree decl)
dw_die_ref context_die = comp_unit_die ();
+ tree ctx_fndecl;
switch (TREE_CODE (decl))
@@ -19889,8 +19890,9 @@ dwarf2out_decl (tree decl)
/* For local statics lookup proper context die. */
- if (TREE_STATIC (decl) && decl_function_context (decl))
- context_die = lookup_decl_die (DECL_CONTEXT (decl));
+ if (TREE_STATIC (decl) &&
+ (ctx_fndecl = decl_function_context (decl)) != NULL_TREE)
+ context_die = lookup_decl_die (ctx_fndecl);
/* If we are in terse mode, don't generate any DIEs to represent any
variable declarations or definitions. */