All Exams Test series for 1 year @ ₹349 only
Question

Consider the control flow graph given below.



Which one of the following options is the set of live variables at the exit point of each basic block?

The correct answer is
B1:{a, b, c, e, f}, B2:{d, e}, B3:{b, c, e, f}, B4:$\emptyset$

The problem requires identifying the set of live variables at the exit point of each basic block in a control flow graph. Let's analyze each block step-by-step:

  1. Basic Block B4:
    • The formula for \(g\) is \(g = d + e\).
    • At the exit of B4, no successors need any variables; hence, it's an empty set.
  2. Basic Block B3:
    • The formula for \(e\) is \(e = a + f\).
    • At the exit, we check the needs of B2 and B4. B2 uses \(d\) and \(e\), B4 uses \(d\) and \(e\).
    • Thus, variables \(b, c, e, f\) are needed at the exit of B3 to supply B2 and B4 correctly.
  3. Basic Block B2:
    • The formula for \(d\) is \(d = a + e\).
    • At the exit of B2, \(d\) and \(e\) must still be live for B4.
  4. Basic Block B1:
    • The formula for \(a\) is \(a = b + c\).
    • At the exit, variables \(a, b, c, e, f\) are needed as they are used or defined in subsequent blocks (B2 and B3).

The correct answer is: B1:{a, b, c, e, f}, B2:{d, e}, B3:{b, c, e, f}, B4:\(\emptyset\)

Was this answer helpful?

Important Questions from Code Optimization

  1. Which of the following is the correct High level code for the given TAC in the passage
  2. What are the various LEADERS (leading statements) for the TAC given in the passage?
  3. What all blocks does Block 3 & Block 5 dominate in the Flow graph for the TAC given in the passage?
  4. Match the LIST-I with LIST-II
    LIST-I InputLIST-II Compiler Phase
    A. Syntax TreeI. Code Generator
    B. Character StreamII. Syntax Analyzer
    C. Intermediate RepresentationIII. Semantic Analyzer
    D. Token StreamIV. Lexical Analyzer
  5. In _______, the bodies of the two loops are merged together to form a single loop provided that they do not make any references to each other.
Need Expert Advice?

Start Your Preparation with Prepp Mobile App

Download the app from Google Play & App Store
Download the app from Google Play & App Store
Prepp Mobile App