Which of the following best describes a basic block in compiler design?
Think about a block where control flow enters at the beginning and leaves at the end without interruption.
A basic block is a straight-line code sequence with no branches in except to the entry and no branches out except at the exit.
In a flow graph representing a program's control flow, what do the nodes and edges represent?
Consider what a flow graph models in terms of program execution paths.
In a flow graph, nodes are basic blocks and edges show possible paths control can take from one block to another.
Given the following sequence of instructions, which instructions are leaders that start a new basic block?
1: a = 5 2: if a > 0 goto 5 3: b = a + 1 4: goto 6 5: b = a - 1 6: print(b)
Leaders include the first instruction, targets of jumps, and instructions following jumps.
Instruction 1 is the first instruction (always a leader). Instruction 3 immediately follows the conditional jump at instruction 2. Instruction 5 is the target of the jump at instruction 2 and instruction 6 is the target of the jump at instruction 4.
Which statement correctly compares basic blocks and flow graphs?
Think about how basic blocks and flow graphs relate to each other structurally.
Basic blocks form the nodes of a flow graph, which illustrates how control moves between these blocks.
In a flow graph of a program, what is the most likely effect of removing an edge that represents a conditional jump?
Consider what happens if a path of execution is removed from the control flow.
Removing an edge that represents a conditional jump can make some blocks unreachable, potentially changing how the program runs.