[RFA/dwarf-2] Avoid unnecessary subrange_type (1/3)
Joel Brobecker
brobecker@gnat.com
Tue Mar 16 05:32:00 GMT 2004
Hello,
I was working on a problem that I found in GDB trying to print the upper
and/or lower bound of the long_long_integer type. After having analyzed
the problem, I found that it could be a bit or work to fix it properly.
However, I also noticed that we seem to be generating subrange_type DIEs
while they are not necessary. And fixing GCC to avoid generating then
also has the nice side-effect of avoiding the GDB problem in the usual
cases. I will explain everything in the final message, since the first
two patches are only cosmetic patches that don't change GCC's behavior.
This first patch is just a small mechanical rewrite that will help
make the final patch (the one that actually changes GCC's dwarf-2
output) much more readable.
2004-03-15 J. Brobecker <brobecker@gnat.com>
* dwarf2out.c (subrange_type_die): Define new variable "subtype"
to hold the subtype tree instead of recomputing several time.
Tested on x86-linux by bootrapping and against the GCC & GDB testsuites.
OK to apply?
thanks,
--
Joel
-------------- next part --------------
--- dwarf2out.c.ref 2004-03-12 13:00:45.000000000 -0800
+++ dwarf2out.c.1.subtype 2004-03-12 14:23:01.000000000 -0800
@@ -8021,14 +8021,15 @@ subrange_type_die (tree type, dw_die_ref
dw_die_ref subrange_die;
tree name = TYPE_NAME (type);
const HOST_WIDE_INT size_in_bytes = int_size_in_bytes (type);
+ tree subtype = TREE_TYPE (type);
if (context_die == NULL)
context_die = comp_unit_die;
- if (TREE_CODE (TREE_TYPE (type)) == ENUMERAL_TYPE)
- subtype_die = gen_enumeration_type_die (TREE_TYPE (type), context_die);
+ if (TREE_CODE (subtype) == ENUMERAL_TYPE)
+ subtype_die = gen_enumeration_type_die (subtype, context_die);
else
- subtype_die = base_type_die (TREE_TYPE (type));
+ subtype_die = base_type_die (subtype);
subrange_die = new_die (DW_TAG_subrange_type, context_die, type);
@@ -8039,7 +8040,7 @@ subrange_type_die (tree type, dw_die_ref
add_name_attribute (subrange_die, IDENTIFIER_POINTER (name));
}
- if (int_size_in_bytes (TREE_TYPE (type)) != size_in_bytes)
+ if (int_size_in_bytes (subtype) != size_in_bytes)
{
/* The size of the subrange type and its base type do not match,
so we need to generate a size attribute for the subrange type. */
More information about the Gcc-patches
mailing list