From patchwork Thu Apr 25 23:42:44 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sriraman Tallam X-Patchwork-Id: 239605 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 228392C00F3 for ; Fri, 26 Apr 2013 09:42:55 +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=ExH3LOjwi4m+Yh2yLO tx/7G6ngvolurRsXXvdyI7oZ8ATANY+I9vLHxS3OiMF8i/c+0CprhdDgelRKLip0 u/eyTAjPlwlHgEMprNJTgTlXi9TKJBWrOhMFRK0scz7HO/6vVya3JGRapeqddygy AXQmOcT1AwaTugM/ZMuz+yuQI= 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=unj3yE4w/pPeXHP+HqXl2ys5 eDs=; b=NjkmQOuDS57siz0og/SA76o3VvpYUZv/OHYWad/Th8IvWN/4aM02F4Db ePFv1tbVBvsLCgEflO/bcavMz1FoPJiKMSM2vwUkULYzwHMzDBVyGco1qGkNAA0X 7LHMT/XeP1+nltbHsG8Le6vIHftTtNem26RYZN7frXfFqALITf8= Received: (qmail 31940 invoked by alias); 25 Apr 2013 23:42:47 -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 31929 invoked by uid 89); 25 Apr 2013 23:42:47 -0000 X-Spam-SWARE-Status: No, score=-3.8 required=5.0 tests=AWL, BAYES_00, KHOP_THREADED, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, RP_MATCHES_RCVD, SPF_PASS 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; Thu, 25 Apr 2013 23:42:45 +0000 Received: by mail-oa0-f48.google.com with SMTP id f4so3418781oah.35 for ; Thu, 25 Apr 2013 16:42:44 -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:cc:content-type:x-gm-message-state; bh=CpS453xyNP8SmFTI6ESB+9VRifnfzl7Y2OduBaUqEH8=; b=kK8ZLmgEjrbuOYMZHyjzW9WT3IEpag019ItUCAoWeRwC66CRkRZ9fIoMdZQ3gtvcWK wjnbGJVSfEd4cFMJDePXgCLf+12Px55MvlVLAAcSX3j6PtASQaRWvL91wb+fq05DyNCe 0CIN8QqGHNLNqzvNrEXhZ49J6hz0JkKe3ojzeueGlo6Z2a5fgDhFWbzsTtsiI7jqR/U5 D5GDlX1PYKQvHfKvInkxH+P8uQWd/DKCZziQsKEwIHyMfpzPyJexkXW3wYJOoAJ4x/GT gkEEJhX3MKIuFa8HUYcsrryB2XBjH7OGtEP+9c7/Z9H1AqTmW48mnqGDQSUkrilpHOSw OP0A== MIME-Version: 1.0 X-Received: by 10.182.241.134 with SMTP id wi6mr16339882obc.46.1366933364111; Thu, 25 Apr 2013 16:42:44 -0700 (PDT) Received: by 10.182.245.229 with HTTP; Thu, 25 Apr 2013 16:42:44 -0700 (PDT) In-Reply-To: <20130424045922.GT12880@tucnak.redhat.com> References: <20130424045922.GT12880@tucnak.redhat.com> Date: Thu, 25 Apr 2013 16:42:44 -0700 Message-ID: Subject: Re: [PATCH] Generate a label for the split cold function while using -freorder-blocks-and-partition From: Sriraman Tallam To: Jakub Jelinek Cc: GCC Patches , Teresa Johnson , David Li X-Gm-Message-State: ALoCoQkjba/7T0DvSNg6SBveF4gdZEpAgv19D97K4tPT6ruVkSGhClXK5XIUfAiMoTZzWLNzgq8t5bj+dUL6fG0Yq1VuaQJW1Y8otX5zjO+KJsjE/dVFlAe0J2Qu/fk7bimYpEM8SXEjPJCJDigmq5RwF0jPSLn5hgvwqvWxtbIvQSSBnduxhWxIdcuSH+2KWN+B7Jc1EwH3 X-Virus-Found: No X-IsSubscribed: yes On Tue, Apr 23, 2013 at 9:59 PM, Jakub Jelinek wrote: > On Tue, Apr 23, 2013 at 03:58:06PM -0700, Sriraman Tallam wrote: >> 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. >> >> * final.c (final_scan_insn): Generate cold label name by suffixing >> ".cold" to function's assembler name. >> * gcc.dg/tree-prof/cold_partition_label.c: New test. > > This doesn't honor NO_DOT_IN_LABEL (and NO_DOLLAR_IN_LABEL). Fixed, by calling clean_symbol_name > Also, don't some function start in cold section and then switch into hot > section? I am not able to generate a test where this happens. However, I fixed this problem by generating the cold label only when the first function block is not cold. Patch attached, please see if this is ok. Thanks Sri > > Jakub Index: final.c =================================================================== --- final.c (revision 198212) +++ final.c (working copy) @@ -2101,6 +2101,22 @@ 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); + clean_symbol_name (cold_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 } } */