On May 29, 2015 8:42:50 PM GMT+02:00, Aldy Hernandez <al...@redhat.com> wrote: >On 05/28/2015 04:35 PM, Jason Merrill wrote: >> On 05/28/2015 02:53 PM, Aldy Hernandez wrote: >>> On 05/27/2015 08:39 AM, Jason Merrill wrote: >>>> On 05/20/2015 11:50 AM, Aldy Hernandez wrote: >>> >>>>> + /* Fill in the size of variable-length fields in late dwarf. >*/ >>>>> + if (TREE_ASM_WRITTEN (type) >>>>> + && !early_dwarf_dumping) >>>>> + { >>>>> + tree member; >>>>> + for (member = TYPE_FIELDS (type); member; member = >DECL_CHAIN >>>>> (member)) >>>>> + fill_variable_array_bounds (TREE_TYPE (member)); >>>>> + return; >>>>> + } >>>> >>>> Why is this happening in late dwarf? I'm concerned that front-end >>>> information that is necessary to do this might be lost by that >point. >>> >>> I thought only after the optimizations had run their course would we >be >>> guaranteed to have accurate bound information. At least, that's >what my >>> experience showed. >> >> Hmm, I'm don't know why optimizations would change the representation >of >> the array type. >> >>>>> + /* Variable-length types may be incomplete even if >>>>> + TREE_ASM_WRITTEN. For such types, fall through to >>>>> + gen_array_type_die() and possibly fill in >>>>> + DW_AT_{upper,lower}_bound attributes. */ >>>>> + if ((TREE_CODE (type) != ARRAY_TYPE >>>>> + && TREE_CODE (type) != RECORD_TYPE >>>>> + && TREE_CODE (type) != UNION_TYPE >>>>> + && TREE_CODE (type) != QUAL_UNION_TYPE) >>>>> + || (TYPE_SIZE (type) >>>>> + && TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST)) >>>> >>>> Similarly, why check for INTEGER_CST here? >>> >>> The INTEGER_CST check was supposed to mean "we have bound >information >>> already, no need to look further". >>> >>> I guess we could have a variable length bound that does not decay to >a >>> constant. >> >> Right. I would expect that to usually be the case with VLAs. >> >>> Perhaps I could check the presence of a cached DIE with a >>> type DIE containing a DW_TAG_subrange_type *and* >>> DW_AT_{lower,upper}_bound ??. Basically I just want to add bound >>> information, if available and not already present. >>> >>> Suggestions? >> >> I'm still not sure why we can't just emit bound info in early dwarf. >Can >> you be more specific about the optimization thing? > >Ok, I see what I was trying to do, albeit incorrectly. Imagine this: > >unsigned int i=555; > >int main() >{ > unsigned int array[i]; > ... >} > >For the VLA, I'd like to check if we have an array type with a missing >DW_AT_{upper,lower}_bound late in the game, and fill it in. > >During early dwarf we only have an uninitialized gimple register >representing the bound, and loc_list_from_tree() cannot find the RTL >with the final bound location. Thus, we end up with a missing bound, >which I propose to fill in late dwarf. > >Obviously I was doing some nonsense with TYPE_SIZE != INTEGER_CST, when > >in reality I should probably check that TREE_CODE (type) == ARRAY_TYPE >and that we are missing the bound late (by looking for DW_AT_*_bound in > >the cached DIE). > >Is this acceptable, or where you thinking of some other scheme?
ISTR I had to mark the gimple reg used for the bound as non-DECL_IGNORED for the LTO stuff. Richard. >Thanks. >Aldy