<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
--></style>
</head>
<body class='hmmessage'>
Problem seems to be here:<div><br></div><div><br></div><div>fold-const.c:fold_ternary_loc<br>...</div><div><div>  switch (code)</div><div>...</div><div>    case BIT_FIELD_REF:</div><div>...</div><div><div>      /* A bit-field-ref that referenced the full argument can be stripped.  */</div><div>      if (INTEGRAL_TYPE_P (TREE_TYPE (arg0))</div><div><span class="Apple-tab-span" style="white-space:pre">     </span>  && TYPE_PRECISION (TREE_TYPE (arg0)) == tree_low_cst (arg1, 1)</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>  && integer_zerop (op2))</div><div><span class="Apple-tab-span" style="white-space:pre">       </span>return fold_convert_loc (loc, type, arg0);</div><div><br></div><div><br></div><div>Turning our bit field refs which are lvalues into casts (nop_expr) which are not.</div><div>For now I'll #if this out.</div><div>Further investigation: see how it compares to trunk; see if we can get the types right.</div><div><br></div><div> - Jay</div></div><br><hr id="stopSpelling">From: jay.krell@cornell.edu<br>To: m3devel@elegosoft.com; hosking@cs.purdue.edu<br>Date: Sun, 27 Jun 2010 13:44:06 +0000<br>Subject: Re: [M3devel] m3cg 4.5 problem<br><br>



<style>
.ExternalClass .ecxhmmessage P
{padding:0px;}
.ExternalClass body.ecxhmmessage
{font-size:10pt;font-family:Verdana;}
</style>


I almost have this figured out.<br><br><div>4.5:</div><div><br></div><div><div style="text-indent:0in !important">(gdb) break is_gimple_lvalue</div><div style="text-indent:0in !important">(gdb) run</div><div>Breakpoint 2, is_gimple_lvalue (t=0x414653b8) at ../../gcc-4.5/gcc/gimple.c:2456</div><div>2456<span class="ecxApple-tab-span" style="white-space:pre"> </span>  return (is_gimple_addressable (t)</div><div>(gdb) call debug_tree(t)</div><div> <nop_expr 0x414653b8</div><div>    type <integer_type 0x41417360 int_64 public DI</div><div>        size <integer_cst 0x41405340 constant 64></div><div>        unit size <integer_cst 0x41405360 constant 8></div><div>        align 64 symtab 0 alias set -1 canonical type 0x41417360 precision 64 min <integer_cst 0x414052e0 -9223372036854775808> max <integer_cst 0x41405300 9223372036854775807>></div><div>   </div><div>    arg 0 <var_decl 0x414680b8 M3_DxNB17_oc</div><div>        type <integer_type 0x414173c0 word_64 sizes-gimplified public unsigned DI size <integer_cst 0x41405340 64> unit size <integer_cst 0x41405360 8></div><div>            align 64 symtab 0 alias set -1 canonical type 0x414173c0 precision 64 min <integer_cst 0x41405380 0> max <integer_cst 0x41405320 18446744073709551615>></div><div>        unsigned DI file ../src/stmts/TypeCaseStmt.m3 line 12 col 0 size <integer_cst 0x41405340 64> unit size <integer_cst 0x41405360 8></div><div>        align 64 context <function_decl 0x41466400 TypeCaseStmt__GetOutcomex>>></div><div><br></div><div><br></div><br><div>(gdb) finish</div><div>Run till exit from #0  is_gimple_lvalue (t=0x414653b8) at ../../gcc-4.5/gcc/gimple.c:2456</div><div>0x004ea8bc 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:7262</div><div>7262<span class="ecxApple-tab-span" style="white-space:pre">      </span>gimple_test_f) (*expr_p))</div><div>Value returned is $13 = 0 '\0'</div><div><br></div><div><br></div><div>4.3:</div><div><div>(gdb) break is_gimple_lvalue</div><div>Breakpoint 1 at 0x5708e3: file ../../gcc/gcc/tree-gimple.c, line 147.</div><div>(gdb) run</div><div>Starting program: /Users/jay/dev2/cm3/m3-sys/m3cc/I386_DARWIN-I386_DARWIN-4.3/gcc/m3cgc1 -m64 TypeCaseStmt.mc</div><div>Reading symbols for shared libraries ++. done</div><div> TypeCaseStmt__GetOutcomex</div><div>Breakpoint 1, is_gimple_lvalue (t=0x41141060) at ../../gcc/gcc/tree-gimple.c:147</div><div>147<span class="ecxApple-tab-span" style="white-space:pre">     </span>  return (is_gimple_addressable (t)</div><div>(gdb) call debug_tree(t)</div><div> <var_decl 0x41141060 M3_DxNB17_oc</div><div>    type <integer_type 0x41111460 word_64 sizes-gimplified public unsigned DI</div><div>        size <integer_cst 0x40b2d6f0 constant invariant 64></div><div>        unit size <integer_cst 0x40b2d720 constant invariant 8></div><div>        align 64 symtab 0 alias set -1 canonical type 0x41111460 precision 64 min <integer_cst 0x40b2d750 0> max <integer_cst 0x40b2d6c0 18446744073709551615>></div><div>    unsigned DI file ../src/stmts/TypeCaseStmt.m3 line 12 col 0 size <integer_cst 0x40b2d6f0 64> unit size <integer_cst 0x40b2d720 8></div><div>    align 64 context <function_decl 0x4113e100 TypeCaseStmt__GetOutcomex>></div><div>(gdb) finish</div><div>Run till exit from #0  is_gimple_lvalue (t=0x41141060) at ../../gcc/gcc/tree-gimple.c:147</div><div>0x003d7541 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:6240</div><div>warning: Source file is more recent than executable.</div><div>6240<span class="ecxApple-tab-span" style="white-space:pre">        </span>  if (!internal_post && (*gimple_test_f) (*expr_p))</div><div>Value returned is $1 = 1 '\001'</div><div><br></div><div><br></div><div>nop_expr is what we use for casting.</div><div>We are casting int64 to word64.</div><div>The result of a cast is not an lvalue.</div><div>I suspect 4.3 has removed this as a "useless conversion".</div><div>..</div><div><br></div><div>In 4.5 we have:</div><div> gdb: call debug_tree(*expr_p)</div><div><br></div><div><div>        stmt <modify_expr 0x41456200 type <integer_type 0x41417360 int_64></div><div>            side-effects used</div><div>            arg 0 <nop_expr 0x414653b8 type <integer_type 0x41417360 int_64></div><div>                arg 0 <var_decl 0x414680b8 M3_DxNB17_oc>></div><div>            arg 1 <integer_cst 0x414057e0 constant 0></div><div>            ../src/stmts/TypeCaseStmt.m3:7:0></div><div><br></div><div><br></div><div>in 4.3 we have:</div><div><br></div><div><div>        stmt <modify_expr 0x4113d180 type <integer_type 0x411113f0 int_64></div><div>            side-effects used</div><div>            arg 0 <bit_field_ref 0x4113d150 type <integer_type 0x411113f0 int_64></div><div>                arg 0 <var_decl 0x41141060 M3_DxNB17_oc></div><div>                arg 1 <integer_cst 0x40b2d6f0 64></div><div>                arg 2 <integer_cst 0x40b2da20 constant invariant 0>></div><div>            arg 1 <integer_cst 0x40b2dde0 constant invariant 0></div><div>            ../src/stmts/TypeCaseStmt.m3:7:0></div><div> </div><div>Again, 4.5 reads:</div><div> (int64)oc = 0;</div><div><br></div><div>4.3 reads:</div><div>  (bit field ref)oc = 0;</div><div><br></div><div>int64 cast is not an lvalue, bit field ref is. Something like that.</div><div><br></div><div>Either one of the #if GCC45 I have or gcc has done a transform in the meantime..</div></div></div><div><br></div><div>I'll keep digging.</div><div><br></div><div>I don't believe we need the cast -- we should just get the type right in the first place.</div><div>But fixing that isn't necessarily what I'm going to do.</div><div>I have to see where 4.3 vs. 4.5 difference comes from first..</div><div><br></div><div><br></div><div> - Jay</div></div><div><br></div><br><br><hr id="ecxstopSpelling">From: jay.krell@cornell.edu<br>To: m3devel@elegosoft.com; hosking@cs.purdue.edu<br>Date: Sun, 27 Jun 2010 09:23:13 +0000<br>Subject: Re: [M3devel] m3cg 4.5 problem<br><br>



<style>
.ExternalClass .ecxhmmessage P
{padding:0px;}
.ExternalClass body.ecxhmmessage
{font-size:10pt;font-family:Verdana;}
</style>


I was a bit off. It is actually set of enum. Like this:<div><br></div><div><div>MODULE TypeCaseStmt;</div><div><br></div><div>TYPE T1 = {A,B};</div><div>TYPE T2 = SET OF T1;</div><div> </div><div>PROCEDURE GetOutcomex (): T2 =</div><div>  VAR oc := T2 {};</div><div>  BEGIN</div><div>    RETURN oc;</div><div>  END GetOutcomex;</div><div><br></div><div>BEGIN</div><div>END TypeCaseStmt.</div><div><br></div><div> - Jay</div><br><hr id="ecxecxstopSpelling">From: jay.krell@cornell.edu<br>To: m3devel@elegosoft.com; hosking@cs.purdue.edu<br>Date: Sun, 27 Jun 2010 08:12:54 +0000<br>Subject: [M3devel] m3cg 4.5 problem<br><br>



<style>
.ExternalClass .ecxhmmessage P
{padding:0px;}
.ExternalClass body.ecxhmmessage
{font-size:10pt;font-family:Verdana;}
</style>


<div>This tiny bit of code, which is cut down from m3front, causes an assertion failure in a 4.5 m3cg:</div><div><br></div><div>MODULE TypeCaseStmt;</div><div><br></div><div>IMPORT M3ID, CG, Expr, Stmt, StmtRep, Type, Variable, Scope;</div><div><br></div><div>PROCEDURE GetOutcomex (): Stmt.Outcomes =</div><div>  VAR oc := Stmt.Outcomes {};  line 6</div><div>  BEGIN</div><div>    RETURN oc;</div><div>  END GetOutcomex;</div><div><br></div><div>BEGIN</div><div>END TypeCaseStmt.</div><div><br></div><div>../src/stmts/TypeCaseStmt.m3:6:0: internal compiler error: in gimplify_expr, at gimplify.c:7315</div><div>Please submit a full bug report,</div><div><br></div><div><br></div><div><div><div>(1) begin_unit</div><div>(2) set_source_file</div><div>(3) set_source_line</div><div>  source line    1</div><div>(4) comment</div><div>  comment: `module global constants'</div><div>(5) declare_segment</div><div>  segment L_1 typeid 0xffffffff</div><div>(6) comment</div><div>  comment: `module global data'</div><div>(7) declare_segment</div><div>  segment MM_TypeCaseStmt typeid 0xffffffff</div><div>(8) set_source_line</div><div>  source line   11</div><div>(9) declare_procedure</div><div>  type:addr</div><div>  procedure:TypeCaseStmt_M3 nparams:0x1 rettype:addr lev:0 exported:1</div><div>(10) declare_param</div><div>  type:int64</div><div>  param M3_AcxOUs_mode type:int64 typeid:0x195c2a74 bytesize:0x40 alignment:0x40 in_memory:0x0 up_level:0x0</div><div>  mode 0x11 (DImode)</div><div>(11) import_procedure</div><div>  type:addr</div><div>  procedure:TypeCaseStmt_I3 nparams:0x0 rettype:addr</div><div>(12) export_unit</div><div>(13) import_procedure</div><div>  type:addr</div><div>  procedure:Scope_I3 nparams:0x0 rettype:addr</div><div>(14) import_unit</div><div>(15) import_procedure</div><div>  type:addr</div><div>  procedure:Variable_I3 nparams:0x0 rettype:addr</div><div>(16) import_unit</div><div>(17) import_procedure</div><div>  type:addr</div><div>  procedure:Type_I3 nparams:0x0 rettype:addr</div><div>(18) import_unit</div><div>(19) import_procedure</div><div>  type:addr</div><div>  procedure:StmtRep_I3 nparams:0x0 rettype:addr</div><div>(20) import_unit</div><div>(21) import_procedure</div><div>  type:addr</div><div>  procedure:Stmt_I3 nparams:0x0 rettype:addr</div><div>(22) import_unit</div><div>(23) import_procedure</div><div>  type:addr</div><div>  procedure:Expr_I3 nparams:0x0 rettype:addr</div><div>(24) import_unit</div><div>(25) import_procedure</div><div>  type:addr</div><div>  procedure:CG_I3 nparams:0x0 rettype:addr</div><div>(26) import_unit</div><div>(27) import_procedure</div><div>  type:addr</div><div>  procedure:M3ID_I3 nparams:0x0 rettype:addr</div><div>(28) import_unit</div><div>(29) import_procedure</div><div>  type:addr</div><div>  procedure:RTHooks_I3 nparams:0x0 rettype:addr</div><div>(30) import_unit</div><div>(31) declare_procedure</div><div>  type:word64</div><div>  procedure:TypeCaseStmt__GetOutcomex nparams:0x0 rettype:word64 lev:0 exported:0</div><div>(32) declare_local</div><div>  type:word64</div><div>  local var M3_EXQtd6_oc type:word64 size:0x40 alignment:0x40</div><div>(33) declare_local</div><div>  type:word64</div><div>  local var M3_EXQtd6__result type:word64 size:0x40 alignment:0x40</div><div>(34) comment</div><div>  comment: `GetOutcomex'</div><div>(35) set_source_line</div><div>  source line    5</div><div>(36) begin_procedure</div><div>  procedure TypeCaseStmt__GetOutcomex</div><div> TypeCaseStmt__GetOutcomex(37) set_source_line</div><div>  source line    6</div><div>(38) load_integer</div><div>  type:int64</div><div>  integer:0x0</div><div>(39) store</div><div>  type:int64</div><div>  type:int64</div><div>  store (M3_EXQtd6_oc) offset:0x0 src_t:int64 dst_t:int64</div><div>(40) set_source_line</div><div>  source line    8</div><div>(41) load</div><div>  type:word64</div><div>  type:int64</div><div>  m3cg_load (M3_EXQtd6_oc): offset 0x0, convert word64 -> int64</div><div>(42) exit_proc</div><div>  type:word64</div><div>(43) end_procedure</div><div>  procedure TypeCaseStmt__GetOutcomex</div><div><br></div><div><br></div><div><div>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:763</div><div>763<span class="ecxecxecxApple-tab-span" style="white-space:pre">   </span>  internal_error ("in %s, at %s:%d", function, trim_filename (file), line);</div><div>(gdb) bt</div><div>#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</div><div>#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</div><div>#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</div><div>#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</div><div>#4  0x00000001004c7800 in gimplify_stmt (stmt_p=0x1416a5f28, seq_p=0x7fff5fbff420) at ../../gcc-4.5/gcc/gimplify.c:5264</div><div>#5  0x00000001004be376 in gimplify_statement_list (expr_p=0x1416c4030, pre_p=0x7fff5fbff420) at ../../gcc-4.5/gcc/gimplify.c:1382</div><div>#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</div><div>#7  0x00000001004c7800 in gimplify_stmt (stmt_p=0x1416c4030, seq_p=0x7fff5fbff420) at ../../gcc-4.5/gcc/gimplify.c:5264</div><div>#8  0x00000001004bdb6c in gimplify_bind_expr (expr_p=0x1416c2298, pre_p=0x7fff5fbff778) at ../../gcc-4.5/gcc/gimplify.c:1127</div><div>#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</div><div>#10 0x00000001004c7800 in gimplify_stmt (stmt_p=0x1416c2298, seq_p=0x7fff5fbff778) at ../../gcc-4.5/gcc/gimplify.c:5264</div><div>#11 0x00000001004ccbe6 in gimplify_body (body_p=0x1416c2298, fndecl=0x1416c2200, do_parms=1 '\001') at ../../gcc-4.5/gcc/gimplify.c:7528</div><div>#12 0x00000001004cceae in gimplify_function_tree (fndecl=0x1416c2200) at ../../gcc-4.5/gcc/gimplify.c:7624</div><div>#13 0x00000001000069c7 in m3_gimplify_function (fndecl=0x1416c2200) at ../../gcc-4.5/gcc/m3cg/parse.c:2370</div><div>#14 0x0000000100009cb4 in m3cg_end_procedure () at ../../gcc-4.5/gcc/m3cg/parse.c:3642</div><div>#15 0x000000010000feb5 in m3_parse_file (xx=0) at ../../gcc-4.5/gcc/m3cg/parse.c:5550</div><div>#16 0x00000001006be6a2 in compile_file () at ../../gcc-4.5/gcc/toplev.c:1053</div><div>#17 0x00000001006c0e19 in do_compile () at ../../gcc-4.5/gcc/toplev.c:2415</div><div>#18 0x00000001006c0ee0 in toplev_main (argc=3, argv=0x7fff5fbff930) at ../../gcc-4.5/gcc/toplev.c:2457</div><div>#19 0x000000010001743b in main (argc=3, argv=0x7fff5fbff930) at ../../gcc-4.5/gcc/main.c:35</div><div>(</div><div><br></div></div></div><div><br></div><div>Wierd, huh?</div><div><br></div><div>The only thing I can think of an int/word mismatch.</div><div>I did change one instance of Integer to Word, after finding this.</div><div>Stmt.Outcomes is an enumeration.</div><div>So presumably Stmt.Outcomes { } is 0.</div><div>Enumerations should work equally well as Integer or Word, right?</div><div>Clearly above there is still a mix. I can try changing them all to Word.</div><div><br></div><div><br></div><div>I'll keep digging.</div><div><br></div><div><br></div><div>Maybe dump the entire function generic tree for this and similar C.</div><div><br></div><div><br></div><div> - Jay</div></div></div></div></div>                                    </body>
</html>