https://gcc.gnu.org/g:04e111ae72a6b4ced48c733e9043d6efbe92d3b6
commit r15-11241-g04e111ae72a6b4ced48c733e9043d6efbe92d3b6 Author: Jan Hubicka <[email protected]> Date: Fri Apr 17 18:10:09 2026 +0200 Fix lto-devirt-23.C testcase failure 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 (cherry picked from commit 1cfd37290199bd69706d5a74d4cee40bd83d671c) Diff: --- gcc/ipa-polymorphic-call.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gcc/ipa-polymorphic-call.cc b/gcc/ipa-polymorphic-call.cc index 7b105f112b2c..4603594be865 100644 --- a/gcc/ipa-polymorphic-call.cc +++ b/gcc/ipa-polymorphic-call.cc @@ -503,8 +503,10 @@ polymorphic_ctor_dtor_p (tree fn, bool check_clones) 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; }
