Hi, Appended below is a proposed fix ported from PathScale 3.3 beta. Sample program exposing the error and the IR dumps before and after the fix are attached and also available in the bug-report. Can a gatekeeper please review the patch?
Thanks. Pallavi Index: osprey/crayf90/fe90/s_io.c =================================================================== --- osprey/crayf90/fe90/s_io.c (revision 3526) +++ osprey/crayf90/fe90/s_io.c (working copy) @@ -1537,7 +1537,7 @@ } else { - attr_idx = find_left_attr(&opnd); + attr_idx = find_base_attr(&opnd, &line, &col); /* create tmp for iolength */ Problem: In the source statement: inquire( iolength=Tvar%field1 ) 100,200 variable 'Tvar%field1' passed to inquire/iolength is expected to be an integer, however in the generated WHIRL, the type is MTYPE_M (type of 'Tvar'). The assertion failure shown in the earlier comment is from the non-debug compiler. The debug compiler catches the problem earlier on. Fix: During the semantic pass in the front-end, use function 'find_base_attr' instead of 'find_left_attr' to get to the attribute for 'field1' in 'Tvar%field1'. >From documentation of find_base_attr: |* Description: |* finds the base attr pointer from reference tree. |* The difference between find_base_attr and find_left_attr is: |* a%b%c(1:10)(1:3) *| |* find_base_attr finds 'c' *| |* find_left_attr finds 'a' *| The attached file 'originalIR.txt' shows the WHIRL IR dump and front-end trace with the incorrect types marked out. The attachment 'IRafterfix.txt' shows the correct trace generated after the patch is applied.
sample.f90
Description: sample.f90
Original WHIRL dump: COMMENT <2,3,inquire(iolength=Tvar%field1)100,200> # {line: 1/13} COMMENT <2,4,START_IO> # {line: 1/13} PRAGMA 0 173 <null-st> 0 (0x0) # START_STMT_CLUMP {line: 1/13} IO_ITEM <1,NONE> IO_ITEM <10,NONE> I4INTCONST 3 (0x3) IO_ITEM <73,FIRST_LAST_FLAG> U8LDA 0 <2,2,t$1> T<57,anon_ptr.,8> IO_ITEM <75,INQLENGTH_VAR> I4INTCONST 100 (0x64) I8INTCONST 562958543355904 (0x2000200000000) IO_ITEM <98,EXPR> T<4,.predef_I4,4> I4INTCONST 200 (0xc8) I8INTCONST 562958543355904 (0x2000200000000) IO_ITEM <98,EXPR> T<4,.predef_I4,4> IO <26,INQUIRE_LENGTH,cray> 2 {line: 1/13} MMLDID 0 <2,2,t$1> T<53,T1,4> MSTID 0 <2,2,t$1> T<53,T1,4> {line: 1/13} MMLDID 0 <2,2,t$1> T<53,T1,4> I4MCVT <--- illegal convert causes assertion failure in debug compiler (### OPCODE_make_op: no opcode available: 28 4 16) I4STID 0 <2,1,TVAR> T<4,.predef_I4,4> {line: 1/13} PRAGMA 0 174 <null-st> 0 (0x0) # END_STMT_CLUMP {line: 1/13} COMMENT <2,5,END_IO> # {line: 1/13} MMLDID 0 <2,1,TVAR> T<53,T1,4> MRETURN_VAL {line: 1/14} Original Front end trace: - CG INQUIRE - 13 SKIP ME -------------------------------------------------- IDX = 4 PREV SH IDX = 9 NEXT SH IDX = 3 COL NUM = 8 PARENT BLK IDX = 0 LOOP END = F DOALL LOOP END = F Start_Io_Opr idx = 3 Typeless * 32 rank = 0; line = 13, col = 8 Left opnd is CN_Tbl_Idx; line = 13, col = 8 "inquire(iolength=Tvar%field1)100,200" IDX = 11 LEN = 36 CHARACTER*(36) Right operand is NO_Tbl_Idx; - INQUIRE - 13 ---------------------------------------------------------- IDX = 3 PREV SH IDX = 4 NEXT SH IDX = 10 COL NUM = 8 PARENT BLK IDX = 0 LOOP END = F DOALL LOOP END = F Asg_Opr idx = 12 INTEGER (4) rank = 0; line = 13, col = 8 Left opnd is AT_Tbl_Idx; line = 13, col = 8 t$1 idx = 476 derived-type * 470 <---- The type (for Tvar%field1) is derived-type instead of integer. Right operand is IR_Tbl_Idx; Inquire_Iolength_Opr idx = 4 Typeless * 32 rank = 0; line = 13, col = 8 Left opnd is IL_Tbl_Idx; list cnt = 1 list item #1, idx = 1, CN_Tbl_Idx line = 13 col = 8 3 IDX = 4 INTEGER * Integer_4 Right operand is IL_Tbl_Idx; list cnt = 2 list item #1, idx = 2, IR_Tbl_Idx Io_Item_Type_Code_Opr idx = 14 INTEGER (4) rank = 0; line = 13, col = 40 DV_INTEGER DP = 0 DEFAULT TYPED INT_LEN = 32 DEC_LEN = 32 Left opnd is CN_Tbl_Idx; line = 13, col = 40 100 IDX = 12 INTEGER * Integer_4 Right operand is NO_Tbl_Idx;
Front end trace: - CG INQUIRE - 13 SKIP ME -------------------------------------------------- IDX = 4 PREV SH IDX = 9 NEXT SH IDX = 3 COL NUM = 8 PARENT BLK IDX = 0 LOOP END = F DOALL LOOP END = F Start_Io_Opr idx = 3 Typeless * 32 rank = 0; line = 13, col = 8 Left opnd is CN_Tbl_Idx; line = 13, col = 8 "inquire(iolength=Tvar%field1)100,200" IDX = 11 LEN = 36 CHARACTER*(36) Right operand is NO_Tbl_Idx; - INQUIRE - 13 ---------------------------------------------------------- IDX = 3 PREV SH IDX = 4 NEXT SH IDX = 10 COL NUM = 8 PARENT BLK IDX = 0 LOOP END = F DOALL LOOP END = F Asg_Opr idx = 12 INTEGER (4) rank = 0; line = 13, col = 8 Left opnd is AT_Tbl_Idx; line = 13, col = 8 t$1 idx = 476 INTEGER * Integer_4 <------correct type Right operand is IR_Tbl_Idx; Inquire_Iolength_Opr idx = 4 Typeless * 32 rank = 0; line = 13, col = 8 Left opnd is IL_Tbl_Idx; list cnt = 1 list item #1, idx = 1, CN_Tbl_Idx line = 13 col = 31 3 IDX = 4 INTEGER * Integer_4 Right operand is IL_Tbl_Idx; list cnt = 2 list item #1, idx = 2, IR_Tbl_Idx Io_Item_Type_Code_Opr idx = 14 INTEGER (4) rank = 0; line = 13, col = 40 DV_INTEGER DP = 0 DEFAULT TYPED INT_LEN = 32 DEC_LEN = 32 Left opnd is CN_Tbl_Idx; line = 13, col = 40 100 IDX = 12 INTEGER * Integer_4 Right operand is NO_Tbl_Idx; WHIRL dump: COMMENT <2,3,inquire(iolength=Tvar%field1)100,200> # {line: 1/13} COMMENT <2,4,START_IO> # {line: 1/13} PRAGMA 0 173 <null-st> 0 (0x0) # START_STMT_CLUMP {line: 1/13} IO_ITEM <1,NONE> IO_ITEM <10,NONE> I4INTCONST 3 (0x3) IO_ITEM <73,FIRST_LAST_FLAG> U8LDA 0 <2,2,t$1> T<57,anon_ptr.,8> IO_ITEM <75,INQLENGTH_VAR> I4INTCONST 100 (0x64) I8INTCONST 562958543355904 (0x2000200000000) IO_ITEM <98,EXPR> T<4,.predef_I4,4> I4INTCONST 200 (0xc8) I8INTCONST 562958543355904 (0x2000200000000) IO_ITEM <98,EXPR> T<4,.predef_I4,4> IO <26,INQUIRE_LENGTH,cray> 2 {line: 1/13} I4I4LDID 0 <2,2,t$1> T<4,.predef_I4,4> I4STID 0 <2,2,t$1> T<4,.predef_I4,4> {line: 1/13} <------- correct type I4I4LDID 0 <2,2,t$1> T<4,.predef_I4,4> I4STID 0 <2,1,TVAR> T<4,.predef_I4,4> {line: 1/13} PRAGMA 0 174 <null-st> 0 (0x0) # END_STMT_CLUMP {line: 1/13} COMMENT <2,5,END_IO> # {line: 1/13} MMLDID 0 <2,1,TVAR> T<53,T1,4> MRETURN_VAL {line: 1/14} END_BLOCK
------------------------------------------------------------------------------ Create and publish websites with WebMatrix Use the most popular FREE web apps or write code yourself; WebMatrix provides all the features you need to develop and publish your website. http://p.sf.net/sfu/ms-webmatrix-sf
_______________________________________________ Open64-devel mailing list Open64-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/open64-devel