...
> What _does_ work however are the following two approaches:
> 
> 1) Perform the equality check on the original variables, creating
> new versions (with OPTIMIZER_HIDE_VAR) of both variables for the
> rest of their use, therefore making sure the pointer dereference
> are not derived from versions of the variables which were compared
> with another pointer. (as suggested by Boqun)

If that is
        a1 = a; OPTIMISER_HIDE_VAR(a1);
        b1 = b; OPTIMISER_HIDE_BAR(b1);
        if (a != b}
                return;
        // code using a1 and b1
then can't the compiler first flip it to:
        if (a != b)
                return;
        a1 = a; OPTIMISER_HIDE_VAR(a1);
        b1 = b; OPTIMISER_HIDE_VAR(b1);
and then replace the last line with:
        b1 = a; OPTIMISER_HIDE_VAR(b1);
which isn't intended at all.
                
        
OTOH if you do:
        a1 = a; OPTIMISER_HIDE_VAR(a1);
        b1 = b; OPTIMISER_HIDE_VAR(b1);
        if (a1 != b1)
                return;
        // code using a and b
(which I think is)

> 2) Perform the equality check on the versions resulting of hiding
> both variables, making sure those versions of the variables are
> not dereferenced afterwards. (as suggested by Linus)

then the compiler can't possibly reverse the asm blocks.

        David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, 
UK
Registration No: 1397386 (Wales)

Reply via email to