From patchwork Mon Sep 9 16:37:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 1159870 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-508681-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="Jv7KQXYY"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46Rv2t6fR3z9s4Y for ; Tue, 10 Sep 2019 02:37:26 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type; q=dns; s= default; b=DgqFdegZqIpuQwuFZ4uvju9h2pkwk4Qf150cgUa9ltoJVxK2FcsH4 dqSExVzX0xrlspq/dn7Y/ZpQ6yLMxWTGvCdvXomyRRCzJ/EOspFg83dkn3DkJCSk Nu8yGWbBaYgn8jELmQA/MY7c+oe9LsxQAK7i42Z1WXfFK2BqSetRoY= 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:from :to:subject:date:message-id:mime-version:content-type; s= default; bh=Q6PvHmr4lnOpkGFIDvAItkjjoL8=; b=Jv7KQXYYYfnIl+zVigdi ClcbbTcJqQ53ymPsgC4Z7+SJmvD+g5GIxIbBdL7f02DVB9mE4xw9KrsamG/nNkOM wuHXdknOPuaMwZwBRvwWBNgOdski4ZqLGLN7ogvty6+hoS2ViUvAWTjUVnA5X5Bn zaOxL9ZGa8V+0DMPEoryasg= Received: (qmail 121708 invoked by alias); 9 Sep 2019 16:37:19 -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 121700 invoked by uid 89); 9 Sep 2019 16:37:18 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-8.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_SHORT autolearn=ham version=3.3.1 spammy=relying X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.110.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 09 Sep 2019 16:37:16 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4951C28 for ; Mon, 9 Sep 2019 09:37:15 -0700 (PDT) Received: from localhost (e121540-lin.manchester.arm.com [10.32.99.62]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E3E2B3F59C for ; Mon, 9 Sep 2019 09:37:14 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: Remove global REG_SETs Date: Mon, 09 Sep 2019 17:37:13 +0100 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 X-IsSubscribed: yes [Follows on from https://gcc.gnu.org/ml/gcc-patches/2019-09/msg00571.html] We currently maintain global REG_SET versions of fixed_reg_set and regs_invalidated_by_call. With bitmap_view, we can instead operate directly on the underlying HARD_REG_SETs, avoiding the need to keep the two pieces of data in sync. I have a series of patches that removes the assumption that there's a single global ABI for all functions in the translation unit, which includes not relying on having a global regs_invalidated_by_call. Removing the REG_SET equivalent is one step to doing that. Note that the affected DF code is used for EH edges or dumping only, so shouldn't be performance critical. Tested on aarch64-linux-gnu and x86_64-linux-gnu. Also tested on an sh-linux-gnu cross and comparing the assembly output for gcc.c-torture, gcc.dg and g++.dg. OK to install? Richard 2019-09-09 Richard Sandiford gcc/ * regset.h (regs_invalidated_by_call_regset): Delete. (fixed_reg_set_regset): Likewise. * reginfo.c (regs_invalidated_by_call_regset): Likewise. (fixed_reg_set_regset, persistent_obstack): Likewise. (init_reg_sets_1, globalize_reg): Update accordingly. * df.h (df_print_regset, df_print_word_regset): Take a const_bitmap instead of a bitmap. * df-core.c (df_print_regset, df_print_word_regset): Likewise. * df-problems.c (df_rd_local_compute): Use regs_invalidated_by_call instead of regs_invalidated_by_call_regset. (df_lr_confluence_n, df_md_confluence_n): Likewise. * df-scan.c (df_scan_start_dump): Likewise. * dse.c (copy_fixed_regs): Likewise. * config/sh/sh.c (sh_find_equiv_gbr_addr): Likewise. Index: gcc/regset.h =================================================================== --- gcc/regset.h 2019-09-09 17:23:00.740796731 +0100 +++ gcc/regset.h 2019-09-09 17:34:18.064026324 +0100 @@ -111,14 +111,6 @@ #define EXECUTE_IF_AND_COMPL_IN_REG_SET( #define EXECUTE_IF_AND_IN_REG_SET(REGSET1, REGSET2, MIN, REGNUM, RSI) \ EXECUTE_IF_AND_IN_BITMAP (REGSET1, REGSET2, MIN, REGNUM, RSI) \ -/* Same information as REGS_INVALIDATED_BY_CALL but in regset form to be used - in dataflow more conveniently. */ - -extern regset regs_invalidated_by_call_regset; - -/* Same information as FIXED_REG_SET but in regset form. */ -extern regset fixed_reg_set_regset; - /* An obstack for regsets. */ extern bitmap_obstack reg_obstack; Index: gcc/reginfo.c =================================================================== --- gcc/reginfo.c 2019-09-09 17:02:41.477377259 +0100 +++ gcc/reginfo.c 2019-09-09 17:34:18.064026324 +0100 @@ -92,17 +92,6 @@ #define CALL_REALLY_USED_REGNO_P(X) cal /* Declaration for the global register. */ tree global_regs_decl[FIRST_PSEUDO_REGISTER]; -/* Same information as REGS_INVALIDATED_BY_CALL but in regset form to be used - in dataflow more conveniently. */ -regset regs_invalidated_by_call_regset; - -/* Same information as FIXED_REG_SET but in regset form. */ -regset fixed_reg_set_regset; - -/* The bitmap_obstack is used to hold some static variables that - should not be reset after each function is compiled. */ -static bitmap_obstack persistent_obstack; - /* Used to initialize reg_alloc_order. */ #ifdef REG_ALLOC_ORDER static int initial_reg_alloc_order[FIRST_PSEUDO_REGISTER] = REG_ALLOC_ORDER; @@ -364,17 +353,6 @@ init_reg_sets_1 (void) CLEAR_HARD_REG_SET (call_used_reg_set); CLEAR_HARD_REG_SET (call_fixed_reg_set); CLEAR_HARD_REG_SET (regs_invalidated_by_call); - if (!regs_invalidated_by_call_regset) - { - bitmap_obstack_initialize (&persistent_obstack); - regs_invalidated_by_call_regset = ALLOC_REG_SET (&persistent_obstack); - } - else - CLEAR_REG_SET (regs_invalidated_by_call_regset); - if (!fixed_reg_set_regset) - fixed_reg_set_regset = ALLOC_REG_SET (&persistent_obstack); - else - CLEAR_REG_SET (fixed_reg_set_regset); operand_reg_set &= accessible_reg_set; for (i = 0; i < FIRST_PSEUDO_REGISTER; i++) @@ -405,10 +383,7 @@ init_reg_sets_1 (void) #endif if (fixed_regs[i]) - { - SET_HARD_REG_BIT (fixed_reg_set, i); - SET_REGNO_REG_SET (fixed_reg_set_regset, i); - } + SET_HARD_REG_BIT (fixed_reg_set, i); if (call_used_regs[i]) SET_HARD_REG_BIT (call_used_reg_set, i); @@ -426,10 +401,7 @@ init_reg_sets_1 (void) if (i == STACK_POINTER_REGNUM) ; else if (global_regs[i]) - { - SET_HARD_REG_BIT (regs_invalidated_by_call, i); - SET_REGNO_REG_SET (regs_invalidated_by_call_regset, i); - } + SET_HARD_REG_BIT (regs_invalidated_by_call, i); else if (i == FRAME_POINTER_REGNUM) ; else if (!HARD_FRAME_POINTER_IS_FRAME_POINTER @@ -442,10 +414,7 @@ init_reg_sets_1 (void) && i == (unsigned) PIC_OFFSET_TABLE_REGNUM && fixed_regs[i]) ; else if (CALL_REALLY_USED_REGNO_P (i)) - { - SET_HARD_REG_BIT (regs_invalidated_by_call, i); - SET_REGNO_REG_SET (regs_invalidated_by_call_regset, i); - } + SET_HARD_REG_BIT (regs_invalidated_by_call, i); } call_fixed_reg_set = fixed_reg_set; @@ -800,10 +769,7 @@ globalize_reg (tree decl, int i) appropriate regs_invalidated_by_call bit, even if it's already set in fixed_regs. */ if (i != STACK_POINTER_REGNUM) - { - SET_HARD_REG_BIT (regs_invalidated_by_call, i); - SET_REGNO_REG_SET (regs_invalidated_by_call_regset, i); - } + SET_HARD_REG_BIT (regs_invalidated_by_call, i); /* If already fixed, nothing else to do. */ if (fixed_regs[i]) Index: gcc/df.h =================================================================== --- gcc/df.h 2019-07-10 19:41:26.363898284 +0100 +++ gcc/df.h 2019-09-09 17:34:18.064026324 +0100 @@ -991,8 +991,8 @@ extern bool df_reg_defined (rtx_insn *, extern df_ref df_find_use (rtx_insn *, rtx); extern bool df_reg_used (rtx_insn *, rtx); extern void df_worklist_dataflow (struct dataflow *,bitmap, int *, int); -extern void df_print_regset (FILE *file, bitmap r); -extern void df_print_word_regset (FILE *file, bitmap r); +extern void df_print_regset (FILE *file, const_bitmap r); +extern void df_print_word_regset (FILE *file, const_bitmap r); extern void df_dump (FILE *); extern void df_dump_region (FILE *); extern void df_dump_start (FILE *); Index: gcc/df-core.c =================================================================== --- gcc/df-core.c 2019-07-12 11:33:27.712037291 +0100 +++ gcc/df-core.c 2019-09-09 17:34:18.060026352 +0100 @@ -2052,7 +2052,7 @@ debug_regset (regset r) This is part of making a debugging dump. */ void -df_print_regset (FILE *file, bitmap r) +df_print_regset (FILE *file, const_bitmap r) { unsigned int i; bitmap_iterator bi; @@ -2077,7 +2077,7 @@ df_print_regset (FILE *file, bitmap r) debugging dump. */ void -df_print_word_regset (FILE *file, bitmap r) +df_print_word_regset (FILE *file, const_bitmap r) { unsigned int max_reg = max_reg_num (); Index: gcc/df-problems.c =================================================================== --- gcc/df-problems.c 2019-09-09 16:53:26.701274338 +0100 +++ gcc/df-problems.c 2019-09-09 17:34:18.064026324 +0100 @@ -389,7 +389,6 @@ df_rd_local_compute (bitmap all_blocks) { unsigned int bb_index; bitmap_iterator bi; - unsigned int regno; class df_rd_problem_data *problem_data = (class df_rd_problem_data *) df_rd->problem_data; bitmap sparse_invalidated = &problem_data->sparse_invalidated_by_call; @@ -406,10 +405,9 @@ df_rd_local_compute (bitmap all_blocks) } /* Set up the knockout bit vectors to be applied across EH_EDGES. */ - EXECUTE_IF_SET_IN_BITMAP (regs_invalidated_by_call_regset, 0, regno, bi) - { - if (! HARD_REGISTER_NUM_P (regno) - || !(df->changeable_flags & DF_NO_HARD_REGS)) + if (!(df->changeable_flags & DF_NO_HARD_REGS)) + for (unsigned int regno = 0; regno < FIRST_PSEUDO_REGISTER; ++regno) + if (TEST_HARD_REG_BIT (regs_invalidated_by_call, regno)) { if (DF_DEFS_COUNT (regno) > DF_SPARSE_THRESHOLD) bitmap_set_bit (sparse_invalidated, regno); @@ -418,7 +416,6 @@ df_rd_local_compute (bitmap all_blocks) DF_DEFS_BEGIN (regno), DF_DEFS_COUNT (regno)); } - } bitmap_release (&seen_in_block); bitmap_release (&seen_in_insn); @@ -983,7 +980,10 @@ df_lr_confluence_n (edge e) /* ??? Abnormal call edges ignored for the moment, as this gets confused by sibling call edges, which crashes reg-stack. */ if (e->flags & EDGE_EH) - changed = bitmap_ior_and_compl_into (op1, op2, regs_invalidated_by_call_regset); + { + bitmap_view eh_kills (regs_invalidated_by_call); + changed = bitmap_ior_and_compl_into (op1, op2, eh_kills); + } else changed = bitmap_ior_into (op1, op2); @@ -4635,8 +4635,10 @@ df_md_confluence_n (edge e) return false; if (e->flags & EDGE_EH) - return bitmap_ior_and_compl_into (op1, op2, - regs_invalidated_by_call_regset); + { + bitmap_view eh_kills (regs_invalidated_by_call); + return bitmap_ior_and_compl_into (op1, op2, eh_kills); + } else return bitmap_ior_into (op1, op2); } Index: gcc/df-scan.c =================================================================== --- gcc/df-scan.c 2019-07-10 19:41:21.635936149 +0100 +++ gcc/df-scan.c 2019-09-09 17:34:18.064026324 +0100 @@ -313,7 +313,7 @@ df_scan_start_dump (FILE *file ATTRIBUTE rtx_insn *insn; fprintf (file, ";; invalidated by call \t"); - df_print_regset (file, regs_invalidated_by_call_regset); + df_print_regset (file, bitmap_view (regs_invalidated_by_call)); fprintf (file, ";; hardware regs used \t"); df_print_regset (file, &df->hardware_regs_used); fprintf (file, ";; regular block artificial uses \t"); Index: gcc/dse.c =================================================================== --- gcc/dse.c 2019-09-09 16:53:26.701274338 +0100 +++ gcc/dse.c 2019-09-09 17:34:18.064026324 +0100 @@ -2392,7 +2392,7 @@ copy_fixed_regs (const_bitmap in) bitmap ret; ret = ALLOC_REG_SET (NULL); - bitmap_and (ret, in, fixed_reg_set_regset); + bitmap_and (ret, in, bitmap_view (fixed_reg_set)); return ret; } Index: gcc/config/sh/sh.c =================================================================== --- gcc/config/sh/sh.c 2019-09-09 17:02:41.549376753 +0100 +++ gcc/config/sh/sh.c 2019-09-09 17:34:18.060026352 +0100 @@ -11695,7 +11695,7 @@ sh_find_equiv_gbr_addr (rtx_insn* insn, { if (CALL_P (DF_REF_INSN (d))) { - if (REGNO_REG_SET_P (regs_invalidated_by_call_regset, GBR_REG)) + if (TEST_HARD_REG_BIT (regs_invalidated_by_call, GBR_REG)) return NULL_RTX; else continue;