This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

loop_latch_edge is NULL during jump threading

In linaro-4.9-branch, with the following (reduced) test case, I run into
a situation where loop_latch_edge is NULL during jump threading. I am
wondering if this  a possible during jump threading or the error lies
some where else? I can't reproduce it with the trunk.

int a;
fn1() {
  while (1)
    switch (a) {
    case '\'':
      b = QSTRING;
      switch (b)
      case UQSTRING:
      b = SQSTRING;

x.c:2:1: internal compiler error: Segmentation fault
 fn1() {
0x83694f crash_signal
0x96d8a8 thread_block_1
0x96da3e thread_block
0x96e59c thread_through_all_blocks(bool)
0x9d77e9 finalize_jump_threads
0x9d77e9 execute_vrp
0x9d77e9 execute
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.

If I apply the following patch, segfault goes away. Is this aright approach?

diff --git a/gcc/tree-ssa-threadupdate.c b/gcc/tree-ssa-threadupdate.c
index d1b289f..0bcef35 100644
--- a/gcc/tree-ssa-threadupdate.c
+++ b/gcc/tree-ssa-threadupdate.c
@@ -794,6 +794,8 @@ thread_block_1 (basic_block bb, bool noloop_only,
bool joiners)
   if (loop->header == bb)
       e = loop_latch_edge (loop);
+      if (!e)
+	return false;
       vec<jump_thread_edge *> *path = THREAD_PATH (e);

       if (path
@@ -1114,6 +1116,8 @@ thread_through_loop_header (struct loop *loop,
bool may_peel_loop_headers)
   basic_block tgt_bb, atgt_bb;
   enum bb_dom_status domst;

+  if (!latch)
+    return false;
   /* We have already threaded through headers to exits, so all the
      requests now are to the inside of the loop.  We need to avoid creating
      irreducible regions (i.e., loops with more than one entry block), and


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]