Skip to content

Instantly share code, notes, and snippets.

View tommymcm's full-sized avatar
💢

Tommy MᶜMichen tommymcm

💢
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.