https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63721

Jiong Wang <jiwang at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Target|                            |arm-*-*, x86-64-*-*

--- Comment #1 from Jiong Wang <jiwang at gcc dot gnu.org> ---
the same ICE will happen on x86-64, if compile with -O2 -fPIC.

the reason is for the following two functions, they are identical, so IPA-ICF
pass try to transform the second function to call the first one directly.

int
atomic_compare_exchange_STRONG_RELEASE_ACQUIRE (int a, int b)
{
  return __atomic_compare_exchange (&v, &a, &b,
                    STRONG, __ATOMIC_RELEASE,
                    __ATOMIC_ACQUIRE);
}

int
atomic_compare_exchange_n_STRONG_RELEASE_ACQUIRE (int a, int b)
{
  return __atomic_compare_exchange_n (&v, &a, b,
                      STRONG, __ATOMIC_RELEASE,
                      __ATOMIC_ACQUIRE);
}

while during this transformation, looks like there are something wrong with the
function argument handling. take "a" for example, because later there are "&a",
so it's marked as addressable. while after transformation, if we turn the
second function into

int atomic_compare_exchange_n_STRONG_RELEASE_ACQUIRE (int a, int b)
{
  return atomic_compare_exchange_STRONG_RELEASE_ACQUIRE (a, b)
}

then argument a is no longer addressable.

so, in cgraph_node::release_body, when making the wrapper, except clearing the
function body, we should also clear the addressable flag for function args
because they are decided by the function body which is cleared.

I have a local patch under testing.

Reply via email to