The testcase now fails because we miss the fact that type can be in construction.
This is because polymorphic_ctor_dtor_p returns false on polymorphic destructor
since it has PURE flag. The problem is that the destructor is optimized in meantime
and the memory store is optimized out. It is however left intact in the inline copy
of the constructor, so we can't really use the flag.
This check was added during early stage of the development of ipa-devirt and it
is not very effective (does not trigger anything useful on testsuite or GCC bootstrap).
So this patch simply drops it.
gcc/ChangeLog:
PR ipa/120098
* ipa-polymorphic-call.cc (polymorphic_ctor_dtor_p): Remove
check for pure/const flags
return NULL_TREE;
}
- if (flags_from_decl_or_type (fn) & (ECF_PURE | ECF_CONST))
- return NULL_TREE;
+ /* We used to check that the ctor/dtor is not pure/const.
+ However this may interact with pass ordering. It is possible that the
+ store of vtable is optimized out in offline copy, but inline copies keep
+ it and then local-pure-const overwrites the flag. See PR120098. */
return fn;
}