Skip to content

Advanced-Compiler-Design LLVM Pass Implementations 2024 Fall, NTUCSIE (by Prof. Shih-Wei Liao)

Notifications You must be signed in to change notification settings

hyyrin/LLVM-Pass

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Environment Setup

Note

You can neglect the following environment setup process by sshing to the ws1 and directly jump to Build Instructions part.

Required LLVM Version and Installation Instructions

  • LLVM Version: Ensure the LLVM version is 12 or higher installed on the system.
  • Installation:
sudo apt-get update
sudo apt-get install llvm-12 llvm-12-dev clang-12

Dependencies and Their Versions

  • CMake: Version 3.13.4 or higher.
  • LLVM: Ensure LLVM_DIR is set to the correct LLVM installation path.

Required Environment Variables or System Configurations

  • Set the LLVM_DIR environment variable to the path of your LLVM installation: export LLVM_DIR=/usr/lib/llvm-12/cmake
  • Ensure your PATH includes the LLVM binaries: export PATH=/usr/lib/llvm-12/bin:$PATH

Build Instructions

  1. Clone the repository and navigate to the directory:
cd code
cd src
  1. Create a build directory and navigate to it:
mkdir build
cd build
  1. Run cmake to configure the project:
cmake ..
  1. Build the project:
make

Running the Pass and Testing

Simple Case

  1. Ensure you are in tests directory.
  2. Execute the command:
bash run_simple.sh
  1. Then, it would generate test.opt.ll and test2.opt.ll in the tests directory.
  2. Verify the output IR file test.opt.ll(compare with test.ll)to ensure the optimizations are applied.
  3. Verify the output IR file test2.opt.ll(compare with test2.ll)to ensure the optimizations are applied.

Benchmark

  1. Navigate to the testsdirectory.
  2. Execute: bash run_bench.sh
  3. Then, it would show the following result:
Running benchmark with unoptimized version...
Constant Folding Test: Time = 0.000014 seconds, Result = 84000
Strength Reduction Test: Time = 0.000009 seconds, Result = 31968000
Algebraic Identities Test: Time = 0.000012 seconds, Result = 42000
Mixed Optimizations Test: Time = 0.000009 seconds, Result = 30720000
Matrix Multiplication Test: Time = 0.000333 seconds, Result = 63360000
Running benchmark with optimized version...
Constant Folding Test: Time = 0.000008 seconds, Result = 84000
Strength Reduction Test: Time = 0.000006 seconds, Result = 31968000
Algebraic Identities Test: Time = 0.000006 seconds, Result = 42000
Mixed Optimizations Test: Time = 0.000005 seconds, Result = 30720000
Matrix Multiplication Test: Time = 0.000203 seconds, Result = 63360000

About

Advanced-Compiler-Design LLVM Pass Implementations 2024 Fall, NTUCSIE (by Prof. Shih-Wei Liao)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published