Live-variable analysis

In compilers, live variable analysis (or simply liveness analysis) is a classic data-flow analysis to calculate the variables that are live at each point in the program. A variable is live at some point if it holds a value that may be needed in the future, or equivalently if its value may be read before the next time the variable is written to.

Example

Consider the following program:

b = 3
c = 5
a = f(b * c)

The set of live variables between lines 2 and 3 is {b, c} because both are used in the multiplication on line 3. But the set of live variables after line 1 is only {b}, since variable c is updated later, on line 2. The value of variable a is not used in this code.

Note that the assignment to a may be eliminated as a is not used later, but there is insufficient information to justify removing all of line 3 as f may have side effects (printing b * c, perhaps).

Expression in terms of dataflow equations

Liveness analysis is a "backwards may" analysis. The analysis is done in a backwards order, and the dataflow confluence operator is set union. In other words, if applying liveness analysis to a function with a particular number of logical branches within it, the analysis is performed starting from the end of the function working towards the beginning (hence "backwards"), and a variable is considered live if any of the branches moving forward within the function might potentially (hence "may") need the variable's current value. This is in contrast to a "backwards must" analysis which would instead enforce this condition on all branches moving forward.

The dataflow equations used for a given basic block s and exiting block f in live variable analysis are the following:

: The set of variables that are used in s before any assignment in the same basic block.
: The set of variables that are assigned a value in s (in many books that discuss compiler design, KILL (s) is also defined as the set of variables assigned a value in s before any use, but this does not change the solution of the dataflow equation):


The in-state of a block is the set of variables that are live at the start of the block. Its out-state is the set of variables that are live at the end of it. The out-state is the union of the in-states of the block's successors. The transfer function of a statement is applied by making the variables that are written dead, then making the variables that are read live.

Second example

// in: {}; predecessor blocks: none
b1: a = 3; 
    b = 5;
    d = 4;
    x = 100; //x is never being used later thus not in the out set {a,b,d}
    if a > b then
// out: {a,b,d}    //union of all (in) successors of b1 => b2: {a,b}, and b3:{b,d}  

// in: {a,b}; predecessor blocks: b1
b2: c = a + b;
    d = 2;
// out: {b,d}

// in: {b,d}; predecessor blocks: b1 and b2
b3: endif
    c = 4;
    return b * d + c;
// out:{}

The in-state of b3 only contains b and d, since c has been written. The out-state of b1 is the union of the in-states of b2 and b3. The definition of c in b2 can be removed, since c is not live immediately after the statement.

Solving the data flow equations starts with initializing all in-states and out-states to the empty set. The work list is initialized by inserting the exit point (b3) in the work list (typical for backward flow). Its computed in-state differs from the previous one, so its predecessors b1 and b2 are inserted and the process continues. The progress is summarized in the table below.

processing out-state old in-state new in-state work list
b3 {} {} {b,d} (b1,b2)
b1 {b,d} {} {} (b2)
b2 {b,d} {} {a,b} (b1)
b1 {a,b,d} {} {} ()

Note that b1 was entered in the list before b2, which forced processing b1 twice (b1 was re-entered as predecessor of b2). Inserting b2 before b1 would have allowed earlier completion.

Initializing with the empty set is an optimistic initialization: all variables start out as dead. Note that the out-states cannot shrink from one iteration to the next, although the out-state can be smaller than the in-state. This can be seen from the fact that after the first iteration the out-state can only change by a change of the in-state. Since the in-state starts as the empty set, it can only grow in further iterations.

References

Aho, Alfred; Lam, Monica; Sethi, Ravi; Ullman, Jeffrey (2007). Compilers: Principles, Techniques, and Tools (2 ed.). p. 608.

Read other articles:

Seorang wanita tua di Britania Raya. Masa tua atau di sebut Lansia merupakan masa sekitar masa hidup manusia. Lansia memiliki kemampuan regeneratif yang terbatas dan lebih mudah terserang penyakit. Untuk biologi penuaan lihat senescence. Di dunia Barat seseorang dianggap tua atau lansia ketika mereka mencapai umur 65 tahun ke atas. Beberapa pemerintah menawarkan pensiun masa tua, dan rencana pensiun. Masa pensiun adalah masa di mana akhir kerja seseorang. Dalam abad ke-20 dan abad ke-21, peni...

 

 

Dewan Perwakilan Rakyat Daerah Kabupaten TangerangDewan Perwakilan RakyatKabupaten Tangerang2019-2024JenisJenisUnikameral SejarahSesi baru dimulai23 Agustus 2019PimpinanKetuaH. Kholid Ismail, S.Ag. (PDI-P) sejak 24 September 2019 Wakil Ketua IH. Astayudin, S.E. (Gerindra) sejak 24 September 2019 Wakil Ketua IIIr. H. Ilham Chair, M.M. (Golkar) sejak 24 September 2019 Wakil Ketua IIIAdi Tiya Wijaya, S.H. (Demokrat) sejak 24 September 2019 KomposisiAnggota50Partai & kursi...

 

 

American football player (1983–2022) American football player Marion Barber IIIBarber with the Dallas Cowboys in 2007No. 24Position:Running backPersonal informationBorn:(1983-06-10)June 10, 1983Plymouth, Minnesota, U.S.Died:June 1, 2022(2022-06-01) (aged 38)Frisco, Texas, U.S.Height:5 ft 11 in (1.80 m)Weight:218 lb (99 kg)Career informationHigh school:Wayzata (Plymouth, Minnesota)College:Minnesota (2001–2004)NFL Draft:2005 / Round: 4 / Pick:...

Short story by L. Sprague de CampThe Stolen DormouseShort story by L. Sprague de Campcover of Astounding Science-Fiction, April 1941, illustrating The Stolen DormouseCountryUnited StatesLanguageEnglishGenre(s)Science fictionPublicationPublished inAstounding Science-FictionPublisherStreet & SmithMedia typePrint (Magazine)Publication dateApril, May 1941 The Stolen Dormouse is a science fiction novella by American writer L. Sprague de Camp. It was first published as a serial in the magaz...

 

 

Asque Entidad subnacional Escudo AsqueLocalización de Asque en Francia Coordenadas 43°02′38″N 0°15′20″E / 43.043888888889, 0.25555555555556Entidad Comuna de Francia • País  Francia • Región Mediodía-Pirineos • Departamento Altos Pirineos • Distrito distrito de Bagnères-de-Bigorre • Cantón cantón de La Barthe-de-Neste • Mancomunidad Communauté de communes Haut-ArrosAlcalde Roger Lacome(2008 - 2014)Superficie  ...

 

 

Ada usul agar artikel ini digabungkan ke Masakan Minangkabau. (Diskusikan) Diusulkan sejak Maret 2019. Rendang Masakan Sumatera Barat adalah jenis kuliner yang berkembang di provinsi Sumatera Barat. Produk kuliner Sumatera Barat merupakan salah satu yang dikenal luas di Indonesia dan disebut juga dengan istilah Masakan Minangkabau yang diperkenalkan oleh para perantau Minangkabau dari berbagai daerah di Sumatera Barat. Terdapat banyak resep dan variasi masakan Sumatera Barat berdasarkan daera...

ستارغيت: ريسيستنس المطور دارك كومت غايمز (2010 -)شايان ماوتن (2009 - مارس 2010) الناشر فايرسكاي الموزع فايرسكاي [1]Direct2Drive[2]ستيم[3] محرك اللعبة أنريل إنجن 3  [لغات أخرى]‏  النظام مايكروسوفت ويندوز تاریخ الإصدار فبراير 10, 2010[4] نوع اللعبة منظور اللاعب الثالث ال...

 

 

Pirâmide de Céstio Pirâmide de CéstioPirâmide de Céstio Tipo Pirâmide Construção entre 18 e 12 a.C. Promotor / construtor Caio Céstio Geografia País Itália Cidade Roma Localização XIII Região - Aventino Coordenadas Coordenadas: 41° 52' 35 N 12° 28' 51 E41° 52' 35 N 12° 28' 51 E Pirâmide de CéstioPirâmide de Céstio A Pirâmide de Céstio (em italiano: Piramide di Caio Cestio/Piramide Cestia) é uma pirâmide da Antiguidade em Roma, Itália...

 

 

This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed.Find sources: Solo 1996 film – news · newspapers · books · scholar · JSTOR (July 2013) (Learn how and when to remove this template message) 1996 American filmSoloOfficial VHS coverDirected byNorberto BarbaScreenplay byDavid L. CorleyBased onWeaponby Robert MasonProduced...

2022 autobiography by Grace Lavery Please Miss AuthorGrace Elisabeth LaveryLanguageEnglishSubjectTransitioning and the trans experienceGenreMemoir; autobiography; Transgender literaturePublisherSeal PressPublication dateFebruary 2022Pages304ISBN978-1-5416-2065-0Websitehttp://www.gracelavery.org/please-miss/ Please Miss: A Heartbreaking Work of Staggering Penis is a February 2022 autobiography by professor Grace Elisabeth Lavery and published by Seal Press. It chronicles her life history of tr...

 

 

15th TVyNovelas AwardsDateMay 15, 1997LocationTeatro Alameda, San Ángel, México D.F.Hosted byRaúl Velasco, Marco Antonio Regil, Julissa & Liza EcheverríaMost awardsCañaveral de pasiones (10)Most nominationsLa antorcha encendida (14)Television/radio coverageNetworkCanal de las estrellas ← 14th · TVyNovelas Awards · 16th → The 15th TVyNovelas Awards were an academy of special awards to the best soap operas and TV shows. The awards ceremony took place o...

 

 

Summer days at Manly Beach Manly Beach is a beach situated among the Northern Beaches of Sydney, Australia, in Manly, New South Wales. From north to south, the three main sections are Queenscliff, North Steyne, and South Steyne. Etymology The beach was named by Capt. Arthur Phillip for the indigenous people living there. He wrote, Their confidence and manly behaviour made me give the name of Manly Cove to this place.[1] Manly Beach circa 1900 Commercial area Within walking distance of...

1988 single by Bonnie Tyler, made popular by Tina Turner in 1989 For other songs, see Best § Songs. The Best is a song by Welsh singer Bonnie Tyler from her seventh studio album, Hide Your Heart (1988). It was written by Mike Chapman and Holly Knight. Produced by Desmond Child, Tyler's version became a top-10 hit in Norway but was a minor hit elsewhere. In 1989, American singer Tina Turner released a cover version of The Best for her seventh studio album, Foreign Affair. It became a worldwid...

 

 

Monumen La Venta 1 Monumen 4 dari La Venta bila dibandingkan dengan besar tubuh seorang perempuan dan anak-anak. Massanya sendiri hampir mencapai 20 ton Kepala-kepala raksasa Olmek adalah pahatan-pahatan berbentuk kepala manusia yang terbuat dari batu-batuan basalt besar. Kepala-kepala ini berasal paling tidak dari tahun 900 SM dan merupakan ciri khas peradaban Olmek di Mesoamerika.[1] Pahatan-pahatan ini menggambarkan kepala orang-orang dengan pipi yang tembam, hidung yang pesek...

 

 

Konsepsi artis dari Bumi dengan dua satelit alam. Terdapat banyak sekali klaim keberadaan satelit lain Bumi sebagai salah satu dari banyak satelit alam lainnya selain Bulan yang mengorbit Bumi dalam berbagai waktu yang berbeda. Beberapa kandidat telah diusulkan, tetapi tidak ada yang terkonfirmasikan.[1] Referensi ^ I. Klotz - Mystery Mini Moons: How Many Does Earth Have? (2012) - Discovery News Bacaan tambahan Research paper describing horseshoe orbits. Willy Ley: Watchers of the Ski...

1961 novel First edition The Arena is a 1961 suspense novel by the British author William Haggard published in England by Cassell and in the United States by Washburn. It was Haggard's third of 21 books involving his urbane protagonist Colonel Charles Russell, the head of the unobtrusive but lethal Security Executive, a government counter-intelligence agency clearly based on the actual MI5 or Security Service, where he moves easily and gracefully along C.P. Snow's Corridors of Power in Whiteh...

 

 

House in Kilmacolm, ScotlandWindy HillMackintosh's design for Windy HillAlternative namesWindyhillGeneral informationStatusExtantTypeHouseArchitectural styleArt NouveauAddressRowantreehill RoadTown or cityKilmacolmCountryScotlandCoordinates55°53′24″N 4°37′13″W / 55.890101°N 4.620414°W / 55.890101; -4.620414Construction started1900Completed1901 (1901)ClientWilliam DavidsonDesign and constructionArchitect(s)Charles Rennie MackintoshDesignationsCategory A...

 

 

Legislative constituency in Russia Tambov single-member constituency Constituency of the Russian State DumaDeputyAleksey ZhuravlyovRodinaFederal subjectTambov OblastDistrictsKotovsk, Michurinsk, Michurinsky, Morshansk, Morshansky, Nikiforovsky, Pervomaysky, Petrovsky, Sosnovsky, Staroyuryevsky, Tambov (Leninsky, Sovetsky), Tambovsky (Avdeyevsky, Belomestnodvoynevsky, Belomestnokriushinsky, Bogoslovsky, Bokinsky, Bolshelipovitsky, Chelnavsky, Chernyanovsky, Gorelsky, Komsomolsky, Krasnosvobodn...

Khagan of the Göktürks Muqan Qaghan 木桿可汗 Ashina Yandou 阿史那俟斤Third Qaghan of the First Turkic KhaganateReign553 – 572PredecessorIssik QaghanSuccessorTaspar QaghanDied572IssueApa Qaghan Empress Ashina Yangsu TeginHouseAshinaFatherBumin QaghanReligionTengrism Muqan Qaghan[1] (Old Turkic:

 

 

Artikel ini sebatang kara, artinya tidak ada artikel lain yang memiliki pranala balik ke halaman ini.Bantulah menambah pranala ke artikel ini dari artikel yang berhubungan atau coba peralatan pencari pranala.Tag ini diberikan pada Februari 2023. Jaringan telepon di Indonesia pada dasarnya dapat dibagi menjadi dua bagian, yaitu jaringan tetap dan jaringan bergerak. Jaringan tetap dapat dinikmati melalui telepon rumah atau kantor yang biasanya menggunakan kabel. Jaringan tetap di Indonesia meli...

 

 

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