Commit 049e6d36 by Jan Hubicka Committed by Jan Hubicka

devirt-46.C: New testcase.


	* g++.dg/ipa/devirt-46.C: New testcase.
	* ipa-prop.c (ipa_compute_jump_functions_for_edge): Call
	get_dynamic_type; drop TODO.
	* ipa-polymorphic-call.c
	(ipa_polymorphic_call_context::get_dynamic_type): Be ready
	for otr_type to be unknown.

From-SVN: r215890
parent 3daa7bbf
2014-10-04 Jan Hubicka <hubicka@ucw.cz>
* ipa-prop.c (ipa_compute_jump_functions_for_edge): Call
get_dynamic_type; drop TODO.
* ipa-polymorphic-call.c
(ipa_polymorphic_call_context::get_dynamic_type): Be ready
for otr_type to be unknown.
2014-10-04 Trevor Saunders <tsaunders@mozilla.com>
* common/config/score/score-common.c: Remove.
......@@ -1390,12 +1390,13 @@ ipa_polymorphic_call_context::get_dynamic_type (tree instance,
This is because we do not update INSTANCE when walking inwards. */
HOST_WIDE_INT instance_offset = offset;
if (otr_type)
otr_type = TYPE_MAIN_VARIANT (otr_type);
/* Walk into inner type. This may clear maybe_derived_type and save us
from useless work. It also makes later comparsions with static type
easier. */
if (outer_type)
if (outer_type && otr_type)
{
if (!restrict_to_inner_class (otr_type))
return false;
......@@ -1484,6 +1485,7 @@ ipa_polymorphic_call_context::get_dynamic_type (tree instance,
/* We look for vtbl pointer read. */
ao.size = POINTER_SIZE;
ao.max_size = ao.size;
if (otr_type)
ao.ref_alias_set
= get_deref_alias_set (TREE_TYPE (BINFO_VTABLE (TYPE_BINFO (otr_type))));
......
......@@ -1898,10 +1898,11 @@ ipa_compute_jump_functions_for_edge (struct func_body_info *fbi,
tree param_type = ipa_get_callee_param_type (cs, n);
if (flag_devirtualize && POINTER_TYPE_P (TREE_TYPE (arg)))
{
tree instance;
struct ipa_polymorphic_call_context context (cs->caller->decl,
arg, cs->call_stmt,
NULL);
/* TODO: We should also handle dynamic types. */
&instance);
context.get_dynamic_type (instance, arg, NULL, cs->call_stmt);
*ipa_get_ith_polymorhic_call_context (args, n) = context;
if (!context.useless_p ())
useful_context = true;
......
2014-10-04 Jan Hubicka <hubicka@ucw.cz>
* g++.dg/ipa/devirt-46.C: New testcase.
2014-10-04 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
PR fortran/36534
......
/* { dg-do compile } */
/* { dg-options "-O3 -fno-ipa-cp -fdump-ipa-inline-details -fno-early-inlining -fdump-tree-optimized" } */
struct A {
virtual int foo(){return 1;}
};
struct B:A {
virtual int foo(){return 2;}
};
static void
test (struct A *a)
{
if (a->foo() != 2)
__builtin_abort ();
}
int
m()
{
struct A *a = new B;
test (a);
return 0;
}
/* { dg-final { scan-ipa-dump-times "Discovered a virtual call to a speculative target\[^\\n\]*B::foo" 1 "inline" } } */
/* { dg-final { scan-ipa-dump-not "OBJ_TYPE_REF" "optimized" } } */
/* { dg-final { scan-ipa-dump-not "abort" "optimized" } } */
/* { dg-final { cleanup-ipa-dump "inline" } } */
/* { dg-final { cleanup-ipa-dump "optimized" } } */
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