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

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Because of -Ofast initial compilation, opt_for_fn (decl,
flag_semantic_interposition) is false for all the decls for which a cgraph node
is created, but they have NULL DECL_FUNCTION_SPECIFIC_OPTIMIZATION, and thus
they look up the bit in optimization_default_node.
That results in node->semantic_interposition to be 0 as well.
Next comes free_lang_data_in_decl, which does:

  if (TREE_CODE (decl) == FUNCTION_DECL)
...
      if (gimple_has_body_p (decl) || (node && node->thunk))
...
          if (!DECL_FUNCTION_SPECIFIC_OPTIMIZATION (decl))
            DECL_FUNCTION_SPECIFIC_OPTIMIZATION (decl)
              = optimization_default_node;
Now, free_lang_data_in_decl is called on 3 FUNCTION_DECLs,
_ZN1SC1Ev aka __ct_comp, which is node->alias && !node->semantic_interposition,
gimple_has_body_p (decl) is false for it and we don't do anything.
Next it is called on _ZN1SC4Ev aka __ct, which has NULL node and
gimple_has_body_p (decl) is false for it too.
Last it is called for _ZN1SC2Ev aka __ct_base, which is !node->alias &&
!node->semantic_interposition, gimple_has_body_p (decl) is true and we set
DECL_FUNCTION_SPECIFIC_OPTIMIZATION (decl) to optimization_default_node.
Then we stream all this out, and stream it back, except that
optimization_default_node is one for -O2 with x_flag_semantic_interposition set
for it.
_ZN1SC2Ev passes the verification, node->semantic_interposition is false
and opt_for_fn (decl, flag_semantic_interposition) is false as well.
But for _ZN1SC1Ev we ICE on:
  if (definition && externally_visible
      && semantic_interposition
         != opt_for_fn (decl, flag_semantic_interposition))
    {
      error ("semantic interposition mismatch");
      error_found = true;
    }
That is because for aliases which don't have a body, we kept
DECL_FUNCTION_SPECIFIC_OPTIMIZATION (decl) NULL.
One way to fix this would be
-  if (definition && externally_visible
+  if (definition
+      && externally_visible
+      && (!alias || thunk)
       && semantic_interposition
          != opt_for_fn (decl, flag_semantic_interposition))
     {
       error ("semantic interposition mismatch");
       error_found = true;
     }
i.e. don't bother verification of mismatches for aliases.  Another would be
to adjust DECL_FUNCTION_SPECIFIC_OPTIMIZATION (decl) in free_lang_data_in_decl
even for aliases.

Reply via email to