From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2178) id DE88B3858C30; Tue, 3 Jan 2023 15:47:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DE88B3858C30 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1672760864; bh=PWruWuS+Faji+p1qhrjT6eSkEGI2gvcoGBwL0+QzpYw=; h=From:To:Subject:Date:From; b=n4jghkwoxKl/a0n03kCyn2RUFnuhDNHlctYZDQNWDmR1TgmkKUhM0FIf34mCLDe2P qJyzESQnGh3pFshyemoyOAFkKELuuRi+GpmfphHCrmsa/jEng16/yL0tHl+90wc1IK VSQGevXs6b1j0PRU5mZEv/RZLztmm6cjHIC6arR8= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Florian Weimer To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-4980] Revert "Define __LIBGCC_DWARF_REG_SIZES_CONSTANT__ if DWARF register size is constant" X-Act-Checkin: gcc X-Git-Author: Florian Weimer X-Git-Refname: refs/heads/master X-Git-Oldrev: 96127a4100e8a62c3dc009b5f06199bf24275bf3 X-Git-Newrev: d010efbfb89721bc9ca9e657e980ff0d8e6187af Message-Id: <20230103154744.DE88B3858C30@sourceware.org> Date: Tue, 3 Jan 2023 15:47:44 +0000 (GMT) List-Id: https://gcc.gnu.org/g:d010efbfb89721bc9ca9e657e980ff0d8e6187af commit r13-4980-gd010efbfb89721bc9ca9e657e980ff0d8e6187af Author: Florian Weimer Date: Tue Jan 3 16:47:31 2023 +0100 Revert "Define __LIBGCC_DWARF_REG_SIZES_CONSTANT__ if DWARF register size is constant" This reverts commit 97bbdb726aba76ead550e25061029cf0aa78671b. Diff: --- gcc/c-family/c-cppbuiltin.cc | 6 ------ gcc/debug.h | 2 -- gcc/dwarf2cfi.cc | 23 ----------------------- libgcc/unwind-dw2.c | 41 ++++++++++++----------------------------- 4 files changed, 12 insertions(+), 60 deletions(-) diff --git a/gcc/c-family/c-cppbuiltin.cc b/gcc/c-family/c-cppbuiltin.cc index 011478c88da..333f3e138d6 100644 --- a/gcc/c-family/c-cppbuiltin.cc +++ b/gcc/c-family/c-cppbuiltin.cc @@ -1521,12 +1521,6 @@ c_cpp_builtins (cpp_reader *pfile) #endif builtin_define_with_int_value ("__LIBGCC_DWARF_FRAME_REGISTERS__", DWARF_FRAME_REGISTERS); - { - int value = dwarf_reg_sizes_constant (); - if (value > 0) - builtin_define_with_int_value ("__LIBGCC_DWARF_REG_SIZES_CONSTANT__", - value); - } #ifdef EH_RETURN_STACKADJ_RTX cpp_define (pfile, "__LIBGCC_EH_RETURN_STACKADJ_RTX__"); #endif diff --git a/gcc/debug.h b/gcc/debug.h index 4fe9f3570ac..799d5e316a2 100644 --- a/gcc/debug.h +++ b/gcc/debug.h @@ -245,8 +245,6 @@ extern const struct gcc_debug_hooks vmsdbg_debug_hooks; /* Dwarf2 frame information. */ -extern int dwarf_reg_sizes_constant (); - extern void dwarf2out_begin_prologue (unsigned int, unsigned int, const char *); extern void dwarf2out_vms_end_prologue (unsigned int, const char *); diff --git a/gcc/dwarf2cfi.cc b/gcc/dwarf2cfi.cc index d5a27dc36c5..4d2bd869a4b 100644 --- a/gcc/dwarf2cfi.cc +++ b/gcc/dwarf2cfi.cc @@ -334,29 +334,6 @@ generate_dwarf_reg_sizes (poly_uint16 *sizes) targetm.init_dwarf_reg_sizes_extra (sizes); } -/* Return 0 if the DWARF register sizes are not constant, otherwise - return the size constant. */ - -int -dwarf_reg_sizes_constant () -{ - poly_uint16 *sizes = XALLOCAVEC (poly_uint16, DWARF_FRAME_REGISTERS); - generate_dwarf_reg_sizes (sizes); - - int result; - for (unsigned int i = 0; i < DWARF_FRAME_REGISTERS; i++) - { - unsigned short value; - if (!sizes[i].is_constant (&value)) - return 0; - if (i == 0) - result = value; - else if (result != value) - return 0; - } - return result; -} - /* Generate code to initialize the dwarf register size table located at the provided ADDRESS. */ diff --git a/libgcc/unwind-dw2.c b/libgcc/unwind-dw2.c index c370121bb29..eaceace2029 100644 --- a/libgcc/unwind-dw2.c +++ b/libgcc/unwind-dw2.c @@ -148,25 +148,9 @@ struct _Unwind_Context char by_value[__LIBGCC_DWARF_FRAME_REGISTERS__+1]; }; -#ifdef __LIBGCC_DWARF_REG_SIZES_CONSTANT__ -static inline unsigned char -dwarf_reg_size (int index __attribute__ ((__unused__))) -{ - return __LIBGCC_DWARF_REG_SIZES_CONSTANT__; -} -#else /* Byte size of every register managed by these routines. */ static unsigned char dwarf_reg_size_table[__LIBGCC_DWARF_FRAME_REGISTERS__+1]; - -static inline unsigned char -dwarf_reg_size (unsigned index) -{ - gcc_assert (index < sizeof (dwarf_reg_size_table)); - return dwarf_reg_size_table[index]; -} -#endif - /* Read unaligned data from the instruction buffer. */ @@ -248,7 +232,8 @@ _Unwind_GetGR (struct _Unwind_Context *context, int regno) #endif index = DWARF_REG_TO_UNWIND_COLUMN (regno); - size = dwarf_reg_size (index); + gcc_assert (index < (int) sizeof(dwarf_reg_size_table)); + size = dwarf_reg_size_table[index]; val = context->reg[index]; if (_Unwind_IsExtendedContext (context) && context->by_value[index]) @@ -295,7 +280,8 @@ _Unwind_SetGR (struct _Unwind_Context *context, int index, _Unwind_Word val) void *ptr; index = DWARF_REG_TO_UNWIND_COLUMN (index); - size = dwarf_reg_size (index); + gcc_assert (index < (int) sizeof(dwarf_reg_size_table)); + size = dwarf_reg_size_table[index]; if (_Unwind_IsExtendedContext (context) && context->by_value[index]) { @@ -343,8 +329,9 @@ _Unwind_SetGRValue (struct _Unwind_Context *context, int index, _Unwind_Word val) { index = DWARF_REG_TO_UNWIND_COLUMN (index); + gcc_assert (index < (int) sizeof(dwarf_reg_size_table)); /* Return column size may be smaller than _Unwind_Context_Reg_Val. */ - gcc_assert (dwarf_reg_size (index) <= sizeof (_Unwind_Context_Reg_Val)); + gcc_assert (dwarf_reg_size_table[index] <= sizeof (_Unwind_Context_Reg_Val)); context->by_value[index] = 1; context->reg[index] = _Unwind_Get_Unwind_Context_Reg_Val (val); @@ -1400,7 +1387,7 @@ static inline void _Unwind_SetSpColumn (struct _Unwind_Context *context, void *cfa, _Unwind_SpTmp *tmp_sp) { - int size = dwarf_reg_size (__builtin_dwarf_sp_column ()); + int size = dwarf_reg_size_table[__builtin_dwarf_sp_column ()]; if (size == sizeof(_Unwind_Ptr)) tmp_sp->ptr = (_Unwind_Ptr) cfa; @@ -1586,13 +1573,11 @@ uw_advance_context (struct _Unwind_Context *context, _Unwind_FrameState *fs) } \ while (0) -#ifndef __LIBGCC_DWARF_REG_SIZES_CONSTANT__ static inline void init_dwarf_reg_size_table (void) { __builtin_init_dwarf_reg_size_table (dwarf_reg_size_table); } -#endif static void __attribute__((noinline)) uw_init_context_1 (struct _Unwind_Context *context, @@ -1611,18 +1596,16 @@ uw_init_context_1 (struct _Unwind_Context *context, code = uw_frame_state_for (context, &fs); gcc_assert (code == _URC_NO_REASON); -#ifndef __LIBGCC_DWARF_REG_SIZES_CONSTANT__ -# if __GTHREADS +#if __GTHREADS { static __gthread_once_t once_regsizes = __GTHREAD_ONCE_INIT; if (__gthread_once (&once_regsizes, init_dwarf_reg_size_table) != 0 && dwarf_reg_size_table[0] == 0) init_dwarf_reg_size_table (); } -# else +#else if (dwarf_reg_size_table[0] == 0) init_dwarf_reg_size_table (); -# endif #endif /* Force the frame state to use the known cfa value. */ @@ -1699,20 +1682,20 @@ uw_install_context_1 (struct _Unwind_Context *current, { _Unwind_Word w; _Unwind_Ptr p; - if (dwarf_reg_size (i) == sizeof (_Unwind_Word)) + if (dwarf_reg_size_table[i] == sizeof (_Unwind_Word)) { w = (_Unwind_Internal_Ptr) t; memcpy (c, &w, sizeof (_Unwind_Word)); } else { - gcc_assert (dwarf_reg_size (i) == sizeof (_Unwind_Ptr)); + gcc_assert (dwarf_reg_size_table[i] == sizeof (_Unwind_Ptr)); p = (_Unwind_Internal_Ptr) t; memcpy (c, &p, sizeof (_Unwind_Ptr)); } } else if (t && c && t != c) - memcpy (c, t, dwarf_reg_size (i)); + memcpy (c, t, dwarf_reg_size_table[i]); } /* If the current frame doesn't have a saved stack pointer, then we