Thanks to Martin we now have a test that exercises (cp) cloning
machinery during the WPA stage of LTO.
Also, during debugging I found that print_all_lattices would trigger
an assert if I tried to call it inside decide_whether_version_node.
Finally I've attached some comment spelling fixes as a bonus.
Bootstrapping (--with-build-config=bootstrap-lto) and regression testing on
x86_64.
Ok for trunk after tests pass?
- Michael
From f8f59d44141726e688cde077aabb5f2ce0bf53e0 Mon Sep 17 00:00:00 2001
From: Michael Ploujnikov
Date: Thu, 6 Dec 2018 13:36:51 -0500
Subject: [PATCH 1/3] Skip constprop clones because we don't make lattices for
them.
gcc/ChangeLog:
2018-12-06 Michael Ploujnikov
* ipa-cp.c (print_all_lattices): Skip cp clones.
---
gcc/ipa-cp.c | 3 +++
1 file changed, 3 insertions(+)
diff --git gcc/ipa-cp.c gcc/ipa-cp.c
index c7c462ab81..c4e879bbc6 100644
--- gcc/ipa-cp.c
+++ gcc/ipa-cp.c
@@ -542,6 +542,9 @@ print_all_lattices (FILE * f, bool dump_sources, bool dump_benefits)
struct ipa_node_params *info;
info = IPA_NODE_REF (node);
+ /* Skip constprop clones since we don't make lattices for them. */
+ if (info->ipcp_orig_node)
+ continue;
fprintf (f, " Node: %s:\n", node->dump_name ());
count = ipa_get_param_count (info);
for (i = 0; i < count; i++)
--
2.19.1
From 1ec489bbb30f410144c0bc84f0c160a8fbed0be6 Mon Sep 17 00:00:00 2001
From: Michael Ploujnikov
Date: Thu, 6 Dec 2018 13:47:00 -0500
Subject: [PATCH 2/3] Testcase for cloning during LTO WPA stage.
Written with Martin Jambor's help:
https://gcc.gnu.org/ml/gcc/2018-12/msg00043.html
gcc/testsuite/ChangeLog:
2018-12-06 Michael Ploujnikov
* gcc.dg/lto/pr88297_0.c: New test.
* gcc.dg/lto/pr88297_1.c: New test.
---
gcc/testsuite/gcc.dg/lto/pr88297_0.c | 57
gcc/testsuite/gcc.dg/lto/pr88297_1.c | 25
2 files changed, 82 insertions(+)
create mode 100644 gcc/testsuite/gcc.dg/lto/pr88297_0.c
create mode 100644 gcc/testsuite/gcc.dg/lto/pr88297_1.c
diff --git gcc/testsuite/gcc.dg/lto/pr88297_0.c gcc/testsuite/gcc.dg/lto/pr88297_0.c
new file mode 100644
index 00..d415015166
--- /dev/null
+++ gcc/testsuite/gcc.dg/lto/pr88297_0.c
@@ -0,0 +1,57 @@
+/* { dg-require-effective-target lto } */
+/* { dg-lto-options {{-flto -O3 -fipa-cp -fipa-cp-clone}} } */
+/* { dg-lto-do run } */
+
+/* In order to trigger IPA-CP cloning we have to:
+
+ 1. Put the calls in main into a loop; otherwise everything is
+ coldand we would not clone.
+
+ 2. Make different foos and bars actually semantically different;
+ otherwise IPA-ICF unified them (as it should).
+
+*/
+
+volatile int g;
+
+void __attribute__ ((noipa))
+use (int v)
+{
+ g = v;
+}
+
+static int __attribute__ ((noinline))
+foo (int arg)
+{
+ return 7 * arg;
+}
+
+static int __attribute__ ((noinline))
+bar (int arg)
+{
+ return arg * arg;
+}
+
+extern int __attribute__ ((noinline))
+entry2 (void);
+
+int __attribute__ ((noipa))
+get_opaque_number (void)
+{
+ return 1;
+}
+
+int main (void)
+{
+ int i;
+ for (i = 0; i < get_opaque_number (); i++)
+{
+ use (bar (3));
+ use (bar (4));
+ use (foo (5));
+ use (foo (6));
+
+ entry2 ();
+}
+ return 0;
+}
diff --git gcc/testsuite/gcc.dg/lto/pr88297_1.c gcc/testsuite/gcc.dg/lto/pr88297_1.c
new file mode 100644
index 00..65c5321cde
--- /dev/null
+++ gcc/testsuite/gcc.dg/lto/pr88297_1.c
@@ -0,0 +1,25 @@
+extern void __attribute__ ((noipa))
+use (int v);
+
+
+static int __attribute__ ((noinline))
+foo (int arg)
+{
+ return 8 * arg;
+}
+
+static int __attribute__ ((noinline))
+bar (int arg)
+{
+ return arg * arg + 3;
+}
+
+int __attribute__ ((noinline))
+entry2 (void)
+{
+ use (bar (3));
+ use (bar (4));
+ use (foo (5));
+ use (foo (6));
+ return 0;
+}
--
2.19.1
From c2db1a6aa7d6787685a28df1e677a66bac6cb9b5 Mon Sep 17 00:00:00 2001
From: Michael Ploujnikov
Date: Thu, 6 Dec 2018 14:06:55 -0500
Subject: [PATCH 3/3] Spelling fixes in comments.
gcc/ChangeLog:
2018-12-06 Michael Ploujnikov
* ipa-cp.c (ipa_get_indirect_edge_target_1): Fix spelling in
comments.
---
gcc/ipa-cp.c | 16
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git gcc/ipa-cp.c gcc/ipa-cp.c
index c4e879bbc6..8c419e1f53 100644
--- gcc/ipa-cp.c
+++ gcc/ipa-cp.c
@@ -191,7 +191,7 @@ public:
/* Depth first search number and low link for topological sorting of
values. */
int dfs, low_link;
- /* True if this valye is currently on the topo-sort stack. */
+ /* True if this value is currently on the topo-sort stack. */
bool on_stack;
ipcp_value()
@@ -883,7 +883,7 @@ ipcp_lattice::set_contains_variable ()
return ret;
}
-/* Set all aggegate lattices in PLATS to bottom and return true if they were
+/* Set all aggregate lattices in PLATS to bottom and return true if they were
not previously set as such. */
static inline bool
@@ -894,7 +894,7 @@ set_agg_lats_to_bottom