aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2023-01-02 16:18:02 +0100
committerFlorian Weimer <fweimer@redhat.com>2023-01-02 16:18:02 +0100
commit97bbdb726aba76ead550e25061029cf0aa78671b (patch)
tree03ebd3c211a0c1a51ac08db65a25a9285dfb516a /gcc
parent3b6cac2b44b384cd2091eaeaebeb3478c253a25d (diff)
downloadgcc-97bbdb726aba76ead550e25061029cf0aa78671b.zip
gcc-97bbdb726aba76ead550e25061029cf0aa78671b.tar.gz
gcc-97bbdb726aba76ead550e25061029cf0aa78671b.tar.bz2
Define __LIBGCC_DWARF_REG_SIZES_CONSTANT__ if DWARF register size is constant
And use that to speed up the libgcc unwinder. gcc/ * debug.h (dwarf_reg_sizes_constant): Declare. * dwarf2cfi.cc (dwarf_reg_sizes_constant): New function. gcc/c-family/ * c-cppbuiltin.cc (__LIBGCC_DWARF_REG_SIZES_CONSTANT__): Define if constant is known. libgcc/ * unwind-dw2.c (dwarf_reg_size): New function. (_Unwind_GetGR, _Unwind_SetGR, _Unwind_SetGRPtr) (_Unwind_SetSpColumn, uw_install_context_1): Use it. (uw_init_context_1): Do not initialize dwarf_reg_size_table if not in use.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/c-family/c-cppbuiltin.cc6
-rw-r--r--gcc/debug.h2
-rw-r--r--gcc/dwarf2cfi.cc23
3 files changed, 31 insertions, 0 deletions
diff --git a/gcc/c-family/c-cppbuiltin.cc b/gcc/c-family/c-cppbuiltin.cc
index 333f3e1..011478c 100644
--- a/gcc/c-family/c-cppbuiltin.cc
+++ b/gcc/c-family/c-cppbuiltin.cc
@@ -1521,6 +1521,12 @@ 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 799d5e3..4fe9f35 100644
--- a/gcc/debug.h
+++ b/gcc/debug.h
@@ -245,6 +245,8 @@ 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 4d2bd86..d5a27dc 100644
--- a/gcc/dwarf2cfi.cc
+++ b/gcc/dwarf2cfi.cc
@@ -334,6 +334,29 @@ 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. */