Questions: Basic Block Analysis

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

A three-address code sequence contains a conditional branch to label L7, followed by another instruction. According to basic block analysis, which of the following is correct?

AOnly the instruction at L7 starts a new basic block; the instruction after the branch stays in the current block
BThe conditional branch itself becomes its own single-instruction basic block
CBoth the instruction at L7 and the instruction immediately following the branch are leaders that start new basic blocks
DThe branch ends the current block; no new block begins until the next unconditional jump
Question 2 Multiple Choice

A compiler wants to propagate constants across an entire function (not just within single blocks). What infrastructure is required beyond basic block identification?

ANo additional infrastructure — constant propagation is purely local and works block-by-block
BA control-flow graph built from the basic blocks, then a dataflow analysis (reaching definitions) across block boundaries
CSplitting basic blocks into smaller single-instruction units so constants propagate more easily
DException handler elimination, since exception targets are the only obstacle to global propagation
Question 3 True / False

Any two instructions within the same basic block can be freely reordered, since a basic block guarantees sequential execution with no branches.

TTrue
FFalse
Question 4 True / False

A basic block has exactly one entry point (its first instruction) and all control flow exits through its last instruction, with no jumps into or out of the middle of the block.

TTrue
FFalse
Question 5 Short Answer

What is a 'leader' in basic block analysis, and what three conditions make an instruction a leader? Why does identifying leaders fully determine the basic block partition?

Think about your answer, then reveal below.