LLVM

LLVM API Reference

Comprehensive documentation for LLVM libraries, tools, and programmatic interfaces

Explore Core APIs

Key API Components

Core LLVM APIs

Fundamental libraries like IR, Pass, Support, and TransformUtils for compiler development.

View Core APIs

Clang APIs

APIs for parsing, analyzing, and transforming C/C++/Objective-C code with AST operations.

View Clang APIs

Tooling APIs

Libraries for creating compilers, static analyzers, and refactoring tools with clangd integration.

View Tooling APIs

Function Pass Example

#include "llvm/Passes/Pass.h"
#include "llvm/IR/Function.h"

using namespace llvm;

namespace {
  struct MyPass : public FunctionPass {
    static char ID;
    MyPass() : FunctionPass(ID) {}

    bool runOnFunction(Function &F) override {
      // Simple optimization logic
      for (auto &BB : F) {
        for (auto &I : BB) {
          // Process instructions here
        }
      }
      return true;
    }
  };
}

char MyPass::ID = 0;
static RegisterPass<MyPass> X("my-pass", "Simple Function Pass");
                    

Enhance LLVM APIs

Add new APIs, improve documentation, or create tutorials for LLVM modules.

Contribute to APIs