From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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-Archive: List-Post: List-Help: Sender: gcc-patches-owner@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, 02 Sep 2015 17:01:00 -0000 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 Content-Type: text/plain; charset=UTF-8 X-SW-Source: 2015-09/txt/msg00177.txt.bz2 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,