http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57434

            Bug ID: 57434
           Summary: [4.7 regression] -fprofile-arcs introduces unused TLS
                    variables
           Product: gcc
           Version: 4.7.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ro at gcc dot gnu.org
                CC: richard.guenther at gmail dot com
              Host: *-*-solaris2.[89]
            Target: *-*-solaris2.[89]
             Build: *-*-solaris2.[89]

I only now noticed that several -fprofile-arcs testcases started to FAIL on
Solaris 8 and 9 with TLS support, e.g.

FAIL: gcc.misc-tests/gcov-1.c execution test
FAIL: gcc.misc-tests/gcov-1.c gcov failed: gcov-1.c.gov does not exist

The testcase tails to execute with

% gcc/xgcc -Bgcc/
/vol/gcc/src/hg/gcc-4.7-branch/solaris/gcc/testsuite/gcc.misc-tests/gcov-1.c
-fprofile-arcs -ftest-coverage -lm -o ./gcov-1.exe
% ./gcov-1.exe
ld.so.1: gcov-1.exe: fatal: gcov-1.exe: object requires TLS, but TLS failed to
initialize
Killed

A reghunt discovered that this is a regression introduced by this patch:

2012-09-11  Richard Guenther  <rguent...@suse.de>

       PR debug/54534
       * cgraph.h (varpool_can_remove_if_no_refs): Restore dependence
       on flag_toplevel_reorder.

With it, gcov-1.s gains two unused definitions of TLS variables:

ro@luole 185 > diff -u 88*/*.s 
--- 880/gcov-1.s        2013-05-27 16:07:38.106783000 +0200
+++ 881/gcov-1.s        2013-05-27 16:07:32.227394000 +0200
@@ -70,10 +70,23 @@
        .cfi_endproc
 .LFE1:
        .size   main, .-main
+       .section        .tbss,"awT",@nobits
+       .align 4
+       .type   __gcov_indirect_call_callee, @object
+       .size   __gcov_indirect_call_callee, 4
+__gcov_indirect_call_callee:
+       .zero   4
+       .align 4
+       .type   __gcov_indirect_call_counters, @object
+       .size   __gcov_indirect_call_counters, 4
+__gcov_indirect_call_counters:
+       .zero   4
        .local  __gcov0.main
+       .bss
        .comm   __gcov0.main,24,8
        .comm   __gcov0.noop,8,8
+       .text
        .type   _GLOBAL__sub_I_65535_0_noop, @function
 _GLOBAL__sub_I_65535_0_noop:
 .LFB2:

As a bad Solaris-specific hack, one could handle -fprofile-arcs like
-fprofile-generate in config/sol2.h LIB_SPEC and LINK_SPEC, but it would be
better to fix the underlying problem.

  Rainer
        .local  __gcov0.noop

Reply via email to