From patchwork Fri Apr 19 20:43:56 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sriraman Tallam X-Patchwork-Id: 238101 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 C07152C0223 for ; Sat, 20 Apr 2013 06:44:05 +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:date:message-id:subject:from:to:content-type; q= dns; s=default; b=j64NSP5uapOYG+DQFMg6MN9wLqn81dXSm90/8nlpt/iSAM eblGBi7H1dnAHXdixoLXD0YlqQA/GYW5hrVSJircwjgjS/jYcppbnQEXIRmSU8He fsVMLSInaYr3GDzCWYA6boFFzk8HXs4EaPwLE5M2JvkiUMGutnjS4KkoNyz+A= 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:date:message-id:subject:from:to:content-type; s= default; bh=fwCNEwbgTO9M7vTRjGuEEFIeM+8=; b=HaUdywzDcyDH0drTKF1r MPWvwGLpc9l42No94AWnZADiMZ9b0FMDCSslYYKxSu/LFeNM7HKojap1sh89+24Z mHuuCxwRC0NJ2h+66qqoisXB+wCCd07IsmEuC7QH+i0Dq6EGN36ZjAZs1TSj+7Oe 4swCT572u5Lw3InZrub6luc= Received: (qmail 21862 invoked by alias); 19 Apr 2013 20:43:59 -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 21853 invoked by uid 89); 19 Apr 2013 20:43:59 -0000 X-Spam-SWARE-Status: No, score=-5.1 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_TRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, RP_MATCHES_RCVD autolearn=ham version=3.3.1 Received: from mail-oa0-f53.google.com (HELO mail-oa0-f53.google.com) (209.85.219.53) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Fri, 19 Apr 2013 20:43:58 +0000 Received: by mail-oa0-f53.google.com with SMTP id m6so4185757oag.40 for ; Fri, 19 Apr 2013 13:43:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-received:date:message-id:subject:from:to :content-type:x-gm-message-state; bh=ISAWssv8elk3SUf/y9y9T4rYcp0V8BoEg1uSkzwB0RQ=; b=pGaMQSHNktknazU3j8FhctLH9ti8hd40mN/grjCJ2cnUUg/1iy/i/pgcawWDuMHLbC mcUO8Q8pwYbWDmatWLI6HIq4GH7AAcCzCxltRlXA6oD0n0MdcZGRm3hM9ucikauIH2OK 5LrNq4oRxvK3f7sK4WC8+c4MFPbuTWOFigztNrPH+OzS0rkwnxPPWQ50kyMHsJRm++J9 1p7R3b8HQ/dxqbMXa7fhYGwAjEw1VX+ZLzg+1pjp87MyGinhTxnaIe8DTNG3gRDGppLu jfnz8BcY8jGJ1Kt+0mLNTTR7/eSJ3Xf7XHTizqaBv+cJf3+Fzw6XsuPeGAfoidkCQNpa 1EDQ== MIME-Version: 1.0 X-Received: by 10.60.60.10 with SMTP id d10mr4876062oer.6.1366404236410; Fri, 19 Apr 2013 13:43:56 -0700 (PDT) Received: by 10.182.245.229 with HTTP; Fri, 19 Apr 2013 13:43:56 -0700 (PDT) Date: Fri, 19 Apr 2013 13:43:56 -0700 Message-ID: Subject: [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: ALoCoQlv1LxPOebqQIYBwmG8ij51Q/1UnK2ehtHzE0dNYDmW1uQfq0t6sPaIRMA7DYnUnCAO82YH1XcgHP11BcTpIplxY4cHdFyT15FqyBrHzeqiZNoQ21ook0lyhH2iR4GsIaYVoELz86GxJOqgnFuvHMLIyaCMOWsmuUZRzAdaZzZ61XlUEEa/Fc4dc4dd24IjuM+yG1mQ X-Virus-Found: No X-IsSubscribed: yes 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: 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 } } */ 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. */ + 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%s", mangled_function_name, + ".cold"); + ASM_OUTPUT_LABEL (asm_out_file, cold_function_name); + XDELETEVEC (cold_function_name); break; case NOTE_INSN_BASIC_BLOCK: