From patchwork Thu May 2 20:41:45 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carrot Wei X-Patchwork-Id: 241080 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 90AE82C00BF for ; Fri, 3 May 2013 06:42:02 +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=aZTqtlqOeZH09Vov9vhWkXn3D7sYVP8xMjnX1L4a2J2K9U ho06Wu1X+n6wh/f8ByvSremN4ZIMWFxIKe8w6bzFxtw20tatB5hMNgXJf5XGE/Ld uqc+biZO1U0SaLymBDILQZQXe/FSX03K1C4EqHkLQ7WrP6q864g+FTH+PPguM= 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=66lKy1Hqbui6tYsQGwIq2OKwppg=; b=LaDkhDxp0JT7laY5AVV1 zqb0z7rtfTlIua2tIexW32elN1+kzFsANyY2E+AZoy9G/nNmqOlYv9qFdhpT0rbm 0YL/h49AeouG6jih4lp1Ax+EoUiN8+uYNnG6bcuxp8xeDf5HseLgJaqmQ+1g2Nxd 7NejHXq90gZTdDNs5/EQcAc= Received: (qmail 12129 invoked by alias); 2 May 2013 20:41:55 -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 12084 invoked by uid 89); 2 May 2013 20:41:49 -0000 X-Spam-SWARE-Status: No, score=-4.0 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, RP_MATCHES_RCVD, SPF_PASS, TW_TM autolearn=ham version=3.3.1 Received: from mail-qa0-f54.google.com (HELO mail-qa0-f54.google.com) (209.85.216.54) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Thu, 02 May 2013 20:41:47 +0000 Received: by mail-qa0-f54.google.com with SMTP id o13so10463qaj.20 for ; Thu, 02 May 2013 13:41:45 -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=hiFRgIQHzscSJ/KQlSTNkMll+v4lHzD4PbA5G0UqM6M=; b=nNJMYf29ul9lx0zZrm2YcJcR9WMDZ+A1Q1NW+8GTjTD8Nw7mlsTSibqyw1vAa61gjG BKxo1XOqmoh5IPySbxyyVJ82us5piaiFbWmjqqedUthJnWvGj+tqDM7PBPcXaSlhtYnR IZuOqLlsI64Rzz6bjCtCEy0qIreJWffikoBV6P1bhzrboDaUlj6soqdtZXH3HenH/eMe Z2z/AvMcalrYT6xztn3cnzXT/QmBTJ0UCJrwqzjdlqGz0dH6V0Rzi1jln0gw5PFbw//z JtRzGVVlNrk72swDb/2KhaJgqt5jVfKWT7df5Bf54oa/sbMnvDhfOzAYn9iwp87yFzRM DDPQ== MIME-Version: 1.0 X-Received: by 10.229.166.144 with SMTP id m16mr3412224qcy.140.1367527305670; Thu, 02 May 2013 13:41:45 -0700 (PDT) Received: by 10.229.178.195 with HTTP; Thu, 2 May 2013 13:41:45 -0700 (PDT) Date: Thu, 2 May 2013 13:41:45 -0700 Message-ID: Subject: [PATCH] Refactor coverage.c, outline the construction of gcov constructor From: Carrot Wei To: "gcc-patches@gcc.gnu.org" , Diego Novillo X-Gm-Message-State: ALoCoQnFDRGgSPZmHmbpgOMiA+Rq4SQFwT7yMKJ8p49yP1z1slqXcty9GMg2XG22p+SyZezAKY+vUp/CzHMTvFtnSKHm2z3WnT0wKZ7lZsLehuF4U+Qh2JJxvl9GcrXdEikfV7LBQSeNAxF4XKqpIZe9a0/ttxGA14kDjutvwSVBuk9WfHhSdtzp4ekabkbBdZyXERlbhuKL This patch outline the construction of gcov constructor from coverage_obj_init as a separate function build_init_ctor. It passed bootstrap and regression test on x86-64. OK for trunk and google 4.7 branch? thanks Carrot 2013-05-02 Guozhi Wei * coverage.c (gcov_info_type): New global variable. (coverage_obj_init): Move the construction of gcov constructor to (build_init_ctor): here. Index: coverage.c =================================================================== --- coverage.c (revision 198557) +++ coverage.c (working copy) @@ -99,6 +99,7 @@ /* Coverage info VAR_DECL and function info type nodes. */ static GTY(()) tree gcov_info_var; +static GTY(()) tree gcov_info_type; static GTY(()) tree gcov_fn_info_type; static GTY(()) tree gcov_fn_info_ptr_type; @@ -967,6 +968,32 @@ return build_constructor (info_type, v1); } +/* Generate the constructor function to call __gcov_init. */ + +static void +build_init_ctor () +{ + tree ctor, stmt, init_fn; + + /* Build a decl for __gcov_init. */ + init_fn = build_pointer_type (gcov_info_type); + init_fn = build_function_type_list (void_type_node, init_fn, NULL); + init_fn = build_decl (BUILTINS_LOCATION, FUNCTION_DECL, + get_identifier ("__gcov_init"), init_fn); + TREE_PUBLIC (init_fn) = 1; + DECL_EXTERNAL (init_fn) = 1; + DECL_ASSEMBLER_NAME (init_fn); + + /* Generate a call to __gcov_init(&gcov_info). */ + ctor = NULL; + stmt = build_fold_addr_expr (gcov_info_var); + stmt = build_call_expr (init_fn, 1, stmt); + append_to_statement_list (stmt, &ctor); + + /* Generate a constructor to run it. */ + cgraph_build_static_cdtor ('I', ctor, DEFAULT_INIT_PRIORITY); +} + /* Create the gcov_info types and object. Generate the constructor function to call __gcov_init. Does not generate the initializer for the object. Returns TRUE if coverage data is being emitted. */ @@ -974,7 +1001,6 @@ static bool coverage_obj_init (void) { - tree gcov_info_type, ctor, stmt, init_fn; unsigned n_counters = 0; unsigned ix; struct coverage_data *fn; @@ -1020,24 +1046,8 @@ ASM_GENERATE_INTERNAL_LABEL (name_buf, "LPBX", 0); DECL_NAME (gcov_info_var) = get_identifier (name_buf); - /* Build a decl for __gcov_init. */ - init_fn = build_pointer_type (gcov_info_type); - init_fn = build_function_type_list (void_type_node, init_fn, NULL); - init_fn = build_decl (BUILTINS_LOCATION, FUNCTION_DECL, - get_identifier ("__gcov_init"), init_fn); - TREE_PUBLIC (init_fn) = 1; - DECL_EXTERNAL (init_fn) = 1; - DECL_ASSEMBLER_NAME (init_fn); + build_init_ctor (); - /* Generate a call to __gcov_init(&gcov_info). */ - ctor = NULL; - stmt = build_fold_addr_expr (gcov_info_var); - stmt = build_call_expr (init_fn, 1, stmt); - append_to_statement_list (stmt, &ctor); - - /* Generate a constructor to run it. */ - cgraph_build_static_cdtor ('I', ctor, DEFAULT_INIT_PRIORITY); - return true; }