From patchwork Sun Apr 21 00:09:47 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sriraman Tallam X-Patchwork-Id: 238194 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 7EA622C00C8 for ; Sun, 21 Apr 2013 10:09:58 +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=ZRnWP81akCLTWkB9g3KEU csG2nB52mkuZw/vSOizk77xabWdO/4pNjvuvo+xAJokEMNKbIqU18XVmh9ZiAU7P k6o9Xu9W5SJbgodJkq6PrXVqH0mTIHeiFCUgTt0KXdpbpHI4ZFj7YgLz+yWhMIwo 0j6xDUaarbfcVXGxWzRh5I= 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=m928+LA/i7wvGJdC/KZT4Zi7LGM =; b=muAxxaxBKefl9op4R+291CqH0C52kBR+9ncITzVYa1sTNpD9C/NjJOQ2vA3 JRDWG7VqdHVdlbfhUzrxMjh81PetPbBlhfFLN5qNntolxeVGrDwtmZoh95okSsw6 qi6Rfy0qeASFAY7j6OsChkMfpxPk4NOsX/5JRbrI64g5rUQ0= Received: (qmail 1321 invoked by alias); 21 Apr 2013 00:09:50 -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 1305 invoked by uid 89); 21 Apr 2013 00:09:50 -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-f48.google.com (HELO mail-oa0-f48.google.com) (209.85.219.48) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Sun, 21 Apr 2013 00:09:49 +0000 Received: by mail-oa0-f48.google.com with SMTP id f4so3167713oah.21 for ; Sat, 20 Apr 2013 17:09:47 -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=GReeT/6zQiN0Lbaa3xSgaNdCHOa9cSo4VjykE4l7pnU=; b=bYe87Ue19UZYyo/kn3hiWE4ZHTLnkxzpEsvFKCj5Cd1O05hbxW7hukRrE0bvmf4KHy ImNmM3wzWP5KOkr17Ro4cKLVABlPVrkZzWaZPvMRO6PXkHyPt0/Ht7lb5V0QVG5hNXID GGO+NgEO8PooFsM4UNhhZO2+VhfwBPNkGaxEAYeWNPNTn+oOmItDtH34gJ1VowolUdbo SczYqqdnXOoHtnpxzFvL/A02cEs7JtPA2QRBDMBixRyM1467qxA5D7X2LPftd3iCMg2m 457sI1VzDqkRjcPcJQdMTvCCFzZUnlUmQEdZHk8ramVQSUzgGOrZ5M8AuTZuLFDDL7fQ mlDQ== MIME-Version: 1.0 X-Received: by 10.60.144.42 with SMTP id sj10mr7149902oeb.130.1366502987557; Sat, 20 Apr 2013 17:09:47 -0700 (PDT) Received: by 10.182.245.229 with HTTP; Sat, 20 Apr 2013 17:09:47 -0700 (PDT) In-Reply-To: References: Date: Sat, 20 Apr 2013 17:09:47 -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: ALoCoQkiJEVDv8/MeRUZB+LZr+1KmpHso1azcG8Xf5g/Huqx7ckMj/oxOGugqELUWAXdWzkbs0uM/QgjdKHQlfGLchEIOcI4zqPInCxoMA5wTSfjDIj9o1FVqUSLtIrxF/QHfBFPSKAPImsTHUyi+mLHM88LtLfkgaBK3pJ7TgxIL7ZZ2y+hdB0fPE98AIoiAlW/Kwd5ICOd X-Virus-Found: No X-IsSubscribed: yes Fixed a bug in the previous patch sent, where I did not check if the switch section was actually to the cold function part. Updated patch attached. Thanks Sri On Fri, Apr 19, 2013 at 1:58 PM, Sriraman Tallam wrote: > 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) @@ -1934,6 +1934,21 @@ 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. */ + if (in_cold_section_p) + { + char *cold_function_name; + const char *mangled_function_name; + tree asm_name = DECL_ASSEMBLER_NAME (current_function_decl); + + mangled_function_name = IDENTIFIER_POINTER (asm_name); + 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 } } */