* 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
+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.
This is because we do not update INSTANCE when walking inwards. */
HOST_WIDE_INT instance_offset = offset;
- otr_type = TYPE_MAIN_VARIANT (otr_type);
+ 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;
/* We look for vtbl pointer read. */
ao.size = POINTER_SIZE;
ao.max_size = ao.size;
- ao.ref_alias_set
- = get_deref_alias_set (TREE_TYPE (BINFO_VTABLE (TYPE_BINFO (otr_type))));
+ if (otr_type)
+ ao.ref_alias_set
+ = get_deref_alias_set (TREE_TYPE (BINFO_VTABLE (TYPE_BINFO (otr_type))));
if (dump_file)
{
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
--- /dev/null
+/* { 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" } } */