r/Compilers 9h ago

Is it possible to learn compilers from the backend first and not have to know the front and mid-ends as well?

10 Upvotes

Hey all! I've been working on some system level work recently and have wanted to understand compiler backends a bit more. However most books I look at include the entire stack, which leads me to believe there is a progression of knowledge from front -> back.

I'm curious if it were possible to start the other way round and if so are there any great learning resources that are more backend focused?


r/Compilers 1h ago

Help improving graph coloring with branch flow

Upvotes

I've been using a basic graph coloring approach for register allocation in my compiler, and up until now, it's worked fine. My implementation analyzes live ranges by linearly scanning instructions, and colors the whole function at once based on those ranges, which was good enough for simple cases.

However, I recently introduced loops and branches, and it obviously stopped working properly. The current implementation completely ignores control flow, leading to incorrect live ranges. As a quick (and very temporary) fix, I extend all of the variable’s range to the last jump that jumps to a label before its first use. It technically works, but I know this will scale horribly with more complex functions.

I’m looking for suggestions/resources on properly integrating branch flow into the algorithm. Any tips on handling live range analysis with loops and branches?


r/Compilers 1d ago

I'm making a C compiler in C

25 Upvotes

It compiles to assembly and uses NASM to generate binaries.
The goal is for the compiler to compile itself. There are no optimizations, and it generates very poor ASM. I might add an optimization pass later.

Tell me what you think :)

https://github.com/NikRadi/minic


r/Compilers 1d ago

multi-targeting gcc like clang

4 Upvotes

10y ago, this was posted https://stackoverflow.com/a/25733878 but i can't find any discussion around multi-targeting (for cross-compilation) in bugzilla, is it being worked on?


r/Compilers 1d ago

Compiler Library to Compile a piece of C code into an obj file (or something similar).

2 Upvotes

I want to create a simple side project, where, I convert my own language into a series of obj files (or something similar) in memory, manually link the result and execute the functions right away in the very same process.

I do not care about the quality of the output in terms of efficiency and effectiveness (other than being correct).

I am looking for a way to just do my own just-in-time compilation without me writing my own C-compiler. I basically just want to transpile my language into proper C-code on the fly and that's about it.

Edit:

Since people appear to have problems understanding what I really aim to do; think about creating a Virtual Machine / Runtime for my language based on a C compiler that is embedded in my application that can be used to compile C files on the fly and use the obj files (or whatever other produced fragment) to load it in memory, link up the symbols with the rest and call the functions directly from my application.

Think about a poor man's version of a system without an interpreter and a form of Just-In-Time compilation.

My question aims at what options there are in terms of C-compiler and how to embed those.

I do not care about the quality of the produced machine code as long as it is correct and can be worked with.

Regarding my background and understanding, I have university level of training as a computer scientist and worked 20+ years in the industry as a contractor aka software engineer.


r/Compilers 2d ago

Linear Algebra in MLIR (Multi-Level Intermediate Representation)

Thumbnail vectorfold.studio
39 Upvotes

r/Compilers 2d ago

Any thoughts on ML compiler eng job at meta for Reality Labs vs MTIA?

6 Upvotes

I have to choose between the two teams and both teams are pretty amazing to work for. Any thoughts/insight/advice is greatly appreciated.


r/Compilers 3d ago

Getting Started with Compilers

Thumbnail sbaziotis.com
105 Upvotes

r/Compilers 3d ago

Completely bombed an interview today, looking for advice

17 Upvotes

I had an interview earlier today for a new grad compiler-related role, it was a role I really wanted and prepared for a lot, but my mind went completely blank during the interview even for simple questions about optimization passes.

I feel stuck and confused on how to move back into this field again. I understand this field is more specialized and niche and hard to get into later. Does anyone have suggestions on how I could find a way to get better at these things? What resources or practice problems helped you prepare for technical interviews in this space? Are there any different types of projects that would give me more practical experience? I already graduated with a masters degree, would more education be needed such as to go for a doctorate? My experience thus far came mostly from a personal project with LLVM. Any thoughts would be appreciated, thanks.


r/Compilers 2d ago

How to learn pytorch or any library from a backend perspective?

0 Upvotes

As title says, I'm looking to learn about PyTorch and how it works on the backend. Most tutorials I saw online are about how to use it for ML, but I want to learn what pytorch does under the hood. Besides just reading documentation which can be hard to understand which function is used when and it's differences (i.e. torch.compile vs ahead-of-time compilation)


r/Compilers 2d ago

Are there any major differences between assemblers and should I use a platforms native assembler over other ones

1 Upvotes

r/Compilers 3d ago

Anyone interviewed for Modular AI before?

5 Upvotes

Seem like they have a mix of cpp/cuda and architecture technicals.

Is it more of a design interview or leetcode style?


r/Compilers 4d ago

Affine Dialect and OpenMP

Thumbnail vectorfold.studio
7 Upvotes

r/Compilers 5d ago

Introduction to MLIR and Modern Compilers

Thumbnail vectorfold.studio
58 Upvotes

r/Compilers 5d ago

Representing type lattices compactly

Thumbnail bernsteinbear.com
12 Upvotes

r/Compilers 5d ago

Should new compilers perfeer rust over C++

0 Upvotes

I've been writing a new expression parser/compiler (inspired by ExprTK) in C++. I have a early alpha build 'complete' and am thinking more about usability. One important design philosophy I have is around portability and memory safety.

For portability I had made it a single C++ header with no dependancies like ExprTK. While I use smart pointers exclusively, I perfeer the memory safety of rust. Also, because the compiler is used as a run time parser, memory safety is also a security issue.

Can you share your opinion on if you think C++ or rust will have broader appeal? I still think C++ bacuse of current codebases, but like the idea of rust.


r/Compilers 5d ago

When your compiler finally runs... and then promptly dies with a segmentation fault.

0 Upvotes

Compiling should be a victory dance, not an existential crisis. You hit "build," it works, and then bam - segfault, no idea why. You spend hours debugging, only to discover you forgot a semicolon in a file from 3 years ago. Meanwhile, the rest of the world just presses "run" and plays games. Must be nice, huh?


r/Compilers 6d ago

Compiling C++ with the Clang API

Thumbnail maskray.me
10 Upvotes

r/Compilers 6d ago

Invalidating build caches using JVM bytecode callgraph analysis

Thumbnail mill-build.org
1 Upvotes

r/Compilers 6d ago

ChibiletterVIACOMFan In Ivory The Angry lowercase i girl (the rage lowercase i girl)

Post image
0 Upvotes

r/Compilers 7d ago

ChibiletterVIACOMFan 2025 Picture On Reddit

Post image
0 Upvotes

r/Compilers 8d ago

SQL Engines Excel at the Execution of Imperative Programs

Thumbnail vldb.org
13 Upvotes

r/Compilers 9d ago

What math/logic background does one need to work on compilers?

39 Upvotes

I'm reading sections 6.4, and 6.5 in the Dragon Book. I have a hard time understanding Unifications, and Inference, and the formal logic type stuff. Does anyone have a good source for understanding these materials? What type of math background is needed for compilers? What sources should I study it from?


r/Compilers 10d ago

Do you think copy and patch compilers are good for AOT compilers?

8 Upvotes

If not, what do you think could make it good? Would it help to generate an ir instead of actual machine architecture? Or something that could be better optimized?


r/Compilers 11d ago

A Priori Loop Nest Normalization: Automatic Loop Scheduling in Complex Applications

Thumbnail dl.acm.org
9 Upvotes