This LLVM pass implements Loop Tiling, an optimization that breaks loops into smaller tiles to improve cache performance. It modifies the loop's structure by creating new loop headers, bodies, and exit blocks, ensuring correct control flow and updating loop counters accordingly. The pass is designed to enhance the efficiency of nested loops by optimizing memory access patterns.
To get started, you'll need to download and set up the LLVM repository. You can do this with the following commands:
wget "http://www.prevodioci.matf.bg.ac.rs/kk/2023/vezbe/llvm-project.zip"
unzip -d llvm-project llvm-project.zipInside the extracted directory, you'll find a script named make_llvm.sh to build the project. Follow these steps:
-
Make the script executable:
chmod +x make_llvm.sh
-
Run the script to build LLVM:
./make_llvm.sh
This will compile the LLVM project.
-
Clone the repository.
-
Move the entire
LoopTilingPassdirectory tollvmproject/llvm/lib/Transforms/directory. -
Update the
llvmproject/llvm/lib/Transforms/CMakeLists.txtand add the following line:add_subdirectory(LoopTilingPass)
To compile and run your code with this optimization:
-
Place the files from the
Testdirectory in thellvmproject/build/directory. -
From the
llvmproject/build/directory, execute the following commands for example:./bin/clang -S -emit-llvm test1.c ./bin/opt -S -load lib/LoopTilingPass.so -enable-new-pm=0 -loop-tiling test1.ll -o -output.ll
-
The optimized code will be available in
output.ll.
-
Bogdan Stojadinović - @bogdans55
-
Anđela Jovanović - @andjixi