aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlya Leoshkevich <iii@linux.ibm.com>2020-11-24 22:47:11 +0100
committerIlya Leoshkevich <iii@linux.ibm.com>2020-11-30 11:50:30 +0100
commit4380d5ae721545f658d63f6df037afa5d7dc66a9 (patch)
treecb497a586d1fc8fce9a3e4464e59b0812c9649d3
parente855b30c28391b190eebb8e6afc8d2116a6d85de (diff)
downloadgcc-4380d5ae721545f658d63f6df037afa5d7dc66a9.zip
gcc-4380d5ae721545f658d63f6df037afa5d7dc66a9.tar.gz
gcc-4380d5ae721545f658d63f6df037afa5d7dc66a9.tar.bz2
rtl_dump_bb: fix segfault when reporting internal error
During ICE reporting, sometimes rtl_dump_bb is called on partially initialized basic blocks. This produces another ICE, obscuring the original problem. Fix by checking that that basic blocks are initialized before touching their bb_infos. gcc/ChangeLog: 2020-11-25 Ilya Leoshkevich <iii@linux.ibm.com> * cfgrtl.c (rtl_bb_info_initialized_p): New function. (rtl_dump_bb): Use rtl_bb_info_initialized_p before accessing bb insns.
-rw-r--r--gcc/cfgrtl.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/gcc/cfgrtl.c b/gcc/cfgrtl.c
index 45d84d3..5e909e2 100644
--- a/gcc/cfgrtl.c
+++ b/gcc/cfgrtl.c
@@ -97,6 +97,7 @@ static basic_block rtl_split_block (basic_block, void *);
static void rtl_dump_bb (FILE *, basic_block, int, dump_flags_t);
static int rtl_verify_flow_info_1 (void);
static void rtl_make_forwarder_block (edge);
+static bool rtl_bb_info_initialized_p (basic_block bb);
/* Return true if NOTE is not one of the ones that must be kept paired,
so that we may simply delete it. */
@@ -2149,7 +2150,8 @@ rtl_dump_bb (FILE *outf, basic_block bb, int indent, dump_flags_t flags)
putc ('\n', outf);
}
- if (bb->index != ENTRY_BLOCK && bb->index != EXIT_BLOCK)
+ if (bb->index != ENTRY_BLOCK && bb->index != EXIT_BLOCK
+ && rtl_bb_info_initialized_p (bb))
{
rtx_insn *last = BB_END (bb);
if (last)
@@ -5135,6 +5137,12 @@ init_rtl_bb_info (basic_block bb)
bb->il.x.rtl = ggc_cleared_alloc<rtl_bb_info> ();
}
+static bool
+rtl_bb_info_initialized_p (basic_block bb)
+{
+ return bb->il.x.rtl;
+}
+
/* Returns true if it is possible to remove edge E by redirecting
it to the destination of the other edge from E->src. */