GATE || Compiler Design || Intermediate code genration || Pyq ( 2010 to 2025 )

Last Updated :
Discuss
Comments

Question 1

Which of the following statements are Correct?

1. Static allocation of all data areas by a compiler makes it impossible to implement recursion.

2. Automatic garbage collection is essential to implement recursion.

3. Dynamic allocation of activation records is essential to implement recursion.

4. Both heap and stack are essential to implement recursion.

[GATE 2014||SET-3 MCQ|| 1-mark]


  • 1 and 2 only

  • 2 and 3 only

  • 3 and 4 only

  • 1 and 3 only

Question 2

Consider the following expression: x[i] = (p + r) ∗−s[i] + u/w

Screenshot-2025-10-13-184554
.

Which one of the following options fills in the missing entries CORRECTLY? [GATE 2024|| SET-2 MCQ|| 2-mark]


  • Screenshot-2025-10-13-185244


  • Screenshot-2025-10-13-185414


  • Screenshot-2025-10-13-185502


  • Screenshot-2025-10-13-185541


Question 3

Consider the following pseudo-code:

Screenshot-2025-10-13-183416
.

Which one of the following options CORRECTLY specifies the number of basic blocks and the number of instructions in the largest basic block, respectively ?

[GATE 2024|| SET-1 MCQ|| 2-mark]


  • 6 and 6

  • 6 and 7

  • 7 and 7

  • 7 and 6

Question 4

Consider the control flow graph shown.

Screenshot-2025-10-14-115216
.


Which one of the following choices correctly lists the set of live variables at the exit point of each basic block? [GATE 2023|| MCQ|| 1-mark]


  • B1: {}, B2: {a}, B3: {a}, B4: {a}


  • B1: {i, j}, B2: {a}, B3: {a}, B4: {i}

  • B1: {a, i, j}, B2: {a, i, j}, B3: {a, i}, B4: {a}

  • B1: {a, i, j}, B2: {a, j}, B3: {a, j}, B4: {a, i, j}

Question 5

Consider the following statements regarding the front-end and back-end of a compiler: - [GATE 2023|| MCQ|| 1-mark]

S1: The front-end includes phases that are independent of the target hardware.
S2: The back-end includes phases that are specific to the target hardware.
S3: The back-end includes phases that are specific to the programming language used in the source code.

Identify the CORRECT option.


  • Only S1 is TRUE.

  • Only S1 and S2 are TRUE.

  • S1, S2, and S3 are all TRUE.


  • Only S1 and S3 are TRUE.

Question 6

Which ONE of the following techniques used in compiler code optimization uses live variable analysis?

[GATE 2025|| SET-1 MCQ|| 1-mark]

  • Run-time function call management

  • Register assignment to variables

  • Strength reduction

  • Constant folding

Question 7

Refer to the given 3-address code sequence. This code sequence is split into basic blocks. The number of basic blocks is _________. (Answer in integer)

1001 : i = 1

1002 : j = 1

1003 : t1 = 10*j

1004 : t2 = t1+j

1005 : t3 = 8*t2

1006 : t4 = t3-88

1007 : a[t4] = 0.0

1008 : j = j+1

1009 : if j <= 10 goto 1003

1010 : i = i+1

1011 : if i<=10 goto 1002

1012 : i = 1

1013 : t5 = i-1

1014 : t6 = 88*t5

1015 : a[t6] = 1.0

1016 : i = i+1

1017 : if <= 10 goto 1013

[GATE 2025|| SET-1 NAT|| 2-mark]

  • 6

Question 8

The program below uses six temporary variables a, b, c, d, e, f.

    a = 1

    b = 10

    c = 20

    d = a+b

    e = c+d

    f = c+e

    b = c+e

    e = b+f

    d = 5+e

    return d+f

Assuming that all operations take their operands from registers, what is the minimum number of registers needed to execute this program without spilling?


[GATE 2010, 2 mark]


  • 2

  • 3

  • 4

  • 6

Question 9

Which languages necessarily need heap allocation in the runtime environment? [GATE 2010 || MCQ|| 1-mark]


  • Those that support recursion

  • Those that use dynamic scoping

  • Those that allow dynamic data structures

  • Those that use global variables

Question 10

Consider the program given below, in a block-structured pseudo-language with lexical scoping and nesting of procedures permitted.

Program main;

Var ...

    Procedure A1;

Var ...

    Call A2;

    End A1

    Procedure A2;

Var ...

      Procedure A21;

Var ...

        Call A1;

        End A21

    Call A21;

  End A21

    Call A1;

  End main.

Consider the calling chain : 

Main->A1->A2->A21->A1.The correct set of activation records along with their access links is given by:

[GATE 2012 || MCQ|| 2-mark]

  • u
    .


  • T
    .


  • F
    .

  • W
    .

There are 21 questions to complete.

Take a part in the ongoing discussion