From patchwork Fri Apr 19 20:58:57 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sriraman Tallam X-Patchwork-Id: 238109 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 D46702C014D for ; Sat, 20 Apr 2013 06:59:06 +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:content-type; q=dns; s=default; b=fzhpkYWX5/UKHYQ321/HM NavGytVh3tvV1NOlt7Qw0x/kv2akCbPhFtjtL+oHr/6Z9/ugNlE2/QsJOHUV/1IH qXA4+DRzYzyuPYYrfO3DLXcDMJ+kML1I2gx0bmpbyNikcSo7k7hHL26MaZoUEEd0 P4zXeWYONEjGYEtV3hHwhE= 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:content-type; s=default; bh=TTTahk2pZL1H8zMrnzckeaTqr/8 =; b=aiMojdbp0xB+3/D6su8RRZk4H4DWZXz00tHJ9w73XUaklJyn1pJQMl8GsI2 JMdL1GQruPwcZ8RQ8lk1g4hkydBduPna3J8Oq7SaSVbHT8OuF2ccxCTljHkA01/Z wgpv/G9HyZyHCzwHTXIMNKJZ5K9Sz2HXbgGDeuzUWkPncg74= Received: (qmail 29594 invoked by alias); 19 Apr 2013 20:59:00 -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 29584 invoked by uid 89); 19 Apr 2013 20:59:00 -0000 X-Spam-SWARE-Status: No, score=-5.9 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_TRUST, KHOP_THREADED, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, RP_MATCHES_RCVD autolearn=ham version=3.3.1 Received: from mail-oa0-f52.google.com (HELO mail-oa0-f52.google.com) (209.85.219.52) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Fri, 19 Apr 2013 20:58:59 +0000 Received: by mail-oa0-f52.google.com with SMTP id k18so4183979oag.25 for ; Fri, 19 Apr 2013 13:58:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type:x-gm-message-state; bh=5gfnTVypjcYw/mbtkYaqIXCaPJKzEkBvTYnPsopI2XE=; b=S0cVeapOcVC1EFhkwQ0L/Drl2yphAJPXeLfFnJyr+gfYzyN/tGW21eDvI5kgAUhWq0 uZKxk+dG3xoW4wUNI23oMaSo8loG4z68UWZkyG70SPRyJ3p/fkAeyysKdX0PT5giX0iX OnEeVPDq4AiM3XMgHfsAzxJi+5Y5psCkMFLVpCVlOida20EBJDT13zA+aLUdFcmq2Mnc AH1MQaMbXLcmdtqnjvj8SO4nigWuqvX1Kh24voVJ/T2HB0VbVr9SQWCo8bURzn1C8zTF 861BxrFWsvYpymn8qx7DCpD/kRy1Ze8me2ddvJjbeUsdQANmr1kNI/RZqFhkyJCZsv+1 mOiw== MIME-Version: 1.0 X-Received: by 10.60.19.3 with SMTP id a3mr9771241oee.11.1366405138029; Fri, 19 Apr 2013 13:58:58 -0700 (PDT) Received: by 10.182.245.229 with HTTP; Fri, 19 Apr 2013 13:58:57 -0700 (PDT) In-Reply-To: References: Date: Fri, 19 Apr 2013 13:58:57 -0700 Message-ID: Subject: Re: [google][4.7] Generate a label for the split cold function while using -freorder-blocks-and-partition From: Sriraman Tallam To: Teresa Johnson , David Li , Paul Pluzhnikov , GCC Patches X-Gm-Message-State: ALoCoQm130fG2ihJOECE0gJFJ9Q3ySTep2t2C2ZxzFpTlPuVWyE/8QKo3zj1aVOA6u151MIbI0yOIGAM63CBlQcJsqJNsHOHn0F9O+joDhHgX3KQ+aGMF5ZwJwXd42B7+opIv6UaMu80ALq9FlFzquKbU8+tfREn6qSU3Yg9vKaSCrl8XRWUVL0lNpjTmHrEuixWiXOrzI7S X-Virus-Found: No X-IsSubscribed: yes Updated patch attached. Thanks Sri On Fri, Apr 19, 2013 at 1:43 PM, Sriraman Tallam wrote: > Hi, > > This patch generates 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. > > This is useful when getting back traces from gdb when the cold function > part does get executed. > > I will port this patch to trunk, please let me know what you think. > > Thanks > Sri 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. This is useful when getting back traces from gdb when the cold function part does get executed. Index: final.c =================================================================== --- final.c (revision 198081) +++ final.c (working copy) @@ -1907,6 +1907,9 @@ final_scan_insn (rtx insn, FILE *file, int optimiz #endif rtx next; + char *cold_function_name; + const char *mangled_function_name; + insn_counter++; /* Ignore deleted insns. These can occur when we split insns (due to a @@ -1934,6 +1937,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 function's assembler name. */ + mangled_function_name + = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (current_function_decl)); + cold_function_name = XNEWVEC (char, + strlen (mangled_function_name) + strlen (".cold") + 1); + sprintf (cold_function_name, "%s.cold", mangled_function_name); + ASM_OUTPUT_LABEL (asm_out_file, cold_function_name); + XDELETEVEC (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 } } */