Re: LTO Test Case Help
Hi, On Wed, Dec 05 2018, Michael Ploujnikov wrote: > Hi, > > I'm trying to write a testcase to reproduce duplicate clone symbols > such as in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88297 I > started with a testcase that is known to have constprop clones and > split it into two object files: so as we discussed on IRC, the testcase as you posted it to the mailing list re-defined functions in a way that would not link, with or without LTO. When I fixed that, I had to make the following changes in order to trigger IPA-CP cloning: 1. I had to put the calls in main into a loop, otherwise everything is cold and we would not clone. 2. I had to make different foos and bars actually semantically different, otherwise IPA-ICF unified them, as it should. The result reproduces the bug. The two files are below. Martin 1.c 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; } 2.c 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; }
Re: LTO Test Case Help
On 2018-12-05 2:38 p.m., Michael Ploujnikov wrote: > Hi, > > I'm trying to write a testcase to reproduce duplicate clone symbols > such as in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88297 I > started with a testcase that is known to have constprop clones and > split it into two object files: > > > bash-4.2# cat /gcc/src/gcc/testsuite/gcc.dg/lto/independent-cloneids-lto_0.c > /* { dg-require-effective-target lto } */ > /* { dg-lto-options {{-O3 -fipa-cp -fipa-cp-clone}} } */ > /* { dg-lto-do run } */ > > #include > > extern int foo (int arg); > extern int bar (int arg); > int __attribute__ ((noinline)) > foo (int arg) > { > return 7 * arg; > } > > int __attribute__ ((noinline)) > bar (int arg) > { > return arg * arg; > } > > int main (void) > { > printf("%d\n", bar (3)); > printf("%d\n", bar (4)); > printf("%d\n", foo (5)); > printf("%d\n", foo (6)); > return 0; > } > > bash-4.2# cat /gcc/src/gcc/testsuite/gcc.dg/lto/independent-cloneids-lto_1.c > int __attribute__ ((noinline)) > foo (int arg) > { > return 7 * arg; > } > > int __attribute__ ((noinline)) > bar (int arg) > { > return arg * arg; > } > > but now decide_whether_version_node does not call decide_about_value > and I don't know enough about ipa/lattices to figure out what's > missing. Any help would be appreciated. > > > - Michael > If I print out the lattices in decide_whether_version_node right before the call to gather_context_independent_values (and some more info within the loop and after) I see: debug: decide_whether_version_node - node: bar count is 1 Lattices: Node: main/13: Node: bar/12: param [0]: BOTTOM ctxs: BOTTOM Bits unusable (BOTTOM) VARYING AGGS BOTTOM Node: foo/11: param [0]: BOTTOM ctxs: BOTTOM Bits unusable (BOTTOM) VARYING AGGS BOTTOM debug: decide_whether_version_node - !lat->bottom: 0 debug: decide_whether_version_node - !plats->aggs_bottom: 0 debug: decide_whether_version_node - node : bar info->do_clone_for_all_contexts: 0 debug: decide_whether_version_node - node: foo count is 1 Lattices: Node: main/13: Node: bar/12: param [0]: BOTTOM ctxs: BOTTOM Bits unusable (BOTTOM) VARYING AGGS BOTTOM Node: foo/11: param [0]: BOTTOM ctxs: BOTTOM Bits unusable (BOTTOM) VARYING AGGS BOTTOM debug: decide_whether_version_node - !lat->bottom: 0 debug: decide_whether_version_node - !plats->aggs_bottom: 0 debug: decide_whether_version_node - node : foo info->do_clone_for_all_contexts: 0 signature.asc Description: OpenPGP digital signature
LTO Test Case Help
Hi, I'm trying to write a testcase to reproduce duplicate clone symbols such as in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88297 I started with a testcase that is known to have constprop clones and split it into two object files: bash-4.2# cat /gcc/src/gcc/testsuite/gcc.dg/lto/independent-cloneids-lto_0.c /* { dg-require-effective-target lto } */ /* { dg-lto-options {{-O3 -fipa-cp -fipa-cp-clone}} } */ /* { dg-lto-do run } */ #include extern int foo (int arg); extern int bar (int arg); int __attribute__ ((noinline)) foo (int arg) { return 7 * arg; } int __attribute__ ((noinline)) bar (int arg) { return arg * arg; } int main (void) { printf("%d\n", bar (3)); printf("%d\n", bar (4)); printf("%d\n", foo (5)); printf("%d\n", foo (6)); return 0; } bash-4.2# cat /gcc/src/gcc/testsuite/gcc.dg/lto/independent-cloneids-lto_1.c int __attribute__ ((noinline)) foo (int arg) { return 7 * arg; } int __attribute__ ((noinline)) bar (int arg) { return arg * arg; } but now decide_whether_version_node does not call decide_about_value and I don't know enough about ipa/lattices to figure out what's missing. Any help would be appreciated. - Michael signature.asc Description: OpenPGP digital signature