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
延伸文章資訊
- 1ud - Urban Dictionary
Why the hell are you looking up the definition of ud, you are already here. Then again, why am I ...
- 2What does UD mean? - Definitions.net
Definition of UD in the Definitions.net dictionary. Meaning of UD. What does UD mean? Information...
- 3UD - 维基百科,自由的百科全书
UD可以指:. UD卡車, 日本一家卡車製造商; 民主统一(Democratic Unification),洪都拉斯一個政黨; 戴頓大學 · 特拉华大学 · 杜比克大學 · 底特律梅西大學, ...
- 4UD - Slang/Internet Slang - Acronym Finder
10 definitions of UD. Definition of UD in Slang/Internet Slang. What does UD stand for?
- 5U/d Definition & Meaning | Dictionary.com