Assignment on Gray Box Probing


Problem Statement:

  1. Observe all the significant dumps for the sample codes explained in presentation.

    The codes are as follows, with possible observations:

    1. Local vs Global variables

      1. Observe the way global variables are treated in rtl and assembly.

      2. Variations in source codes: Try assigning global to local and local to global constant assignments, variable assignments, expression assignments. In short, observe in which cases the copy of a global variable needs to be saved and when it doesn't need to be saved.

    2. 1D array access

      1. Observe the address computation of the array indices in rtl and ahead.

    3. 2D array access

      1. Same as above.

    4. Use of pointers

      1. The address is computed first and then the value is stored or retrieved.

      2. Variations: Use character pointers to see string handling.

    5. Use of structures

      1. Observe the memory allocation for structures.

      2. Variations: Check unions.

    6. Pointer to array

      1. Observe the address computation of both pointers and arrays.

    7. Translation of Conditional statements

      1. Observe the introduction of jumps due to conditional statements.

      2. Variations: Try if then elseif else.

    8. Translation of loops

      1. Observe the conditional jumps introduced due to looping statements.

      2. Observe the blocks introduced due to loops.

      3. Variations: Try various loops like do while, for, etc.

    9. Function calls

      1. Apart from cgraph, observe cfg for how the blocks are created for the function calls.

      2. Observe function calls in rtl dumps for following:
        • - How the function is called?
        • - How the parameters are passed by the calling function and accessed by the called function?

      3. Variations: Try different orders of the function and function calls. Try different extern functions with mutually recursive calls.

    10. Extra Assignments

    11. Arithmetic operations:

      Variations: Try operations on floating point numbers. Assign single to double, double to single and observe the following:

      • - Type casting done in gimple and subsequent dumps.

      • - The change in the mode and the registers allocated.

      • - Float variables handled differently in assembly.

    12. Binary operations:

      Try binary operations inside a condition e.g. if (a && b) or if (a | b). Observe primarily the gimple dumps and subsequent, if interesting.

PS: Many variations of the above assignments are possible. New features can be tried and the results can be observed.


Anticipated difficulties:

There will hardly be any difficulty in the assignments since the dumps need to be studied in detail. The more variations one tries, better would be the understanding of the dumps.