]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix lto-devirt-23.C testcase failure
authorJan Hubicka <hubicka@ucw.cz>
Fri, 17 Apr 2026 16:10:09 +0000 (18:10 +0200)
committerJan Hubicka <hubicka@ucw.cz>
Fri, 17 Apr 2026 16:10:09 +0000 (18:10 +0200)
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

gcc/ipa-polymorphic-call.cc

index b32dc70806f52fc9c650cbb2ce2e6cc90205b603..66b70e529669eb8d99990b13f6dfc7cbe0a1dfde 100644 (file)
@@ -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;
 }