Skip to main content

Compiler Construction MCQs with Answers

Practice important Compiler Construction MCQs with answers and explanations.

Chapter: 43
Q1141:
What happens to variable x after executing the statement "x = y + z" in live variable analysis?
A. It is added to the live set
B. It is removed from the live set
C. It remains unchanged
D. It is duplicated
Correct Answer: B
Chapter: 43
Q1142:
In basic block code generation, which technique uses node numbering?
A. Basic code generation
B. DAGS
C. Register allocation
D. None of the above
Correct Answer: B
Chapter: 43
Q1143:
Which of the following is NOT a basic block code generation strategy?
A. Using liveness information
B. Using DAGs
C. Node numbering
D. Register removal
Correct Answer: D
Chapter: 43
Q1144:
What is the final step in the algorithm for computing live status in a basic block?
A. Add variables y and z to live set
B. Attach live set to the statement
C. Remove x from live set
D. Initialize live set
Correct Answer: A
Chapter: 43
Q1145:
Fill in the blank: The set of edges E in a CFG represent the ______ of control between basic blocks.
A. Memory flow
B. Data flow
C. Control flow
D. Information flow
Correct Answer: C
Chapter: 43
Q1146:
Fill in the blank: In the CFG, the unique program entry point is called ______.
A. Exit
B. Entry
C. Leader
D. Block start
Correct Answer: B
Chapter: 43
Q1147:
Fill in the blank: In partitioning basic blocks, any statement that immediately follows a ______ is a leader.
A. Goto
B. If statement
C. Function call
D. Return statement
Correct Answer: A
Chapter: 43
Q1148:
Fill in the blank: The basic block code generation strategy using liveness information emits code to save any ______ left in registers at the end of the block.
A. Dead variables
B. Live values
C. Temporary variables
D. Constants
Correct Answer: B
Chapter: 43
Q1149:
Fill in the blank: In liveness analysis, a variable is said to be ______ at a given point if it has a next use.
A. Dead
B. Live
C. Undefined
D. Constant
Correct Answer: B
Chapter: 44
Q1150:
What is the purpose of live/next use information in basic code generation?
A. To optimize register usage
B. To increase memory size
C. To slow down execution
D. To delete dead code
Correct Answer: A
Chapter: 44
Q1151:
Which data structure keeps track of register status and contents?
A. Address descriptor
B. Register descriptor
C. Symbol table
D. Stack frame
Correct Answer: B
Chapter: 44
Q1152:
What does the address descriptor track in code generation?
A. Register contents
B. Location(s) of a variable
C. Instruction set
D. Memory leaks
Correct Answer: B
Chapter: 44
Q1153:
In the instruction type "x = y op z", what is the first step if y is non-live and in register R?
A. Generate OP z’, R
B. Generate MOV y’, R
C. Generate MOV z’, R
D. Generate OP y’, R
Correct Answer: A
Chapter: 44
Q1154:
If the operation is commutative and z is non-live in register R, what instruction is generated?
A. OP y’, R
B. OP z’, R
C. MOV y’, R
D. MOV z’, R
Correct Answer: A
Chapter: 44
Q1155:
When no free register is available, how is code generated?
A. Use a memory location
B. Allocate new register
C. Delete a variable
D. Stop code generation
Correct Answer: A
Chapter: 44
Q1156:
Initially, how many registers are empty before starting code generation in the example?
A. One
B. Two
C. Three
D. Four
Correct Answer: C
Chapter: 44
Q1157:
After the instruction "a = b + c", which register is assigned to variable a?
A. R1
B. R2
C. R3
D. R4
Correct Answer: A
Chapter: 44
Q1158:
What is the machine instruction generated for "a = b + c" when b is moved to R1?
A. ADD c,R1
B. MOV b,R1
C. SUB c,R1
D. MOV c,R1
Correct Answer: B
Chapter: 44
Q1159:
During code generation, what operation is performed for "t1 = a * a" after moving a to R2?
A. ADD R2,R2
B. MUL R2,R2
C. SUB R2,R2
D. DIV R2,R2
Correct Answer: B
Chapter: 44
Q1160:
In the instruction "b = t1 + a", which register holds the value of a?
A. R1
B. R2
C. R3
D. R4
Correct Answer: A

Test Your Knowledge

Take a timed quiz on Compiler Construction

🚀 Start Quiz Now