From patchwork Mon Nov 18 20:01:04 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sriraman Tallam X-Patchwork-Id: 292181 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)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 1A7692C0094 for ; Tue, 19 Nov 2013 07:01:24 +1100 (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=cB5j+1JcqWfO3QSSnz 7ZRsySNeMyAaFxkMc+5oswYsc6jaEER2V36n7u8k21IdYGzo/DQGqhAmdv414epl Cs+ODE8VvYnO21TwAjMN0S9b/HNiyJF9fVayhPlQyswCaMNjTyrIgt7Fzz6ytLB4 XLAydgXHUMnNVDWktT5gqDTHk= 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=G7c374GrtUeaWcdB8KTICNzh dBQ=; b=B/zhGvAkFRQJrsR5ROnMBZYpsuZBqLngTV+UEQGinCBdTy2aWUGNKMn7 qFBOiaS+YQawroEKNA2ZuZN3VX2dgajHZd+STGreq9gspZI3njlElCpg1K8ICKuq OaQs8fMWICX4xb28N4WWlEqoQ2+Doca+aQ9t3NOy0Lv68sST3MA= Received: (qmail 16720 invoked by alias); 18 Nov 2013 20:01:14 -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 16711 invoked by uid 89); 18 Nov 2013 20:01:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.2 required=5.0 tests=AWL, BAYES_50, RCVD_IN_DNSWL_LOW, RDNS_NONE, SPF_PASS autolearn=no version=3.3.2 X-HELO: mail-vb0-f42.google.com Received: from Unknown (HELO mail-vb0-f42.google.com) (209.85.212.42) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Mon, 18 Nov 2013 20:01:13 +0000 Received: by mail-vb0-f42.google.com with SMTP id p14so5137954vbm.1 for ; Mon, 18 Nov 2013 12:01:04 -0800 (PST) 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=+eU4iJ7OL4wGPa27EkTK/ZMTX12rY/djojH4n1EMPQw=; b=B/liYYhbayyNTWUbjlgb209WffhfG1WdqYNKagbzcglwVuRpT54ZhPGzi+WKUVR/PX aTA9q5y8nCIte5QKSNkz5lDVPRU3KE+yIq3itz/7YtPb0iqRae/zbcZyxilEJxKPDd2L WH0/3sw5a7UylVZlkeeqTMW2G5Ae5iT2h6xEIa2xcwsDnXkkjyb9by00gM4a3f2l7LXH 5P2vHu+s0A7dxYgibft4/Puw1Jp8PZKkYm7/G6wKo5HXtdmP7i3EwWeyhZHlZ59LV3G3 VJfxsB46boyHRPDGLXnhdonoeeXP6oe7dOyxD7F2KUqzr6YrHo1bnlJ/RlN551hVXVoF 1wow== X-Gm-Message-State: ALoCoQkpE3k/yJkvyZMlpR86KfmrmHbjvOPey00iDWFYtYBuz4O0wWrQ/F5hv4NDxoSs/fqI2m3XBgk7xvpKc4cd4pK9WtaTW4IxA1Wn1uMjae/S61zWY3wcwfui4YktqyrzOov33ViZjewQllqJAbxCCQOFRm5kVfCOvasPfw9gt8zfk7PhpGgq/9xLZddaCcsZA+HudMfcXhP0zXtbuREC7qr/ElywYw== MIME-Version: 1.0 X-Received: by 10.58.254.200 with SMTP id ak8mr17371841ved.12.1384804864769; Mon, 18 Nov 2013 12:01:04 -0800 (PST) Received: by 10.52.167.35 with HTTP; Mon, 18 Nov 2013 12:01:04 -0800 (PST) In-Reply-To: References: Date: Mon, 18 Nov 2013 12:01:04 -0800 Message-ID: Subject: Re: [PATCH] Generate a label for the split cold function while using -freorder-blocks-and-partition From: Sriraman Tallam To: Cary Coutant Cc: Steven Bosscher , Teresa Johnson , GCC Patches , David Li , Richard Biener X-IsSubscribed: yes On Wed, Nov 13, 2013 at 10:00 AM, Sriraman Tallam wrote: > On Tue, Nov 12, 2013 at 10:10 AM, Cary Coutant wrote: >>>>> Is there a format for compiler-defined labels that would not be able >>>>> to clash with other user-generated labels? >>>> >>>> My understanding is that the "." in the generated name ensures that it >>>> will not clash with user-generated labels which cannot contain ".". So >>>> this should not be an issue. >>> >>> Is that true for all languages? I don't think we can make that >>> assumption. Also, there may be clashes with other compiler generated >>> symbols. I know of at least one Fortran compiler that composes names >>> for module symbols as "modulename.symbolname", and if symbolname is >>> "cold" then you can have a clash. >> >> GCC already uses "." to generate names for cloned functions, and picks >> a different separator for targets where "." is legal (see >> clone_function_name in cgraphclones.c). It would probably be a good >> idea to use clone_function_name to generate the new name (in >> particular, because the C++ demangler already knows how to handle that >> style when it's applied to mangled names). > > I have modified my original patch to use clone_function_name to > generate the cold part label and attached it. Is this patch fine for commit? Thanks Sri > > Thanks > Sri > > >> >> -cary Patch to generate labels for cold function parts that are split when using the option -freorder-blocks-and-partition. The cold label name is generated by suffixing "cold" to the assembler name of the hot function in a demangler friendly way. This is useful when getting back traces from gdb when the cold function part does get executed. * final.c (final_scan_insn): Generate cold label name by suffixing "cold" to function's name. * gcc.dg/tree-prof/cold_partition_label.c: New test. Index: final.c =================================================================== --- final.c (revision 204712) +++ final.c (working copy) @@ -2167,6 +2167,15 @@ final_scan_insn (rtx insn, FILE *file, int optimiz targetm.asm_out.function_switched_text_sections (asm_out_file, current_function_decl, in_cold_section_p); + /* Emit a label for the split cold section. Form label name by + suffixing "cold" to the original function's name. */ + if (in_cold_section_p) + { + tree cold_function_name + = clone_function_name (current_function_decl, "cold"); + ASM_OUTPUT_LABEL (asm_out_file, + IDENTIFIER_POINTER (cold_function_name)); + } break; case NOTE_INSN_BASIC_BLOCK: Index: testsuite/gcc.dg/tree-prof/cold_partition_label.c =================================================================== --- testsuite/gcc.dg/tree-prof/cold_partition_label.c (revision 0) +++ testsuite/gcc.dg/tree-prof/cold_partition_label.c (revision 0) @@ -0,0 +1,39 @@ +/* Test case to check if function foo gets split and the cold function + gets a label. */ +/* { dg-require-effective-target freorder } */ +/* { dg-options "-O2 -freorder-blocks-and-partition --save-temps" } */ + +#define SIZE 10000 + +const char *sarr[SIZE]; +const char *buf_hot; +const char *buf_cold; + +__attribute__((noinline)) +void +foo (int path) +{ + int i; + if (path) + { + for (i = 0; i < SIZE; i++) + sarr[i] = buf_hot; + } + else + { + for (i = 0; i < SIZE; i++) + sarr[i] = buf_cold; + } +} + +int +main (int argc, char *argv[]) +{ + buf_hot = "hello"; + buf_cold = "world"; + foo (argc); + return 0; +} + +/* { dg-final-use { scan-assembler "foo.cold" } } */ +/* { dg-final-use { cleanup-saved-temps } } */