Author: shihui
Date: 2011-04-06 01:54:02 -0400 (Wed, 06 Apr 2011)
New Revision: 3536

Modified:
   trunk/osprey/be/com/constraint_graph.cxx
Log:
Fix bug751:

StInfo::alignOffset doesn't return pointer size aligned constraint graph node.
Issue is computation order in expression "if (offset & (~(Pointer_Size-1)) == 
offset)" is wrong.
== has higher priority than &

Another isuse is handling complex element.
In setting modulus for complex, it's treated as a structure with two elements.
However in StInfo::alignOffset, it always aligns offset to the real part of the 
complex.
Which cauese real part always alias with img part.

Fix in StInfo::alignOffset
1. Correct computation order using parenthesis.
2. for complex, offset can be aligned to both real and img part.

Code Review: Sun Chan


Modified: trunk/osprey/be/com/constraint_graph.cxx
===================================================================
--- trunk/osprey/be/com/constraint_graph.cxx    2011-04-06 05:40:05 UTC (rev 
3535)
+++ trunk/osprey/be/com/constraint_graph.cxx    2011-04-06 05:54:02 UTC (rev 
3536)
@@ -2752,7 +2752,7 @@
   // is not need to adjust.  It is the sub-pointer size offsets
   // that will cause issues, especially if the offsets to not
   // match up with a valid field offset in the current TY
-  if (offset & (~(Pointer_Size-1)) == offset)
+  if ((offset & (~(Pointer_Size-1))) == offset)
     return offset;
 
   TY ty = Ty_Table[ty_idx];
@@ -2773,8 +2773,16 @@
   if (kind == KIND_SCALAR ||
       kind == KIND_FUNCTION ||
       kind == KIND_POINTER ||
-      kind == KIND_VOID)
-    offset = offset & (~(TY_size(ty)-1));
+      kind == KIND_VOID) {
+    UINT64 size = TY_size(ty);
+    // if scalar type is a complex, no need align to start of
+    // complex, it can also align to the imaginary part.
+    // Complex actually need treated as a struct.
+    if (MTYPE_is_complex(TY_mtype(ty))) {
+      size = size / 2;
+    }
+    offset = offset & (~(size-1));
+  }
   else { // kind == KIND_STRUCT
     FmtAssert(kind == KIND_STRUCT,("Expecting only structs here"));
 
@@ -2786,6 +2794,12 @@
          if (TY_kind(fty) == KIND_ARRAY ||
              TY_kind(fty) == KIND_STRUCT)
            offset = start + alignOffset(FLD_type(fld),(offset-start));
+         // treat complex as a struct
+         else if (MTYPE_is_complex(TY_mtype(fty))) {
+           UINT64 size = TY_size(fty);
+           size = size / 2;
+           offset = start + ((offset-start) & (~(size-1)));
+         }
          else
            offset = start;
          break;


------------------------------------------------------------------------------
Xperia(TM) PLAY
It's a major breakthrough. An authentic gaming
smartphone on the nation's most reliable network.
And it wants your games.
http://p.sf.net/sfu/verizon-sfdev
_______________________________________________
Open64-devel mailing list
Open64-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/open64-devel

Reply via email to