]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
rtl-reader: Disable reuse_rtx support for generator building
authorAndrew Pinski <quic_apinski@quicinc.com>
Wed, 20 Nov 2024 07:45:20 +0000 (23:45 -0800)
committerAndrew Pinski <quic_apinski@quicinc.com>
Wed, 20 Nov 2024 18:07:38 +0000 (10:07 -0800)
reuse_rtx is not documented nor the format to use it is ever documented.
So it should not be supported for the .md files.

This also fixes the problem if an invalid index is supplied for reuse_rtx,
instead of ICEing, put out a real error message.  Note since this code
still uses atoi, an invalid index can still be used in some cases but that is
recorded as part of PR 44574.

Note I did a grep of the sources to make sure that this was only used for
the read rtl in the GCC rather than while reading in .md files.

Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

* read-md.h (class rtx_reader): Don't include m_reuse_rtx_by_id
when GENERATOR_FILE is defined.
* read-rtl.cc (rtx_reader::read_rtx_code): Disable reuse_rtx
support when GENERATOR_FILE is defined.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
gcc/read-md.h
gcc/read-rtl.cc

index 9703551a8fd4cf99edd9a02ea19ee7fa8327a727..e613c42b724115372c0a76dca0b4a9fbf7539be1 100644 (file)
@@ -364,8 +364,10 @@ class rtx_reader : public md_reader
   /* Analogous to rtx_writer's m_in_call_function_usage.  */
   bool m_in_call_function_usage;
 
+#ifndef GENERATOR_FILE
   /* Support for "reuse_rtx" directives.  */
   auto_vec<rtx> m_reuse_rtx_by_id;
+#endif
 };
 
 /* Global singleton; constrast with md_reader_ptr above.  */
index bfce806f9d6999bd5d8e6df863e6a4116dd737a2..630f9c59c37b81208e2499e5e23e3ee36210886e 100644 (file)
@@ -1672,7 +1672,6 @@ rtx_reader::read_rtx_code (const char *code_name)
   struct md_name name;
   rtx return_rtx;
   int c;
-  long reuse_id = -1;
 
   /* Linked list structure for making RTXs: */
   struct rtx_list
@@ -1681,6 +1680,8 @@ rtx_reader::read_rtx_code (const char *code_name)
       rtx value;               /* Value of this node.  */
     };
 
+#ifndef GENERATOR_FILE
+  long reuse_id = -1;
   /* Handle reuse_rtx ids e.g. "(0|scratch:DI)".  */
   if (ISDIGIT (code_name[0]))
     {
@@ -1696,10 +1697,12 @@ rtx_reader::read_rtx_code (const char *code_name)
       read_name (&name);
       unsigned idx = atoi (name.string);
       /* Look it up by ID.  */
-      gcc_assert (idx < m_reuse_rtx_by_id.length ());
+      if (idx >= m_reuse_rtx_by_id.length ())
+       fatal_with_file_and_line ("invalid reuse index %u", idx);
       return_rtx = m_reuse_rtx_by_id[idx];
       return return_rtx;
     }
+#endif
 
   /* Handle "const_double_zero".  */
   if (strcmp (code_name, "const_double_zero") == 0)
@@ -1727,12 +1730,14 @@ rtx_reader::read_rtx_code (const char *code_name)
   memset (return_rtx, 0, RTX_CODE_SIZE (code));
   PUT_CODE (return_rtx, code);
 
+#ifndef GENERATOR_FILE
   if (reuse_id != -1)
     {
       /* Store away for later reuse.  */
       m_reuse_rtx_by_id.safe_grow_cleared (reuse_id + 1, true);
       m_reuse_rtx_by_id[reuse_id] = return_rtx;
     }
+#endif
 
   /* Check for flags. */
   read_flags (return_rtx);