From: Martin Liska Date: Wed, 7 Mar 2018 09:46:01 +0000 (+0100) Subject: Backport r257877 X-Git-Tag: releases/gcc-6.5.0~473 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=05df2a0032aeea2badbf71c292a297f09c0834b2;p=thirdparty%2Fgcc.git Backport r257877 2018-03-07 Martin Liska Backport from mainline 2018-02-21 Jan Hubicka PR c/84229 * ipa-cp.c (determine_versionability): Do not version functions caling va_arg_pack. From-SVN: r258324 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1e4242633461..1b451894b3f5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2018-03-07 Martin Liska + + Backport from mainline + 2018-02-21 Jan Hubicka + + PR c/84229 + * ipa-cp.c (determine_versionability): Do not version functions caling + va_arg_pack. + 2018-03-07 Martin Liska Backport from mainline diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c index 98bb9514777f..caa346f7016b 100644 --- a/gcc/ipa-cp.c +++ b/gcc/ipa-cp.c @@ -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);