Hi,

Would a gatekeeper please review my fix for bug 611:

https://bugs.open64.net/show_bug.cgi?id=611


The failing case is shown as following. It asserts when compiled in –m32.


typedef __complex__ double cdouble;

cdouble to_complex(double r) {

  cdouble z;

  __real__ z = r;

  return z;

}



The assertion (nrv type not in mem) happens in wgen_decl.cxx. The reason is
that gcc FE treats returning “complex double” as return_in_memory and
performs nrv opt in -m32 mode. While, wgen not treat any complex type as
return_in_memroy.



My fix is to set complex type whose tsize larger than 12 to be
return_in_memory in –m32 mode (according to gcc FE convention).  I also
changed two assertions to add complex type as one possibility of
return_in_memory type.



Thanks,



Min



Index: wgen_spin_symbol.cxx

===================================================================

--- wgen_spin_symbol.cxx        (revision 3336)

+++ wgen_spin_symbol.cxx        (working copy)

@@ -606,6 +606,10 @@

                default:  FmtAssert(FALSE, ("Get_TY unexpected size"));

                }

                idx = MTYPE_To_TY (mtype);      // use predefined type

+        // gcc FE will set the complex type with size larger than 12 to be

+        // return_in_memory in -m32 mode (e.g., gcc/config/i386/i386.c)

+        if (!TARGET_64BIT && tsize > 12)

+            Set_TY_return_in_mem(idx);

                break;

        case GS_POINTER_TYPE:

                if (gs_type_ptrmem_p(type_tree)) {



Index: wgen_stmt.cxx

===================================================================

--- wgen_stmt.cxx       (revision 3336)

+++ wgen_stmt.cxx       (working copy)

@@ -2326,8 +2326,9 @@

     // object is created by a TARGET_EXPR, have the TARGET_EXPR write
directly

     // to the memory return area.

     if (TY_return_in_mem(ret_ty_idx)) {

-      FmtAssert (TY_mtype (ret_ty_idx) == MTYPE_M,

-                ("WGEN_Expand_Return: return_in_mem type is not MTYPE_M"));

+      FmtAssert (TY_mtype (ret_ty_idx) == MTYPE_M ||

+        !TARGET_64BIT && MTYPE_is_complex(TY_mtype(ret_ty_idx)) && TY_mtype
(ret_ty_idx) != MTYPE_C4,

+                ("WGEN_Expand_Return: return_in_mem type is not MTYPE_M or
complex type"));

       // Skip the NOP_EXPRs, if any, before the TARGET_EXPR.  Bug 3448.

       gs_t t = retval;

       while (gs_tree_code(t) == GS_NOP_EXPR) {

@@ -2498,8 +2499,9 @@

       // Copy the return value into the return area.  Based on code in

       // lower_return_val().



-      FmtAssert (TY_mtype (ret_ty_idx) == MTYPE_M,

-                ("WGEN_Expand_Return: return_in_mem type is not MTYPE_M"));

+      FmtAssert (TY_mtype (ret_ty_idx) == MTYPE_M ||

+      !TARGET_64BIT && MTYPE_is_complex(TY_mtype(ret_ty_idx)) && TY_mtype
(ret_ty_idx) != MTYPE_C4,

+                ("WGEN_Expand_Return: return_in_mem type is not MTYPE_M or
complex type"));



       WN *first_formal = WN_formal(Current_Entry_WN(), 0);

       TY_IDX tidx = ST_type(WN_st(first_formal));
------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
Open64-devel mailing list
Open64-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/open64-devel

Reply via email to