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: [trans-mem] PR46653: handle identical log entries in hash


On Mon, Nov 29, 2010 at 3:39 PM, Aldy Hernandez <aldyh@redhat.com> wrote:
> operand_equal_p() will return false for volatiles, even if they are exactly
> the same pointer because of the side-effects. ?This causes problems when
> we search for an existing hash slot, because we never match ourselves.
>
> Fixed thus.
>
> OK for branch?

But that'll still treat s.a and s.a as different when s is volatile.

Richard.

> ? ? ? ?PR/46653
> ? ? ? ?* trans-mem.c (tm_log_eq): Return true for identical addresses.
>
> Index: testsuite/g++.dg/tm/pr46653.C
> ===================================================================
> --- testsuite/g++.dg/tm/pr46653.C ? ? ? (revision 0)
> +++ testsuite/g++.dg/tm/pr46653.C ? ? ? (revision 0)
> @@ -0,0 +1,18 @@
> +// { dg-do compile }
> +// { dg-options "-fgnu-tm -O" }
> +
> +class shared_count
> +{
> +public:
> + ? ?volatile int j;
> + ?shared_count() : j(0) { }
> +};
> +
> +shared_count * c;
> +int main()
> +{
> + ?__transaction [[atomic]] {
> + ? ?shared_count sc;
> + ?}
> + ?return 0;
> +}
> Index: trans-mem.c
> ===================================================================
> --- trans-mem.c (revision 167111)
> +++ trans-mem.c (working copy)
> @@ -860,6 +860,13 @@ tm_log_eq (const void *p1, const void *p
> ?{
> ? const struct tm_log_entry *log1 = (const struct tm_log_entry *) p1;
> ? const struct tm_log_entry *log2 = (const struct tm_log_entry *) p2;
> +
> + ?/* Special case plain equality because operand_equal_p() below will
> + ? ? return FALSE if the addresses are equal but they have
> + ? ? side-effects (e.g. a volatile address). ?*/
> + ?if (log1->addr == log2->addr)
> + ? ?return true;
> +
> ? return operand_equal_p (log1->addr, log2->addr, 0);
> ?}
>
>


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