Before writing any code, read:
- CODING_GUIDELINES.md — C++ and Python style rules
- CLAUDE.md — project architecture, build setup, constraints
- caveats.txt — known limitations and gotchas
# Run from the repo root. The setup script runs cmake and make internally.
./setup -LLFI_BUILD_ROOT /path/to/LLTFI-build \
-LLVM_SRC_ROOT /path/to/llvm-project \
-LLVM_DST_ROOT /usr/lib/llvm-20 \
-LLVM_GXX_BIN_DIR /usr/lib/llvm-20/binAfter code changes, rebuild without re-running setup:
cd /path/to/LLTFI-build && make- Target C++17; compile against LLVM 20 APIs
- Use
nullptr,#ifndefinclude guards, RAII memory management - LLVM 20 API:
arg_size()(notgetNumArgOperands()),#include "llvm/IR/CFG.h"(notllvm/Support/CFG.h),InsertPositionvia.getIterator()for instruction insertion points,--passes=name(not-name) for opt invocation runOnModulemust returnbool
- Python 3 only; follow PEP 8
- Always use
with open(...)for file I/O - Never use
shell=Truein subprocess calls - Use
sys.exit(), notexit() - Use
yaml.safe_load(), notyaml.load() - Minimum
except Exception:— never bareexcept:
See docs/adding_a_test.md for a step-by-step guide to creating a new
regression test, including how to register a program, structure the test case
directory, and use the SKIP convention for optional dependencies.
From the build directory:
# All core tests (must pass before any PR)
./test_suite/SCRIPTS/llfi_test --all_cpp
# Specific subsets
./test_suite/SCRIPTS/llfi_test --all_hardware_faults
./test_suite/SCRIPTS/llfi_test --all_trace_tools_tests
# Single test case
./test_suite/SCRIPTS/llfi_test --test_cases <TestName>./test_suite/SCRIPTS/llfi_test --all_mlThese are not part of --all because they require optional dependencies.
Tests with missing deps report SKIP, not FAIL, and don't affect the pass/fail count.
| Group | Requirements |
|---|---|
| ML tool unit tests | pip install onnx pygraphviz pydot |
| TensorFlow → ONNX | pip install tensorflow tf2onnx onnx |
| PyTorch → ONNX | pip install torch onnx |
| ONNX → LLVM IR | onnx-mlir binary (ONNX_MLIR_BUILD env var) |
| Fault injection (ML) | LLTFI build + model.ll from sample_programs/.../mnist/compile.sh |
All core tests (--all_cpp) must pass before submitting a pull request. ML tests (--all_ml) should pass for any change that touches ML-related code.
- All tests pass (
llfi_test --all_cpp) - Code follows CODING_GUIDELINES.md
- If changing a public API or behavior: README.md is updated
- New functionality has a corresponding test case