https://github.com/ethanuppal/llvm-pass-skeleton-rs
example LLVM pass but in Rust 🦀
https://github.com/ethanuppal/llvm-pass-skeleton-rs
llvm tutorial
Last synced: about 1 year ago
JSON representation
example LLVM pass but in Rust 🦀
- Host: GitHub
- URL: https://github.com/ethanuppal/llvm-pass-skeleton-rs
- Owner: ethanuppal
- License: mit
- Created: 2025-03-10T19:59:00.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-12T10:08:01.000Z (over 1 year ago)
- Last Synced: 2025-03-31T07:41:34.007Z (over 1 year ago)
- Topics: llvm, tutorial
- Language: Rust
- Homepage: https://www.ethanuppal.com/blog/3-12-35-llvm-pass-in-rust.html
- Size: 6.84 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
A completely useless LLVM pass. It's for LLVM 18. This is the Rust version of
[sampsyo/llvm-pass-skeleton](https://github.com/sampsyo/llvm-pass-skeleton).
See the `mutate` branch for a slightly less skeletal example.
1. Build:
```shell
export LLVM_SYS_180_PREFIX=$(/bin/sh prefix.sh)
cargo build || (cargo clean && cargo build)
```
2. Generate IR (replace `test.c` with any other C/C++ file you want to test):
```
$LLVM_SYS_180_PREFIX/bin/clang -S -emit-llvm -o out.ll test.c
```
3. Run:
- **macOS**:
```shell
$LLVM_SYS_180_PREFIX/bin/opt --load-pass-plugin="target/debug/libskeleton_pass.dylib" --passes=skeleton-pass -disable-output out.ll
```
- **Linux**:
```shell
$LLVM_SYS_180_PREFIX/bin/opt --load-pass-plugin="target/debug/libskeleton_pass.so" --passes=skeleton-pass -disable-output out.ll
```
It can be useful to put these commands in a `Makefile`, `Justfile`, or shell
script.
This pass is verified under continuous integration to work on macOS and Linux.