Select the correct option(s):
Select the correct option(s):
Answer: C. A basic block is a sequence of instructions where control enters the sequence at the beginning and exits at the end.; D. Live variable analysis can be used for dead code elimination. — Concept: Each statement here names a formal definition from a different area of compiler theory. An L-attributed definition allows, for every attribute,…
- A.
Every L-attributed attribute is also a synthesized attribute.
- B.
Every inherited attribute satisfies the L-attributed restriction.
- C.
A basic block is a sequence of instructions where control enters the sequence at the beginning and exits at the end.
- D.
Live variable analysis can be used for dead code elimination.
Attempted by 312 students.
Show answer & explanation
Correct answer: C, D
Concept: Each statement here names a formal definition from a different area of compiler theory. An L-attributed definition allows, for every attribute, either a synthesized attribute (computed bottom-up from the children's attributes) or an inherited attribute restricted to depend only on the parent and on symbols to its left in the same production — the class permits both kinds and places a specific dependency restriction only on inherited attributes. Separately, a basic block is a maximal sequence of consecutive instructions with a single entry point (the first instruction) and a single exit point (the last instruction), and live variable analysis is a backward data-flow analysis that finds, at each program point, which variables may still be read later — an assignment outside that live set can be dropped as dead code.
"Every L-attributed attribute is also a synthesized attribute" is false: the L-attributed class explicitly includes restricted inherited attributes alongside synthesized ones, so membership in the class does not force an attribute to be synthesized.
"Every inherited attribute satisfies the L-attributed restriction" is false: an inherited attribute is L-attributed only when its dependencies are limited to the parent and left siblings; an inherited attribute that reads a right sibling's attribute (a common pattern in general attribute grammars) violates this restriction and is not L-attributed.
"A basic block is a sequence of instructions where control enters at the beginning and exits at the end" is true: this is precisely the textbook definition — single entry at the first instruction, single exit at the last, with no internal branch targets or branch-causing instructions in between.
"Live variable analysis can be used for dead code elimination" is true: once live variable analysis determines a variable is not live immediately after an assignment (and the assignment's right-hand side has no other externally observable effect), the optimizer can treat that assignment as dead code and remove it — this is exactly how live-variable data flow feeds dead-code elimination.
Cross-check: The two false statements both mishandle the direction of a subset relationship in L-attributed grammar theory (synthesized-in-L-attributed and inherited-in-L-attributed are not "every member automatically qualifies" claims), while the two true statements are independent, standard definitions from code optimization that hold without exception. Hence the correct options are the basic-block definition and the live-variable-analysis/dead-code-elimination statement.