PitchHut
Log in / Sign up
LLQL
6 views
Unlock the power of LLVM with SQL-like queries.
Pitch

LLQL is an innovative tool that enables you to perform SQL-like queries on LLVM IR/Bitcode files. By using pattern matching functions inspired by LLVM InstCombine, LLQL allows you to reveal complex instruction relationships effortlessly. Whether you are analyzing performance or exploring optimizations, LLQL simplifies your inquiries into the intricate world of LLVM.

Description

LLQL is an innovative SQL-like query language specifically designed for analyzing LLVM Intermediate Representation (IR) and Bitcode files. This powerful tool employs pattern matching functions inspired by LLVM's InstCombine Pattern Matchers, allowing developers to run complex queries on their LLVM files seamlessly.

Features

  • SQL-Like Queries: Utilize familiar SQL syntax to extract valuable information from LLVM IR/Bitcode files.
  • Pattern Matching: Leverage advanced pattern matching capabilities to pinpoint specific instruction sequences, enhancing code analysis efficiency.
  • Flexible Usage: Easily query functions, instructions, and data structures within your LLVM files for insights into their performance and structure.

Quick Example

Imagine you have an LLVM IR function defined as follows:

define i32 @function(i32 %a, i32 %b) {  
  %sub = sub i32 %a, %b  
  %mull = mul i32 %a, %b  
  %add = add i32 %sub, %mull  
  ret i32 %add  
}  

You can extract specific instructions with LLQL using:

SELECT instruction FROM instructions WHERE m_inst(instruction, m_add(m_sub(), m_mul()))  

Or count occurrences of this pattern across functions:

SELECT function_name, count() FROM instructions WHERE m_inst(instruction, m_add(m_sub(), m_mul())) GROUP BY function_name  

Available Functions

Explore a variety of functions designed for instruction and type matching:

Instruction Table Structure

The primary table you will interact with is the "Instructions" table, structured as follows:

NameTypeDescription
function_nameTextInstruction function name
basic_block_nameTextBasic block of this instruction
instructionLLVMValueLLVM Instruction

Usage

Run LLQL to begin querying your LLVM IR/Bitcode files effectively. Use the following command to explore LLQL's options:

LLQL is a SQL-like query language to run on LLVM IR/BitCode files  
Usage: LLQL [OPTIONS]  

Options:  
  -f,  --files <paths>        Path for local files to run query on  
  -q,  --query <GQL Query>    LLQL query to run on selected files  
  -p,  --pagination           Enable print result with pagination  
  -ps, --pagesize             Set pagination page size [default: 10]  
  -o,  --output               Set output format [render, json, csv]  
  -a,  --analysis             Print Query analysis  
  -e,  --editor               Enable GitQL LineEditor  
  -h,  --help                 Print LLQL help  
  -v,  --version              Print LLQL Current Version  

Join the community of LLVM developers enhancing their workflows with LLQL and discover the unmatched analytical capability of this tool!