From patchwork Fri Sep 13 05:18:58 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Teresa Johnson X-Patchwork-Id: 274657 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 did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 3251E2C0149 for ; Fri, 13 Sep 2013 15:19:10 +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=sqnb5t1goUuC9IFyO4 gqlaU2R0g0CuF5VaQva+YLd8P8GHaMSAadHqy9x0riS9xMZDcSG4nRy6DQUUX22R Azj0yN+Qr0Zb/aRsSDLLavDHHHWJ4U/5qaivtpacjayEyvHh220pADkDVtnMYrGW /KHwXv0pNJZ+pT8GGIJwmf4ug= 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=URfwKqkpFoh0K75siXtTHtyo pNM=; b=WoQWS88JIc/SSlG6FNTeSynT+W/4nKLey+Ftsep/KE9Y9IwxwWUYFvBz RbTw7Yq3oLOlw0Mbpbi51IInpjtqSVgDEqnMLEVSHPi0JjxNe3doehhzrD6qlwK3 C32RjtyTQXEDWoq6jb5q1sxjcL0I22tbKLld7iLLu/aaWdwAit4= Received: (qmail 22416 invoked by alias); 13 Sep 2013 05:19:02 -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 22405 invoked by uid 89); 13 Sep 2013 05:19:01 -0000 Received: from mail-qe0-f48.google.com (HELO mail-qe0-f48.google.com) (209.85.128.48) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Fri, 13 Sep 2013 05:19:01 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=AWL, BAYES_00, KHOP_THREADED, NO_RELAYS autolearn=ham version=3.3.2 X-HELO: mail-qe0-f48.google.com Received: by mail-qe0-f48.google.com with SMTP id nd7so609703qeb.7 for ; Thu, 12 Sep 2013 22:18:58 -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=3e0Tf7KsRVcU9kFIMkoVOTDhXYptPh3yLW0xmduBgUQ=; b=ms0Kxh1SIP1mypR+bq+sSPGflYassQi/nPAjNj0MJ5MqlwgnmGPPk93o2+oRQtnr6t 91dERanmVm4Thh+bnES+t1grVj0rb0EPEF7IEp/7v1cDFfXsdQk0EbPCIPrBxcf9xc2C DeKQa5jSmS5iSeAJr5KIXCptc8YjaZtjrajlhWBm4lyzoTAmXa9VtbaLrgdSkzzPWAhy JPblnusZ9XzKWsN13N6v5HQTwZ+0R8AxmRcik/aw7WL4nuGKJIUxwUBhRKHad8o/+55Q M1qMl4XrtU5fLLI8lwTa7JwBQ2iqqWTRm2sYqLjHR624Ama9K6KJ3PsuaOxznkRZyezZ vfMA== X-Gm-Message-State: ALoCoQly1a/3BUmoDhhRLJk7dtcZqqEFV2hLtIVeX2cgLNNLsABEkmLh3eTStdf/kEazZaaZOq85oLWUBcVi/gKrQNZWrd/6zRTppMRxFnn+fLRju1DrRcsjaiSt7jD+EI82TbRpFPa5eAhTBBR2H3jssVpkpbmVnLvei8I1/3uBGRXK16DTqnPd0+4FGo7aDuEpxczwT7WUoMJF94gJ+CY7O8B//Mixwg== MIME-Version: 1.0 X-Received: by 10.49.107.105 with SMTP id hb9mr20921782qeb.74.1379049538133; Thu, 12 Sep 2013 22:18:58 -0700 (PDT) Received: by 10.49.24.225 with HTTP; Thu, 12 Sep 2013 22:18:58 -0700 (PDT) In-Reply-To: References: Date: Thu, 12 Sep 2013 22:18:58 -0700 Message-ID: Subject: Re: [Google] Fix test failure after porting __gcov_get_profile_prefix from google/4_7 From: Teresa Johnson To: Xinliang David Li Cc: "gcc-patches@gcc.gnu.org" X-IsSubscribed: yes On Thu, Sep 12, 2013 at 2:32 PM, Xinliang David Li wrote: > When absolute path is specified for the object file, no prefix will be > prepended to the gcda path. If you record the cwd as in the > _gcov_profile_prefix variable, at profile dump time, the prefix will > be wrong -- as it is never used. Yes I think I agree with you now. Basically, for non-lto compilations, you get the following: -fprofile-generate={path} -> no auxbase-strip and profile_data_prefix={path} -fprofile-generate -o relative/path/to/file.o -> no auxbase-strip and profile_data_prefix=getpwd() -fprofile-generate -o /absolute/path/to/file.o -> auxbase-strip /absolute/path/to/file.o and profile_data_prefix=NULL But with -flto and -fprofile-generate -o relative/path/to/file.o -> auxbase-strip /tmp/file.ltrans.out and profile_data_prefix=NULL In the LTO case the gcda files will go into cwd, but not in the case just above where the absolute path is given to the object file. However, for our purposes we rely on the path being specified to -fprofile-generate={path} in places where we query __gcov_profile_prefix in order to find the dump directory. Therefore, I think it is best to simply record a NULL string as the profile_data_prefix value in all cases where profile_data_prefix=NULL. Here is the patch I am regression testing: > > David > > On Thu, Sep 12, 2013 at 2:07 PM, Teresa Johnson wrote: >> On Thu, Sep 12, 2013 at 1:20 PM, Xinliang David Li wrote: >>> On Thu, Sep 12, 2013 at 1:06 PM, Teresa Johnson wrote: >>>> After porting r198033 from google/4_7 to google/4_8 a test case failed >>>> with an assert when trying to take the strlen of profile_data_prefix. >>>> >>>> In most cases this is either set from the directory specified to >>>> -fprofile-generate=, or to getpwd when a directory is not specified. >>>> However, the exception is when no directory is specified for >>>> -fprofile-generate and -auxbase-strip option is used with the absolute >>>> pathname. In that case the code does not set profile_data_prefix since >>>> the filenames already have the full path. >>>> >>>> In the code that sets __gcov_get_profile_prefix, the fix is to simply >>>> check if profile_data_prefix is still NULL, and if so just set via >>>> getpwd. >>> >>> Why setting it to getpwd() val? Should it be set to null instead? >> >> The specified behavior when no path is given to -fprofile-generate (or >> -fprofile-dir) is to use the current directory. >> >> The case where this was happening was an lto test case, where lto1 was >> first run in WPA (-fwpa) mode and was emitting the ltrans output to a >> /tmp/ path (-fltrans-output-list=/tmp/cciR1m1o.ltrans.out). Then lto1 >> was run again in LTRANS mode (-fltrans) with -auxbase-strip >> /tmp/cciR1m1o.ltrans0.ltrans.o, triggering the problem. >> >> Teresa >> >>> >>> David >>> >>>> >>>> Passes regression tests and failure I reproduced. Ok for google branches? >>>> >>>> Thanks, >>>> Teresa >>>> >>>> 2013-09-12 Teresa Johnson >>>> >>>> * tree-profile.c (tree_init_instrumentation): Handle the case >>>> where profile_data_prefix is NULL. >>>> >>>> Index: tree-profile.c >>>> =================================================================== >>>> --- tree-profile.c (revision 202500) >>>> +++ tree-profile.c (working copy) >>>> @@ -470,8 +470,11 @@ tree_init_instrumentation (void) >>>> DECL_ASSEMBLER_NAME (gcov_profile_prefix_decl)); >>>> TREE_STATIC (gcov_profile_prefix_decl) = 1; >>>> >>>> - prefix_len = strlen (profile_data_prefix); >>>> - prefix_string = build_string (prefix_len + 1, profile_data_prefix); >>>> + const char *prefix = profile_data_prefix; >>>> + if (!prefix) >>>> + prefix = getpwd (); >>>> + prefix_len = strlen (prefix); >>>> + prefix_string = build_string (prefix_len + 1, prefix); >>>> TREE_TYPE (prefix_string) = build_array_type >>>> (char_type_node, build_index_type >>>> (build_int_cst (NULL_TREE, prefix_len))); >>>> >>>> >>>> -- >>>> Teresa Johnson | Software Engineer | tejohnson@google.com | 408-460-2413 >> >> >> >> -- >> Teresa Johnson | Software Engineer | tejohnson@google.com | 408-460-2413 Index: tree-profile.c =================================================================== --- tree-profile.c (revision 202500) +++ tree-profile.c (working copy) @@ -470,8 +470,15 @@ tree_init_instrumentation (void) DECL_ASSEMBLER_NAME (gcov_profile_prefix_decl)); TREE_STATIC (gcov_profile_prefix_decl) = 1; - prefix_len = strlen (profile_data_prefix); - prefix_string = build_string (prefix_len + 1, profile_data_prefix); + const char null_prefix[] = "\0"; + const char *prefix = null_prefix; + prefix_len = 0; + if (profile_data_prefix) + { + prefix_len = strlen (profile_data_prefix); + prefix = profile_data_prefix; + } + prefix_string = build_string (prefix_len + 1, prefix); TREE_TYPE (prefix_string) = build_array_type (char_type_node, build_index_type (build_int_cst (NULL_TREE, prefix_len)));