RSSAmplifier

Blog

Low Level Bits 🇺🇦 on Low Level Bits 🇺🇦

Recent content in Low Level Bits 🇺🇦 on Low Level Bits 🇺🇦

lowlevelbits.orgRSS feed ↗14 posts

Latest posts

Different ways to build LLVM/MLIR tools

This is a mirror of the Substack article Different ways to build LLVM/MLIR tools The most recent version is there. LLVM and MLIR frameworks are typically used to build compilers for various use cases, but I’m using word “tools” here to cover a broader set of possibilities (compilers, language plugins, analyzers, etc.). If you want to build such a tool, then you obviously need to somehow “connect”…

Building LLVM plugins with Bazel

This is a mirror of the Substack article Building LLVM plugins with Bazel The most recent version is there. One of the premises of Bazel is to provide reproducible, hermetic builds, thus you shouldn’t depend on whatever is installed on the host OS and all the dependencies typically managed by Bazel directly. However, if you want to build plugins for LLVM (or any other project really), then you…

Compiling Ruby. Part 5: exceptions

Call Stack, Stack Frames, and Program Counter During the program execution, a machine maintains a pointer to the instruction being executed. It’s called Program Counter (or Instruction Pointer ). When you call a method (or send a message if we are speaking of Ruby), the program counter is set to the first instruction on the called function ( callee ). The program somehow needs to know how to…

Compiling Ruby. Part 4: progress update

It’s been a while since I wrote the last blog post. One of the reasons is that so far, I had to change a lot of things in the implementation due to the exception support. I’m writing a short progress update on where we are and what’s coming next. What Happened During this year, I gave two short talks related to this project: a high-level overview of the project (EuroLLVM dev…

Compiling Ruby. Part 3: MLIR and compilation

Now as we have a decent understanding of how RiteVM works, we can tackle the compilation. The question I had around two years ago - how do I even do this? A note of warning: so far, this is the longest article on this blog. And I’m afraid the most cryptic one. The topics covered here: MLIR Control-Flow Graphs (CFG) Static Single Assignment (SSA) Dataflow Analysis Compilation mruby is written…

Compiling Ruby. Part 2: RiteVM

mruby (so-called “embedded” Ruby) is a relatively small Ruby implementation. mruby is based on a register-based virtual machine. In the previous article, I mentioned the difference between stack- and register-based VMs, but what is a Virtual Machine? As obvious as it gets, a Virtual Machine is a piece of software that mimics specific behavior(s) of a Real Machine. Depending on the kind…

Compiling Ruby. Part 1: Compilers vs. Interpreters

With the (hopefully) convincing motivation out of the way, we can get to the technical details. Compiling Interpreter, Interpreting Compiler As mentioned in the motivation, I want to build an ahead-of-time compiler for Ruby. I want it to be compatible with the existing Ruby implementation to fit it naturally into the existing system. So the first question I had to answer is - how do I even do it?…

Compiling Ruby. Part 0: Motivation

For the last couple of years, I’ve been working on a fun side project called DragonRuby Game Toolkit , or GTK for short. GTK is a professional-grade 2D game engine. Among the many incredible features: you can build games in Ruby it targets many (like, many!) platforms (Windows, Linux, macOS, iOS, Android, WASM, Nintendo Switch, Xbox, PlayStation, Oculus VR, Steam Deck) super lightweight…

How to learn compilers: LLVM Edition

This is a mirror of the Substack article How to learn Compilers (LLVM Edition) The most recent version is there. Compilers and Programming Languages is a huge topic. You cannot just take a learning path and finish it at some point. There are many different areas, each of which is endless. Here, I want to share some links that would help to learn compilers. The list could not be exhaustive -…

LLVM meets Code Property Graphs

This is a cross-post from LLVM’s blog post LLVM meets Code Property Graphs The code property graph (CPG) is a data structure designed to mine large codebases for instances of programming patterns via a domain-specific query language. It was first introduced in the proceedings of the IEEE Security and Privacy conference in 2014 ( publication , PDF ) in the context of vulnerability discovery…

Exploring LLVM Bitcode interactively

While working on a tool for software analysis , I find myself looking into the bitcode quiet often. It works OK when there is one small file, but it’s incredibly annoying when it comes to real-world projects which have tens and hundreds of files. To simplify my life, I built a tool that converts LLVM Bitcode into the GraphML format: llvm2graphml . What is GraphML GraphML is an XML-based file…

Type Equality in LLVM

Some months ago, I joined ShiftLeft Security to work on the LLVM support for the custom code analysis platform Ocular . During these months, we have faced and overcome several challenges. Here I want to share one of them: Type Equality in LLVM. Intro LLVM’s type system is a complicated topic. It attempts to solve problems that are not so obvious when you look at them from a high-level.…

Building an LLVM-based tool. Lessons learned

This article is a text version of my recent EuroLLVM talk called Building an LLVM-based tool: lessons learned . Intro For the last three years, I work on a tool for mutation testing: Mull . It is based on LLVM and targets C and C++ primarily. What makes it interesting? it works on Linux, macOS, and FreeBSD it supports any version of LLVM starting from 3.9 it is fast because of JIT and…

Bottom-up CMake introduction

If you want to learn CMake, but do not have time to go through all the resources on the internet, then this article is for you. I will cover essentials you’ll need to start: targets commands variables functions macros In the next few minutes, we will reimplement some CMake’s builtin functionality using the CMake itself. Disclaimer: there are several very inaccurate statements about…