From patchwork Tue Aug 20 23:19:55 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dehao Chen X-Patchwork-Id: 268658 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 2FB802C010E for ; Wed, 21 Aug 2013 09:20:07 +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=nUvk4kvnGe/4lcbQqH HYSM65YFl8a6Mp8i3TUMmVS75OKBw4FmG2jquYVH4uvgrzXs6WJ/jfPpa26eMfv8 ADa8wJVR6p0XiIvUmTHhcu+0SNJX4+0wZtAk1Mnk7OHv63RzmWwLNe8vLwHsG8Ae dleA+SFmItlVYdHZWXI5YJfOc= 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=aiEwoY6eDGShJ6JiVifoniGD FyI=; b=hXJhPUs6T6Td0jaz4MBYUnmcCWruhqQ27fn4sWZ1Ij6mLUr79A83Y5Lj RKWErOaIB1tbO1EfBELXv0tvuUBCRV7LszZ6+SIoTMCaR7BfdM09fsJowP/fprNa UUleQfkUMEhhTsFIx8s4N3Ys0+IbSHa8zYRks00Ucn345gfpt48= Received: (qmail 16264 invoked by alias); 20 Aug 2013 23:19:58 -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 16255 invoked by uid 89); 20 Aug 2013 23:19:58 -0000 X-Spam-SWARE-Status: No, score=-5.4 required=5.0 tests=AWL, BAYES_00, KHOP_THREADED, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 Received: from mail-ob0-f175.google.com (HELO mail-ob0-f175.google.com) (209.85.214.175) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Tue, 20 Aug 2013 23:19:57 +0000 Received: by mail-ob0-f175.google.com with SMTP id xn12so925666obc.20 for ; Tue, 20 Aug 2013 16:19:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=IrsqVsDAKyRp3Wm8qP4zC3QYaAU++3ZhOnlZP40Jsv4=; b=UBPMe3uRY28ycSfZKaMLFcWbxkQAalgBEUL3/JSu4oNmG7vQEwP8/PS1ERoDwLrxhj +gqE+68FfRnfz04+6X01xFIoTnsYniKRrJ6yKOQk6nF4OxecVOb4Yxg83bMpbxDU6sfy +XNQlwsX0htvxfXZk9/vh8orX8seua1cgQxggGaohFI1o9haM0fgptDuu2n0t0f+kBXM 2fP2SHk4KL59MnU9rWtCQCP85OEOeHYNmUgcRe0ZXC8mIKkogPzUrPQ/KDTOrLXD9Sup 7eC5M4yrl8y4fkBlIE0wqeGXMeRfAlDoVc29I92tIyLGStiGdb3O6NPQxR1N2xMbDbhA SGOg== X-Gm-Message-State: ALoCoQl9jqqqXIFZEFaYgiG/rBE+SgWnHUOcuekj9mAnWb88tX4elxug78yO9wZTdK/jcAar1Rzha37+Aw+4Q11nvXdpjxUzYSbhPYErxSCV5TENDgb03WbBBfdnokiwQDI2iDC0H4ZHefIwFiklEqV4WUa6+Mdzceu7p+ukUXiIRS+NcmTJeAzoLFaaKzbctCRq+xPGPcEGjQRW455V4GGM9JN7+Ua8FQ== MIME-Version: 1.0 X-Received: by 10.50.61.137 with SMTP id p9mr5667774igr.45.1377040795819; Tue, 20 Aug 2013 16:19:55 -0700 (PDT) Received: by 10.231.73.73 with HTTP; Tue, 20 Aug 2013 16:19:55 -0700 (PDT) In-Reply-To: References: Date: Tue, 20 Aug 2013 16:19:55 -0700 Message-ID: Subject: Re: [GOOGLE] Assign discriminators for different callsites at a same line within one BB From: Dehao Chen To: Cary Coutant Cc: GCC Patches You are right, we need discriminator for non-CALL stmts too. Patch updated: On Tue, Aug 20, 2013 at 2:54 PM, Cary Coutant wrote: >> This patch assigns discriminators for different callsites within the >> same BB. This is needed for accurate profile attribution in AutoFDO. >> >> Testing on going. >> >> OK for google branches if test pass? > >> + for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) >> + { >> + gimple stmt = gsi_stmt (gsi); >> + if (gimple_code (stmt) != GIMPLE_CALL) >> + continue; >> + if (curr_locus == UNKNOWN_LOCATION || >> + !same_line_p (curr_locus, gimple_location (stmt))) >> + curr_locus = gimple_location (stmt); >> + else >> + gimple_set_location (stmt, location_with_discriminator ( >> + gimple_location (stmt), >> + next_discriminator_for_locus (gimple_location (stmt)))); >> + } > > Please add a comment above this block explaining what it's doing. Are > you sure it's sufficient to just assign a new discriminator to the > CALL stmt, and not to the subsequent stmts after the CALL? > > -cary Index: gcc/tree-cfg.c =================================================================== --- gcc/tree-cfg.c (revision 201858) +++ gcc/tree-cfg.c (working copy) @@ -781,9 +781,37 @@ assign_discriminators (void) { edge e; edge_iterator ei; + gimple_stmt_iterator gsi; gimple last = last_stmt (bb); location_t locus = last ? gimple_location (last) : UNKNOWN_LOCATION; + location_t curr_locus = UNKNOWN_LOCATION; + int curr_discr = 0; + /* Traverse the basic block, if two function calls within a basic block + are mapped to a same line, assign a new discriminator because a call + stmt could be a split point of a basic block. */ + 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))) + { + 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)); + } + /* 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) continue;