From patchwork Mon Aug 25 03:53:50 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Mi X-Patchwork-Id: 382621 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 24980140080 for ; Mon, 25 Aug 2014 13:54:04 +1000 (EST) 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:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; q=dns; s=default; b=Jj6ytyalQYU0DuuuVJ y7E8/PW8KaD5ZZGi9vb8ddYuxoU5jc0JG2CgdcCjonov0HkDb+2Wiu78LS1e+fYv x8FcO+H/+KZI3U7soBzrN6mNGcnCrf5t129AKwK/82Zz0+z7fqdRo3j80L72cxdL eD/eC45jDwkh2FGPbHtJSK3Vs= 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:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; s=default; bh=7dtaSyMjY1I3y5MHAlJFc0sR zAo=; b=OwxtpR6dg5PTAh4dmojrktyGq1CnWcP8zLfgbUAkolSSMc/Nwf48sJVr AeDWrYCsmQZwmND7Hf5j5aQnqQ4tI7JTOUgrDw6EiwMBCYApfnN1PH5UMQRmsneO +gdH1RwPK2trm9f4xqc3SEncLnUZ49NQ8K7s2pUAN5OUAzXgcI4= Received: (qmail 23772 invoked by alias); 25 Aug 2014 03:53:56 -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 23759 invoked by uid 89); 25 Aug 2014 03:53:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.7 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-oi0-f44.google.com Received: from mail-oi0-f44.google.com (HELO mail-oi0-f44.google.com) (209.85.218.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Mon, 25 Aug 2014 03:53:53 +0000 Received: by mail-oi0-f44.google.com with SMTP id x69so9372010oia.31 for ; Sun, 24 Aug 2014 20:53:50 -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:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=40qMvRPEGwEAJbItBpxrTMUhhIkbYXHrznH8ntlqlkU=; b=I4+lZlcK7voHkI8VllSdqOUJEKXf5pxjuBZB4u7yJBA4Q5+0iVrRGpj4Xn61jCxK5W tbacjdFWI5Ko5a+8bHUbMRi0iS8VVOIMqNJ+5NKyT3eG8tNsvIrDqUFlOB3c7hJtnWFJ gBElDZli2Nh2JPysEga4Uzg1ufMxwIdN9rZ31sE4CBXbLmbxUjEt6NnWKkHuDQTSjEsV vqRPxD/yNZ2bvn0l4lLUVYeqTUe6r1oAb9FWPzg6LwdFi4baBlgUWEKd3wSt+LnE/+9f BrzJjRndX0pN8GB53XgKg1C8AOqP3pm8b6ZDw1yeuri8M7uvSairfXHnqX3DlYu0dnLo 6qug== X-Gm-Message-State: ALoCoQmhJ4VQ5PmbzRHyYR17zXih9BFMRLVumKK1N633yCRUNnXRDMxFfR9dtCNGH/jEV9DWj+QB MIME-Version: 1.0 X-Received: by 10.182.87.167 with SMTP id az7mr19061765obb.41.1408938830863; Sun, 24 Aug 2014 20:53:50 -0700 (PDT) Received: by 10.76.91.138 with HTTP; Sun, 24 Aug 2014 20:53:50 -0700 (PDT) In-Reply-To: References: Date: Sun, 24 Aug 2014 20:53:50 -0700 Message-ID: Subject: Re: [GOOGLE, AUTOFDO] Assign different discriminators to calls with the same lineno From: Wei Mi To: Cary Coutant Cc: GCC Patches , David Li , Dehao Chen To avoid the unused new discriminator value, I added a map "found_call_this_line" to track whether a call is the first call in a source line seen when assigning discriminators. For the first call in a source line, its discriminator is 0. For the following calls in the same source line, a new discriminator will be used everytime. The new patch is attached. Internal perf test and regression test are ok. Is it ok for google-4_9? Thanks, Wei. On Thu, Aug 7, 2014 at 2:10 PM, Wei Mi wrote: > Yes, that is intentional. It is to avoid assiging a discriminator for > the first call in the group of calls with the same source lineno. > Starting from the second call in the group, it will get a different > discriminator with previous call in the same group. > > Thanks, > Wei. > > On Thu, Aug 7, 2014 at 12:17 PM, Cary Coutant wrote: >>> static int >>> -next_discriminator_for_locus (location_t locus) >>> +increase_discriminator_for_locus (location_t locus, bool return_next) >>> { >>> struct locus_discrim_map item; >>> struct locus_discrim_map **slot; >>> @@ -934,8 +936,10 @@ next_discriminator_for_locus (location_t >>> (*slot)->locus = locus; >>> (*slot)->discriminator = 0; >>> } >>> + >>> (*slot)->discriminator++; >>> - return (*slot)->discriminator; >>> + return return_next ? (*slot)->discriminator >>> + : (*slot)->discriminator - 1; >>> } >> >> Won't this have the effect of sometimes incrementing the next >> available discriminator without actually using the new value? That is, >> if you call it once with return_next == false, and then with >> return_next == true. >> >> -cary ChangeLog: 2014-08-24 Wei Mi * tree-cfg.c (assign_discriminators): Assign different discriminators for calls belonging to the same source line. Index: tree-cfg.c =================================================================== --- tree-cfg.c (revision 213402) +++ tree-cfg.c (working copy) @@ -992,7 +992,13 @@ static void assign_discriminators (void) { basic_block bb; + /* If there is a location saved in the hash_table, it means that we + already found a call in the source line before. For the calls which + are not the first call found in the same source line, we don't assign + new discriminator for it, so that .debug_line section will be smaller. */ + hash_table found_call_this_line; + found_call_this_line.create (13); FOR_EACH_BB_FN (bb, cfun) { edge e; @@ -1009,23 +1015,31 @@ assign_discriminators (void) for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) { gimple stmt = gsi_stmt (gsi); - if (curr_locus == UNKNOWN_LOCATION) - { - curr_locus = gimple_location (stmt); - } - else if (!same_line_p (curr_locus, gimple_location (stmt))) + if (gimple_code (stmt) == GIMPLE_CALL) { + struct locus_discrim_map item; + struct locus_discrim_map **slot; + curr_locus = gimple_location (stmt); - curr_discr = 0; - } - else if (curr_discr != 0) - { - gimple_set_location (stmt, location_with_discriminator ( - gimple_location (stmt), curr_discr)); + item.locus = curr_locus; + item.discriminator = 0; + slot = found_call_this_line.find_slot (&item, INSERT); + /* If the current call is not the first call seen in curr_locus, + assign the next discriminator to it, else keep its discriminator + unchanged. */ + if (*slot != HTAB_EMPTY_ENTRY) + { + curr_discr = next_discriminator_for_locus (curr_locus); + gimple_set_location (stmt, location_with_discriminator ( + gimple_location (stmt), curr_discr)); + } + else + { + *slot = XNEW (struct locus_discrim_map); + (*slot)->locus = curr_locus; + (*slot)->discriminator = 0; + } } - /* Allocate a new discriminator for CALL stmt. */ - if (gimple_code (stmt) == GIMPLE_CALL) - curr_discr = next_discriminator_for_locus (curr_locus); } if (locus == UNKNOWN_LOCATION) @@ -1047,6 +1061,7 @@ assign_discriminators (void) } } } + found_call_this_line.dispose (); } /* Create the edges for a GIMPLE_COND starting at block BB. */