Showing posts with label llvm. Show all posts
Showing posts with label llvm. Show all posts

Monday, 9 February 2026

Rust uses C++

Tales of the end of C++ are greatly exaggerated. 

Rust uses C++ in the form of LLVM which is built in C++. Sure, the Rust compiler (rustc - which was initially OCaml'd and rewritten in Rust) is mostly Rust with some legacy bits in C++, but the backend (LLVM) used for code generation is C++ code. 

The standard library has some C bindings too, but that's by the by.

Friday, 12 December 2025

LLVM Concepts - Optimizable IL from SSA Approach

What is LLVM?

LLVM ("Low Level Virtual Machine") is a collection of modular and reusable compiler and toolchain technologies (you could call it a "compiler infrastructure framework" or a "framework of reusable components to build compilers"). 

LLVM was born from research work at the University of Illinois.

How does LLVM tackle the compilation problem?

LLVM analyses a program and renders it into intermediate language.

The intermediate language (IL) is constrained by static single assignment (or SSA), where variables are assigned only once - enabling aggressive optimization. 

The IL is an abstract RISC-like instruction set with additional information - a major feature being type information.  A detailed guide can be found here.  It is designed to be human-readable. Note that LLVM documentation does not refer tot the language as an IL but rather an IR, or intermediate representation.

A Core Tenent of LLVM - "Lifelong" Program Analysis and Transformation

One of the stated goals of LLVM is to make "lifelong program analysis and transformation available for arbitrary software".

Get Python SHAP Explainer in Ubuntu

pip install shap

is what you need.

It has dependencies on:
  • numba
  • scikit-learn
Numba is a very interesting tool. It is an open source JIT compiler that translates a subset of Python and NumPy code into fast machine code. It uses the LLVM compiler library.

scikit-learn is the de facto Python machine learning kit. Everyone knows scikit-learn! But knowing it well - ah that's the rub!

You may see llvmlite downloaded too as part of shap, to support Numba.

Sunday, 9 August 2020

Static Single Assignment-Based Compilation Explained

 SSA refers to Static Single Assignment.

It is a naming convention for storage locations such that the value of a variable is independent of its location in the program. This is known as referential transparency.

An example of an SSA-based compilation toolchain is LLVM which has an associated Project Blog here.