LUND UNIVERSITY
Department of Computer Science

LLVM 6.0 Project, EDAN75 Optimizing Compilers, 2018

  1. Download and build LLVM according to instructions in the book or lecture 13.

  2. Produce textual LLVM bitcode for the following function and save it in a file a.ll:
    int f(int a, int b)
    {
            int     c;
    
            if (a < b)
                    c = a * b;
            else
                    c = a * b;
    
            return c * a + c * a;
    }
    


  3. Copy the Hello-transformation (see Lecture 13) to create a new optimization called EDAN75.

  4. The compulsory part of the LLVM project is to recognize and optimize a redundant expression (not ''the'' since it is unspecified which term is evaluated first in C/C++) in the return-statement.

  5. Enable your optimization and also the mem2reg optimization. In your build directory, run with the command:

    bin/opt -mem2reg -load lib/EDAN75.so -edan75 a.ll -S b.ll

  6. Inspect the bitcode in b.ll and when you are satisfied, email it and your C++ source file(s) to Jonas.

    Tue Oct 9 11:21:40 CEST 2018