From patchwork Thu Dec 1 20:05:19 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 128746 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 497A7B6F6F for ; Fri, 2 Dec 2011 07:05:51 +1100 (EST) Received: (qmail 9450 invoked by alias); 1 Dec 2011 20:05:45 -0000 Received: (qmail 9429 invoked by uid 22791); 1 Dec 2011 20:05:40 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from mail-ey0-f175.google.com (HELO mail-ey0-f175.google.com) (209.85.215.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 01 Dec 2011 20:05:24 +0000 Received: by eaad13 with SMTP id d13so2767251eaa.20 for ; Thu, 01 Dec 2011 12:05:23 -0800 (PST) Received: by 10.216.88.70 with SMTP id z48mr551194wee.46.1322769922881; Thu, 01 Dec 2011 12:05:22 -0800 (PST) Received: by 10.216.88.70 with SMTP id z48mr551188wee.46.1322769922705; Thu, 01 Dec 2011 12:05:22 -0800 (PST) Received: from [192.168.44.105] (5ac3c889.bb.sky.com. [90.195.200.137]) by mx.google.com with ESMTPS id ep16sm6940665wbb.21.2011.12.01.12.05.21 (version=SSLv3 cipher=OTHER); Thu, 01 Dec 2011 12:05:21 -0800 (PST) Message-ID: <4ED7DDFF.60708@acm.org> Date: Thu, 01 Dec 2011 20:05:19 +0000 From: Nathan Sidwell User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.23) Gecko/20110922 Lightning/1.0b2 Thunderbird/3.1.15 MIME-Version: 1.0 To: GCC Patches CC: Markus Trippelsdorf Subject: [Gcov] Unbreak C++ coverage X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org I've committed this patch, which unbreaks the firefox build problem Markus found. The problem is that the list of functions to emit coverage data is determined before the final culling of functions that don't need emitting. There's a circular dependency here with the cgraph machinery, and I need to look carefully as to how that might be broken. This does revert some of the new features I was implementing, and the xfailed gcov test is a case of this. I decided to simply remove the tests checking coverage object visibility, rather than augment the scan-assembler machinery. tested on i686-pc-linux-gnu. Thanks to Markus for verifying this patch does indeed unbreak firefox. nathan 2011-12-01 Nathan Sidwell PR gcov-profile/51113 * coverage.c (build_var): Keep coverage variables static. testsuite/ * lib/gcov.exp (verify-lines): Add support for xfailing. (run-gcov): Likewise. * gcc.misc-tests/gcov-13.c: Xfail weak function. * gcc.misc-tests/gcov-16.c: Remove. * gcc.misc-tests/gcov-17.c: Remove. * g++.dg/gcov-8.C: Remove. * g++.dg/gcov-9.C: Remove. * g++.dg/gcovpart-12b.C: New. * g++.dg/gcov-12.C: New. Index: coverage.c =================================================================== --- coverage.c (revision 181858) +++ coverage.c (working copy) @@ -657,8 +657,7 @@ coverage_end_function (unsigned lineno_c } /* Build a coverage variable of TYPE for function FN_DECL. If COUNTER - >= 0 it is a counter array, otherwise it is the function structure. - Propagate appropriate linkage and visibility from the function decl. */ + >= 0 it is a counter array, otherwise it is the function structure. */ static tree build_var (tree fn_decl, tree type, int counter) @@ -675,21 +674,6 @@ build_var (tree fn_decl, tree type, int TREE_STATIC (var) = 1; TREE_ADDRESSABLE (var) = 1; DECL_ALIGN (var) = TYPE_ALIGN (type); - DECL_WEAK (var) = DECL_WEAK (fn_decl); - TREE_PUBLIC (var) - = TREE_PUBLIC (fn_decl) && (counter < 0 || DECL_WEAK (fn_decl)); - if (DECL_ONE_ONLY (fn_decl)) - make_decl_one_only (var, DECL_COMDAT_GROUP (fn_decl)); - - if (TREE_PUBLIC (var)) - { - DECL_VISIBILITY (var) = DECL_VISIBILITY (fn_decl); - DECL_VISIBILITY_SPECIFIED (var) - = DECL_VISIBILITY_SPECIFIED (fn_decl); - - /* Initialize assembler name so we can stream out. */ - DECL_ASSEMBLER_NAME (var); - } return var; } Index: testsuite/lib/gcov.exp =================================================================== --- testsuite/lib/gcov.exp (revision 181858) +++ testsuite/lib/gcov.exp (working copy) @@ -39,19 +39,28 @@ proc clean-gcov { testcase } { # proc verify-lines { testcase file } { #send_user "verify-lines\n" + global subdir set failed 0 set fd [open $file r] while { [gets $fd line] >= 0 } { # We want to match both "-" and "#####" as count as well as numbers, # since we want to detect lines that shouldn't be marked as covered. - if [regexp "^ *(\[^:]*): *(\[0-9\\-#]+):.*count\\((\[0-9\\-#]+)\\)" \ - "$line" all is n shouldbe] { + if [regexp "^ *(\[^:]*): *(\[0-9\\-#]+):.*count\\((\[0-9\\-#]+)\\)(.*)" \ + "$line" all is n shouldbe rest] { + if [regexp "^ *{(.*)}" $rest all xfailed] { + switch [dg-process-target $xfailed] { + "N" { continue } + "F" { setup_xfail "*-*-*" } + } + } if { $is == "" } { - fail "$n:no data available for this line" + fail "$subdir/$testcase:$n:no data available for this line" incr failed } elseif { $is != $shouldbe } { - fail "$n:is $is:should be $shouldbe" + fail "$subdir/$testcase:$n:is $is:should be $shouldbe" incr failed + } else { + pass "$subdir/$testcase:$n line count" } } } @@ -230,32 +239,36 @@ proc run-gcov { args } { global GCOV global srcdir subdir - set gcov_args [lindex $args end] - + set gcov_args "" set gcov_verify_calls 0 set gcov_verify_branches 0 - set gcov_execute_xfail "" - set gcov_verify_xfail "" + set xfailed 0 foreach a $args { if { $a == "calls" } { set gcov_verify_calls 1 } elseif { $a == "branches" } { set gcov_verify_branches 1 + } elseif { $gcov_args == "" } { + set gcov_args $a + } else { + switch [dg-process-target $a] { + "N" { return } + "F" { set xfailed 1 } + } } } # Extract the test name from the arguments. set testcase [lindex $gcov_args end] - if { $gcov_execute_xfail != "" } { - eval setup_xfail [split $gcov_execute_xfail] - } - verbose "Running $GCOV $testcase" 2 set testcase [remote_download host $testcase] set result [remote_exec host $GCOV $gcov_args] if { [lindex $result 0] != 0 } { + if { $xfailed } { + setup_xfail "*-*-*" + } fail "$subdir/$testcase gcov failed: [lindex $result 1]" clean-gcov $testcase return @@ -264,16 +277,15 @@ proc run-gcov { args } { # Get the gcov output file after making sure it exists. set files [glob -nocomplain $testcase.gcov] if { $files == "" } { + if { $xfailed } { + setup_xfail "*-*-*" + } fail "$subdir/$testcase gcov failed: $testcase.gcov does not exist" clean-gcov $testcase return } remote_upload host $testcase.gcov $testcase.gcov - if { $gcov_verify_xfail != "" } { - eval setup_xfail [split $gcov_verify_xfail] - } - # Check that line execution counts are as expected. set lfailed [verify-lines $testcase $testcase.gcov] @@ -293,6 +305,9 @@ proc run-gcov { args } { # Report whether the gcov test passed or failed. If there were # multiple failures then the message is a summary. set tfailed [expr $lfailed + $bfailed + $cfailed] + if { $xfailed } { + setup_xfail "*-*-*" + } if { $tfailed > 0 } { fail "$subdir/$testcase gcov: $lfailed failures in line counts, $bfailed in branch percentages, $cfailed in return percentages" } else { Index: testsuite/gcc.misc-tests/gcov-13.c =================================================================== --- testsuite/gcc.misc-tests/gcov-13.c (revision 181858) +++ testsuite/gcc.misc-tests/gcov-13.c (working copy) @@ -7,7 +7,7 @@ int __attribute__ ((weak)) weak () { - return 1; /* count(-) */ + return 1; /* count(-) { xfail *-*-* } PR51113*/ } int main () @@ -15,5 +15,6 @@ int main () return weak (); /* count(1) */ } -/* { dg-final { run-gcov { -a gcov-13.c } } } */ +/* xfailed due to PR 51113 */ +/* { dg-final { run-gcov { -a gcov-13.c } { xfail *-*-* } } } */ /* { dg-final { run-gcov { -a gcovpart-13b.c } } } */ Index: testsuite/gcc.misc-tests/gcov-16.c =================================================================== --- testsuite/gcc.misc-tests/gcov-16.c (revision 181858) +++ testsuite/gcc.misc-tests/gcov-16.c (working copy) @@ -1,12 +0,0 @@ -/* Test visibility is copied */ - -/* { dg-options "-fprofile-arcs -fvisibility=hidden" } */ -/* { dg-require-visibility "" } */ -/* { dg-require-weak "" } */ - -void Foo () -{ -} - - /* { dg-final { scan-assembler "\\.hidden\t__gcov__Foo" { target { ! *-*-darwin* } } } } */ - /* { dg-final { scan-assembler "\\.private_extern ___gcov__Foo" { target *-*-darwin* } } } */ Index: testsuite/gcc.misc-tests/gcov-17.c =================================================================== --- testsuite/gcc.misc-tests/gcov-17.c (revision 181858) +++ testsuite/gcc.misc-tests/gcov-17.c (working copy) @@ -1,12 +0,0 @@ -/* Test visibility is copied */ - -/* { dg-options "-fprofile-arcs" } */ -/* { dg-require-visibility "" } */ -/* { dg-require-weak "" } */ - -void __attribute__ ((visibility ("hidden"), weak)) Foo () -{ -} - -/* { dg-final { scan-assembler "\\.hidden\t__gcov__Foo" { target { ! *-*-darwin* } } } } */ -/* { dg-final { scan-assembler "\\.private_extern ___gcov__Foo" { target *-*-darwin* } } } */ Index: testsuite/g++.dg/gcov/gcov-8.C =================================================================== --- testsuite/g++.dg/gcov/gcov-8.C (revision 181858) +++ testsuite/g++.dg/gcov/gcov-8.C (working copy) @@ -1,14 +0,0 @@ -/* { dg-options "-fprofile-arcs -fvisibility=hidden" } */ -/* { dg-require-visibility "" } */ - -struct __attribute__((visibility ("hidden"))) X -{ - void Fink (); -}; - -void X::Fink () -{ -} - -/* { dg-final { scan-assembler "\\.hidden\t__gcov___ZN1X4FinkEv" { target { ! *-*-darwin* } } } } */ -/* { dg-final { scan-assembler "\\.private_extern ___gcov___ZN1X4FinkEv" { target *-*-darwin* } } } */ Index: testsuite/g++.dg/gcov/gcov-9.C =================================================================== --- testsuite/g++.dg/gcov/gcov-9.C (revision 181858) +++ testsuite/g++.dg/gcov/gcov-9.C (working copy) @@ -1,17 +0,0 @@ -/* { dg-options "-fprofile-arcs -fvisibility-inlines-hidden" } */ -/* { dg-require-visibility "" } */ - -inline void Boo () -{ -} - -extern "C" void (*Foo ()) () -{ - return Boo; -} - -/* { dg-final { scan-assembler "\\.hidden\t__gcov___Z3Boov" { target { ! *-*-darwin* } } } } */ -/* { dg-final { scan-assembler "\\.private_extern ___gcov___Z3Boov" { target *-*-darwin* } } } */ -/* { dg-final { scan-assembler "__gcov__Foo:" } } */ -/* { dg-final { scan-assembler-not "\\.hidden\t__gcov__Foo" { target { ! *-*-darwin* } } } } */ -/* { dg-final { scan-assembler-not "\\.private_extern ___gcov__Foo" { target *-*-darwin* } } } */ Index: testsuite/g++.dg/gcov/gcov-12.C =================================================================== --- testsuite/g++.dg/gcov/gcov-12.C (revision 0) +++ testsuite/g++.dg/gcov/gcov-12.C (revision 0) @@ -0,0 +1,21 @@ +/* PR 51113 */ +/* { dg-options "-fprofile-arcs -ftest-coverage -fpic" } */ +/* { dg-do run { target native } } */ +/* { dg-additional-sources "gcovpart-12b.C" } */ + +struct Foo { + Foo () + {} /* count(1) */ + virtual void Func () /* count(#####) */ + {} /* count(#####) */ +}; + +int main () +{ + Foo b; + + return 0; /* count (1) */ +} + +/* { dg-final { run-gcov gcov-12.C } } */ +/* { dg-final { run-gcov gcovpart-12b.C { xfail *-*-* } } } */ Index: testsuite/g++.dg/gcov/gcovpart-12b.C =================================================================== --- testsuite/g++.dg/gcov/gcovpart-12b.C (revision 0) +++ testsuite/g++.dg/gcov/gcovpart-12b.C (revision 0) @@ -0,0 +1,5 @@ +struct Foo { + Foo () {} + virtual void Func () /* count(-) { xfail *-*-* } */ + {} /* count(-) { xfail *-*-* } */ +};