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; }