From patchwork Sun Jan 9 04:24:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sandra Loosemore X-Patchwork-Id: 49763 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 50022386F437 for ; Sun, 9 Jan 2022 04:24:34 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa3.mentor.iphmx.com (esa3.mentor.iphmx.com [68.232.137.180]) by sourceware.org (Postfix) with ESMTPS id 8A6FD3858401 for ; Sun, 9 Jan 2022 04:24:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8A6FD3858401 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com IronPort-SDR: 7dE18LC42tQPXmtkBzavj/YHVFcBmSCsWXZJ8xydaIwLaXcQ07Ab1n/Khlixq0gSJjJuWLQuNm X7z/x8grbW/Ee/L7Xvl6nJnIE6a9gkGe+h+M7LUSU+XEIodQ+dHVaEwqRsAp9vzyX7AIYYk0+z WXHpEi8QSu0BFFeq2ZZ5NrpQMpShfeGGLD7UxZiXPSHpD5feQzf+tcYhNkq7/m+ulkZvlk81i+ OxXCwoO0vNOY+06qcHKIye554CL3HCV31hElDX8t7j/26M7szcjkBCaO7e8NZ0YAnRJiUX5MRY B7pKUb13J64VQupuDMjHiw/F X-IronPort-AV: E=Sophos;i="5.88,273,1635235200"; d="scan'208";a="70396562" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa3.mentor.iphmx.com with ESMTP; 08 Jan 2022 20:24:17 -0800 IronPort-SDR: NfRIaaBjtMuKV6yOeKXw5z43rPrm1xSauLpbGqAe0PO1Q76NKS2ybEcLgtA8sYMfghTzn47vao KmofsU6B04wpF6tGprbGRtTK4hELH1LOvKpjlc6/hRJGKyUhECGplXyESxuGz6pEiyH/mK0TCI FxbKAtCAxj5LEDVOTm/EeiZ1XJWtxQNghQi6rk9sXqh/gZ7ecd4aCrcO8Lqlau6eEkU/jJWafH yyqPtHHlndnMfE183eElnAwedomGYX8LnP20Jp9+pwi6GE0MRhQGIrOICfJnz3G35Ce3jmM8Wp 73M= To: "gcc-patches@gcc.gnu.org" From: Sandra Loosemore Subject: [PATCH] middle-end: move initialization of stack_limit_rtx [PR103163] Message-ID: Date: Sat, 8 Jan 2022 21:24:09 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 Content-Language: en-US X-ClientProxiedBy: SVR-ORW-MBX-06.mgc.mentorg.com (147.34.90.206) To svr-orw-mbx-03.mgc.mentorg.com (147.34.90.203) X-Spam-Status: No, score=-10.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" This patch fixes the ICE I reported in PR103163. We were initializing stack_limit_rtx before the register properties it depends on were getting set. I moved it to the same function where stack_pointer_rtx, frame_pointer_rtx, etc are being initialized. Besides nios2 where I observed it, this bug was also reported to affect powerpc. Anybody want to check it there? Otherwise, OK to check in? -Sandra commit bd91ec874339f9fd256b2d83de7159f6c11f0000 Author: Sandra Loosemore Date: Sat Jan 8 19:59:26 2022 -0800 middle-end: move initialization of stack_limit_rtx [PR103163] stack_limit_rtx was being initialized before init_reg_modes_target (), resulting in the REG expression being created incorrectly and an ICE later in compilation. 2022-01-08 Sandra Loosemore PR middle-end/103163 gcc/ * emit-rtl.c (init_emit_regs): Initialize stack_limit_rtx here... (init_emit_once): ...not here. diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c index feeee16..76dbe42 100644 --- a/gcc/emit-rtl.c +++ b/gcc/emit-rtl.c @@ -6097,6 +6097,13 @@ init_emit_regs (void) if ((unsigned) PIC_OFFSET_TABLE_REGNUM != INVALID_REGNUM) pic_offset_table_rtx = gen_raw_REG (Pmode, PIC_OFFSET_TABLE_REGNUM); + /* Process stack-limiting command-line options. */ + if (opt_fstack_limit_symbol_arg != NULL) + stack_limit_rtx + = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (opt_fstack_limit_symbol_arg)); + if (opt_fstack_limit_register_no >= 0) + stack_limit_rtx = gen_rtx_REG (Pmode, opt_fstack_limit_register_no); + for (i = 0; i < (int) MAX_MACHINE_MODE; i++) { mode = (machine_mode) i; @@ -6177,13 +6184,6 @@ init_emit_once (void) /* Create the unique rtx's for certain rtx codes and operand values. */ - /* Process stack-limiting command-line options. */ - if (opt_fstack_limit_symbol_arg != NULL) - stack_limit_rtx - = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (opt_fstack_limit_symbol_arg)); - if (opt_fstack_limit_register_no >= 0) - stack_limit_rtx = gen_rtx_REG (Pmode, opt_fstack_limit_register_no); - /* Don't use gen_rtx_CONST_INT here since gen_rtx_CONST_INT in this case tries to use these variables. */ for (i = - MAX_SAVED_CONST_INT; i <= MAX_SAVED_CONST_INT; i++)