예제 #1
0
 /** Print the value numbers for each node in the value graph. */
 public void printValueNumbers() {
   for (Enumeration e = valueGraph.enumerateVertices(); e.hasMoreElements(); ) {
     OPT_ValueGraphVertex v = (OPT_ValueGraphVertex) e.nextElement();
     int valueNumber = v.getValueNumber();
     OPT_GVCongruenceClass c = (OPT_GVCongruenceClass) B.get(valueNumber);
     System.out.println(v.name + " " + valueNumber + " " + c.getLabel());
   }
 }
예제 #2
0
  /**
   * Definitely-different relation for two value numbers. Returns true for the following cases:
   *
   * <ul>
   *   <li>v1 and v2 are both constants, but don't match
   *   <li>v1 and v2 both result from NEW statements, but don't match
   *   <li>one of v1 and v2 is a parameter, and the other results from a new statement
   * </ul>
   *
   * <p>TODO: add more smarts
   *
   * @param v1 first value number
   * @param v2 second value number
   * @return true iff the value numbers for two variables are definitely different
   */
  public boolean DD(int v1, int v2) {
    if ((v1 == -1) || (v2 == -1)) return false;
    OPT_GVCongruenceClass class1 = (OPT_GVCongruenceClass) B.get(v1);
    OPT_GVCongruenceClass class2 = (OPT_GVCongruenceClass) B.get(v2);
    Object label1 = class1.getLabel();
    Object label2 = class2.getLabel();
    // if one is a constant, they must both be ...
    if (isConstant(label1) && !isConstant(label2)) return false;
    if (!isConstant(label1) && isConstant(label2)) return false;
    if (isConstant(label1)) return (v1 != v2);
    // handle DD for allocations
    if (isBornAtAllocation(label1)) {
      if (isBornAtAllocation(label2)) {
        // both are NEW.  Are they dd?
        return (v1 != v2);
      } else if (class2.containsParameter()) {
        // one is NEW, other is parameter. They are DD.
        return true;
      }
    } else {
      if (isBornAtAllocation(label2)) {
        if (class1.containsParameter()) {
          // one is NEW, other is parameter. They are DD.
          return true;
        }
      }
    }
    // assume parameters are not aliased?
    if (NO_PARAM_ALIAS) {
      if (v1 != v2) {
        if (class1.containsParameter()) {
          if (class2.containsParameter()) {
            return true;
          }
        }
      }
    }

    // if we haven't figured out they're DD, return false;
    return false;
  }