Note:  The SUIF 1.1.2 patches at the bottom of this page are obsolete.  What you really want to start with is the SUIF 1.3.0.X distribution from here.

Interested in compiling SUIF to run under Windows? See this page from David Pearce.


One of my colleagues at CMU, Pedro Artigas provides the following patch:

Hi all,

S2C does not generate correct casts, for example in the code below ...

#include

int  main (){
  int flips = 1344;
  int attmax = 5515;

printf("%3d%s\n", (int)(100.0*(double)flips / (double)attmax),"%");

return 0;
}

... S2C drops the cast to int, resulting in a bogus pointer being
dereferenced, here is the fix, it seems to work well:

basesuif/s2c/ctree.cc

            else if ((op == ctree_funcall) && (child_num != 0))
              {
                type_node *func_base = child(0)->expr_type()->unqual();
                if (func_base->is_ptr())
                  {
                    ptr_type *func_ptr = (ptr_type *)func_base;
                    func_base = func_ptr->ref_type()->unqual();
                  }
                assert(func_base->is_func());
                func_type *the_func_type = (func_type *)func_base;

                //PVA: Added condition that if the procedure has a
                //variable number of parameters the parameter has to
                //be one of known type otherwise we do not use
                //C's implicit type convertion.
                //if the function has a variable number of arguments
                //we should not rely on C's automatic type conversion
                //for parameters of unknown type

                if (
                    (the_func_type->args_known())
                    //PVA: Changes begin
                    &&(
                      (!the_func_type->has_varargs())||
                      (the_func_type->num_args()>=child_num)
                    )
                    //PVA: Changes end
                   )
                  {
                    do_fold =
                            assign_convert_implicit(child_type,
implicit_type);
                    do_not_repeat = TRUE;
                  }
                else
                  {
                    do_fold = call_convert_implicit(child_type,
implicit_type);
                  }
              }
             else if ((op == ctree_compl) || (op == ctree_neg) ||
                     (op == ctree_lshift) || (op == ctree_rshift))

Tim Callahan from Berkeley sent me the following patch:

Have you found/fixed this suif 1.3.0.5 bug yet?  
It's in basesuif/useful/eval.cc.

The bug occurs twice, in the two lines that use "sizeof()",
lines 1124 and 1130.


	      if (t->size() <= (int)sizeof(long)) {

should be

	      if (t->size() <= (int)sizeof(long) * suif_byte_size) {

and

	      if (t->size() <= (int)sizeof(unsigned long)) {

should be

	      if (t->size() <= (int)sizeof(unsigned long) * suif_byte_size) {






Here is a test case:

------------------
int y =  (-0.867) * (1 << 16);

main()
{
        printf("y = %x\n", y);
}
------------------

 

If you have SUIF 1.3.0.5, you may want these patches which I posted to the SUIF mailing list:
 


1.  The find-predefines-gcc script seems to get some "as" commands as
well as the defines when I run it.  The following patch corrects this:


Index: Compilers/suif_1.3.0/src/basesuif/config/find-predefines-gcc
diff -c Compilers/suif_1.3.0/src/basesuif/config/find-predefines-gcc:1.1
Compilers/suif_1.3.0/src/basesuif/config/find-predefines-gcc:1.2
*** Compilers/suif_1.3.0/src/basesuif/config/find-predefines-gcc:1.1
Thu Nov 25 21:52:32 1999
--- Compilers/suif_1.3.0/src/basesuif/config/find-predefines-gcc
Sun Nov 28 18:15:02 1999
***************
*** 19,25 ****


  touch temp-predefines.c


! gcc -c -v temp-predefines.c 2>&1 | sed -n /.cpp/p | sed s/' [^-][^
]*'//g | sed s/' -[^D][^ ]*'//g | sed s/'>'.*// | sed s/'[^ ]*cpp'// >
${1}
  RESULT=${?}


  rm -f temp-predefines.c temp-predefines.o
--- 19,25 ----


  touch temp-predefines.c


! gcc -c -v temp-predefines.c 2>&1 | sed -n /\\/cpp/p | sed s/' [^-][^
]*'//g | sed s/' -[^D][^ ]*'//g | sed s/'>'.*// | sed s/'[^ ]*cpp'// >
${1}
  RESULT=${?}


  rm -f temp-predefines.c temp-predefines.o



2.  gcc 2.95.2 has a "bug" when it comes to dealing with string
constants.  It can't seem to decide whether or not you are allowed to
have non-constant pointers point at them.


Following are the casts I had to make in order to allow SUIF to compile
using gcc 2.95.2:


Index: Compilers/suif_1.3.0/src/basesuif/s2c/util.cc
diff -c Compilers/suif_1.3.0/src/basesuif/s2c/util.cc:1.1
Compilers/suif_1.3.0/src/basesuif/s2c/util.cc:1.2
*** Compilers/suif_1.3.0/src/basesuif/s2c/util.cc:1.1   Thu Nov 25
21:52:07 1999
--- Compilers/suif_1.3.0/src/basesuif/s2c/util.cc       Thu Nov 25
23:40:27 1999
***************
*** 518,524 ****
      case TYPE_STRUCT:
      case TYPE_UNION: {
          struct_type *stn = (struct_type *) tn;
!         basetype->append(struct_is_union(stn) ? "union " : "struct ");


          basetype->append(stn->name());
          append_type_comments(tn, basetype, 1, 0);
          return;
--- 518,525 ----
      case TYPE_STRUCT:
      case TYPE_UNION: {
          struct_type *stn = (struct_type *) tn;
!         basetype->append(struct_is_union(stn) ?
!                        (char *)"union " : (char *)"struct ");
          basetype->append(stn->name());
          append_type_comments(tn, basetype, 1, 0);
          return;


Index: Compilers/suif_1.3.0/src/basesuif/snoot/gen.cc
diff -c Compilers/suif_1.3.0/src/basesuif/snoot/gen.cc:1.1
Compilers/suif_1.3.0/src/basesuif/snoot/gen.cc:1.2
*** Compilers/suif_1.3.0/src/basesuif/snoot/gen.cc:1.1  Thu Nov 25
21:52:16 1999
--- Compilers/suif_1.3.0/src/basesuif/snoot/gen.cc      Thu Nov 25
23:40:27 1999
***************
*** 958,963 ****
    {
      annote *result = new annote(k_line);
      result->immeds()->append(immed((int)location->y));
!     result->immeds()->append(immed(location->file ? location->file :
""));
      return result;
    }
--- 958,964 ----
    {
      annote *result = new annote(k_line);
      result->immeds()->append(immed((int)location->y));
!     result->immeds()->append(immed(location->file ?
!                                  location->file : (char *)""));
      return result;
    }


Index: Compilers/suif_1.3.0/src/basesuif/snoot/genop.cc
diff -c Compilers/suif_1.3.0/src/basesuif/snoot/genop.cc:1.1
Compilers/suif_1.3.0/src/basesuif/snoot/genop.cc:1.2
*** Compilers/suif_1.3.0/src/basesuif/snoot/genop.cc:1.1        Thu Nov
25 21:52:16 1999
--- Compilers/suif_1.3.0/src/basesuif/snoot/genop.cc    Thu Nov 25
23:40:28 1999
***************
*** 620,626 ****
    {
      immed_list *result = new immed_list;
      result->append(immed((the_coordinate.file == NULL) ?
!                          "" : the_coordinate.file));
      result->append(immed((int)the_coordinate.x));
      result->append(immed((int)the_coordinate.y));
      return result;
--- 620,626 ----
    {
      immed_list *result = new immed_list;
      result->append(immed((the_coordinate.file == NULL) ?
!                          (char *)"" : the_coordinate.file));
      result->append(immed((int)the_coordinate.x));
      result->append(immed((int)the_coordinate.y));
      return result;


Index: Compilers/suif_1.3.0/src/basesuif/suif1/fileset.cc
diff -c Compilers/suif_1.3.0/src/basesuif/suif1/fileset.cc:1.1
Compilers/suif_1.3.0/src/basesuif/suif1/fileset.cc:1.2
*** Compilers/suif_1.3.0/src/basesuif/suif1/fileset.cc:1.1      Thu Nov
25 21:52:17 1999
--- Compilers/suif_1.3.0/src/basesuif/suif1/fileset.cc  Thu Nov 25
23:40:28 1999
***************
*** 309,315 ****
      is = inn ? new in_stream(lexicon->enter(inn)->sp) : NULL;
      os = NULL;


!     table = new file_symtab(inn ? inn : (outn ? outn : "file"), this);


      par->globals()->add_child(table);
      if (is) {
        par->open_stream(is, this);
--- 309,315 ----
      is = inn ? new in_stream(lexicon->enter(inn)->sp) : NULL;
      os = NULL;


!     table = new file_symtab(inn ? inn : (outn ? outn : (char
*)"file"), this);
      par->globals()->add_child(table);
      if (is) {
        par->open_stream(is, this);


====================
3.  For varargs to work on Irix (using gcc-2.95.2 as a back end), we
need the GNU header files to be included.  So I get rid of the
"-nostdinc" flag passed to cpp.  Also, I force all enums to be integers
on SGI machines for binary compatibility with libraries:


Index: Compilers/suif_1.3.0/src/basesuif/scc/commands.def
diff -c Compilers/suif_1.3.0/src/basesuif/scc/commands.def:1.1
Compilers/suif_1.3.0/src/basesuif/scc/commands.def:1.3
*** Compilers/suif_1.3.0/src/basesuif/scc/commands.def:1.1      Thu Nov
25 21:52:07 1999
--- Compilers/suif_1.3.0/src/basesuif/scc/commands.def  Sun Nov 28
23:32:42 1999
***************
*** 103,109 ****
        }
        p->flags[1] = new String(" -I");
        *p->flags[1] += suif_include;
!       if (strstr(target_machine, "linux") == 0) {
            *p->flags[1] += " -nostdinc -I/usr/include";
        } else {
            *p->flags[1] += " -undef -U__GNUC__ -U__GNUC_MINOR__";
--- 103,113 ----
        }
        p->flags[1] = new String(" -I");
        *p->flags[1] += suif_include;
!
!       if(strstr(target_machine, "irix") != 0) {
!           /* Do nothing, we need the standard include files for
varargs
!            * functions to work. */
!       } else if (strstr(target_machine, "linux") == 0) {
            *p->flags[1] += " -nostdinc -I/usr/include";
        } else {
            *p->flags[1] += " -undef -U__GNUC__ -U__GNUC_MINOR__";
***************
*** 138,143 ****
--- 142,156 ----
            *p->flags[0] += "-T";
            *p->flags[0] += target_machine;
        }
+
+       if(strcmp(target_machine, "mips-sgi-irix6.2") == 0) {
+           /* Irix machines assume that all enum values are type int in
their
+            * compilers.  For binary compatability of structures shared
with
+            * SGI libraries we need to make SUIF have the same
assumption.
+            * For example, this is required by the SPECInt95 gcc
benchmark. */
+           *p->flags[0] += "-force-enum-is-int";
+       }
+
        if (no_warn_flag) *p->flags[0] += " -w"; )


  PASS( FIXFORTRAN,



 

 





Old stuff follows...




While working with the SUIF 1.1.2 compiler system from Stanford, I have encountered and fixed a number of bugs.  In order to help others who are also working with SUIF, I am posting my collection of patches here.  These patches are by myself and others, and includes an extensive set of patches that I obtained from Harvard's HUBE research group.  These patches provide a number of capabilities, including: The patch file is available here (basesuif-1.1.2.cmu.patch.gz, 44k, June 1 1999).  Apply it with the command:
cd $SUIFHOME/.. ; gzcat[insert appropriate path here]/basesuif-1.1.2.cmu.patch.gz | patch -p5


OK, so as I get more patches I will put them here with a date.  After I get a fair number of patches I will roll another patch file with all of the patches.  These patches are cumulative and should be applied on top of the patches in the above file.



June 3, 1999:  An additional patch to linksuif.cc, which fixes a bug found by Tim Callahan at Berkley:
diff -c -r1.11 linksuif.cc
*** linksuif.cc 1999/05/27 21:32:25     1.11
--- linksuif.cc 1999/06/03 18:48:13
***************
*** 1385,1390 ****
--- 1385,1402 ----
      if (type1->op() != type2->op())
          return FALSE;

+     /* If either type has a "unique" mark on it, we don't need to
+      * compare it to anything else since is by definition unique: */
+     immed_list *mark_immeds1 =
+             (immed_list *)(type1->peek_annote(k_linksuif_temp_mark));
+     immed_list *mark_immeds2 =
+             (immed_list *)(type2->peek_annote(k_linksuif_temp_mark));
+     if(mark_immeds1 != NULL ||
+        mark_immeds2 != NULL)
+       {
+       return FALSE;
+       }
+
      switch (type1->op())
        {
          case TYPE_ENUM:



June 14, 1999:  Fixed a bug in s2c having to do with landing pads:
suif_1.1.2/src/basesuif/s2c/main.cc
diff -c -r1.2 -r1.3
*** main.cc     1999/05/28 17:04:04     1.2
--- main.cc     1999/06/15 03:24:50     1.3
***************
*** 1596,1601 ****
--- 1596,1606 ----
          new_if->addchild(then_tree);

          tree = new_if;
+
+       ctree *lbpart = new ctree(ctree_assign);
+       lbpart->addchild(ctree_for_for_index(tfor->index()));
+       lbpart->addchild(operand_to_tree(tfor->lb_op()));
+       tree->addchild(lbpart);
        }

      return tree;