This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] PR/8354

Devang Patel wrote:
*dwarf2out.c (modified_type_die): Reuse existing type die.

This patch doesn't make sense within the context of the current code.

Note that there is already code in modified_type_die which tries to reuse the type die if it exists. However, the code assumes that the arg TYPE may not contain the const/volatile qualifiers, so we must call get_qualified_type first before lookup_type_die.

In this context, your patch is wrong, because it will randomly add/drop const/volatile qualifiers when the type does not match the specified const/volatile qualifiers. This just happens to drop the extra const qualifier for the example, giving the correct result by accident.

The real problem seems to be calls to add_type_attribute, which pass in TREE_READONLY (decl) and TREE_THIS_VOLATILE (decl). I.e., they are adding decl qualifiers to the type. This is wrong for a decl which has an array type, because the qualifiers apply to the element type, not the array type.

Looking at this further, one wonders why we do this at all, since we would always expect the type to already include the type qualifiers, so adding in type qualifiers from the decl seems completely unnecessary. The correct solution here seems to be to modify everyplace that uses this idiom to not pass in extra unnecessary type qualifiers. This is gen_formal_parameter_die, gen_variable_die, gen_field_die, gen_typedef_die. I did a quick check, and this worked for one of the simplified examples.

After fixing these, we are left with two places that pass in extra qualifiers, in add_bound_info. Both of these appear to be legitimate. They create fake variables to hold SAVE_EXPR results, and then mark them as const. Thus we still need the const/volatile arguments, and we still need the get_qualified_type call in modified_type_die.

However, if we modified these two places to create a const qualified type before calling add_type_attribute, then we could delete the const/volatile arguments to add_type_attribute and modified_type_die, and just extra the qualifiers from the type. In this case, we would no longer need the get_qualified_type call in modified_type_die, as the type would already have the type qualifiers in all cases.
Jim Wilson, GNU Tools Support,

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]