Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sloorush/llvm-pass-learn
Small dummy llvm pass created while learning how to write a llvm pass.
https://github.com/sloorush/llvm-pass-learn
Last synced: about 1 month ago
JSON representation
Small dummy llvm pass created while learning how to write a llvm pass.
- Host: GitHub
- URL: https://github.com/sloorush/llvm-pass-learn
- Owner: sloorush
- Created: 2022-10-19T06:04:24.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-10-19T14:37:13.000Z (over 2 years ago)
- Last Synced: 2024-05-02T03:43:44.855Z (9 months ago)
- Language: C++
- Homepage:
- Size: 21.5 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# llvm-pass-learn
A dummy LLVM pass collection made to learn.
It's for LLVM 14.Build:
$ cd llvm-pass-skeleton
$ mkdir build
$ cd build
$ cmake ..
$ make
$ cd ..## Logger Pass
A dummy LLVM pass to log the LLVM IR and get the functions, basic blocks, and instructions.
Run:
$ clang -flegacy-pass-manager -Xclang -load -Xclang build/logger/libLoggerPass.* a.cpp
## BadCalculator Pass
A bad calculator that changes you first addition to multiplication
Run:
$ clang -flegacy-pass-manager -Xclang -load -Xclang build/badCalculator/libBadCalculatorPass.* a.cpp
Example
```
❯ clang a.cpp
❯ ./a.out
❯ echo $?
6
❯ ./a.out a b c
❯ echo $?
9
❯ clang -flegacy-pass-manager -Xclang -load -Xclang build/badCalculator/libBadCalculatorPass.* a.cpp
HOHOHO Bad calculator
❯ ./a.out
❯ echo $?
5
❯ ./a.out a b c
❯ echo $?
20
```## First operator
Logs the result of the first binary operation
Example
```
❯ cc -c rtlib.c
❯ clang -flegacy-pass-manager -Xclang -load -Xclang build/firstOperator/libFirstOperatorPass.so -c a.cpp
❯ cc rtlib.o a.o -o exe
❯ ./exe
computed: 6
```---
Skeleton to write the LLVM pass was picked up from -> https://github.com/sampsyo/llvm-pass-skeleton