Use-define chain

Within computer science, a use-definition chain (or 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 that use without any other intervening definitions.[1][2] A UD Chain generally means the assignment of some value to a variable.

A counterpart of a UD Chain is a definition-use chain (or DU chain), which consists of a definition D of a variable and all the uses U reachable from that definition without any other intervening definitions.[3]

Both UD and DU chains are created by using a form of static code analysis known as data flow analysis. Knowing the use-def and def-use chains for a program or subprogram is a prerequisite for many compiler optimizations, including constant propagation and common subexpression elimination.

Purpose

Making the use-define or define-use chains is a step in liveness analysis, so that logical representations of all the variables can be identified and tracked through the code.

Consider the following snippet of code:

 int x = 0;    /* A */
 x = x + y;    /* B */
 /* 1, some uses of x */
 x = 35;       /* C */
 /* 2, some more uses of x */

Notice that x is assigned a value at three points (marked A, B, and C). However, at the point marked "1", the use-def chain for x should indicate that its current value must have come from line B (and its value at line B must have come from line A). Contrariwise, at the point marked "2", the use-def chain for x indicates that its current value must have come from line C. Since the value of the x in block 2 does not depend on any definitions in block 1 or earlier, x might as well be a different variable there; practically speaking, it is a different variable — call it x2.

 int x = 0;    /* A */
 x = x + y;    /* B */
 /* 1, some uses of x */
 int x2 = 35;  /* C */
 /* 2, some uses of x2 */

The process of splitting x into two separate variables is called live range splitting. See also static single assignment form.

Setup

The list of statements determines a strong order among statements.

  • Statements are labeled using the following conventions: , where i is an integer in ; and n is the number of statements in the basic block
  • Variables are identified in italic (e.g., v,u and t)
  • Every variable is assumed to have a definition in the context or scope. (In static single assignment form, use-define chains are explicit because each chain contains a single element.)

For a variable, such as v, its declaration is identified as V (italic capital letter), and for short, its declaration is identified as . In general, a declaration of a variable can be in an outer scope (e.g., a global variable).

Definition of a variable

When a variable, v, is on the LHS of an assignment statement, such as , then is a definition of v. Every variable (v) has at least one definition by its declaration (V) (or initialization).

Use of a variable

If variable, v, is on the RHS of statement , there is a statement, with i < j and , that it is a definition of v and it has a use at (or, in short, when a variable, v, is on the RHS of a statement , then v has a use at statement ).

Execution

Consider the sequential execution of the list of statements, , and what can now be observed as the computation at statement, j:

  • A definition at statement with i < j is alive at j, if it has a use at a statement with kj. The set of alive definitions at statement i is denoted as and the number of alive definitions as . ( is a simple but powerful concept: theoretical and practical results in space complexity theory, access complexity(I/O complexity), register allocation and cache locality exploitation are based on .)
  • A definition at statement kills all previous definitions ( with k < i) for the same variables.

Execution example for def-use-chain

This example is based on a Java algorithm for finding the gcd. (It is not important to understand what this function does.)

/**
 * @param(a, b) The values used to calculate the divisor.
 * @return The greatest common divisor of a and b.
 */
int gcd(int a, int b) { 
    int c = a;
    int d = b; 
    if (c == 0)
        return d;
    while (d != 0) { 
        if (c > d)
            c = c - d;
        else
            d = d - c;
    } 
    return c; 
}

To find out all def-use-chains for variable d, do the following steps:

  1. Search for the first time the variable is defined (write access).
    In this case it is "d=b" (l.7)
  2. Search for the first time the variable is read.
    In this case it is "return d"
  3. Write down this information in the following style: [name of the variable you are creating a def-use-chain for, the concrete write access, the concrete read access]
    In this case it is: [d, d=b, return d]

Repeat these steps in the following style: combine each write access with each read access (but NOT the other way round).

The result should be:

 [d, d=b, return d] 
 [d, d=b, while(d!=0)] 
 [d, d=b, if(c>d)] 
 [d, d=b, c=c-d] 
 [d, d=b, d=d-c]
 [d, d=d-c, while(d!=0)] 
 [d, d=d-c, if(c>d)] 
 [d, d=d-c, c=c-d] 
 [d, d=d-c, d=d-c]

You have to take care, if the variable is changed by the time.

For example: From line 7 down to line 13 in the source code, d is not redefined / changed. At line 14, d could be redefined. This is why you have to recombine this write access on d with all possible read accesses which could be reached. In this case, only the code beyond line 10 is relevant. Line 7, for example, cannot be reached again. For your understanding, you can imagine 2 different variables d:

 [d1, d1=b, return d1] 
 [d1, d1=b, while(d1!=0)] 
 [d1, d1=b, if(c>d1)] 
 [d1, d1=b, c=c-d1] 
 [d1, d1=b, d1=d1-c]
 [d2, d2=d2-c, while(d2!=0)] 
 [d2, d2=d2-c, if(c>d2)] 
 [d2, d2=d2-c, c=c-d2] 
 [d2, d2=d2-c, d2=d2-c]

As a result, you could get something like this. The variable d1 would be replaced by b

/**
 * @param(a, b) The values used to calculate the divisor.
 * @return The greatest common divisor of a and b.
 **/
int gcd(int a, int b) {
    int c = a;
    int d; 
    if (c == 0)
        return b;
    if (b != 0) {
        if (c > b) {
            c = c - b;
            d = b;
        }
        else
            d = b - c;
        while (d != 0) { 
            if (c > d)
                c = c - d;
            else
                d = d - c;
        }
    } 
    return c; 
}

Method of building a use-def (or ud) chain

  1. Set definitions in statement
  2. For each i in , find live definitions that have use in statement
  3. Make a link among definitions and uses
  4. Set the statement , as definition statement
  5. Kill previous definitions

With this algorithm, two things are accomplished:

  1. A directed acyclic graph (DAG) is created on the variable uses and definitions. The DAG specifies a data dependency among assignment statements, as well as a partial order (therefore parallelism among statements).
  2. When statement is reached, there is a list of live variable assignments. If only one assignment is live, for example, constant propagation might be used.

References

  1. ^ Kennedy, Ken (January 1978). "Use-definition chains with applications". Computer Languages. 3 (3): 163–179. doi:10.1016/0096-0551(78)90009-7.
  2. ^ Searle, Aaron; Gough, John; Abramson, David (2003). "DUCT: An Interactive Define-Use Chain Navigation Tool for Relative Debugging". arXiv:cs/0311037.
  3. ^ Leiss, Ernst L. (26 September 2006). A Programmer's Companion to Algorithm Analysis. CRC Press. ISBN 978-1-4200-1170-8.

Read other articles:

Voce principale: Athlītikos Podosfairikos Omilos Pegeias Kinyras. APOP KinyrasStagione 2010-2011Sport calcio Squadra APOP Kinyras AllenatoreGeorgios Polyviou, poi Sofoklis Sofokleous A' Katīgoria14º posto Coppa di CiproSedicesimi di finale 2006-2007 2008-2009 Si invita a seguire il modello di voce Questa voce raccoglie le informazioni riguardanti l'APOP Kinyras nelle competizioni ufficiali della stagione 2010-2011. Indice 1 Stagione 2 Rosa 3 Risultati 3.1 Campionato 3.2 Coppa di Cipro...

 

SMA Negeri 6 MetroInformasiDidirikan2010JenisNegeriAkreditasiAKepala SekolahSunarti ,M.Pd.Jumlah kelas4-8 kelas setiap tingkatJurusan atau peminatanIPA dan IPSRentang kelasX IPA, X IPS, XI IPA, XI IPS, XII IPA, XII IPSKurikulumKurikulum 2013 (2014-2015) Kurikulum Tingkat Satuan Pendidikan (2015-2016)Kurikulum 2013Jumlah siswa>500 siswa (maks. 32 siswa per kelas)StatusSekolah Atlet (2011-2013) Sekolah Standar Nasional Adiwiyata (2013-sekarang)AlamatLokasiJalan FKPPI No 1, Rej...

 

Private, day, college-prep boys' school in Dallas, Texas, United StatesSt. Mark's School of TexasAddress10600 Preston RoadDallas, Texas 75230United StatesCoordinates32°53′25″N 96°48′03″W / 32.890363°N 96.800762°W / 32.890363; -96.800762InformationTypePrivate, day, college-prep boys' schoolMottoCourage and HonorEstablished1906HeadmasterDavid W. DiniFaculty127 full-time teachersGrades1–12Number of students911Campus size42 acres (17 ha)Athletics confere...

Gemeindeverwaltungsverband Brettach-Jagst im Landkreis Schwäbisch Hall in Baden-Württemberg Im Gemeindeverwaltungsverband Brettach-Jagst im baden-württembergischen Landkreis Schwäbisch Hall haben sich eine Stadt und zwei Gemeinden zur Erledigung ihrer Verwaltungsgeschäfte zusammengeschlossen. Der Sitz des Gemeindeverwaltungsverbands liegt in der Gemeinde Rot am See. Mitgliedsgemeinden Mitglieder dieser Körperschaft des öffentlichen Rechts sind: Stadt Kirchberg an der Jagst, 4456 Einwoh...

 

MdB Ulrich Freese im Paul-Löbe-Haus des Deutschen Bundestages MdB Ulrich Freese in seinem Bundestagsbüro im Paul-Löbe-Haus Ulrich Ronald Freese (* 12. April 1951 in Drevenack, Kreis Rees, Nordrhein-Westfalen) ist ein deutscher Gewerkschafter (IG BCE), Politiker (SPD) und Kohlelobbyist. Inhaltsverzeichnis 1 Biografie 2 Politik 3 Nebentätigkeiten 4 Mitgliedschaften 5 Weblinks 6 Einzelnachweise Biografie Ulrich Freese absolvierte nach dem Volksschulbesuch eine Lehre zum Betriebsschlosser und...

 

You can help expand this article with text translated from the corresponding article in German. (July 2012) Click [show] for important translation instructions. View a machine-translated version of the German article. Machine translation, like DeepL or Google Translate, is a useful starting point for translations, but translators must revise errors as necessary and confirm that the translation is accurate, rather than simply copy-pasting machine-translated text into the English Wikipedia...

Belgian footballer (born 1995) Kylian Hazard Hazard with Zulte Waregem in 2014Personal informationDate of birth (1995-08-05) 5 August 1995 (age 28)[1]Place of birth La Louvière, BelgiumHeight 1.72 m (5 ft 8 in)[2]Position(s) Attacking midfielderTeam informationCurrent team RWDMNumber 14Youth career2001–2011 Tubize2011–2013 LilleSenior career*Years Team Apps (Gls)2013–2014 White Star Bruxelles 4 (0)2014–2015 Zulte Waregem 2 (0)2015–2017 Újpest 34...

 

Atatürk Monument Artvin Atatürk Statue, is a monument in Artvin, Turkey.[1] Monument consists of the world's largest Atatürk statue made of steel and copper.[2] The monument was completed in 2012 and unveiled in a ceremony in 2017.[3] It is the most popular site in Artvin with more than 35.000 visitors per year.[4][5] Monument was sculpted by Georgian sculptor Jumber Jikia. References ^ Two ceremonies to be held for Atatürk statue. hurriyetdailynews...

 

Cet article est une ébauche concernant un compositeur français. Vous pouvez partager vos connaissances en l’améliorant (comment ?). Pour plus d’informations, voyez le projet musique classique. Jules Auguste DemerssemanBiographieNaissance 9 janvier 1833HondschooteDécès 1er décembre 1866 (à 33 ans)9e arrondissement de ParisNationalité françaiseFormation Conservatoire national supérieur de musique et de danse de ParisActivités Compositeur, flûtisteAutres informatio...

2008 greatest hits album by Tim McGrawGreatest Hits: Limited EditionGreatest hits album by Tim McGrawReleasedApril 29, 2008GenreCountryLength2:03:58LabelCurbProducer Byron Gallimore Tim McGraw The Neptunes Darran Smith James Stroud Tim McGraw chronology Let It Go(2007) Greatest Hits: Limited Edition(2008) Greatest Hits 3(2008) Professional ratingsReview scoresSourceRatingAllmusic[1] Greatest Hits: Limited Edition is a compilation of American country music artist Tim McGraw's f...

 

Gold mine in Western Australia This article uses bare URLs, which are uninformative and vulnerable to link rot. Please consider converting them to full citations to ensure the article remains verifiable and maintains a consistent citation style. Several templates and tools are available to assist in formatting, such as reFill (documentation) and Citation bot (documentation). (September 2022) (Learn how and when to remove this template message) ThunderboxLocationThunderbox Gold MineLocation in...

 

Japanese historical estate in Yamashiro province Yodo Domain淀藩Domain of Japan1623–1871CapitalYodo Castle [ja]History • TypeDaimyō Historical eraEdo period• Established 1623• Disestablished 1871 Today part ofKyoto Prefecture Yodo castle The Yodo Domain (淀藩, Yodo-han) was a Japanese domain of the Edo period, and the only domain located in Yamashiro Province. Its castle was located within modern-day Fushimi, Kyoto. The strategic location of the c...

Опис файлу Опис Рекламний плакат фільму, спортивного або іншого заходу. Фільм Д'Артаньян та три мушкетери Джерело http://www.ozon.ru/context/detail/id/276412/ Час створення 1978 Автор зображення Невідомий Ліцензія Це зображення є рекламним плакатом фільму, спортивного або іншого заходу. Найі...

 

In 1958, the United States FBI, under Director J. Edgar Hoover, continued for a ninth year to maintain a public list of the people it regarded as the Ten Most Wanted Fugitives. As 1958 opened, the FBI had gone for a full ten months through the end of the prior year without being able to add a single fugitive to the top Ten list. The reason for the paucity of new fugitives is that by March of the prior year, the list of Ten Fugitives had become entirely populated by the most difficult captures...

 

United States historic placeOsceola County CourthouseU.S. National Register of Historic Places Osceola County Courthouse, July 2014.Show map of IowaShow map of the United StatesLocation3rd Ave & 8th St.Sibley, IowaCoordinates43°24′07.5″N 95°44′57.7″W / 43.402083°N 95.749361°W / 43.402083; -95.749361Arealess than one acreBuilt1903Built byC.E. AtkinsonArchitectE.N. KinneyMPSCounty Courthouses in Iowa TRNRHP reference No.81000261[1]Added ...

This article uses bare URLs, which are uninformative and vulnerable to link rot. Please consider converting them to full citations to ensure the article remains verifiable and maintains a consistent citation style. Several templates and tools are available to assist in formatting, such as reFill (documentation) and Citation bot (documentation). (August 2022) (Learn how and when to remove this template message) Public high school in Germantown, Tennessee, United StatesHouston High SchoolAddres...

 

London Underground station Not to be confused with Mansion House tube station. Manor House Main northwest entranceManor HouseLocation of Manor House in Greater LondonLocationManor HouseLocal authorityLondon Borough of Hackney/London Borough of HaringeyManaged byLondon UndergroundNumber of platforms2Fare zone2 and 3OSIHarringay Green Lanes London Underground annual entry and exit2018 8.10 million[1]2019 8.55 million[2]2020 3.60 million[3]2021 3.59 million[4]2022...

 

Scheduling tool by Microsoft Microsoft BookingsBookings Icon as appears on Android and iOSScreenshot Customers scheduling hair appointment using Microsoft BookingsType of siteSchedulingAvailable inEnglishOwnerMicrosoftURLOfficial SiteLaunchedUS:July 20, 2016 (2016-July-20)Worldwide:July 20, 2017 (2017-July-20)Current statusActive Microsoft BookingsDeveloper(s)Microsoft CorporationStable releaseAndroid2.0.6 / July 2, 2019; 4 years ago (...

Settlement in Newfoundland, Canada Former community in Newfoundland and Labrador, CanadaBoyd's CoveFormer communityHarbour of Boyd's CoveBoyd's CoveLocation of Hopewell in NewfoundlandCoordinates: 49°26′36″N 54°39′27″W / 49.44333°N 54.65750°W / 49.44333; -54.65750Country CanadaProvince Newfoundland and LabradorPopulation (2016) • Total183Time zoneUTC-3:30 (Newfoundland Time) • Summer (DST)UTC-2:30 (Newfoundland Dayligh...

 

2007 novel by Chris d'Lacey This article includes a list of references, related reading, or external links, but its sources remain unclear because it lacks inline citations. Please help to improve this article by introducing more precise citations. (October 2016) (Learn how and when to remove this template message) The Fire Eternal First imageAuthorChris D'LaceyCountryUnited KingdomLanguageEnglishSeriesThe Last Dragon ChroniclesGenreFantasy novelPublisherOrchard Books, an imprint of Scholasti...

 

Strategi Solo vs Squad di Free Fire: Cara Menang Mudah!