0
0
Compiler Designknowledge~10 mins

Live variable analysis in Compiler Design - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to identify variables that are live at a program point.

Compiler Design
live_vars = [1]
Drag options to blanks, or click blank then click option'
Aint()
Blist()
Cdict()
Dset()
Attempts:
3 left
💡 Hint
Common Mistakes
Using a list can cause duplicates and slower lookups.
Using a dictionary or integer is not suitable for storing variables.
2fill in blank
medium

Complete the code to update live variables after processing a statement.

Compiler Design
live_vars = (live_vars - [1]) | [2]
Drag options to blanks, or click blank then click option'
Adefs
Buses
Ckills
Dgen
Attempts:
3 left
💡 Hint
Common Mistakes
Removing used variables instead of defined variables.
Confusing gen and kill sets.
3fill in blank
hard

Fix the error in the live variable update formula.

Compiler Design
live_in = (live_out - [1]) | [2]
Drag options to blanks, or click blank then click option'
Agen
Buses
Ckills
Ddefs
Attempts:
3 left
💡 Hint
Common Mistakes
Using '+' instead of '|' for set union.
Removing uses instead of defs.
4fill in blank
hard

Fill both blanks to compute live variables at a program point.

Compiler Design
live_in = (live_out - [1]) | [2]
Drag options to blanks, or click blank then click option'
Adefs
Buses
Ckills
Dgen
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping defs and uses in the formula.
Using kills or gen incorrectly.
5fill in blank
hard

Fill all three blanks to create a dictionary of live variables for each program point.

Compiler Design
live_vars_map = {point: ([3] - [1]) | [2] for point, ([3]) in program_points.items()}
Drag options to blanks, or click blank then click option'
Adefs
Buses
Clive_info
Dkills
Attempts:
3 left
💡 Hint
Common Mistakes
Using kills or d instead of defs or uses.
Not unpacking live_info correctly.