Commit 570215f9 by Jason Merrill Committed by Jason Merrill

re PR c++/58678 (pykde4-4.11.2 link error (devirtualization too trigger happy))

	PR c++/58678
	* ipa-devirt.c (ipa_devirt): Don't choose an implicitly-declared
	function.

From-SVN: r208241
parent e73cafde
2014-02-28 Jason Merrill <jason@redhat.com>
PR c++/58678
* ipa-devirt.c (ipa_devirt): Don't choose an implicitly-declared
function.
2014-02-28 Paolo Carlini <paolo.carlini@oracle.com> 2014-02-28 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/60314 PR c++/60314
......
...@@ -1710,7 +1710,7 @@ ipa_devirt (void) ...@@ -1710,7 +1710,7 @@ ipa_devirt (void)
int npolymorphic = 0, nspeculated = 0, nconverted = 0, ncold = 0; int npolymorphic = 0, nspeculated = 0, nconverted = 0, ncold = 0;
int nmultiple = 0, noverwritable = 0, ndevirtualized = 0, nnotdefined = 0; int nmultiple = 0, noverwritable = 0, ndevirtualized = 0, nnotdefined = 0;
int nwrong = 0, nok = 0, nexternal = 0;; int nwrong = 0, nok = 0, nexternal = 0, nartificial = 0;
FOR_EACH_DEFINED_FUNCTION (n) FOR_EACH_DEFINED_FUNCTION (n)
{ {
...@@ -1820,6 +1820,17 @@ ipa_devirt (void) ...@@ -1820,6 +1820,17 @@ ipa_devirt (void)
nexternal++; nexternal++;
continue; continue;
} }
/* Don't use an implicitly-declared destructor (c++/58678). */
struct cgraph_node *non_thunk_target
= cgraph_function_node (likely_target);
if (DECL_ARTIFICIAL (non_thunk_target->decl)
&& DECL_COMDAT (non_thunk_target->decl))
{
if (dump_file)
fprintf (dump_file, "Target is artificial\n\n");
nartificial++;
continue;
}
if (cgraph_function_body_availability (likely_target) if (cgraph_function_body_availability (likely_target)
<= AVAIL_OVERWRITABLE <= AVAIL_OVERWRITABLE
&& symtab_can_be_discarded (likely_target)) && symtab_can_be_discarded (likely_target))
...@@ -1862,10 +1873,10 @@ ipa_devirt (void) ...@@ -1862,10 +1873,10 @@ ipa_devirt (void)
" %i speculatively devirtualized, %i cold\n" " %i speculatively devirtualized, %i cold\n"
"%i have multiple targets, %i overwritable," "%i have multiple targets, %i overwritable,"
" %i already speculated (%i agree, %i disagree)," " %i already speculated (%i agree, %i disagree),"
" %i external, %i not defined\n", " %i external, %i not defined, %i artificial\n",
npolymorphic, ndevirtualized, nconverted, ncold, npolymorphic, ndevirtualized, nconverted, ncold,
nmultiple, noverwritable, nspeculated, nok, nwrong, nmultiple, noverwritable, nspeculated, nok, nwrong,
nexternal, nnotdefined); nexternal, nnotdefined, nartificial);
return ndevirtualized ? TODO_remove_functions : 0; return ndevirtualized ? TODO_remove_functions : 0;
} }
......
// PR c++/58678
// { dg-options "-O3 -fdump-ipa-devirt" }
struct A {
virtual ~A();
};
struct B : A {
virtual int m_fn1();
};
void fn1(B* b) {
delete b;
}
// { dg-final { scan-assembler-not "_ZN1AD2Ev" } }
// { dg-final { scan-assembler-not "_ZN1BD0Ev" } }
// { dg-final { scan-ipa-dump "Target is artificial" "devirt" } }
// { dg-final { cleanup-ipa-dump "devirt" } }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment