Data dependences, which relate statements that compute data values to statements that use those values, are useful for automating a variety of program-comprehension-related activities, such as reverse engineering, impact analysis, and debugging. Unfortunat
ninetypes—inwhicheitherthede nitionortheuseisnotde nite—intoonetype,whichtheycallveryweakdef-useassociation.
3.4Computationofdef-useassociations
Tocomputethedi erenttypesofdef-useassociationsidenti edintheprevioussection,wemodifybothstepsofthetraditionalalgorithmforcomputingdef-useassociations:(1)thecomputationofreachingde nitionsusingdata- owequations,and(2)thecomputationofthedef-useassociationsusingthereachingde nitions.Topropagateadditionalinformationandcomputesolutionsateachnodethatfacilitatetheidenti cationofeachofthe24typesofdef-useassociations,weextendthereaching-de nitioncomputationintwoways.First,unlikethetraditionalalgorithm,themodi edalgorithmcomputestwosetsofreachingde nitionsateachnode—oneforthosede nitionsthatde nitelyreachthenode,andtheotherforthosede nitionsthatpossiblyreachthenode.Second,unlikethetraditionalalgorithm,whichdoesnotpropagatekilledde nitions,themodi edalgorithmalsopropagatesthekilledde nitionsandcomputes,ateachnode,thesetofde nitionsthatarekilledalongapathtothatnode.Thus,ateachnode,themodi edalgorithmcomputesasolutionthatcomprisesthreesetsofreachingde nitions:thede nitereachingde nitions,thepossiblereachingde nitions,andthekilledreachingde nitions.
Figure5presentsthemodi edalgorithmforcomputingreachingde nitions.Theoverallstructureofthemodi edalgorithmisthethesameasthatofthetraditionalalgorithm.Thealgorithmevaluatesasetofdata- owequationsateachnode,andpropagatesthesolutionsoftheequationstothesuccessorsofthenodeintheCFG;thealgorithmperformsthesestepsiterativelyuntilthesolutionsateachnodeconverge.Todistinguishde nitereachingde nitionsfrompossiblereachingde nitions,thealgorithmreceivesasinputtwotypesofkillinformationforeachnode:KILLd(n)containsthede nitionsthatarede nitelykilledatnoden,whereasKILLp(n)containsthosede nitionsthatarepossiblykilledatnoden.ThealgorithmalsoassociatesthreeseparateINandOUTsetswitheachnode,oneseteachforde nitereachingde nitions,possiblereachingde nitions,andkilledreachingde nitions.Thealgorithmmanipulateseachofthesesetsinasimilarway.First,algorithmcomputestheINsetsatanodenbymergingtherespectiveOUTsetsofallpredecessorsofn(lines6,9,and12).Next,thealgorithmsavesthecurrentvaluesoftheOUTsetsatnodenpriortocomputingthenewvaluesforthosesets(lines7,10,and13).Finally,thealgorithmcomputesnewvaluesfortheOUTsetsatnodenusingthefollowingequations:
OUTd(n)=GEN(n)∪(INd(n) KILLd(n) KILLp(n))(line8);itcontainsthosede nitionsthateitheraregeneratedatnoden,orde nitelyreachtheentryofnodenandareneitherde nitelykillednorpossiblykilledatnoden.
OUTp(n)=(INp(n) KILLd(n))∪(INd(n)∩KILLp(n))(line11);itcontains(1)de nitionsthatei-therpossiblyreachtheentryofnandarenotde nitelykilledatn,and(2)de nitionsthatde nitelyreachtheentryofnandarepossiblykilledatn.
OUTk(n)=INk(n)∪(INd(n)∪INp(n)∩KILLd(n))(line14);itcontains(1)thosekilledde nitionsthatreachtheentryofn,and(2)thosede nitionsthatde nitelyorpossiblyreachtheentryofnandarede nitelykilledatn.
IfthevalueofanyOUTsetatnodenchanges,thealgorithmsetsthe agchange(lines15–16),whichcausesthenodesintheCFGtobeprocessedagain.ThealgorithmterminateswhentheOUTsetsateach