Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dancing4am/llvm-assignment
A basic LLVM pass for learning
https://github.com/dancing4am/llvm-assignment
llvm llvm-ir llvm-pass llvm-plugins
Last synced: 2 months ago
JSON representation
A basic LLVM pass for learning
- Host: GitHub
- URL: https://github.com/dancing4am/llvm-assignment
- Owner: dancing4am
- Created: 2024-07-29T15:46:25.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-08-05T15:22:12.000Z (5 months ago)
- Last Synced: 2024-10-02T07:42:33.508Z (3 months ago)
- Topics: llvm, llvm-ir, llvm-pass, llvm-plugins
- Language: CMake
- Homepage:
- Size: 24.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# llvm-assignment
## Overview
This is an out-of-tree LLVM plugin example, that uses bogus conditional branch by command line argument `--bogus=`.## Development Environment
### Platform Support And RequirementsThis project has been tested on **Ubuntu 22.04.4 LTS**.
In order to build **llvm-assignment** you will need:- LLVM 18
- C++ compiler that supports C++17
- CMake 3.20 or higherIn order to run the passes, you will need:
- **clang-18** (to generate input LLVM files)
- [opt](https://llvm.org/docs/CommandGuide/opt.html) (to run the passes)There are additional requirements for tests (these will be satisfied by installing LLVM 18):
- [lit](https://llvm.org/docs/CommandGuide/lit.html) (aka **llvm-lit**, LLVM tool for executing the tests)
- [FileCheck](https://llvm.org/docs/CommandGuide/FileCheck.html) (LIT requirement, it's used to check whether tests generate the expected output)## Building & Testing
### Building
You can build **llvm-assignment** (and all the provided pass plugins) as follows:```
cd
cmake -DLT_LLVM_INSTALL_DIR=
make
```The `LT_LLVM_INSTALL_DIR` variable should be set to the root of either the installation or build directory of LLVM 18. It is used to locate the corresponding `LLVMConfig.cmake` script that is used to set the include and library paths.
### Testing
In order to run **llvm-assignment** tests, you need to install **llvm-lit** (aka **lit**). It's not bundled with LLVM 18 packages, but you can install it with **pip**:
```
# Install lit - note that this installs lit globally
pip install lit
```
Running the tests is as simple as:
```
$ lit /test
```## Running
### Generating Input
Before you can test it, you need to prepare an input file:
```
# Generate an LLVM test file
$LLVM_DIR/bin/clang -O1 -S -emit-llvm /inputs/input_for_obfuscator.cpp -o input_for_obfuscator.ll
```### Generating Output
```
# Watch out '>' between input and output
$LLVM_DIR/bin/opt -load-pass-plugin /lib/libObfuscator.{so|dylib} --bogus= -passes=obfuscator
-S >
```### Without Output
```
$LLVM_DIR/bin/opt -load-pass-plugin /lib/libObfuscator.{so|dylib} --bogus= -passes=obfuscator
-disable-output
```>Above description is mostly copied from [llvm-tutor README](https://github.com/banach-space/llvm-tutor?tab=readme-ov-file) for convenience.