From a08a479fec88b963c28fc068d09f40298c5565b6 Mon Sep 17 00:00:00 2001
From: "Frank Ch. Eigler" <fche@redhat.com>
Date: Tue, 12 Apr 2005 18:09:09 +0000
Subject: [PATCH] re PR other/19266 ([mudflap] ICE when compiling with
 -fmudflap -O)

2005-04-12  Frank Ch. Eigler  <fche@redhat.com>

	PR mudflap/19266
	From Richard Henderson <rth@redhat.com>:
	* tree-mudflap.c (mf_build_check_statement_for): Correct block
	splitting logic.

2005-04-12  Frank Ch. Eigler  <fche@redhat.com>

	PR mudflap/19266
	* testsuite/libmudflap.c++/c++frags.exp: Also test -O permutation.
	* testsuite/libmudflap.c++/pass57-frag.cxx: New test.

From-SVN: r98028
---
 gcc/ChangeLog                                 |  7 ++++
 gcc/tree-mudflap.c                            | 33 +++++--------------
 libmudflap/ChangeLog                          |  6 ++++
 .../testsuite/libmudflap.c++/c++frags.exp     |  2 +-
 .../testsuite/libmudflap.c++/pass57-frag.cxx  | 25 ++++++++++++++
 5 files changed, 48 insertions(+), 25 deletions(-)
 create mode 100644 libmudflap/testsuite/libmudflap.c++/pass57-frag.cxx

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index ebbc082c222a..a64c04278b07 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2005-04-12  Frank Ch. Eigler  <fche@redhat.com>
+
+	PR mudflap/19266
+	From Richard Henderson <rth@redhat.com>:
+	* tree-mudflap.c (mf_build_check_statement_for): Correct block
+	splitting logic.
+
 2005-04-12  Dorit Naishlos  <dorit@il.ibm.com>
 
 	* tree-cfg.c (tree_verify_flow_info): Use LABEL_EXPR_LABEL.
diff --git a/gcc/tree-mudflap.c b/gcc/tree-mudflap.c
index c2e09ad5c74c..b1efae87057c 100644
--- a/gcc/tree-mudflap.c
+++ b/gcc/tree-mudflap.c
@@ -497,40 +497,25 @@ mf_build_check_statement_for (tree base, tree limit,
   block_stmt_iterator bsi;
   basic_block cond_bb, then_bb, join_bb;
   edge e;
-  tree cond, t, u, v, l1, l2;
+  tree cond, t, u, v;
   tree mf_base;
   tree mf_elem;
   tree mf_limit;
 
   /* We first need to split the current basic block, and start altering
      the CFG.  This allows us to insert the statements we're about to
-     construct into the right basic blocks.  The label l1 is the label
-     of the block for the THEN clause of the conditional jump we're
-     about to construct, and l2 is the ELSE clause, which is just the
-     continuation of the old statement stream.  */
-  l1 = create_artificial_label ();
-  l2 = create_artificial_label ();
+     construct into the right basic blocks.  */
+
   cond_bb = bb_for_stmt (bsi_stmt (*instr_bsi));
   bsi = *instr_bsi;
   bsi_prev (&bsi);
   if (! bsi_end_p (bsi))
-    {
-      /* We're processing a statement in the middle of the block, so
-         we need to split the block.  This creates a new block and a new
-         fallthrough edge.  */
-      e = split_block (cond_bb, bsi_stmt (bsi));
-      cond_bb = e->src;
-      join_bb = e->dest;
-    }
+    e = split_block (cond_bb, bsi_stmt (bsi));
   else
-    {
-      /* We're processing the first statement in the block, so we need
-         to split the incoming edge.  This also creates a new block
-         and a new fallthrough edge.  */
-      join_bb = cond_bb;
-      cond_bb = split_edge (find_edge (join_bb->prev_bb, join_bb));
-    }
-  
+    e = split_block_after_labels (cond_bb);
+  cond_bb = e->src;
+  join_bb = e->dest;
+
   /* A recap at this point: join_bb is the basic block at whose head
      is the gimple statement for which this check expression is being
      built.  cond_bb is the (possibly new, synthetic) basic block the
@@ -721,7 +706,7 @@ mf_decl_eligible_p (tree decl)
           /* The decl must have its address taken.  In the case of
              arrays, this flag is also set if the indexes are not
              compile-time known valid constants.  */
-          && TREE_ADDRESSABLE (decl)
+          && TREE_ADDRESSABLE (decl)    /* XXX: not sufficient: return-by-value structs! */
           /* The type of the variable must be complete.  */
           && COMPLETE_OR_VOID_TYPE_P (TREE_TYPE (decl))
 	  /* The decl hasn't been decomposed somehow.  */
diff --git a/libmudflap/ChangeLog b/libmudflap/ChangeLog
index 4f25712e7c68..73dfcbe50ddb 100644
--- a/libmudflap/ChangeLog
+++ b/libmudflap/ChangeLog
@@ -1,3 +1,9 @@
+2005-04-12  Frank Ch. Eigler  <fche@redhat.com>
+
+	PR mudflap/19266
+	* testsuite/libmudflap.c++/c++frags.exp: Also test -O permutation.
+	* testsuite/libmudflap.c++/pass57-frag.cxx: New test.
+
 2005-04-04  Alan Modra  <amodra@bigpond.net.au>
 
 	* mf-runtime.c (__mfu_unregister): Warning fix for char unsigned.
diff --git a/libmudflap/testsuite/libmudflap.c++/c++frags.exp b/libmudflap/testsuite/libmudflap.c++/c++frags.exp
index 5eb69aa65282..1ac24adbe929 100644
--- a/libmudflap/testsuite/libmudflap.c++/c++frags.exp
+++ b/libmudflap/testsuite/libmudflap.c++/c++frags.exp
@@ -5,7 +5,7 @@ dg-init
 
 global srcdir
 
-foreach flags [list {} {-static} {-O2} {-O3}] {
+foreach flags [list {} {-static} {-O} {-O2} {-O3}] {
     foreach srcfile [lsort [glob -nocomplain ${srcdir}/libmudflap.c++/*frag.cxx]] {
 	set bsrc [file tail $srcfile]
 	setenv MUDFLAP_OPTIONS "-viol-segv"
diff --git a/libmudflap/testsuite/libmudflap.c++/pass57-frag.cxx b/libmudflap/testsuite/libmudflap.c++/pass57-frag.cxx
new file mode 100644
index 000000000000..e4fa70176b73
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c++/pass57-frag.cxx
@@ -0,0 +1,25 @@
+#include <vector>
+#include <string>
+
+class fitscolumn
+  {
+  private:
+    std::string name_, unit_;
+   int i, t;
+  public:
+    fitscolumn (const std::string &nm, const std::string &un,int i1,int t1)
+      : name_(nm), unit_(un), i(i1), t(t1){}
+  };
+
+void init_bintab(std::vector<fitscolumn> & columns_)
+{
+  char ttype[81], tunit[81], tform[81];
+  long repc;
+  int typecode;
+  columns_.push_back (fitscolumn (ttype,tunit,1,typecode));
+}
+
+int main ()
+{
+  return 0;
+}
-- 
GitLab