https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89246

            Bug ID: 89246
           Summary: LTO produces references to cloned symbols which the
                    compiler failed to clone
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Keywords: link-failure, lto
          Severity: normal
          Priority: P3
         Component: lto
          Assignee: unassigned at gcc dot gnu.org
          Reporter: asolokha at gmx dot com
                CC: marxin at gcc dot gnu.org
  Target Milestone: ---
            Target: x86_64-pc-linux-gnu

I suspect this PR is just a user error in the first place, as ones ignores a
compiler warning here and also bars the compiler from performing proper
analysis of the program.

The symptom is that during LTO, under certain circumstances gcc still emits
references to functions that should have been cloned but turned out to be
impossible to clone:

int
u0 (int z5)
{
  return z5;
}

#pragma omp declare simd
int
d6 (__int128 tn __attribute__ ((unused)))
{
  return u0 (0) + u0 (0) + u0 (0);
}

#pragma omp declare simd
int
k4 (void)
{
  return u0 (0) + u0 (0) + d6 (0);
}

int
main (void)
{
  return d6 (0) + d6 (0) + k4 () + k4 ();
}

% x86_64-pc-linux-gnu-gcc-9.0.0-alpha20190203 -O1 -flto -fopenmp-simd
-fno-ipa-pure-const --param lto-min-partition=7 ui2rn7yh.c
ui2rn7yh.c:9:1: warning: unsupported argument type '__int128' for simd
    9 | d6 (__int128 tn)
      | ^
/tmp/ccU4vevn.ltrans1.ltrans.o:<artificial>:function _ZGVbN4_k4: error:
undefined reference to '_ZGVbN4v_d6'
/tmp/ccU4vevn.ltrans1.ltrans.o:<artificial>:function _ZGVcN4_k4: error:
undefined reference to '_ZGVcN4v_d6'
/tmp/ccU4vevn.ltrans1.ltrans.o:<artificial>:function _ZGVdN8_k4: error:
undefined reference to '_ZGVdN8v_d6'
/tmp/ccU4vevn.ltrans1.ltrans.o:<artificial>:function _ZGVeN16_k4: error:
undefined reference to '_ZGVeN16v_d6'
collect2: error: ld returned 1 exit status

Removing "#pragma omp declare simd" annotation from d6() definition, or
omitting -flto or -fno-ipa-pure-const from the command line, or increasing
--param lto-min-partition value, obviously, resolves the link failure.

Reply via email to