[M3devel] m3cg 4.5 problem
Jay K
jay.krell at cornell.edu
Sun Jun 27 17:04:59 CEST 2010
Problem seems to be here:
fold-const.c:fold_ternary_loc
... switch (code)... case BIT_FIELD_REF:... /* A bit-field-ref that referenced the full argument can be stripped. */ if (INTEGRAL_TYPE_P (TREE_TYPE (arg0)) && TYPE_PRECISION (TREE_TYPE (arg0)) == tree_low_cst (arg1, 1) && integer_zerop (op2)) return fold_convert_loc (loc, type, arg0);
Turning our bit field refs which are lvalues into casts (nop_expr) which are not.For now I'll #if this out.Further investigation: see how it compares to trunk; see if we can get the types right.
- Jay
From: jay.krell at cornell.edu
To: m3devel at elegosoft.com; hosking at cs.purdue.edu
Date: Sun, 27 Jun 2010 13:44:06 +0000
Subject: Re: [M3devel] m3cg 4.5 problem
I almost have this figured out.
4.5:
(gdb) break is_gimple_lvalue(gdb) runBreakpoint 2, is_gimple_lvalue (t=0x414653b8) at ../../gcc-4.5/gcc/gimple.c:24562456 return (is_gimple_addressable (t)(gdb) call debug_tree(t) <nop_expr 0x414653b8 type <integer_type 0x41417360 int_64 public DI size <integer_cst 0x41405340 constant 64> unit size <integer_cst 0x41405360 constant 8> align 64 symtab 0 alias set -1 canonical type 0x41417360 precision 64 min <integer_cst 0x414052e0 -9223372036854775808> max <integer_cst 0x41405300 9223372036854775807>> arg 0 <var_decl 0x414680b8 M3_DxNB17_oc type <integer_type 0x414173c0 word_64 sizes-gimplified public unsigned DI size <integer_cst 0x41405340 64> unit size <integer_cst 0x41405360 8> align 64 symtab 0 alias set -1 canonical type 0x414173c0 precision 64 min <integer_cst 0x41405380 0> max <integer_cst 0x41405320 18446744073709551615>> unsigned DI file ../src/stmts/TypeCaseStmt.m3 line 12 col 0 size <integer_cst 0x41405340 64> unit size <integer_cst 0x41405360 8> align 64 context <function_decl 0x41466400 TypeCaseStmt__GetOutcomex>>>
(gdb) finishRun till exit from #0 is_gimple_lvalue (t=0x414653b8) at ../../gcc-4.5/gcc/gimple.c:24560x004ea8bc in gimplify_expr (expr_p=0x41456218, pre_p=0xbffff510, post_p=0xbffff230, gimple_test_f=0x4c9bd5 <is_gimple_lvalue>, fallback=2) at ../../gcc-4.5/gcc/gimplify.c:72627262 gimple_test_f) (*expr_p))Value returned is $13 = 0 '\0'
4.3:(gdb) break is_gimple_lvalueBreakpoint 1 at 0x5708e3: file ../../gcc/gcc/tree-gimple.c, line 147.(gdb) runStarting program: /Users/jay/dev2/cm3/m3-sys/m3cc/I386_DARWIN-I386_DARWIN-4.3/gcc/m3cgc1 -m64 TypeCaseStmt.mcReading symbols for shared libraries ++. done TypeCaseStmt__GetOutcomexBreakpoint 1, is_gimple_lvalue (t=0x41141060) at ../../gcc/gcc/tree-gimple.c:147147 return (is_gimple_addressable (t)(gdb) call debug_tree(t) <var_decl 0x41141060 M3_DxNB17_oc type <integer_type 0x41111460 word_64 sizes-gimplified public unsigned DI size <integer_cst 0x40b2d6f0 constant invariant 64> unit size <integer_cst 0x40b2d720 constant invariant 8> align 64 symtab 0 alias set -1 canonical type 0x41111460 precision 64 min <integer_cst 0x40b2d750 0> max <integer_cst 0x40b2d6c0 18446744073709551615>> unsigned DI file ../src/stmts/TypeCaseStmt.m3 line 12 col 0 size <integer_cst 0x40b2d6f0 64> unit size <integer_cst 0x40b2d720 8> align 64 context <function_decl 0x4113e100 TypeCaseStmt__GetOutcomex>>(gdb) finishRun till exit from #0 is_gimple_lvalue (t=0x41141060) at ../../gcc/gcc/tree-gimple.c:1470x003d7541 in gimplify_expr (expr_p=0x4113d16c, pre_p=0xbffff350, post_p=0xbffff34c, gimple_test_f=0x5708dd <is_gimple_lvalue>, fallback=fb_either) at ../../gcc/gcc/gimplify.c:6240warning: Source file is more recent than executable.6240 if (!internal_post && (*gimple_test_f) (*expr_p))Value returned is $1 = 1 '\001'
nop_expr is what we use for casting.We are casting int64 to word64.The result of a cast is not an lvalue.I suspect 4.3 has removed this as a "useless conversion"...
In 4.5 we have: gdb: call debug_tree(*expr_p)
stmt <modify_expr 0x41456200 type <integer_type 0x41417360 int_64> side-effects used arg 0 <nop_expr 0x414653b8 type <integer_type 0x41417360 int_64> arg 0 <var_decl 0x414680b8 M3_DxNB17_oc>> arg 1 <integer_cst 0x414057e0 constant 0> ../src/stmts/TypeCaseStmt.m3:7:0>
in 4.3 we have:
stmt <modify_expr 0x4113d180 type <integer_type 0x411113f0 int_64> side-effects used arg 0 <bit_field_ref 0x4113d150 type <integer_type 0x411113f0 int_64> arg 0 <var_decl 0x41141060 M3_DxNB17_oc> arg 1 <integer_cst 0x40b2d6f0 64> arg 2 <integer_cst 0x40b2da20 constant invariant 0>> arg 1 <integer_cst 0x40b2dde0 constant invariant 0> ../src/stmts/TypeCaseStmt.m3:7:0> Again, 4.5 reads: (int64)oc = 0;
4.3 reads: (bit field ref)oc = 0;
int64 cast is not an lvalue, bit field ref is. Something like that.
Either one of the #if GCC45 I have or gcc has done a transform in the meantime..
I'll keep digging.
I don't believe we need the cast -- we should just get the type right in the first place.But fixing that isn't necessarily what I'm going to do.I have to see where 4.3 vs. 4.5 difference comes from first..
- Jay
From: jay.krell at cornell.edu
To: m3devel at elegosoft.com; hosking at cs.purdue.edu
Date: Sun, 27 Jun 2010 09:23:13 +0000
Subject: Re: [M3devel] m3cg 4.5 problem
I was a bit off. It is actually set of enum. Like this:
MODULE TypeCaseStmt;
TYPE T1 = {A,B};TYPE T2 = SET OF T1; PROCEDURE GetOutcomex (): T2 = VAR oc := T2 {}; BEGIN RETURN oc; END GetOutcomex;
BEGINEND TypeCaseStmt.
- Jay
From: jay.krell at cornell.edu
To: m3devel at elegosoft.com; hosking at cs.purdue.edu
Date: Sun, 27 Jun 2010 08:12:54 +0000
Subject: [M3devel] m3cg 4.5 problem
This tiny bit of code, which is cut down from m3front, causes an assertion failure in a 4.5 m3cg:
MODULE TypeCaseStmt;
IMPORT M3ID, CG, Expr, Stmt, StmtRep, Type, Variable, Scope;
PROCEDURE GetOutcomex (): Stmt.Outcomes = VAR oc := Stmt.Outcomes {}; line 6 BEGIN RETURN oc; END GetOutcomex;
BEGINEND TypeCaseStmt.
../src/stmts/TypeCaseStmt.m3:6:0: internal compiler error: in gimplify_expr, at gimplify.c:7315Please submit a full bug report,
(1) begin_unit(2) set_source_file(3) set_source_line source line 1(4) comment comment: `module global constants'(5) declare_segment segment L_1 typeid 0xffffffff(6) comment comment: `module global data'(7) declare_segment segment MM_TypeCaseStmt typeid 0xffffffff(8) set_source_line source line 11(9) declare_procedure type:addr procedure:TypeCaseStmt_M3 nparams:0x1 rettype:addr lev:0 exported:1(10) declare_param type:int64 param M3_AcxOUs_mode type:int64 typeid:0x195c2a74 bytesize:0x40 alignment:0x40 in_memory:0x0 up_level:0x0 mode 0x11 (DImode)(11) import_procedure type:addr procedure:TypeCaseStmt_I3 nparams:0x0 rettype:addr(12) export_unit(13) import_procedure type:addr procedure:Scope_I3 nparams:0x0 rettype:addr(14) import_unit(15) import_procedure type:addr procedure:Variable_I3 nparams:0x0 rettype:addr(16) import_unit(17) import_procedure type:addr procedure:Type_I3 nparams:0x0 rettype:addr(18) import_unit(19) import_procedure type:addr procedure:StmtRep_I3 nparams:0x0 rettype:addr(20) import_unit(21) import_procedure type:addr procedure:Stmt_I3 nparams:0x0 rettype:addr(22) import_unit(23) import_procedure type:addr procedure:Expr_I3 nparams:0x0 rettype:addr(24) import_unit(25) import_procedure type:addr procedure:CG_I3 nparams:0x0 rettype:addr(26) import_unit(27) import_procedure type:addr procedure:M3ID_I3 nparams:0x0 rettype:addr(28) import_unit(29) import_procedure type:addr procedure:RTHooks_I3 nparams:0x0 rettype:addr(30) import_unit(31) declare_procedure type:word64 procedure:TypeCaseStmt__GetOutcomex nparams:0x0 rettype:word64 lev:0 exported:0(32) declare_local type:word64 local var M3_EXQtd6_oc type:word64 size:0x40 alignment:0x40(33) declare_local type:word64 local var M3_EXQtd6__result type:word64 size:0x40 alignment:0x40(34) comment comment: `GetOutcomex'(35) set_source_line source line 5(36) begin_procedure procedure TypeCaseStmt__GetOutcomex TypeCaseStmt__GetOutcomex(37) set_source_line source line 6(38) load_integer type:int64 integer:0x0(39) store type:int64 type:int64 store (M3_EXQtd6_oc) offset:0x0 src_t:int64 dst_t:int64(40) set_source_line source line 8(41) load type:word64 type:int64 m3cg_load (M3_EXQtd6_oc): offset 0x0, convert word64 -> int64(42) exit_proc type:word64(43) end_procedure procedure TypeCaseStmt__GetOutcomex
Breakpoint 1, fancy_abort (file=0x1009f0c6f "../../gcc-4.5/gcc/gimplify.c", line=7315, function=0x1009f1242 "gimplify_expr") at ../../gcc-4.5/gcc/diagnostic.c:763763 internal_error ("in %s, at %s:%d", function, trim_filename (file), line);(gdb) bt#0 fancy_abort (file=0x1009f0c6f "../../gcc-4.5/gcc/gimplify.c", line=7315, function=0x1009f1242 "gimplify_expr") at ../../gcc-4.5/gcc/diagnostic.c:763#1 0x00000001004cc4d6 in gimplify_expr (expr_p=0x1410e2060, pre_p=0x7fff5fbff420, post_p=0x7fff5fbfeff8, gimple_test_f=0x1004aac7f <is_gimple_lvalue>, fallback=2) at ../../gcc-4.5/gcc/gimplify.c:7315#2 0x00000001004c5ad3 in gimplify_modify_expr (expr_p=0x1416a5f28, pre_p=0x7fff5fbff420, post_p=0x7fff5fbfeff8, want_value=0 '\0') at ../../gcc-4.5/gcc/gimplify.c:4444#3 0x00000001004caafc in gimplify_expr (expr_p=0x1416a5f28, pre_p=0x7fff5fbff420, post_p=0x7fff5fbfeff8, gimple_test_f=0x1004ab1a6 <is_gimple_stmt>, fallback=0) at ../../gcc-4.5/gcc/gimplify.c:6619#4 0x00000001004c7800 in gimplify_stmt (stmt_p=0x1416a5f28, seq_p=0x7fff5fbff420) at ../../gcc-4.5/gcc/gimplify.c:5264#5 0x00000001004be376 in gimplify_statement_list (expr_p=0x1416c4030, pre_p=0x7fff5fbff420) at ../../gcc-4.5/gcc/gimplify.c:1382#6 0x00000001004cb6f5 in gimplify_expr (expr_p=0x1416c4030, pre_p=0x7fff5fbff420, post_p=0x7fff5fbff2e8, gimple_test_f=0x1004ab1a6 <is_gimple_stmt>, fallback=0) at ../../gcc-4.5/gcc/gimplify.c:6935#7 0x00000001004c7800 in gimplify_stmt (stmt_p=0x1416c4030, seq_p=0x7fff5fbff420) at ../../gcc-4.5/gcc/gimplify.c:5264#8 0x00000001004bdb6c in gimplify_bind_expr (expr_p=0x1416c2298, pre_p=0x7fff5fbff778) at ../../gcc-4.5/gcc/gimplify.c:1127#9 0x00000001004cae2b in gimplify_expr (expr_p=0x1416c2298, pre_p=0x7fff5fbff778, post_p=0x7fff5fbff618, gimple_test_f=0x1004ab1a6 <is_gimple_stmt>, fallback=0) at ../../gcc-4.5/gcc/gimplify.c:6719#10 0x00000001004c7800 in gimplify_stmt (stmt_p=0x1416c2298, seq_p=0x7fff5fbff778) at ../../gcc-4.5/gcc/gimplify.c:5264#11 0x00000001004ccbe6 in gimplify_body (body_p=0x1416c2298, fndecl=0x1416c2200, do_parms=1 '\001') at ../../gcc-4.5/gcc/gimplify.c:7528#12 0x00000001004cceae in gimplify_function_tree (fndecl=0x1416c2200) at ../../gcc-4.5/gcc/gimplify.c:7624#13 0x00000001000069c7 in m3_gimplify_function (fndecl=0x1416c2200) at ../../gcc-4.5/gcc/m3cg/parse.c:2370#14 0x0000000100009cb4 in m3cg_end_procedure () at ../../gcc-4.5/gcc/m3cg/parse.c:3642#15 0x000000010000feb5 in m3_parse_file (xx=0) at ../../gcc-4.5/gcc/m3cg/parse.c:5550#16 0x00000001006be6a2 in compile_file () at ../../gcc-4.5/gcc/toplev.c:1053#17 0x00000001006c0e19 in do_compile () at ../../gcc-4.5/gcc/toplev.c:2415#18 0x00000001006c0ee0 in toplev_main (argc=3, argv=0x7fff5fbff930) at ../../gcc-4.5/gcc/toplev.c:2457#19 0x000000010001743b in main (argc=3, argv=0x7fff5fbff930) at ../../gcc-4.5/gcc/main.c:35(
Wierd, huh?
The only thing I can think of an int/word mismatch.I did change one instance of Integer to Word, after finding this.Stmt.Outcomes is an enumeration.So presumably Stmt.Outcomes { } is 0.Enumerations should work equally well as Integer or Word, right?Clearly above there is still a mix. I can try changing them all to Word.
I'll keep digging.
Maybe dump the entire function generic tree for this and similar C.
- Jay
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20100627/0a29baa9/attachment-0002.html>
More information about the M3devel
mailing list