This is the mail archive of the gcc-patches@gcc.gnu.org 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] Fix PRs 52080, 52097 and 48124, rewrite bitfield expansion, enable the C++ memory model wrt bitfields everywhere


> Hmm, yeah.  Or something like
>
> Index: expr.c
> ===================================================================
> --- expr.c      (revision 186082)
> +++ expr.c      (working copy)
> @@ -4490,8 +4490,8 @@ get_bit_range (unsigned HOST_WIDE_INT *b
>    bitoffset += (tree_low_cst (DECL_FIELD_BIT_OFFSET (field), 1)
>                 - tree_low_cst (DECL_FIELD_BIT_OFFSET (repr), 1));
>
> -  *bitstart = bitpos - bitoffset;
> -  *bitend = *bitstart + tree_low_cst (DECL_SIZE (repr), 1) - 1;
> +  *bitstart = bitpos < (HOST_WIDE_INT) bitoffset ? 0 : bitpos -
> bitoffset;
> +  *bitend = bitpos + tree_low_cst (DECL_SIZE (repr), 1) - bitoffset - 1;
>  }
>
>  /* Returns true if the MEM_REF REF refers to an object that does not
>
> which conservatively truncates the bitrange.

What do you think about allowing get_bit_range to adjust offset and bitpos?

      tem = get_inner_reference (to, &bitsize, &bitpos, &offset, &mode1,
				 &unsignedp, &volatilep, true);

      if (TREE_CODE (to) == COMPONENT_REF
	  && DECL_BIT_FIELD_TYPE (TREE_OPERAND (to, 1)))
	get_bit_range (&bitregion_start, &bitregion_end, &offset, &bitpos, to);

so as to have a really non-negative bitregion_start/bitregion_end?  It would 
assert that offset is already non-null in that case.

-- 
Eric Botcazou


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