aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Hubicka <hubicka@ucw.cz>2018-02-21 20:05:30 +0100
committerJan Hubicka <hubicka@gcc.gnu.org>2018-02-21 19:05:30 +0000
commitea49d40b3e4fe753cc9180bd9bb814b2a8262721 (patch)
tree3b03e64ed273f26c5a6079942feb39ed3b270bba
parente68757438d8f5b6eacc8b95798835aada2b11668 (diff)
downloadgcc-ea49d40b3e4fe753cc9180bd9bb814b2a8262721.zip
gcc-ea49d40b3e4fe753cc9180bd9bb814b2a8262721.tar.gz
gcc-ea49d40b3e4fe753cc9180bd9bb814b2a8262721.tar.bz2
re PR c/84229 (A valid code rejected with -flto)
PR c/84229 * ipa-cp.c (determine_versionability): Do not version functions caling va_arg_pack. From-SVN: r257877
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/ipa-cp.c18
2 files changed, 24 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 1432608..2bc276e 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+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-02-21 Martin Liska <mliska@suse.cz>
PR driver/83193
diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c
index 4202c99..182dc49 100644
--- a/gcc/ipa-cp.c
+++ b/gcc/ipa-cp.c
@@ -630,6 +630,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 is not versionable, reason: %s.\n",
node->dump_name (), reason);