On Tue, Jan 12, 2016 at 06:51:31PM +0100, Martin Jambor wrote: > On Tue, Jan 12, 2016 at 06:36:21PM +0100, Martin Jambor wrote: > > > remap_decl (old_var, id); > > > } > > > - phase 2 - do the full remap_decls, but during that arrange that > > > remap_decl for non-zero id->remapping_type_depth if (!n) just returns > > > decl > > > > ...they would not be copied here because remap_decl would not be > > duplicating stuff. So I'd end up with an original local decl when I > > actually need a duplicate. > > > > ugh, I'm trying to be too fast and obviously forgot about the > id->remapping_type_depth part of the proposed condition. > > Still, when could relying solely on id->remapping_type_depth fail?
Well, those functions are used for numerous purposes, and you'd only want to not remap decls if not already remapped if id->remapping_type_depth when inside of the copy_gimple_seq_and_replace_locals path (and only for the remap_decls in there), so you need IMHO some flag to distinguish that. And the reason for the above suggested 2 phases, where the first phase just calls remap_decl and nothing else on the non-VLAs is to make sure that if a VLA type or DECL_VALUE_EXPR uses (usually scalar) vars declared in the same bind block, then those are processed first. Jakub