Skip to content

Instantly share code, notes, and snippets.

View lenary's full-sized avatar

Sam Elliott lenary

View GitHub Profile
@tommymcm
tommymcm / lto-custom-pass.md
Last active May 27, 2025 15:16
Custom LLVM passes at LTO

Running Custom LLVM Passes at LTO

I had a long time trying to find the proper way to run LLVM pass plugins at LTO. There were a lot of times where I found a solution and it turned out to be flimsy and break under some circumstances, or not fully support all the features I needed. This post gives your my solution and concludes with some thoughts about why this solution works. If anyone knows that I am correct/wrong please confirm/correct me. Otherwise, take the explanation with a grain of salt, I have not extensively tested it.

My Solution

In the examples, I will use a hypothetical LLVM pass plugin where:

  • MyPlugin.so is the shared object containing the LLVM pass plugin.
@pizlonator
pizlonator / pizlossafull.md
Last active November 26, 2025 17:53
How I implement SSA form

This document explains how I would implement an SSA-based compiler if I was writing one today.

This document is intentionally opinionated. It just tells you how I would do it. This document is intended for anyone who has read about SSA and understands the concept, but is confused about how exactly to put it into practice. If you're that person, then I'm here to show you a way to do it that works well for me. If you're looking for a review of other ways to do it, I recommend this post.

My approach works well when implementing the compiler in any language that easily permits cyclic mutable data structures. I know from experience that it'll work great in C++, C#, or Java. The memory management of this approach is simple (and I'll explain it), so you won't have to stress about use after frees.

I like my approach because it leads to an ergonomic API by minimizing the amount of special cases you have to worry about. Most of the compiler is analyses and transformations ov

@pizlonator
pizlonator / pizlossa.md
Last active November 18, 2025 18:33
Pizlo SSA Form (short version)

Here's a much more complete description of how I do SSA, beyond just how I do Phis.

This describes how I do SSA form, which avoids the need to have any coupling between CFG data structures and SSA data structures.

Let's first define a syntax for SSA and some terminology. Here's an example SSA node:

A = Add(B, C)

In reality, this will be a single object in your in-memory representation, and the names are really addresses of those objects. So, this node has an "implicit variable" called A; it's the variable that is implicitly assigned to when you execute the node. If you then do:

@timothyham
timothyham / ipv6guide.md
Last active December 4, 2025 16:38
A Short IPv6 Guide for Home IPv4 Admins

A Short IPv6 Guide for Home IPv4 Admins

This guide is for homelab admins who understand IPv4s well but find setting up IPv6 hard or annoying because things work differently. In some ways, managing an IPv6 network can be simpler than IPv4, one just needs to learn some new concepts and discard some old ones.

Let’s begin.

First of all, there are some concepts that one must unlearn from ipv4:

Concept 1

Introduction

This document provides a detailed exploration of how C++ standard library headers are used when building, testing, and using the LLVM libc++ library. It covers the different types of headers involved, the main header layouts used, and the importance of include paths and how they are constructed. It also dives into the specific include paths used in key scenarios on Linux and Apple platforms. The goal is to explain the key concepts and complexities around libc++ headers to support informed decision making about the library's header layout.

The Headers

There are several types of headers involved in the libc++ library:

@matteyeux
matteyeux / f.md
Last active July 21, 2025 05:13
macOS and iOS Security Internals Advent Calendar
@rrika
rrika / unscramble.py
Created September 5, 2023 20:54
ME: please show me the tweets in the order that they were liked COMPUTER: thats too hard. heres some tweets i think are good.
class Node:
capacity = 10
def __init__(self, index, count):
self.index = index
self.count = count
self.children = []
def __iter__(self):
return iter(self.children)
def __len__(self):
return len(self.children)
@Endilll
Endilll / clang+gcc+xcode.txt
Last active July 25, 2023 13:22
C++ compiler version history
Clang GCC Xcode
2023.03.17 16.0.0
2022.09.06 15.0.0
2022.03.25 14.0.0
2021.10.04 13.0.0
2021.06.01 9.4
2021.04.14 12.0.0
2020.10.12 11.0.0
2020.03.24 10.0.0
2020.03.04 8.4
@animetosho
animetosho / gf2p8affineqb-articles.md
Last active November 18, 2025 00:51
A list of articles documenting uses of the GF2P8AFFINE instruction

Unexpected Uses for the Galois Field Affine Transformation Instruction

Intel added the Galois Field instruction set (GFNI) extensions to their Sunny Cove and Tremont cores. What’s particularly interesting is that GFNI is the only new SIMD extension that came with SSE and VEX/AVX encodings (in addition to EVEX/AVX512), to allow it to be supported on all future Intel cores, including those which don’t support AVX512 (such as the Atom line, as well as Celeron/Pentium branded “big” cores).

I suspect GFNI was aimed at accelerating SM4 encryption, however, one of the instructions can be used for many other purposes. The extension includes three instructions, but of particular interest here is the Affine Transformation (GF2P8AFFINEQB), aka bit-matrix multiply, instruction.

There have been various articles which discuss out-of-band

@abey79
abey79 / dpx2x00.toml
Last active November 28, 2021 22:50
Roland DPX-2x00 config for vpype
# Notes from https://webmanual.rolanddg.com/contents/manuals/DPX-3700A+2700A_USE_E_R8.pdf
# * we use the default "DPX" origin system
# * paper_size: set to value from the X/Y columns (p.17)
# * for A3+ (where Xmm is paper long edge in mm and Ymm is paper short edge in mm):
# - x_range = (-Xmm * 20 - 480, Xmm * 20 - 480)
# - y_range = (-Ymm * 20, Ymm * 20
# * for A4:
# - x_range = (-Xmm * 20, Xmm * 20)
# - y_range = (-Ymm * 20 - 480, Ymm * 20 - 480)
# * origin_location: set to (-LLx, URy) from table on p. 17