]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Backport r257877
authorMartin Liska <mliska@suse.cz>
Wed, 7 Mar 2018 09:46:01 +0000 (10:46 +0100)
committerMartin Liska <marxin@gcc.gnu.org>
Wed, 7 Mar 2018 09:46:01 +0000 (09:46 +0000)
2018-03-07  Martin Liska  <mliska@suse.cz>

Backport from mainline
2018-02-21  Jan Hubicka  <hubicka@ucw.cz>

PR c/84229
* ipa-cp.c (determine_versionability): Do not version functions caling
va_arg_pack.

From-SVN: r258324

gcc/ChangeLog
gcc/ipa-cp.c

index 1e4242633461c91796eeab58e8e901e6670fa4be..1b451894b3f520a7b3b90c879c48781644cdc6f8 100644 (file)
@@ -1,3 +1,12 @@
+2018-03-07  Martin Liska  <mliska@suse.cz>
+
+       Backport from mainline
+       2018-02-21  Jan Hubicka  <hubicka@ucw.cz>
+
+       PR c/84229
+       * ipa-cp.c (determine_versionability): Do not version functions caling
+       va_arg_pack.
+
 2018-03-07  Martin Liska  <mliska@suse.cz>
 
        Backport from mainline
index 98bb9514777fe69ca99d2ab02f6bd05835b3b460..caa346f7016b06c2f294ae9d5f6a6f201824f8dc 100644 (file)
@@ -544,6 +544,24 @@ determine_versionability (struct cgraph_node *node,
       reason = "calls comdat-local function";
     }
 
+  /* Functions calling BUILT_IN_VA_ARG_PACK and BUILT_IN_VA_ARG_PACK_LEN
+     works only when inlined.  Cloning them may still lead to better code
+     becuase ipa-cp will not give up on cloning further.  If the function is
+     external this however leads to wrong code becuase we may end up producing
+     offline copy of the function.  */
+  if (DECL_EXTERNAL (node->decl))
+    for (cgraph_edge *edge = node->callees; !reason && edge;
+        edge = edge->next_callee)
+      if (DECL_BUILT_IN (edge->callee->decl)
+         && DECL_BUILT_IN_CLASS (edge->callee->decl) == BUILT_IN_NORMAL)
+        {
+         if (DECL_FUNCTION_CODE (edge->callee->decl) == BUILT_IN_VA_ARG_PACK)
+           reason = "external function which calls va_arg_pack";
+         if (DECL_FUNCTION_CODE (edge->callee->decl)
+             == BUILT_IN_VA_ARG_PACK_LEN)
+           reason = "external function which calls va_arg_pack_len";
+        }
+
   if (reason && dump_file && !node->alias && !node->thunk.thunk_p)
     fprintf (dump_file, "Function %s/%i is not versionable, reason: %s.\n",
             node->name (), node->order, reason);