For 32-bit targets, when address of data reference crosses the boundary of 
0x80000000, signed comparisons of address expressions will lead to  incorrect 
results.
Additional comments and patches are also available in the bug database.

My fix is:
1. In LFTR, force comparison of address expressions to use unsigned type for
32-bit targets.
2. Allow results of pointer arithmetic "p + a" and "p - a" (where "p" is a
pointer or an address expression, "a" is neither a pointer nor an address
expression") to be recognized as an address expression.

Index: be/opt/opt_htable.cxx
===================================================================
--- be/opt/opt_htable.cxx           (revision 3488)
+++ be/opt/opt_htable.cxx        (working copy)
@@ -5102,8 +5102,11 @@
       if (res0 == ADDRESSABILITY_UNKNOWN)
               return ADDRESSABILITY_UNKNOWN;
       res1 = Opnd(1)->Check_if_result_is_address(opt_stab);
-      if (res1 == ADDRESSABILITY_UNKNOWN)
+      if (res1 == ADDRESSABILITY_UNKNOWN) {
+             if (res0 == ADDRESSABILITY_IS_ADDRESS)
+               return res0;
               return ADDRESSABILITY_UNKNOWN;
+      }
       if (res0 == res1) {
         if (res0 == ADDRESSABILITY_IS_ADDRESS)
           return ADDRESSABILITY_NOT_ADDRESS;
Index: be/opt/opt_lftr2.cxx
===================================================================
--- be/opt/opt_lftr2.cxx                (revision 3488)
+++ be/opt/opt_lftr2.cxx             (working copy)
@@ -1216,11 +1216,18 @@
     // adjust operator of new comparison
     OPERATOR new_compare_opr = comparison_cr->Opr();
-#ifdef KEY
+#ifdef KEY
     MTYPE new_compare_type = tempcr->Dtyp();
     // do not change signedness of comparison since that could change semantics
     new_compare_type = Mtype_TransferSign(comparison_cr->Dsctyp(),
                                                                                
  new_compare_type);
+    if (Is_Target_32bit()
+             && (addressable == ADDRESSABILITY_IS_ADDRESS)
+             && MTYPE_is_signed(new_compare_type)) {
+      // For 32-bit targets, force comparison of address expressions to be 
unsigned.
+      new_compare_type = Mtype_from_mtype_class_and_size(MTYPE_CLASS_UNSIGNED,
+                                                                               
                              MTYPE_size_min(new_compare_type)/8);
+    }
#else
     MTYPE new_compare_type = comparison_cr->Dsctyp();
     if (addressable == ADDRESSABILITY_IS_ADDRESS &&

Attachment: odc
Description: odc

------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in 
Real-Time with Splunk. Collect, index and harness all the fast moving IT data 
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business 
insights. http://p.sf.net/sfu/splunk-dev2dev 
_______________________________________________
Open64-devel mailing list
Open64-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/open64-devel

Reply via email to