+2016-01-11 Martin Jambor <mjambor@suse.cz>
+
+ PR ipa/66616
+ * ipa-cp.c (propagate_constants_accross_call): Move thuk check...
+ (call_passes_through_thunk_p): ...here.
+ (find_more_scalar_values_for_callers_subset): Perform thunk checks
+ like propagate_constants_accross_call does.
+ * cgraphclones.c (duplicate_thunk_for_node): Copy can_change_signature
+ flag from the node to the new flag.
+
2016-01-08 Martin Jambor <mjambor@suse.cz>
Backport from mainline
new_thunk = cgraph_create_node (new_decl);
set_new_clone_decl_and_node_flags (new_thunk);
new_thunk->definition = true;
+ new_thunk->local.can_change_signature = node->local.can_change_signature;
new_thunk->thunk = thunk->thunk;
new_thunk->unique_name = in_lto_p;
new_thunk->former_clone_of = thunk->decl;
return ret;
}
+/* Return true if on the way cfrom CS->caller to the final (non-alias and
+ non-thunk) destination, the call passes through a thunk. */
+
+static bool
+call_passes_through_thunk_p (struct cgraph_edge *cs)
+{
+ struct cgraph_node *alias_or_thunk = cs->callee;
+ while (alias_or_thunk->alias)
+ alias_or_thunk = cgraph_alias_target (alias_or_thunk);
+ return alias_or_thunk->thunk.thunk_p;
+}
+
/* Propagate constants from the caller to the callee of CS. INFO describes the
caller. */
{
struct ipa_node_params *callee_info;
enum availability availability;
- struct cgraph_node *callee, *alias_or_thunk;
+ struct cgraph_node *callee;
struct ipa_edge_args *args;
bool ret = false;
int i, args_count, parms_count;
/* If this call goes through a thunk we must not propagate to the first (0th)
parameter. However, we might need to uncover a thunk from below a series
of aliases first. */
- alias_or_thunk = cs->callee;
- while (alias_or_thunk->alias)
- alias_or_thunk = cgraph_alias_target (alias_or_thunk);
- if (alias_or_thunk->thunk.thunk_p)
+ if (call_passes_through_thunk_p (cs))
{
ret |= set_all_contains_variable (ipa_get_parm_lattices (callee_info,
0));
struct ipa_jump_func *jump_func;
tree t;
- if (i >= ipa_get_cs_argument_count (IPA_EDGE_REF (cs)))
+ if (i >= ipa_get_cs_argument_count (IPA_EDGE_REF (cs))
+ || (i == 0
+ && call_passes_through_thunk_p (cs)))
{
newval = NULL_TREE;
break;
--- /dev/null
+// { dg-do run }
+// { dg-options "-O2 -fipa-cp-clone" }
+
+struct Distraction
+{
+ char fc[8];
+ virtual Distraction * return_self ()
+ { return this; }
+};
+
+static int go;
+
+struct A;
+
+struct A
+{
+ int fi;
+
+ A () : fi(0) {}
+ A (int pi) : fi (pi) {}
+ virtual void foo (int p) = 0;
+};
+
+struct B;
+
+struct B : public Distraction, A
+{
+ B () : Distraction(), A() { }
+ B (int pi) : Distraction (), A (pi) {}
+ virtual void foo (int p)
+ {
+ int o = fi;
+ for (int i = 0; i < p; i++)
+ o += i + i * i;
+ go = o;
+ }
+};
+
+struct B gb2 (2);
+
+extern "C" void abort (void);
+
+int
+main (void)
+{
+ for (int i = 0; i < 2; i++)
+ {
+ struct A *p = &gb2;
+ p->foo (0);
+ if (go != 2)
+ abort ();
+ }
+ return 0;
+}