On Wed, Nov 10, 2021 at 12:36:04PM +0100, Richard Biener wrote: > > I'm afraid I forgot the DECL_FIELD_OFFSET vs. DECL_FIELD_BIT_OFFSET stuff > > enough that I'm not sure what is the right fix for that case, maybe it would > > work if we dropped the && TREE_CODE (DECL_FIELD_OFFSET (decl)) == > > INTEGER_CST > > check and instead used: > > - bitpos_int = wi::to_offset (DECL_FIELD_BIT_OFFSET (decl)); > > + if (TREE_CODE (DECL_FIELD_OFFSET (decl)) == INTEGER_CST) > > + bitpos_int = wi::to_offset (bit_position (decl)); > > + else > > + bitpos_int = wi::to_offset (DECL_FIELD_BIT_OFFSET (decl)); > > at the start and > > - if (ctx->variant_part_offset == NULL_TREE) > > + if (ctx->variant_part_offset == NULL_TREE > > + && TREE_CODE (DECL_FIELD_OFFSET (decl)) == INTEGER_CST) > > { > > *cst_offset = object_offset_in_bytes.to_shwi (); > > return NULL; > > } > > tree_result = wide_int_to_tree (sizetype, object_offset_in_bytes); > > + if (TREE_CODE (DECL_FIELD_OFFSET (decl)) == INTEGER_CST) > > + tree_result = size_binop (PLUS_EXPR, DECL_FIELD_OFFSET (decl), > > + tree_result); > > that needs multiplication by BITS_PER_UNIT.
I don't think so. >From bit_from_pos and byte_from_pos functions it is clear that DECL_FIELD_OFFSET is in bytes and DECL_FIELD_BIT_OFFSET in bits. And object_offset_in_bytes is in bytes too. > > > or so. > > Not sure if it's worth special-casing constant DECL_FIELD_OFFSET > though, or whether the code can just work with DECL_FIELD_BIT_OFFSET > and DECL_FIELD_OFFSET be always added. It has certainly the advantage that it doesn't change anything for the most common case (where DECL_FIELD_OFFSET is INTEGER_CST). Jakub