示例#1
0
        private VarSet InferCalleeOutputDependancy(CallCmd cmd, Variable output, Dependencies state, List <VarSet> inputExpressionsDependency)
        {
            if (Analysis.DacMerged != null && !IsImpactedOutput(cmd.Proc, output))
            {
                return(new VarSet());
            }

            if (!paramNameToIndex.ContainsKey(cmd.Proc))
            {
                paramNameToIndex[cmd.Proc] = new Dictionary <string, int>();
                for (int i = 0; i < cmd.Proc.InParams.Count; ++i)
                {
                    var p = cmd.Proc.InParams[i];
                    paramNameToIndex[cmd.Proc][p.Name] = i;
                }
            }

            var outputDependency        = ProcDependencies[cmd.Proc][output]; // output is dependent on a set of formals and globals
            var inferedOutputDependency = new VarSet();

            foreach (var dependentOn in outputDependency) // foreach (formal parameter p\global g) o_i is dependent upon
            {
                if (dependentOn is GlobalVariable)        // global
                {                                         // add in the global's dependency set
                    inferedOutputDependency.Add(dependentOn);
                    if (state.ContainsKey(dependentOn))
                    {
                        inferedOutputDependency.UnionWith(state[dependentOn]);
                    }
                    continue;
                }

                var inputIndex = 0;
                if (inputExpressionsDependency.Count == 0)
                {
                    continue;
                }

                //inputIndex = cmd.Proc.InParams.FindIndex(p => p.Name == dependentOn.Name);
                if (paramNameToIndex[cmd.Proc].ContainsKey(dependentOn.Name))
                {
                    inputIndex = paramNameToIndex[cmd.Proc][dependentOn.Name];
                }
                if (inputIndex >= 0) // formal parameter
                // replace the formal with the actual's dependency set
                {
                    inferedOutputDependency.UnionWith(inputExpressionsDependency[inputIndex]);
                }
            }

            return(inferedOutputDependency);
        }
示例#2
0
 public void InferDominatorDependency(Block currBlock, VarSet dependsSet)
 {
     if (dataOnly)
     {
         return;
     }
     // assignment under a branch is dependent on all the variables in the branch's conditional
     if (dominatedBy.Keys.Contains(currBlock))
     {
         foreach (var dominator in dominatedBy[currBlock])
         {
             if (branchCondVars.ContainsKey(dominator))
             {
                 foreach (var v in branchCondVars[dominator])
                 {
                     dependsSet.Add(v);
                     // it is also dependends on all that v depends on *at the point of branching*
                     if (worklist.stateSpace.ContainsKey(dominator.TransferCmd))
                     {
                         var domDep = worklist.stateSpace[dominator.TransferCmd];
                         if (domDep.ContainsKey(v))
                         {
                             dependsSet.UnionWith(domDep[v]);
                         }
                     }
                 }
             }
         }
     }
 }