Status: Complete

Overview

A custom LLVM pass that analyzes loop structures and identifies unroll opportunities. This project demonstrates understanding of classical compiler infrastructure and serves as a foundation for quantum circuit compiler development.

Features

The pass traverses all functions in LLVM IR and reports:

  • Detected loops and their nesting depth
  • Loop bounds analysis
  • Unroll recommendations
  • Metadata attachment for unroll recommendations

Technical Approach

New Pass Manager

Uses LLVM 18 New Pass Manager for modern pass infrastructure compatibility, providing better performance and flexibility compared to the legacy pass manager.

Scalar Evolution

Scalar Evolution (SE) is a powerful LLVM analysis that computes loop trip counts. It handles complex expressions and is essential for accurate loop analysis and optimization decisions.

Usage

# Compile test C code to LLVM IR
clang-18 -emit-llvm -S tests/test.c -o tests/test.ll

# Run the pass on the IR
opt-18 -load-pass-plugin=./libUnrollAnalyzerPass.so \
       -passes="unroll-analyzer" tests/test.ll -S -o output.ll

Project Structure

llvm-CRstuMErenaAcsrkD/toeMUsttttlLEn/eeeeli.rssss-smottttatdl..__nslcleea.Alddltnggyxaeeztl__eyccrzaa/essree.ssc..pclpl

Technology Stack

  • LLVM Version: 18
  • Language: C++
  • Build: CMake
  • Analysis: Scalar Evolution, Loop Analysis

Connection to Quantum Work

This project bridges classical compiler optimization with quantum circuit compilation:

  • LLVM Pass Infrastructure → Informs quantum circuit optimizer pass manager design
  • Loop Analysis → Analogous to circuit depth analysis
  • Optimization Decisions → Similar to gate cancellation/commutation decisions

Understanding classical compiler infrastructure (SSA, pass managers, analysis passes) directly translates to building effective quantum compilers.