Skip to content

Add an interface and example for running LLVM passes on loaded modules #32

@wongey

Description

@wongey

In Module.cc, we have implemented basic functionality to resolve entry points and interpret metadata in a QIR file. However, we have not yet implemented anything that takes advantage of the true LLVM IR capabilities: namely, code simplification and modification through automated refactoring passes.

We want a new interface and example of using LLVM passes to interpret and refactor QIR code. For each case here, add a new helper class in src/qiree (and a new test) that takes a Module and:

  1. Add dead block elimination: if a block is unreachable or empty, branch statements should bypass it. Add a test using teleport.ll.
  2. Eliminate dead blocks, and reorder blocks so that the only branching from block A is br <cond>, label B, label C, and block B jumps directly to block C. If multiple branching or else statements are encountered, raise an error. (This condition is necessary for QIREE to reformulate blocks as predicates e.g. for connecting with XACC). Test that it works on teleport.ll, and add a new QIR example test where it fails.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestunitaryHACK2025Issues that can receive Unitary Hack bounties

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions