User account creation filtered due to spam.

Bug 57434

Summary: [4.7 regression] -fprofile-arcs introduces unused TLS variables
Product: gcc Reporter: Rainer Orth <ro>
Component: middle-endAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: normal CC: rguenth
Priority: P3    
Version: 4.7.4   
Target Milestone: 4.8.0   
Host: *-*-solaris2.[89] Target: *-*-solaris2.[89]
Build: *-*-solaris2.[89] Known to work: 4.8.0
Known to fail: 4.7.4 Last reconfirmed:

Description Rainer Orth 2013-05-27 14:17:59 UTC
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  <rguenther@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
Comment 1 Richard Biener 2013-05-27 15:00:21 UTC
Working in 4.8 and 4.9?
Comment 2 ro@CeBiTec.Uni-Bielefeld.DE 2013-05-27 15:15:34 UTC
> --- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
> Working in 4.8 and 4.9?

Working in both.

	Rainer
Comment 3 Richard Biener 2014-06-12 13:27:47 UTC
Fixed in 4.8.0