Skip to content

Commit e74f3eb

Browse files
committed
rtl-reader: Disable reuse_rtx support for generator building
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 <[email protected]>
1 parent 342eb51 commit e74f3eb

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

gcc/read-md.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,8 +364,10 @@ class rtx_reader : public md_reader
364364
/* Analogous to rtx_writer's m_in_call_function_usage. */
365365
bool m_in_call_function_usage;
366366

367+
#ifndef GENERATOR_FILE
367368
/* Support for "reuse_rtx" directives. */
368369
auto_vec<rtx> m_reuse_rtx_by_id;
370+
#endif
369371
};
370372

371373
/* Global singleton; constrast with md_reader_ptr above. */

gcc/read-rtl.cc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1672,7 +1672,6 @@ rtx_reader::read_rtx_code (const char *code_name)
16721672
struct md_name name;
16731673
rtx return_rtx;
16741674
int c;
1675-
long reuse_id = -1;
16761675

16771676
/* Linked list structure for making RTXs: */
16781677
struct rtx_list
@@ -1681,6 +1680,8 @@ rtx_reader::read_rtx_code (const char *code_name)
16811680
rtx value; /* Value of this node. */
16821681
};
16831682

1683+
#ifndef GENERATOR_FILE
1684+
long reuse_id = -1;
16841685
/* Handle reuse_rtx ids e.g. "(0|scratch:DI)". */
16851686
if (ISDIGIT (code_name[0]))
16861687
{
@@ -1696,10 +1697,12 @@ rtx_reader::read_rtx_code (const char *code_name)
16961697
read_name (&name);
16971698
unsigned idx = atoi (name.string);
16981699
/* Look it up by ID. */
1699-
gcc_assert (idx < m_reuse_rtx_by_id.length ());
1700+
if (idx >= m_reuse_rtx_by_id.length ())
1701+
fatal_with_file_and_line ("invalid reuse index %u", idx);
17001702
return_rtx = m_reuse_rtx_by_id[idx];
17011703
return return_rtx;
17021704
}
1705+
#endif
17031706

17041707
/* Handle "const_double_zero". */
17051708
if (strcmp (code_name, "const_double_zero") == 0)
@@ -1727,12 +1730,14 @@ rtx_reader::read_rtx_code (const char *code_name)
17271730
memset (return_rtx, 0, RTX_CODE_SIZE (code));
17281731
PUT_CODE (return_rtx, code);
17291732

1733+
#ifndef GENERATOR_FILE
17301734
if (reuse_id != -1)
17311735
{
17321736
/* Store away for later reuse. */
17331737
m_reuse_rtx_by_id.safe_grow_cleared (reuse_id + 1, true);
17341738
m_reuse_rtx_by_id[reuse_id] = return_rtx;
17351739
}
1740+
#endif
17361741

17371742
/* Check for flags. */
17381743
read_flags (return_rtx);

0 commit comments

Comments
 (0)