flow.c (flow_call_edges_add): New.
authorMichael Hayes <mhayes@redhat.com>
Thu, 11 Jan 2001 09:13:02 +0000 (09:13 +0000)
committerMichael Hayes <m.hayes@gcc.gnu.org>
Thu, 11 Jan 2001 09:13:02 +0000 (09:13 +0000)
* flow.c (flow_call_edges_add): New.
* basic_block.h (flow_call_edges_add): New.

From-SVN: r38899

gcc/ChangeLog
gcc/basic-block.h
gcc/flow.c

index 7b0099a5a108e34f4d983c33f7f7cb994ba6c8c9..35f1fe0f0902ffc405a9265326e1b05332461130 100644 (file)
@@ -1,3 +1,8 @@
+2001-01-11  Michael Hayes  <mhayes@redhat.com>
+
+       * flow.c (flow_call_edges_add): New.
+       * basic_block.h (flow_call_edges_add): New.
+
 2001-01-11  J"orn Rennecke <amylaar@redhat.com>
 
        * reload1.c (move2add_note_store): Update reg_set_luid even if
index c48a54701b38b4db44080e1f79aae441c4144573..b0175464b3a10aea0d606b6df2277591e10dfe6d 100644 (file)
@@ -249,6 +249,7 @@ extern void commit_edge_insertions  PARAMS ((void));
 extern void remove_fake_edges          PARAMS ((void));
 extern void add_noreturn_fake_exit_edges       PARAMS ((void));
 extern void connect_infinite_loops_to_exit     PARAMS ((void));
+extern int flow_call_edges_add                 PARAMS ((sbitmap));
 extern rtx flow_delete_insn            PARAMS ((rtx));
 extern void flow_delete_insn_chain     PARAMS ((rtx, rtx));
 extern void make_edge                  PARAMS ((sbitmap *, basic_block,
index faed23fdd0cfd7323eab8a2812109c0f18e35326..862d40f52148617ef85470ec5491c382c792b66b 100644 (file)
@@ -2011,6 +2011,75 @@ commit_edge_insertions ()
       bb = BASIC_BLOCK (i);
     }
 }
+
+/* Add fake edges to the function exit for any non constant calls in
+   the bitmap of blocks specified by BLOCKS or to the whole CFG if
+   BLOCKS is zero.  Return the nuber of blocks that were split.  */
+
+int
+flow_call_edges_add (blocks)
+     sbitmap blocks;
+{
+  int i;
+  int blocks_split = 0;
+  int bb_num = 0;
+  basic_block *bbs;
+
+  /* Map bb indicies into basic block pointers since split_block
+     will renumber the basic blocks.  */
+
+  bbs = xmalloc (n_basic_blocks * sizeof (*bbs));
+
+  if (! blocks)
+    {
+      for (i = 0; i < n_basic_blocks; i++)
+       bbs[bb_num++] = BASIC_BLOCK (i);
+    }
+  else
+    {
+      EXECUTE_IF_SET_IN_SBITMAP (blocks, 0, i, 
+      {
+       bbs[bb_num++] = BASIC_BLOCK (i);
+      });
+    }
+
+
+  /* Now add fake edges to the function exit for any non constant
+     calls since there is no way that we can determine if they will
+     return or not...  */
+
+  for (i = 0; i < bb_num; i++)
+    {
+      basic_block bb = bbs[i];
+      rtx insn;
+      rtx prev_insn;
+
+      for (insn = bb->end; ; insn = prev_insn)
+       {
+         prev_insn = PREV_INSN (insn);
+         if (GET_CODE (insn) == CALL_INSN && ! CONST_CALL_P (insn))
+           {
+             edge e;
+
+             /* Note that the following may create a new basic block
+                and renumber the existing basic blocks.  */
+             e = split_block (bb, insn);
+             if (e)
+               blocks_split++;
+
+             make_edge (NULL, bb, EXIT_BLOCK_PTR, EDGE_FAKE);
+           }
+         if (insn == bb->head)
+           break;
+       }
+    }
+
+  if (blocks_split)
+    verify_flow_info ();
+
+  free (bbs);
+  return blocks_split;
+}
 \f
 /* Delete all unreachable basic blocks.   */