README.md 890 Bytes
Newer Older
1
2
# Examples for the Program Optimization Practical Course SS20
This is organized by analysis. For each analysis, there is at least one example consisting of
Michael Schwarz's avatar
Michael Schwarz committed
3
4
 - the input C program (`*.c`)
 - the resulting ll-file (`*.ll`)
5
6
7
8
    ```
        clang -emit-llvm -Xclang -disable-O0-optnone -c 1.c
        llvm-dis 1.bc
    ```
Michael Schwarz's avatar
Michael Schwarz committed
9
10
    Here, all local variables are represented by calling `alloca` and then accessing them using pointers.
 - the resulting ll-file after the mem2reg pass (`*-opt.ll`)
11
12
13
14
15
    ```
        opt -mem2reg 1.bc -o 1-opt.bc
        llvm-dis 1-opt.bc
    ```
    This transforms the program so registers are used for local variables instead of memory accesses.
Michael Schwarz's avatar
Michael Schwarz committed
16
17
 - the ll-file after mem2reg annotated with possible analysis results (`*-opt-annotated.ll`)
 - a possible ll-file after applying the transformation based on the analysis result from the step before (`*-opt-optimized.ll`)