Subject: Re: your mail

From: Zheng Gengbing <[email-masked]>
Date: Thu, 18 Apr 1996 16:48:39 +0800 (EAT)

On Wed, 17 Apr 1996, Zheng Qiang wrote:

> Hi, Zheng Gengbing
> 
>     The following is the bugs from A to L and my comment on it ( between 
> ++++ and ****), hope it will be helpful.
> 
> Zheng Qiang
> -----------------------------------------------------------------------
> 
> ! Subject: bug report A
>       program test
>       real x,y
>       x = 3.14
>       call sub1(x)
>       y = x*2
>       stop
>       contains
>         subroutine sub1(x)
>         real x
>         x = 1.0
>         return
>         end subroutine sub1
>       end
> 
> ++++++++++++++++++++++++++++++++++++++>
>     Zhang Guansong have different idea with us about this bug. He think the 
> subroutine "sub1" should be treated as the son of the statement 
> contains while we think the subroutine is the son of the programm.

	subroutine "sub1" is the son of the program . But the blob ptr1 link
of program did not contain this subroutine . it is the blob ptr2 of program
contains the subroutine .

> ****************************************<
> 
> Subject: bug report B
> 
> The following program cause dumpdep segment faults. 
> _______________________________
> 
>           program test_case
>             integer a
> test:   SELECT CASE(a)
>                 CASE(2:3,12) TEST
>                         a = a + 1
>                 CASE(7,11) TEST
>                         a = a + 2
>         CASE(4:6,8:10) TEST
>             a = a + 3
>         CASE(1) TEST
>             a = a + 3
>                 CASE DEFAULT
>                         a = a * 3
>         END SELECT
> 
>         END
> ++++++++++++++++++++++++++++++++++++++>
> I forgot to deal with the DEFAULT in case_select before. When I added the line( you can see below) , the bug disappeared. 
> 
> case_selector
>     :  LEFTBRACKET case_value_range_list
>        RIGHTBRACKET  {
>           $$ = $2;
>           }
>     |  DEFAULTL {
>           $$ = makeLlnd(fi,DEFAULT,LLNULL,LLNULL,SMNULL);/* I added this line */
>           }
>     ;
> ****************************************<

	We have considered this .

> 
> Try the following program, you will find i is not linked to for_node.
> 
>       program test
>       real x
>       do  i = 1,20
>          a(i) = sin (x)
>       enddo
>       end
> 
> ++++++++++++++++++++++++++++++++++++++>
>  In order to fix this bug,I replaced the statement 
>  " $$ = makeDoBfnd($$,SMNULL,doDdot,$7,LLNULL,LBNULL); " 
>  with 
>  "$$ = makeDoBfnd($$,$1,doDdot,LLNULL,LLNULL,LBNULL); "
>  or
>  "$$ = makeDoBfnd($$,$2,doDdot,LLNULL,LLNULL,LBNULL); "
>  in the following rules:
>  loop_control
>     :  COMMA do_variable EQUAL numeric_expr
>        COMMA numeric_expr
>        COMMA numeric_expr {
> 	  ......
>           $$ = makeDoBfnd($$,SMNULL,doDdot,$8,LLNULL,LBNULL);
>           }
>     |  do_variable EQUAL numeric_expr COMMA
>        numeric_expr {
>           ......
>           $$ = makeDoBfnd($$,SMNULL,doDdot,LLNULL,LLNULL,LBNULL);
>           }
>     |  do_variable EQUAL numeric_expr COMMA
>        numeric_expr COMMA
>        numeric_expr {
>           ......
>           $$ = makeDoBfnd($$,SMNULL,doDdot,$7,LLNULL,LBNULL);
>           }
>     |  COMMA do_variable EQUAL numeric_expr
>        COMMA numeric_expr {
>           ......
>           $$ = makeDoBfnd($$,SMNULL,doDdot,LLNULL,LLNULL,LBNULL);
>           }
> ****************************************<
>

	We also found this ,
	But your change is not complete . Check do_variable , it returns a 
LLND, intead of SYMBOL ptr . so this is the correct :

 $$ = makeDoBfnd($$,$2->entry.Template.symbol,doDdot,$8,LLNULL,LBNULL);
                    ^^^^^^^^^^^^^^^^^^^^^^^^

> Same problem exist in for_all
> 
>       program tt
>       integer a(10,20)
>       forall(i=1:n,j=1:m)
>         a(i,j) = i+j
>       end forall
>       end
> 
> ++++++++++++++++++++++++++++++++++++++>
>   It is not a bug, but Zgs's wrong understanding.
> ****************************************<
> 
> Subject: bug report D: use, entry
> 
> Try the following program
> ________________________________
> 
> module m
> integer a,x
> end
> program ii
> use m,only:a,b=>x
> entry en(e,f) result(g)
> end
> _________________________________
> ________________________________
> 
> program  sss
> intent (in) :: ao,bo
> end
> _________________________________
> 
> ++++++++++++++++++++++++++++++++++++++>
> Lxy fixed this one, I will send you the comment after I ask her.
> ****************************************<
> 
> Subject: Re report bug E
> 
> intent (in) or (out, inout) is used to declare a list of auguments which are
> used as input, output of a subroutine. There is no reason to seperate the
> arguments list. (In this case ao, bo). 
> 
> On Mar 16,  7:01pm, Zheng Qiang wrote:
> > Subject:
> > >Try following and see bo is not linked to the intent statement
> > ________________________________
> >
> > program  sss
> > intent (in) :: ao,bo
> > end
> > ________________________________
> >
> >** End of excerpt from Zheng Qiang
> 
> ++++++++++++++++++++++++++++++++++++++>
> I replace one statement to fix this bug:
> Original one :
> intent_stmt
>     :  INTENT LEFTBRACKET intent_spec
>        RIGHTBRACKET opt_double_colon name {......
>         }
>     |  intent_stmt COMMA name {......
>           add_to_lowLevelList(r, $1->entry.Template.ll_ptr1);
>           }
> Modified one :
> 
> intent_stmt
>     :  INTENT LEFTBRACKET intent_spec
>        RIGHTBRACKET opt_double_colon name {......
> 	}
>     |  intent_stmt COMMA name {......
>           add_to_lowLevelList(r, $1->entry.Template.ll_ptr2);
>           }
> ****************************************<
>

     We also found this , and your change is completely wrong .
     The intent's ll_ptr2 is attr_expr , you need list field .
     You must change the makespec.c makeIntent() , where you assign the 
 list & attr_expr reversely.

> Subject: bug report F
> See this, 4-B' symble is O-S?
> ____________________________________
> 
> PROGRAM COINED
>    do2: DO 10 , i = 1, 100, 2
>     DO 20 i = 1,3,1
>    20   LOCATION = I
>    10   LOCATION = I + 2
> 
> END
> _____________________________________
> 
> ++++++++++++++++++++++++++++++++++++++>
> I had not deal with the name before, so I replace the following:
> nonlabel_do_stmt
>     :  /*do_construct_*/name COLON
>        DO loop_control  {
>           PTR_LLND nameRef;
>           $$ = $4;
>           nameRef = makeLlnd(fi,VAR_REF,LLNULL,LLNULL,SMNULL);
>           nameRef = makeLlVarRef(nameRef,LLNULL,LLNULL,$1);
>           $$ = modiDoBfnd($$,nameRef,LBNULL);
>           makeSonBlob($$,1);
>           }
> 
> with the following
>  nonlabel_do_stmt
>     :  /*do_construct_*/name COLON
>        DO loop_control  {
>           PTR_LLND nameRef;
>           PTR_SYMB s;
> 
>           s = makeSymbVar(fi,cur_scope(),LOCAL,$1,0);
>           $$ = $4;
>           nameRef = makeLlnd(fi,VAR_REF,LLNULL,LLNULL,SMNULL);
>           nameRef = makeLlVarRef(nameRef,LLNULL,LLNULL,s);
>           $$ = modiDoBfnd($$,nameRef,LBNULL,s);
>           makeSonBlob($$,1);
>           }
> 
> ****************************************<
>

	Not only this place , we have noticed about 30 places , where you
use the name(return string)  as symbol ptr .

> Subject: bug report G:
> 
> 4-B and 7-B is repeated in 2-B
> 
> ________________________________________________________
> 
>     program forallprog
> 
>     forall(i = 2 : 5 : 2 , j = 1 : 4 ) a(i,j) = i + j
>     forall(i = 2 : 5 : 2 , j = 1 : 4 , i > j) a(i,j) = i + j
> 
>     end
> _______________________________________________________
> 
> ++++++++++++++++++++++++++++++++++++++>
>   In fact, this one is A REAL BUG ! I modified the rule to fit for the sytax directed translation, the following is the result:
> 
> forall_stmt
>     :  forall_stmt1 forall_assignment {
>           PTR_BFND endFor;
> 
>           endFor = makeEnd(fi);
>           --(endFor->g_line);
>           --(endFor->l_line);
>           setBfndList($2,endFor);
>           $$ = $1;
>           }
> 
> forall_stmt1
>     :  FORALL LEFTBRACKET forall_control
>        RIGHTBRACKET {
>           $$ = makeBfnd(fi,FORALL_STMT);
>           $$ = makeForallBfnd($$,$3,$3->entry.Template.ll_ptr2);
>           makeSonBlob($$,1);
>           /*setBlob($5,pred_bfnd);*/
>           }
>     ;
> 
> 
>   The following is the previous rules and their action :
> 
> forall_stmt
>     :  FORALL LEFTBRACKET forall_control
>        RIGHTBRACKET forall_assignment  {
>           PTR_BFND endFor;
>           PTR_BLOB p;
>           $$ = makeBfnd(fi,FORALL_STMT);
>           makeSonBlob($$,1);
>           $$ = makeForallBfnd($$,$3,$3->entry.Template.ll_ptr2);
>           setBlob($5,pred_bfnd);
>           endFor = makeEnd(fi);
>           --(endFor->g_line);
>           --(endFor->l_line);
>           setBfndList($5,endFor);
>           }
>     ;
> 
> forall_control
>     :  forall_script_control_list COMMA level_4_expr {
>           $$ = makeLlnd(fi,FORALL_HEADER_OP,$1,$3,SMNULL);
>           }
>     |  forall_script_control_list {
>           $$ = makeLlnd(fi,FORALL_HEADER_OP,$1,LLNULL,SMNULL);
>           }
> ****************************************<
>

	Not only forall_stmt , but also if_stmt , do_stmt , where_stmt
have this bug !

> Subject: bug report H
> 
> I am totally lost to the following program,
> 
> How LABEL_REF is defined? and lots of 0-S when dumping dep?
> ___________________________________
> 
>         program gototest
>         integer i,j,k
>         Ia=b
> 20      goto i
>         goto i(10,20,30,40)
>         goto i,(10,20,30,40)
> 10      goto 13
>         goto (10,20,30,40),i
>         goto (10,20,30,40)i
> 
>         end program
> ++++++++++++++++++++++++++++++++++++++>
> I think because dumpast treat the label_list wrongly ! It treat the label 
 pointer as symbol field.
> ****************************************<
>

	It is not the error of dumpdep . Just think the  symbol & label
are used in the same union field ! like 
 union {
  PTR_SYMBOL symbol;
  PTR_LABEL  label;
 }
 they occupy the same place . And dumpdep cannot distinguish them .

> Subject: bug report I ?
> ____________________________________
> 
> program test
>   DO 1240 WHILE (var128 .NE. 0)
>   1240 var128 = 0
> 
> end
> 
> ++++++++++++++++++++++++++++++++++++++>
> It seems to me that this bug disappeared after I fixed some other bugs. I cannot remember now where did I make the modification.
> ****************************************<
> 
> Subject: re report bug J
> 
>  Dumpdep deal with K and N, one as constant, one as varible.
> 
>       PROGRAM LAPLACE
>         INTEGER N
>         PARAMETER(N=16)
>         PARAMETER(K=1)
>       END
> 
> ++++++++++++++++++++++++++++++>
> The problem comes from the second statement, an entry for N is
> established there, and the next parameter statement don't change its tag to
> CONS_NAME.
> so I replace the following:
> named_constant_def
>     :  name EQUAL expr {
>           PTR_SYMB s;
>           s = makeSymbConst(fi,$1);
> with
> named_constant_def
>     :  name EQUAL expr {
>           PTR_SYMB s;
>           s = makeSymbConst(fi,$1);
>           s->variant = CONST_NAME;
> 	  ......}
> ********************************<
>

	We also notice this . but we use a different way to modify .
we add the statement in  the function makeSymbConst .

> Subject: bug reports K
> 
> The following program's check (2-S) is not linked to AST.
> 
>      program test
>       i = 10
>       check: select case (i)
>       case (1)
>        i=1
>       case (2)
>        i=2
>       end select check
>       end
> 
> ++++++++++++++++++++++++++++++++++++++>
>  I used things below to include the name "check" of the construction 
> "SWITCH-CASE"
> select_case_stmt
>     :  /*case_construct_*/name COLON SELECTCASE
>        LEFTBRACKET case_expr RIGHTBRACKET  {
>           PTR_SYMB s;
> 
>           s = makeSymbVar(fi,cur_scope(),LOCAL,$1,0); /* This line is newly added for bug-fixing */
>           $$ = makeBfnd(fi,SWITCH_NODE);
>           $$ = makeSeleBfnd($$,s,$5); /* This line is modified for bug-fixing , the previous one is $$ = makeSeleBfnd($$,$1,$5)*/
>           makeSonBlob($$,1);
>           }
>     |  SELECTCASE LEFTBRACKET case_expr RIGHTBRACKET  {
>           $$ = makeBfnd(fi,SWITCH_NODE);
>           $$ = makeSeleBfnd($$,SMNULL,$3);
>           makeSonBlob($$,1);
>           }
>     ;
> ****************************************<
> 

	Not only switch , but also if , do construct name are also not 
included . we have modified all these .

> Subject: bug report L
> 
> This program will cause dumpdep segment fault. So I don't know which sentence
> cause the problem.
> 
>       PROGRAM directive_8
> 
>       REAL SHAPE(100)
> 
> !HPF$ DISTRIBUTE SHAPE(BLOCK)
>       CALL PROBATE(SHAPE)
> 
>       end
> 
>       SUBROUTINE PROBATE(CIRCLE)
>       REAL CIRCLE(10)
> !HPF$ INHERIT CIRCLE
> 
>       END SUBROUTINE
> 
> ++++++++++++++++++++++++++++++++>
> 
> I have not touched it.
> 
> **********************************<
> 

	We have no core dump in our machine .

> Subject: Re: bug report H
> 
> On Fri, 8 Mar 1996, Guansong Zhang wrote:
> 
> > I am totally lost to the following program,
> > 
> > How LABEL_REF is defined? and lots of 0-S when dumping dep?
> > ___________________________________
> > 
> > 
> >         program gototest
> >         integer i,j,k
> >         Ia=b
> > 20      goto i
> >         goto i(10,20,30,40)
> >         goto i,(10,20,30,40)
> > 10      goto 13
> >         goto (10,20,30,40),i
> >         goto (10,20,30,40)i
> > 
> >         end program
> > 
> 
> ++++++++++++++++++++++++++++++++++++++>
>    I've fixed the bug. But now 2-S take the place of 0-S now. The reason 
> is a little more compex. But I will explain it clearly. 
> 
>    The definition of LABEL_REF is different from other llnd. It has a 
> label pointer instead of symbol pointer commonly used by other llnd. Maybe 
> you have noted that there is just a column called Symb in the llnd table 
> in the file dumped from .dep file. It is the symbol pointer. But there is no 
> place for label pointer. I think maybe it is because the dump program 
> treat the label pointer in LABEL_REF as sumbol pointer. So the bug arose.
> ****************************************
> 

	You are right . I have just explain the same thing just before .

***************************************************************************
*     Zheng Gengbin                 *                                     *
*                                   *                                     *
*  Dept. of Computer Science        *  Phone:  86-10-2585088              *
*         & Technology              *  Email:                             *
*                                   *      [email-masked]   *
*  Peking University P.R.China      *  Mail:                              *
*                                   *      Room 1077 ,Building 47,        *
*                                   *      Peking University, P.R.China   *
***************************************************************************