r/LLVM • u/slacka123 • Nov 05 '21
r/LLVM • u/ArmchairmanMao • Jun 11 '26
Vibe coders contributing to LLVM
There is a github account, which has submitted around 100 PRs to llvm (ClangIR) and it looks like every single one was entirely AI generated. They're not exactly keeping it a secret either. All the comments and replies from the guy seem AI generated too. Thankfully, the maintainers are reviewing everything quite carefully.
It's hard to tell whether the account is even ran by a human and not just some automated openclaw bot. It's a bit scary to think that an agent effectively has full Member permissions for the LLVM github repo through this account.
I'm not anti AI, I use coding tools all the time but this doesn't sit right with me. Am I overreacting, and this is just the way things are now?
r/LLVM • u/MHijazi007 • Sep 27 '20
How the ever loving hell does a beginner start learning LLVM?
I want to create my own programming language for an educational purpose, and have been looking at using assembly code to do so (tiresome as it may be). But I found out that it would be very difficult to port to other architectures and that I may be better served using a language like C.
Reading further (I'm by no means an expert, I just want to know where to invest my time) it's said that LLVM is like a "universal assembler" and that it is better than C. Problem is, I have no idea where to start. Is there any books for beginners on the topic, how do I install it, how do I run a hello world? How can I learn more about the language coming in as an outsider?
r/LLVM • u/slacka123 • Jan 15 '19
The Official LLVM Git Repository Is Now On GitHub
r/LLVM • u/nickdesaulniers • Oct 21 '18
Favorite shirt from 2018 US Developers' Meeting, Look Familiar? (Kudos Jessica)
r/LLVM • u/Glittering_Age7553 • Oct 17 '23
How to become a Compiler Engineer ?
I'm interested in learning how to pursue a career as a Compiler Engineer and what reading materials are recommended. Although I hold an MSc in Computer Science, my current understanding of compilers is not very deep.
r/LLVM • u/yossarian_flew_away • Jul 19 '21
LLVM internals, part 1: the bitcode format
r/LLVM • u/Any-Perspective1933 • Apr 02 '26
Prysma: Anatomy of an LLVM Compiler Built from Scratch in 8 Weeks
Prysma: https://github.com/prysma-llvm/prysma
This is a compiler development project I started about 8 weeks ago. I’m a CEGEP student, and since systems engineering of this scale isn’t taught at my level, I decided to build my own low-level ecosystem from scratch. Prysma isn’t just a student project; it’s a complete language and a modular infrastructure designed with the constraints of industrial production tools in mind. This document is a technical dissection of the architecture, my engineering choices, and the effort invested in the project.
1. Meta-generation and automation of the frontend
Developing a compiler normally requires manually coding hundreds of classes for the Abstract Syntax Tree (AST) and its visitors, which generates a lot of technical debt. To avoid this, I created a compiler generator in Python.
Prysma’s grammar is defined in an ast.yaml file. My Python engine (engine_generation.py), which uses Jinja2, reads this specification and generates all the C++ code for the frontend (classes, virtual methods, interfaces). This strategy is inspired by LLVM’s TableGen. It allows me to add a new operator in 30 seconds. Without this technique, it would take me about an hour to add a single node, because I would have to manually modify the token, the lexer, the parser, and the visitors, with a high risk of errors. Now, everything is handled by automated templates.
2. Parallel Orchestration with llvm::ThreadPool
A modern compiler needs to be fast, so I architected the orchestrator around llvm::ThreadPool. Prysma processes files in parallel for the lexing, parsing, and IR generation phases. The technical challenge was that LLVM contexts are not thread-safe. I had to isolate each compilation unit in its own context and memory module before the final merging by the linker. Managing race conditions on global symbols required strict adherence to the object lifecycle.
3. Native Object Model and V-Tables
Prysma implements a class model directly in LLVM IR, including encapsulation (public, private, protected). Implementing polymorphism was one of the most complex aspects. I modeled navigation in virtual method tables (V-Tables) at the binary level using LLVM’s opaque types (llvm::StructType). Call resolution is handled at runtime with GetElementPtr (GEP) instructions to retrieve function pointers. Because a single-byte error causes Segfaults, this part is still in an unstable version in the compiler.
4. Memory Management: Arena and Heap
Memory allocation is crucial for speed. For the AST nodes, I use a memory arena (llvm::BumpPtrAllocator). The compiler reserves a massive block and simply advances a pointer for each allocation in $O(1)$. Everything is freed at once at the end, as in Clang.
For the Prysma language itself, I implemented dynamic allocation with the new and delete keywords, which communicate with libc’s malloc and free. Loops also manage their stack via LLVM’s alloca instruction.
5. Unit and Functional Testing System
To ensure the reliability of the backend, I implemented a robust pipeline. I use Catch2 for C++ tests of the AST and the register. I also developed a test orchestrator in Python (orchestrator_test.py) that uses templates to compile and execute hundreds of files simultaneously. This allows testing recursion, variable shading, and thread collisions. Deployment is blocked by GitHub Actions if a single test fails.
6. Execution Volume and Work Methodology
Systems engineering demands a significant amount of execution time. To make this much progress in 8 weeks, I worked 14 hours a day, 7 days a week. Designing an LLVM backend requires reading thousands of pages of documentation and debugging complex memory errors.
AI was a great help in understanding this complexity. My method was iterative: I generated LLVM IR code (version 18) from C++ code to inspect and understand each line. I combined Doxygen’s technical documentation with questions posed to the AI to master everything. To maintain this pace, I managed my fatigue with caffeine (a maximum of three times a week to avoid upregulation), accepting the impact on my mental health to achieve my goals. I was completely absorbed by the project.
7. Data-Oriented Design (Work by Félix-Olivier Dumas)
Félix-Olivier Dumas joined the Prysma team to restructure the project’s algorithmic foundation. He implemented a Data-Oriented Design (DOD) architecture for managing the AST, which is more efficient.
In its system (currently being finalized), a node is a simple integer (node_id_t). Data (name, type) is stored in Sparse Sets as flat arrays. The goal is to maximize the L1/L2 cache: by traversing aligned arrays, the CPU can preload data and avoid cache misses. It also uses Tag Dispatching in C++ to link components at no runtime cost (zero-cost abstraction), without v-tables or switch statements.
8. Current State of the Language
Prysma is currently a functional language with stable capabilities:
Syntax: Primitive types (int32, float, bool), full arithmetic, and operator precedence.
Structures: If-else conditions and while loops.
Functions: Recursion support and passing arguments by value.
Memory & OOP: Native arrays, classes, inheritance, and heap allocation.
Tools: Error diagnostics (row/column), Graphviz export of the AST, and a VS Code extension for syntax highlighting.
9. Roadmap and Future Vision
The project is evolving, and here are the planned objectives:
Short term (v1.1): Development of the Standard Library (lists, stacks, queues) and an import system for linking C libraries.
Medium term (v1.2): Support for Generics (templates), addition of Namespaces, and stricter semantic analysis for type checking.
Long term: Just-In-Time (JIT) compilation, integration of the inline assembler (asm {}), and custom SSA optimization passes.
The project is open source, and anyone interested in LLVM or Data-Oriented Design can contribute to the project on GitHub. The code is the only judge.
r/LLVM • u/blazing_cannon • Sep 07 '26
How to start learning compiler optimizations as a newbie?
I come with a background in computer architecture and embedded Linux. I was interested in ML systems and was reading up about it, and after going through several job postings and this link , noted that optimizing compiler code is a requirement. My questions are -
Is knowledge of how compiler front end is written and IR code generated required to optimize them? https://engineering.purdue.edu/online/courses/tagged_items?q=compiler
What's a good resource for compiler optimizations that can help in ML systems?
3) Are learning compiler optimization techniques the same for LLVM and MLIR? I don't see a lot of resources for MLIR compiler optimization. Is learning optimizations on LLVM helpful for MLIR and is learning LLVM not so useful for ML code optimizations ?
Thank you.
r/LLVM • u/slacka123 • Aug 17 '21
Exploring Clang/LLVM optimization on programming horror
r/LLVM • u/HighSchoolNerd • Jan 09 '24
I Wrote a Backend for a Custom Architecture
Hey everyone! For context. I did my undergrad at Georgia Tech, and there I TAed for CS 2110: Intro. Computer Architecture. I liked how the course was organized. We start by building gates out of transistors, then building combinational logic, then sequential logic, which we use to build a datapath which we program in Assembly. The last part of the course is on C, but the connection between it and the earlier parts is weak. No compiler exists for the Assembly language we use, so we have to use ARM or x86 instead. This means students don't see how constructs in C can be lowered to Assembly.
My professor wanted to fix this, and I took him up on the opportunity. Sadly, we can't incorporate my work into the course for logistical reasons, so we open-sourced it instead: https://github.com/lc-3-2. It has a fork of LLVM with a backend for the LC-3.2, which is a version of the LC-3 architecture we use modified to have byte-addressibility and 32-bit words. It also has a basic simulator for the architecture, and a rudimentary C library.
It would be nice to have a (good) compiler to the LC-3, but I don't think LLVM supports targets that are not byte-addressable. The LC-3b (https://users.ece.utexas.edu/~patt/19s.460n/handouts/appA.pdf) might be an easier target. A lot of the code could be reused - the LC-3.2 is based off the LC-3b. What do you think?
r/LLVM • u/nickdesaulniers • Dec 25 '20
A Complete Guide to LLVM for Programming Language Creators (diagrams + code)
r/LLVM • u/[deleted] • Dec 23 '23
What after Kaleidoscope Tutorial?
So I followed the Kaleidoscope tutorial and made the language. But I have now got no idea to like how to make an imperative and useful programming language frontend. I tried to make one, again from the beginning (I targeted Lua), but it went really really messy. I couldn't think of "how to actually implement the thing", Is there some resources I can go through to make one. I want to make one useful language.
r/LLVM • u/Polygon_809 • May 13 '21
Tips for getting started with LLVM development?
I'm working on a toy project to work with MLIR, but the tutorial code alone seems to assume a lot of knowledge about the codebase and the LLVM codebase (e.g. how things are organized, the concepts of operation context objects and builder objects).
Does anyone here have tips for learning about the LLVM codebase? I confess I'm a lot more used to working with tools so common that I can google my question and get a stackOverflow thread telling me exactly what I need to know, and working with a codebase that's far less googlable is rather new to me.
r/LLVM • u/nickdesaulniers • Jul 31 '20
LLVM Microconference Accepted into 2020 Linux Plumbers Conference
r/LLVM • u/Late_Attention_8173 • Jan 04 '26
Beyond Syntax: Introducing GCC Workbench for VSCode/VSCodium
galleryr/LLVM • u/ArtisticHamster • Aug 25 '23
Book recommendations to get proficient at LLVM compiler infra
Could anyone recommend a good book(s)/courses/lecture notes to get understanding required to be fluent at what happens inside of LLVM? I have seen recommendation of this book: https://www.amazon.com/Advanced-Compiler-Design-Implementation-Muchnick/dp/1558603204 but it's circa 1997, which is ages in the CS field.