Hi Richard.

David reports that on AIX, you can have DECL_COMDAT defined, but no DEC_COMDAT_GROUP. Consequently tm_mangle() gets called incorrectly with a null. I suggested making tm_mangle() handle nulls, but David preferred handling it in the caller.

I tested this patch on x86-64 Linux, and David tells me this fixes the problem on his AIX end.

Thanks to David for finding and fixing this problem.

OK?
        * trans-mem.c (ipa_tm_create_version_alias): Handle unsupported
        HAVE_COMDAT_GROUP.
        (ipa_tm_create_version): Same.

Index: trans-mem.c
===================================================================
--- trans-mem.c (revision 181488)
+++ trans-mem.c (working copy)
@@ -4198,8 +4198,10 @@ ipa_tm_create_version_alias (struct cgra
   TREE_SYMBOL_REFERENCED (tm_name) = 1;
 
   /* Perform the same remapping to the comdat group.  */
-  if (DECL_COMDAT (new_decl))
+  if (DECL_COMDAT (new_decl) && HAVE_COMDAT_GROUP)
     DECL_COMDAT_GROUP (new_decl) = tm_mangle (DECL_COMDAT_GROUP (old_decl));
+  else
+    DECL_COMDAT_GROUP (new_decl) = DECL_COMDAT_GROUP (old_decl);
 
   new_node = cgraph_same_body_alias (NULL, new_decl, info->new_decl);
   new_node->tm_clone = true;
@@ -4233,8 +4235,10 @@ ipa_tm_create_version (struct cgraph_nod
   TREE_SYMBOL_REFERENCED (tm_name) = 1;
 
   /* Perform the same remapping to the comdat group.  */
-  if (DECL_COMDAT (new_decl))
+  if (DECL_COMDAT (new_decl) && HAVE_COMDAT_GROUP)
     DECL_COMDAT_GROUP (new_decl) = tm_mangle (DECL_COMDAT_GROUP (old_decl));
+  else
+    DECL_COMDAT_GROUP (new_decl) = DECL_COMDAT_GROUP (old_decl);
 
   new_node = cgraph_copy_node_for_versioning (old_node, new_decl, NULL, NULL);
   new_node->lowered = true;

Reply via email to