Use-define chain - Wikipedia
文章推薦指數: 80 %
A Use-Definition Chain (UD Chain) is a data structure that consists of a use, U, of a variable, and all the definitions, D, of that variable that can reach ...
Use-definechain
FromWikipedia,thefreeencyclopedia
Jumptonavigation
Jumptosearch
Datastructurethattracksvariableuseanddefinitions
AUse-DefinitionChain(UDChain)isadatastructurethatconsistsofause,U,ofavariable,andallthedefinitions,D,ofthatvariablethatcanreachthatusewithoutanyotherinterveningdefinitions.AUDChaingenerallymeanstheassignmentofsomevaluetoavariable.
AcounterpartofaUDChainisaDefinition-UseChain(DUChain),whichconsistsofadefinition,D,ofavariableandalltheuses,U,reachablefromthatdefinitionwithoutanyotherinterveningdefinitions.
BothUDandDUchainsarecreatedbyusingaformofstaticcodeanalysisknownasdataflowanalysis.Knowingtheuse-defanddef-usechainsforaprogramorsubprogramisaprerequisiteformanycompileroptimizations,includingconstantpropagationandcommonsubexpressionelimination.
Contents
1Purpose
2Setup
2.1DefinitionofaVariable
2.2UseofaVariable
3Execution
4Executionexamplefordef-use-chain
5Methodofbuildingause-def(orud)chain
Purpose[edit]
Makingtheuse-defineordefine-usechainsisastepinlivenessanalysis,sothatlogicalrepresentationsofallthevariablescanbeidentifiedandtrackedthroughthecode.
Considerthefollowingsnippetofcode:
intx=0;/*A*/
x=x+y;/*B*/
/*1,someusesofx*/
x=35;/*C*/
/*2,somemoreusesofx*/
Noticethatxisassignedavalueatthreepoints(markedA,B,andC).However,atthepointmarked"1",theuse-defchainforxshouldindicatethatitscurrentvaluemusthavecomefromlineB(anditsvalueatlineBmusthavecomefromlineA).Contrariwise,atthepointmarked"2",theuse-defchainforxindicatesthatitscurrentvaluemusthavecomefromlineC.Sincethevalueofthexinblock2doesnotdependonanydefinitionsinblock1orearlier,xmightaswellbeadifferentvariablethere;practicallyspeaking,itisadifferentvariable—callitx2.
intx=0;/*A*/
x=x+y;/*B*/
/*1,someusesofx*/
intx2=35;/*C*/
/*2,someusesofx2*/
Theprocessofsplittingxintotwoseparatevariablesiscalledliverangesplitting.Seealsostaticsingleassignmentform.
Setup[edit]
Thelistofstatementsdeterminesastrongorderamongstatements.
Statementsarelabeledusingthefollowingconventions:
s
(
i
)
{\displaystyles(i)}
,whereiisanintegerin
[
1
,
n
]
{\displaystyle[1,n]}
;andnisthenumberofstatementsinthebasicblock
Variablesareidentifiedinitalic(e.g.,v,uandt)
Everyvariableisassumedtohaveadefinitioninthecontextorscope.(Instaticsingleassignmentform,use-definechainsareexplicitbecauseeachchaincontainsasingleelement.)
Foravariable,suchasv,itsdeclarationisidentifiedasV(italiccapitalletter),andforshort,itsdeclarationisidentifiedas
s
(
0
)
{\displaystyles(0)}
.Ingeneral,adeclarationofavariablecanbeinanouterscope(e.g.,aglobalvariable).
DefinitionofaVariable[edit]
Whenavariable,v,isontheLHSofanassignmentstatement,suchas
s
(
j
)
{\displaystyles(j)}
,then
s
(
j
)
{\displaystyles(j)}
isadefinitionofv.Everyvariable(v)hasatleastonedefinitionbyitsdeclaration(V)(orinitialization).
UseofaVariable[edit]
Ifvariable,v,isontheRHSofstatement
s
(
j
)
{\displaystyles(j)}
,thereisastatement,
s
(
i
)
{\displaystyles(i)}
withi
延伸文章資訊
- 1What does UD stand for? - Abbreviations.com
What does UD stand for? What does UD mean? This page is about the various possible meanings of th...
- 2U/d Definition & Meaning | Dictionary.com
- 3What does UD mean? - Definitions.net
Definition of UD in the Definitions.net dictionary. Meaning of UD. What does UD mean? Information...
- 4UD - What does UD stand for? The Free Dictionary - Acronyms ...
- 5What does U.D. stand for? - Abbreviations.com
stand for? What does U.D. mean? This page is about the various possible meanings of the acronym, ...