llvm-optimization

llvm-optimization is a skill for Claude Code from gmh5225/awesome-llvm-security. It costs 44 tokens per session (2,426 once invoked), scanned A, original, MIT.

A technical guide to LLVM, the compiler infrastructure that turns program code into machine code. It covers optimization passes, which transform code to improve speed or reduce size, and how those passes fit into compilation.

In plain words
What is it for?
Use it to create custom LLVM optimization passes, study the optimization pipeline, tune compiled performance, or improve generated code quality.
Why use it?
It helps developers understand why generated code behaves as it does and choose or implement transformations without treating the compiler as a black box.

Skill for Claude Code

Written for Claude Code: installed under .claude/.

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/gmh5225/awesome-llvm-security/llvm-optimization
Any agent
npx skills add gmh5225/awesome-llvm-security --skill llvm-optimization
Clone the repo
git clone --depth 1 https://github.com/gmh5225/awesome-llvm-security

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for llvm-optimization

README.md
[![agentmods](https://agentmods.dev/badge/skills/gmh5225/awesome-llvm-security/llvm-optimization.svg)](https://agentmods.dev/skills/gmh5225/awesome-llvm-security/llvm-optimization)
Your own site
<a href="https://agentmods.dev/skills/gmh5225/awesome-llvm-security/llvm-optimization"><img src="https://agentmods.dev/badge/skills/gmh5225/awesome-llvm-security/llvm-optimization.svg" alt="Measured on agentmods" height="20"></a>
Per session 44 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,426 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00044 $0.02426
Opus 5 $0.00022 $0.01213
Sonnet 5 $0.00009 $0.00485
Haiku 4.5 $0.00004 $0.00243

Measured 6d ago against content hash 7adec1f3aee5, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

llvm-optimization scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/skills/llvm-optimization/SKILL.md · 359 lines

How it starts

The opening of the file, as written. The whole thing — 359 lines — stays where its author put it; the contents beside it link to each section on GitHub.

LLVM Optimization Skill

This skill covers LLVM optimization infrastructure, pass development, and performance tuning techniques.

Optimization Pipeline Overview

Pipeline Stages

Source → Frontend → LLVM IR → Optimization Passes → CodeGen → Machine Code
                        ↓
                 [Transform Passes]
                 [Analysis Passes]

Optimization Levels

# No optimization
clang -O0 source.c

# Basic optimization (most optimizations enabled)
clang -O1 source.c

# Full optimization (aggressive inlining, vectorization)
clang -O2 source.c

# Maximum optimization (may increase code size)
clang -O3 source.c

# Size optimization
clang -Os source.c  # Optimize for size
clang -Oz source.c  # Aggressive size optimization

Core Optimization Passes

Scalar Optimizations

  • Constant Propagation: Replace variables with known constant values
  • Dead Code Elimination (DCE): Remove unreachable or unused code
  • Common Subexpression Elimination (CSE): Avoid redundant computations
  • Instruction Combining: Merge multiple instructions into simpler forms
  • Scalar Replacement of Aggregates (SROA): Break up aggregate allocations

Loop Optimizations

  • Loop Invariant Code Motion (LICM): Hoist invariant computations
  • Loop Unrolling: Duplicate loop body to reduce overhead
  • Loop Vectorization: Convert scalar loops to vector operations
  • Loop Fusion/Fission: Combine or split loops
  • Induction Variable Simplification: Optimize loop counters

Interprocedural Optimizations

  • Inlining: Replace call sites with function body
  • Dead Argument Elimination: Remove unused function parameters
  • Interprocedural Constant Propagation: Propagate constants across functions
  • Link-Time Optimization (LTO): Whole-program optimization

Writing Custom Optimization Passes

New Pass Manager (LLVM 13+)

#include "llvm/IR/PassManager.h"
#include "llvm/Passes/PassBuilder.h"
#include "llvm/Passes/PassPlugin.h"

struct MyOptimizationPass : public llvm::PassInfoMixin<MyOptimizationPass> {
    llvm::PreservedAnalyses run(llvm::Function &F,
                                 llvm::FunctionAnalysisManager &FAM) {
        bool Changed = false;
        
        for (auto &BB : F) {
            for (auto &I : BB) {
                // Implement optimization logic
                if (optimizeInstruction(I)) {
                    Changed = true;
                }
            }
        }
        
        if (Changed)
            return llvm::PreservedAnalyses::none();
        return llvm::PreservedAnalyses::all();
    }
    
private:
    bool optimizeInstruction(llvm::Instruction &I) {
        // Example: Replace add x, 0 with x
        if (auto *BinOp = llvm::dyn_cast<llvm::BinaryOperator>(&I)) {
            if (BinOp->getOpcode() == llvm::Instruction::Add) {
                if (auto *C = llvm::dyn_cast<llvm::ConstantInt>(BinOp->getOperand(1))) {
                    if (C->isZero()) {
                        I.replaceAllUsesWith(BinOp->getOperand(0));
                        return true;
                    }
                }
            }
        }
        return false;
    }
};

// Plugin registration
extern "C" LLVM_ATTRIBUTE_WEAK ::llvm::PassPluginLibraryInfo
llvmGetPassPluginInfo() {
    return {LLVM_PLUGIN_API_VERSION, "MyOptPass", LLVM_VERSION_STRING,
            [](llvm::PassBuilder &PB) {
                PB.registerPipelineParsingCallback(
                    [](llvm::StringRef Name, llvm::FunctionPassManager &FPM,
                       llvm::ArrayRef<llvm::PassBuilder::PipelineElement>) {
                        if (Name == "my-opt") {
                            FPM.addPass(MyOptimizationPass());
                            return true;
                        }
                        return false;
                    });
            }};
}

Read the full file on GitHub · 359 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 6d ago First seen · 359 lines · 44 tokens per session scan A 7adec1f3aee5

Subscribe to this mod's changes

llvm-optimization is a skill published in the GitHub repository gmh5225/awesome-llvm-security (879 stars, last pushed 22d ago), licensed MIT. It adds 44 tokens to every session and 2,426 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

Deobfuscation

Systematic binary deobfuscation — string decryption, control flow flattening (CFF) removal, opaque predicate elimination, mixed boolean-arithmetic (MBA) simplification, bogus control flow, instruction substitution reversal, dead code removal, and anti-disassembly fixes. Trigger: deobfuscate, unobfuscate…

buzzer-re/Rikugan · 114 tokens

defeating-control-flow-flattening

Defeats control-flow-flattening obfuscation by identifying the dispatcher/state- variable structure and reconstructing the original control flow so the logic becomes readable. Activates for requests to defeat control-flow flattening, deobfuscate an OLLVM-flattened function, or recover original control flow from a…

meltedinhex/analyst-ai-pack · 74 tokens

stop-chasing-the-optimizer-reduce-instead

After two failed anti-optimization patches, stop and reduce; don't keep bolting on volatile / noinline.

chen3feng/agent-skills · 36 tokens

debug-optimize-lcp

Guides debugging and optimizing Largest Contentful Paint (LCP) using Chrome DevTools MCP tools. Use this skill whenever the user asks about LCP performance, slow page loads, Core Web Vitals optimization, or wants to understand why their page's main content takes too long to appear. Also use when the user mentions…

ChromeDevTools/chrome-devtools-mcp · 99 tokens

systematic-debugging

Use when debugging a failing test, build error, or runtime issue that isn't immediately obvious. Guides a 4-phase root cause analysis instead of random fix attempts.

open-metadata/OpenMetadata · 37 tokens

diagnose

Trace from a reproduced symptom to the source code that causes it. Pin the specific file and approximate line, rate confidence in the cause and clarity of the fix independently, and always propose a concrete fix.

emdash-cms/emdash · 43 tokens