Example #1
0
    private void process(WorkItem wi) {
      Contract.Requires(wi != null);
      GenKillWeight/*!*/ w = wi.getWeightAfter();
      Contract.Assert(w != null);

      for (int i = wi.block.Cmds.Count - 1; i >= 0; i--) {
        Cmd/*!*/ c = wi.block.Cmds[i];
        Contract.Assert(c != null);
        if (c is CallCmd && procICFG.ContainsKey(cce.NonNull(cce.NonNull((CallCmd)c).Proc).Name)) {
          w = GenKillWeight.extend(getWeightCall(cce.NonNull((CallCmd)c)), w);
        } else {
          GenKillWeight/*!*/ cweight = getWeight(c, wi.cfg.impl, program);
          Contract.Assert(cweight != null);
          w = GenKillWeight.extend(cweight, w);
        }
      }

      bool change = wi.setWeightBefore(w);

      if (change && wi.cfg.srcNodes.Contains(wi.block)) {
        GenKillWeight/*!*/ prev = wi.cfg.summary;
        Contract.Assert(prev != null);
        GenKillWeight/*!*/ curr = GenKillWeight.combine(prev, wi.cfg.weightBefore[wi.block]);
        Contract.Assert(curr != null);
        if (!GenKillWeight.isEqual(prev, curr)) {
          wi.cfg.summary = curr;
          // push callers onto the worklist
          if (callers.ContainsKey(wi.cfg.impl.Name)) {
            foreach (WorkItem/*!*/ caller in callers[wi.cfg.impl.Name]) {
              Contract.Assert(caller != null);
              AddToWorkList(caller);
            }
          }
        }
      }

      foreach (Block/*!*/ b in wi.cfg.predEdges[wi.block]) {
        Contract.Assert(b != null);
        GenKillWeight/*!*/ prev = wi.cfg.weightAfter[b];
        Contract.Assert(prev != null);
        GenKillWeight/*!*/ curr = GenKillWeight.combine(prev, w);
        Contract.Assert(curr != null);
        if (!GenKillWeight.isEqual(prev, curr)) {
          wi.cfg.weightAfter[b] = curr;
          AddToWorkList(new WorkItem(wi.cfg, b));
        }
      }

    }