From patchwork Wed Sep 2 17:01:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Deeds X-Patchwork-Id: 513584 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 0D8331401DA for ; Thu, 3 Sep 2015 03:01:55 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=h6Oo7k6r; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:date:message-id:subject:from:to:cc:content-type; q=dns; s=default; b=ou9jIwHVPiPewANWdG16RWAW6pcKG5QDims4JL1BKvz Ybvzi20eAzge8myHXxY/fPc4BdsBDksF5/etfDZhvbi9ZsBc7UuDStXJkNa8JWgd Ij4ZfaM86eWMy/4bGm5neI/Y8L1XF+hGKlhKu14nHOx0fE4gXROwFaarfCGT7UG0 = 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 :mime-version:date:message-id:subject:from:to:cc:content-type; s=default; bh=UhakImfEfiyXSjT4hnXnbGqDCdM=; b=h6Oo7k6rAtVcupca9 uf5HQqTt1mahau1ZCcU1/5EsRpuvxLPqo/K8gfzk0q9a8KKb+wtMFkk4ID3iBvyy Qh/vRc4TInimIMDkocCSs8rdNCfJYNUQEAgdSrFu4ENfwduna+lSOCR/SC7C6/ye 6Z5SWEVGfvtfHPIiFzHvog2euw= Received: (qmail 24962 invoked by alias); 2 Sep 2015 17:01:47 -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 24953 invoked by uid 89); 2 Sep 2015 17:01:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.5 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mail-ob0-f175.google.com Received: from mail-ob0-f175.google.com (HELO mail-ob0-f175.google.com) (209.85.214.175) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Wed, 02 Sep 2015 17:01:45 +0000 Received: by obqa2 with SMTP id a2so13423389obq.3 for ; Wed, 02 Sep 2015 10:01:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to:cc :content-type; bh=mBq0E6YwzHkdBTB1/I/CKK8CanEPTZKQdNrDEXM0MQI=; b=K2HVr6ea2bQgAokQ1BFG1AI9Pi3mkdVNOKv2ljIXbjw2FUnQIyowTIkoGT1GD3RPwe yECAypC0kf8J7BQiw+wXxjtNTjLSIZO2QtGIePf9YON31vovNccp1BVmWSDW1UfjpFhL f/jksRtKPNCogNaRXtQkHcyK0pr41Uhs+w3TNTZyk/HN2HHOaro/gauW7xo0LhTyno1a KUDilFj5wXqGrlwpS4b3Sx+k9V8quhjjCxpd5ThbU9HaCWHRsQAxV/Z9lIAwG2ow4t7x Egt8ULDg3fO7Bk5fhs0G7+G62CLkexDaiZSpzpnhtFRwEv87o/AHLD1g0mae2Fo+E8TX MxMA== X-Gm-Message-State: ALoCoQlYOQb1sR2mk1BiafvrMXENz2gIJdRiaUPiXNOZg1kI62Ip1DyQQDuv/6Qk1woKzl0mRs3A MIME-Version: 1.0 X-Received: by 10.182.236.102 with SMTP id ut6mr22307683obc.75.1441213303329; Wed, 02 Sep 2015 10:01:43 -0700 (PDT) Received: by 10.202.50.86 with HTTP; Wed, 2 Sep 2015 10:01:43 -0700 (PDT) Date: Wed, 2 Sep 2015 10:01:43 -0700 Message-ID: Subject: Patch GCC for profile-func-internal-id=0 coverage-callback=1 From: Matt Deeds To: gcc-patches@gcc.gnu.org, Jan Hubicka Cc: Rong Xu , David Li Hello, Honza. David Li said you might be able to help me get this patch into GCC trunk. I sent mail for this on August 27, but didn't get a reply. It's a small change to make these two options work together: profile-func-internal-id=0 coverage-callback=1 Let me know what I can do to get this submitted. This patch is for svn://gcc.gnu.org/svn/gcc/branches/google/gcc-4_9. I add support for the profile_func_internal-id in the instrumentation generated for __coverage_callback. Add support for the profile-func-internal-id parameter to the coverage callback. Without this change, the function identifier passed to __coverage_callback (enabled with param=coverage-callback=1) does not match the values emitted in the .gcno file. Because the function profile_id is typically more unique (typically 32 bits) than the function internal id (typically 16 bits), it can be desirable to have the profile_id used to identify a function as opposed to the function internal id. I've instrumented a large binary creating over 500 .gcno files and confirmed that function IDs in these .gcno files match the IDs in __coverage_callback. In my example, there were typically about one to four functions sharing the same internal function ID. There were no collisions using profile_id. Index: gcc/tree-profile.c =================================================================== --- gcc/tree-profile.c (revision 226647) +++ gcc/tree-profile.c (working copy) @@ -864,8 +864,20 @@ gimple_gen_edge_profiler (int edgeno, edge e) { gimple call; tree tree_edgeno = build_int_cst (gcov_type_node, edgeno); - tree tree_uid = build_int_cst (gcov_type_node, + + tree tree_uid; + if (PARAM_VALUE (PARAM_PROFILE_FUNC_INTERNAL_ID)) + { + tree_uid = build_int_cst (gcov_type_node, current_function_funcdef_no); + } + else + { + gcc_assert (coverage_node_map_initialized_p ()); + + tree_uid = build_int_cst + (gcov_type_node, cgraph_get_node (current_function_decl)->profile_id); + } tree callback_fn_type = build_function_type_list (void_type_node, gcov_type_node,