dwarf2out var loc handling fix
Jan Hubicka
hubicka@ucw.cz
Mon Sep 21 12:00:00 GMT 2009
Hi,
when outputting debug info for function in .final, we first populate our
location lists hashtable and then we start expanding scope block. When
hitting scope block of inline function we call
dwarf2out_abstract_function that nullifies the hashtable. This causes
us to lose most of location info in any function with some inlines.
It is neccesary to avoid inline abstract function to reffer to the
hashtable or the locations would be output in abstract function that is
wrong. This patch avoids it by setting the hashtable to NULL and
restoring it at exit and modifying lookup_decl_loc.
THe patch increases amount of variables tracked in tramp3d from 4900 to
16000.
Bootstrapped/regtested x86_64-linux, OK?
Honza
* gcc.dg/guality/inline-params.c: New testcase.
* dwarf2out.c (lookup_decl_loc): Allow decl_loc_table to be NULL.
(dwarf2out_abstract_function): NULLify decl_loc_table at begginig and
restore at the end.
Index: testsuite/gcc.dg/guality/inline-params.c
===================================================================
*** testsuite/gcc.dg/guality/inline-params.c (revision 0)
--- testsuite/gcc.dg/guality/inline-params.c (revision 0)
***************
*** 0 ****
--- 1,41 ----
+ /* { dg-do run { xfail *-*-* } } */
+ /* IPA-SRA removes the argumet as dead, so we don't see their values. */
+ /* { dg-options "-g -fno-ipa-sra" } */
+ #define GUALITY_DONT_FORCE_LIVE_AFTER -1
+
+ #ifndef STATIC_INLINE
+ #define STATIC_INLINE /*static*/
+ #endif
+
+
+ #include "guality.h"
+
+ struct a{
+ struct b {int a;} b;
+ struct c{ int a;} c;
+ };
+
+ __attribute__ ((always_inline)) static inline void
+ t1 (struct b *ab, int b)
+ {
+ GUALCHKXPRVAL ("b", 0xbbb, 0);
+ GUALCHKVAL (ab);
+ }
+ __attribute__ ((always_inline)) static inline void
+ t2 (struct c *ac, char *msg)
+ {
+ GUALCHKVAL (ac);
+ GUALCHKVAL (msg);
+ }
+ __attribute__ ((always_inline)) static inline void
+ t3 (struct a *a)
+ {
+ t1(&a->b, 0xbbb);
+ t2(&a->c, "test");
+ }
+ struct a a={{0},{1}};
+ int
+ main (int argc, char *argv[])
+ {
+ t3(&a);
+ }
Index: dwarf2out.c
===================================================================
*** dwarf2out.c (revision 151901)
--- dwarf2out.c (working copy)
*************** decl_loc_table_eq (const void *x, const
*** 7491,7496 ****
--- 7491,7498 ----
static inline var_loc_list *
lookup_decl_loc (const_tree decl)
{
+ if (!decl_loc_table)
+ return NULL;
return (var_loc_list *)
htab_find_with_hash (decl_loc_table, decl, DECL_UID (decl));
}
*************** dwarf2out_abstract_function (tree decl)
*** 15533,15548 ****
tree save_fn;
tree context;
int was_abstract = DECL_ABSTRACT (decl);
/* Make sure we have the actual abstract inline, not a clone. */
decl = DECL_ORIGIN (decl);
- htab_empty (decl_loc_table);
old_die = lookup_decl_die (decl);
if (old_die && get_AT (old_die, DW_AT_inline))
/* We've already generated the abstract instance. */
return;
/* Be sure we've emitted the in-class declaration DIE (if any) first, so
we don't get confused by DECL_ABSTRACT. */
if (debug_info_level > DINFO_LEVEL_TERSE)
--- 15535,15556 ----
tree save_fn;
tree context;
int was_abstract = DECL_ABSTRACT (decl);
+ htab_t old_decl_loc_table;
/* Make sure we have the actual abstract inline, not a clone. */
decl = DECL_ORIGIN (decl);
old_die = lookup_decl_die (decl);
if (old_die && get_AT (old_die, DW_AT_inline))
/* We've already generated the abstract instance. */
return;
+ /* We can be called while recursively when seeing block defining inlined subroutine
+ DIE. Be sure to not clobber the outer location table nor use it or we would
+ get locations in abstract instantces. */
+ old_decl_loc_table = decl_loc_table;
+ decl_loc_table = NULL;
+
/* Be sure we've emitted the in-class declaration DIE (if any) first, so
we don't get confused by DECL_ABSTRACT. */
if (debug_info_level > DINFO_LEVEL_TERSE)
*************** dwarf2out_abstract_function (tree decl)
*** 15564,15569 ****
--- 15572,15578 ----
set_decl_abstract_flags (decl, 0);
current_function_decl = save_fn;
+ decl_loc_table = old_decl_loc_table;
pop_cfun ();
}
More information about the Gcc-patches
mailing list