On 2025-12-16 09:21, Andrew MacLeod wrote:
The new integrated PTA figures out a couple of things.. first, it knows
   *  from earlier that buf3 and buf1 points to the same thing,
   * and can also figure out that buf3 + 4 == buf1 + 4, so it can fold away the condition afterwards since arg1 is the result

How does it know of this equivalence?  Is PTA somehow ignoring __noinline__?

No, it earlier in the function we have a few statements like :

if (memcpy (buf3, buf5, 8) != (char *) buf1
   abort ();
which translates into
  _9 = __builtin___memcpy_chk (buf3_60(D), "a", 1, _5);
   if (_9 != &buf1)
     goto <bb 13>; [INV]
   else
     goto <bb 12>; [INV]


where it can establish that  buf3_60 == &buf1 since _9 == buf3_60 and _9 == &buf1 from bb12 onward

Aha, ok! It looks like test2_sub needs to be broken up then, to have each of those tests run independently. That way the compiler won't have a chance to leak the result of one test into the ones that follow.

Something like:

__attribute__((noinline))
test2_sub_1 (...)
{
  if (__builtin_memcpy (buf3, "ABCDEF", 6) != (char *) buf1
      || memcmp (buf1, "ABCDEFghijklmnopq\0", 19))
    abort ();
}

test2_sub ()
{
...
  test2_sub_1 (buf3, buf4, buf6, n);
...
}

and so on. Basically all of the tests with buf3 based expressions as the destination need their own noinline function.

Sid

Reply via email to