From patchwork Thu Nov 9 10:24:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 836272 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-466364-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="FgJPgdbS"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yXfSw0KL1z9s71 for ; Thu, 9 Nov 2017 21:25:51 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :resent-from:resent-to:resent-date:resent-message-id:message-id :in-reply-to:references:from:date:subject:to:cc; q=dns; s= default; b=LXTb32Rc1tvjIMr2Iibau5rAgLl0C0H3sJzkJRujA2Po45gBPwMgh Uzdb9K7XSnN0+TjRSttLWJjdOlr9WWnyGTvF3n8VRE/o1n/TbVlbUzhagcSKMIVH LmSG8vJL+xTVi4ru+m2d8MdPusVjM4R3IMdfnM4JrlG2JA0UODGvS0= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :resent-from:resent-to:resent-date:resent-message-id:message-id :in-reply-to:references:from:date:subject:to:cc; s=default; bh=Q ff28rHfCOFVy19oXtS9UlVjs+c=; b=FgJPgdbS1qqmcn9xPZioE0rj+e/1RxbF2 GSRpXI+9MObfgbPvUicfD0WnrqCDyyGdZlV2hV8MI9d38/ycnCeClTHubLcT5VIe 6fmRgOVLnUQ9QJOe4kiRn1MFzO47XRc190UdW03dZzpIdAsWtnPvV2Xj42KcHtnL bWXWclclGQ= Received: (qmail 55365 invoked by alias); 9 Nov 2017 10:25:17 -0000 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 Received: (qmail 54387 invoked by uid 89); 9 Nov 2017 10:25:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SEM_URIRED, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 09 Nov 2017 10:25:00 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 5EF93ABFA for ; Thu, 9 Nov 2017 10:24:58 +0000 (UTC) Resent-From: =?utf-8?q?Martin_Li=C5=A1ka?= Resent-To: GCC Patches Resent-Date: Thu, 9 Nov 2017 11:24:58 +0100 Resent-Message-ID: <4b5f6842-78e5-8053-0256-7ae991c212be@suse.cz> Resent-User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 Message-Id: <28f3909ec37c4da2dbd543326ae1781004578785.1510223055.git.mliska@suse.cz> In-Reply-To: References: From: marxin Date: Thu, 9 Nov 2017 11:24:05 +0100 Subject: [PATCH 2/7] GCOV: simplify usage of function_info::artificial. To: gcc-patches@gcc.gnu.org Cc: nathan@acm.org X-IsSubscribed: yes gcc/ChangeLog: 2017-11-09 Martin Liska * gcov.c (is_artificial): New function. (process_file): Erase all artificial early. (generate_results): Skip as all artificial are already removed. --- gcc/gcov.c | 66 +++++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 40 insertions(+), 26 deletions(-) diff --git a/gcc/gcov.c b/gcc/gcov.c index 83239639247..3dc159726c7 100644 --- a/gcc/gcov.c +++ b/gcc/gcov.c @@ -1088,6 +1088,14 @@ struct function_start_pair_hash : typed_noop_remove } }; +/* Function filter based on function_info::artificial variable. */ + +static bool +is_artificial (function_info *fn) +{ + return fn->artificial; +} + /* Process a single input file. */ static void @@ -1122,33 +1130,40 @@ process_file (const char *file_name) fn_map.put (needle, *it); } + /* Remove all artificial function. */ + functions.erase (remove_if (functions.begin (), functions.end (), + is_artificial), functions.end ()); + for (vector::iterator it = functions.begin (); it != functions.end (); it++) { function_t *fn = *it; + unsigned src = fn->src; if (fn->counts || no_data_file) { - unsigned src = fn->src; - unsigned block_no; + source_info *s = &sources[src]; + s->functions.push_back (fn); - /* Process only non-artificial functions. */ - if (!fn->artificial) + /* Mark last line in files touched by function. */ + for (unsigned block_no = 0; block_no != fn->blocks.size (); + block_no++) { - source_info *s = &sources[src]; - s->functions.push_back (fn); - - /* Mark last line in files touched by function. */ - for (block_no = 0; block_no != fn->blocks.size (); block_no++) + block_t *block = &fn->blocks[block_no]; + for (unsigned i = 0; i < block->locations.size (); i++) { - block_t *block = &fn->blocks[block_no]; - for (unsigned i = 0; i < block->locations.size (); i++) + /* Sort lines of locations. */ + sort (block->locations[i].lines.begin (), + block->locations[i].lines.end ()); + + if (!block->locations[i].lines.empty ()) { - /* Sort lines of locations. */ - sort (block->locations[i].lines.begin (), - block->locations[i].lines.end ()); + s = &sources[block->locations[i].source_file_idx]; + unsigned last_line + = block->locations[i].lines.back (); - if (!block->locations[i].lines.empty ()) + /* Record new lines for the function. */ + if (last_line >= s->lines.size ()) { s = &sources[block->locations[i].source_file_idx]; unsigned last_line @@ -1162,17 +1177,18 @@ process_file (const char *file_name) } } } - - /* Allocate lines for group function, following start_line - and end_line information of the function. */ - if (fn->is_group) - fn->lines.resize (fn->end_line - fn->start_line + 1); } - - solve_flow_graph (fn); - if (fn->has_catch) - find_exception_blocks (fn); } + + /* Allocate lines for group function, following start_line + and end_line information of the function. */ + if (fn->is_group) + fn->lines.resize (fn->end_line - fn->start_line + 1); + + + solve_flow_graph (fn); + if (fn->has_catch) + find_exception_blocks (fn); } else { @@ -1221,8 +1237,6 @@ generate_results (const char *file_name) { function_t *fn = *it; coverage_t coverage; - if (fn->artificial) - continue; memset (&coverage, 0, sizeof (coverage)); coverage.name = flag_demangled_names ? fn->demangled_name : fn->name;