Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
2453f60
Added tests and script sofr software fault injection
karthikp-ubc Apr 10, 2026
c5dc31d
Remove SoftwareFaults again from LLTFI
abrahamchan May 9, 2026
0b91d8c
Bug fixes
karthikp-ubc Apr 10, 2026
30c0aab
Refactored code for conformity with guidelines
karthikp-ubc Apr 10, 2026
3aed3cd
Refactored code for conformity with coding guidelines
karthikp-ubc Apr 10, 2026
ddd9f79
Refactored code for conformity with coding guidelines
karthikp-ubc Apr 10, 2026
c8a86cc
Added coding guidelines
karthikp-ubc Apr 10, 2026
0286857
Refactored code for conformity with coding guidelines
karthikp-ubc Apr 10, 2026
5ed853b
Refactored code for conformity with coding guidelines
karthikp-ubc Apr 10, 2026
034ec2e
Refactored code for conformity with coding guidelines
karthikp-ubc Apr 10, 2026
7d5767d
Refactored code for conformity with coding guidelines
karthikp-ubc Apr 10, 2026
4972fe0
Added tests for FIDL generation
karthikp-ubc Apr 10, 2026
c2c723a
Added tests for FIDL
karthikp-ubc Apr 10, 2026
9f2a58a
Minor
karthikp-ubc Apr 10, 2026
7b92e70
Make lists
karthikp-ubc Apr 10, 2026
4633763
Added claude agent file
karthikp-ubc Apr 10, 2026
89f0a30
Updated documentation to be consistent with code
karthikp-ubc Apr 10, 2026
70c737a
Removed outdated cluster file
karthikp-ubc Apr 10, 2026
bfaf43f
Removed PDF flyer
karthikp-ubc Apr 10, 2026
492d92a
Removed outdated README
karthikp-ubc Apr 10, 2026
99ffa04
Added code enforcement rules
karthikp-ubc Apr 10, 2026
e903a81
Added contribution guidelines
karthikp-ubc Apr 10, 2026
e20d77a
Removed web-app
karthikp-ubc Apr 10, 2026
76a5951
Removed web-app
karthikp-ubc Apr 10, 2026
9c11eea
Removed web-app directory
karthikp-ubc Apr 10, 2026
33effad
Removed auto installer
karthikp-ubc Apr 10, 2026
8a04f5d
Removed auto-installer completely
karthikp-ubc Apr 10, 2026
c9216ae
Removed auto-installer
karthikp-ubc Apr 10, 2026
9ca43a5
Updated to include docs
karthikp-ubc Apr 10, 2026
3699184
Removed protobufs
karthikp-ubc Apr 10, 2026
1d13052
Removed reference to web-app
karthikp-ubc Apr 10, 2026
5d9ea7f
Updated documentation for ML tests
karthikp-ubc Apr 11, 2026
6c93eac
Added ML tests
karthikp-ubc Apr 11, 2026
b62e01f
Added ML tests to doc and master script
karthikp-ubc Apr 11, 2026
f863e33
Cleaned up code to conform to style guidelines
karthikp-ubc Apr 11, 2026
741c444
Bring the code in line with coding guidelines
karthikp-ubc Apr 11, 2026
48e556f
Metadata conformity to guidelines
karthikp-ubc Apr 11, 2026
1979175
Run instruction duplication test
karthikp-ubc Apr 11, 2026
45f3e70
Added instruction duplication pass tests
karthikp-ubc Apr 11, 2026
b8207bf
Added migration plan to LLVM 17 or later with Claude code
karthikp-ubc Apr 11, 2026
5ff6c3c
Used Claue code to upgrade to LLVM20
karthikp-ubc Apr 11, 2026
92fe749
Updated the documentation for the migration; except insn duplication
karthikp-ubc Apr 11, 2026
cca621f
Migrated the instruction duplication pass
karthikp-ubc Apr 11, 2026
1a18be0
Removed deprecated features in code; update docs
karthikp-ubc Apr 12, 2026
aa0e076
Fixed linter issues and bugs found by code review
karthikp-ubc Apr 12, 2026
ecf32e3
Added lint rules
karthikp-ubc Apr 12, 2026
80e9b50
Updated docs and fixed install script bugs
karthikp-ubc Apr 12, 2026
8ffa528
Modified code to pass Linter checks
karthikp-ubc Apr 12, 2026
43a2eb7
Added Clang/LLVM code formatting rules
karthikp-ubc Apr 12, 2026
0264248
Updated coding guidelines to match lint rules
karthikp-ubc Apr 12, 2026
4fc31ed
Updated migration status report
karthikp-ubc Apr 12, 2026
c72a85e
Fixed code conformity issues in FIDL
karthikp-ubc Apr 12, 2026
ef63af9
Fixed issues in the profiling and insn duplication
karthikp-ubc Apr 12, 2026
9e2151b
Updated documentation to fix minore issues; old LLVM15 refs
karthikp-ubc Apr 12, 2026
f50ad34
Added tests for ONNX-MLIR
karthikp-ubc Apr 12, 2026
28ce0ab
Added tests for ONNX-MLIR
karthikp-ubc Apr 12, 2026
535bcf2
Added human readable architecture description
karthikp-ubc Apr 13, 2026
cdf40b5
Fix test instructions on README
abrahamchan May 9, 2026
0d5194d
Added guide to input YAML format
karthikp-ubc Apr 13, 2026
de7fd2c
Added input YAML guide
karthikp-ubc Apr 13, 2026
6ba808a
Minor
karthikp-ubc Apr 13, 2026
dc63fdc
Added new tutorial on running and writing tests
karthikp-ubc Apr 13, 2026
f7233fa
Added CHANGELOG from the LLVM 15 version
karthikp-ubc Apr 14, 2026
036edd7
Fixed up minor issues with old version; updated migration
karthikp-ubc Apr 15, 2026
9eccd18
Updated changelog
karthikp-ubc Apr 15, 2026
f384619
Updated to match code
karthikp-ubc Apr 24, 2026
fa076f0
Added new ML tutorial
karthikp-ubc Apr 24, 2026
43c3648
Modified README to reflect new tutorial
karthikp-ubc Apr 24, 2026
8b4d326
Modified to reflect new ML tutorial
karthikp-ubc Apr 24, 2026
21e6ddf
Modified to reflect new tutorial
karthikp-ubc Apr 24, 2026
d8d75bb
Updated with tutorial
karthikp-ubc Apr 25, 2026
7c36254
Updated cross-references
karthikp-ubc Apr 25, 2026
8bebfb2
Minor; bug fix
karthikp-ubc Apr 25, 2026
28f8d81
Update CMakeLists file for LLVM19 upgrade
abrahamchan May 7, 2026
aa05570
Remove FIDL from LLTFI
abrahamchan May 14, 2026
0458be8
Update factorial program source code
abrahamchan May 16, 2026
19b8851
Reformat indentation in Python files
abrahamchan May 16, 2026
ae56e2d
Remove Software Faults from LLTFI
abrahamchan May 21, 2026
3e3c918
Fix factorial and mnist tests
abrahamchan May 26, 2026
559eec4
Update compile.sh and image.c files in sample programs
abrahamchan May 26, 2026
0d3e894
Update Dockerfile to only rebuild needed LLTFI components
abrahamchan May 26, 2026
14e0ca5
Change all tests to all_cpp tests
abrahamchan May 26, 2026
7c6433b
Update input.c files for sample nlp models
abrahamchan May 31, 2026
a46baae
Change --all to --all_cpp in documentation
abrahamchan Jun 1, 2026
507d15c
Update PointerAlignment to right in clang format and reformat C++ files
abrahamchan Jun 2, 2026
bf8a012
Remove references to apt install for LLVM
abrahamchan Jun 2, 2026
0d09209
Update Dockerfile to checkout LLTFI branch of ONNX-MLIR
abrahamchan Jun 2, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
60 changes: 60 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# clang-format configuration for LLTFI
#
# Based on LLVM style (K&R braces, 2-space indent, 80-col limit).
# Run: clang-format-20 -i <file.cpp>
# Or: lint.sh --fix (reformats all C++ files in-place)

---
BasedOnStyle: LLVM
Language: Cpp
Standard: c++17

# Indentation
IndentWidth: 2
TabWidth: 2
UseTab: Never
ContinuationIndentWidth: 4
IndentCaseLabels: false
IndentPPDirectives: None

# Line length
ColumnLimit: 80

# Line break
LineEnding: LF

# Braces — attach (K&R / LLVM style)
BreakBeforeBraces: Attach

# Includes
SortIncludes: CaseSensitive
IncludeBlocks: Regroup
IncludeCategories:
# LLTFI local headers first
- Regex: '^"(FI|Utils|Controller|Profil|Inst|Reg|Gen|LLFIDot)'
Priority: 1
# LLVM headers
- Regex: '^"llvm/'
Priority: 2
# System headers
- Regex: '^<'
Priority: 3

# Pointer alignment: right (int *p, not int* p)
PointerAlignment: Right

# Function arguments
AllowAllArgumentsOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
BinPackArguments: true
BinPackParameters: true

# Short constructs — keep consistent with LLVM defaults
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false

# Misc
SpaceBeforeParens: ControlStatements
SpacesInAngles: Never
SpacesInParentheses: false
62 changes: 62 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# clang-tidy configuration for LLTFI
#
# Run from the repo root (requires compile_commands.json in the build dir):
# clang-tidy-20 -p /path/to/LLTFI-build <file.cpp>
# Or use lint.sh which handles discovery automatically.
#
# To generate compile_commands.json, add -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
# to the cmake invocation inside ./setup, or run:
# cd /path/to/LLTFI-build && cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON .

---
Checks: >
bugprone-*,
clang-analyzer-core.*,
clang-analyzer-cplusplus.*,
clang-analyzer-deadcode.*,
clang-analyzer-security.*,
cppcoreguidelines-init-variables,
cppcoreguidelines-narrowing-conversions,
cppcoreguidelines-slicing,
llvm-namespace-comment,
llvm-twine-local,
modernize-use-nullptr,
modernize-use-override,
modernize-redundant-void-arg,
performance-for-range-copy,
performance-implicit-conversion-in-loop,
performance-unnecessary-copy-initialization,
readability-const-return-type,
readability-container-size-empty,
readability-delete-null-pointer,
readability-misplaced-array-index,
readability-redundant-declaration,
-bugprone-easily-swappable-parameters,
-bugprone-macro-parentheses,
-bugprone-branch-clone,
-bugprone-assignment-in-if-condition,
-clang-analyzer-optin.*,
-clang-analyzer-cplusplus.NewDelete,
-clang-diagnostic-macro-redefined,

# Checks disabled because they fire heavily on legitimate LLVM-pass idioms:
# cppcoreguidelines-pro-bounds-* — pointer arithmetic is normal in LLVM IR
# cppcoreguidelines-pro-type-* — reinterpret_cast used in IR manipulation
# cppcoreguidelines-avoid-magic-numbers — opcode numbers are intentional
# cppcoreguidelines-pro-type-vararg — some C APIs use varargs
# modernize-use-trailing-return-type — not in our style guide

WarningsAsErrors: ''

HeaderFilterRegex: 'llvm_passes/.*\.h$'

CheckOptions:
# Enforce nullptr over NULL
- key: modernize-use-nullptr.NullMacros
value: 'NULL'

# Namespace comment style: closing brace should say "// namespace llfi"
- key: llvm-namespace-comment.ShortNamespaceLines
value: '10'
- key: llvm-namespace-comment.SpacesBeforeComments
value: '2'
26 changes: 26 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.{cpp,h,c}]
indent_style = space
indent_size = 2

[*.py]
indent_style = space
indent_size = 4

[*.{yaml,yml}]
indent_style = space
indent_size = 2

[CMakeLists.txt]
indent_style = space
indent_size = 2

[Makefile]
indent_style = tab
19 changes: 3 additions & 16 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,7 @@ config/java_paths.cmake
config/java_paths.py
tools/zgrviewer/llfi_run.sh

# Same holds for the installer directory
installer/downloads/*
installer/llfi/*
installer/llfisrc/*
installer/llvm/*
installer/llvmsrc/*
installer/pyyaml/*
installer/pyyamlsrc/*
installer/fontconfig/*
build/
sample_programs/

# All the .ll and .bc files
*.ll
Expand All @@ -28,8 +18,9 @@ sample_programs/
__pycache__/
*.pyc

# FIDL-generated software fault selector files (regenerated by setup via FIDL-Algorithm.py)
llvm_passes/software_failures/_*_*Selector.cpp
# protobuf build artifacts (downloaded during ML dependency setup)
protobuf-*/
protobuf-all-*.zip

# gedit backup files
*~
Expand All @@ -56,7 +47,3 @@ gui/sum/
gui/min/
gui/bfs/

# web app
web-app/node_modules/
web-app/views/bundle.min.js
web-app/server/uploads/*
160 changes: 160 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
# Changelog

All notable changes to LLTFI are recorded here.
Format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

---

## [Unreleased] — LLVM 20 branch (`LLVM20`)

This release upgrades LLTFI from LLVM 15 to LLVM 20. Every change is
backward-compatible with LLFI. The full migration narrative, task breakdown,
and effort accounting are in `migration.md`.

### Breaking changes

- **LLVM version requirement raised from 15 to 20.** LLVM 15 is no longer
supported. Install LLVM 20 via the LLVM apt repository or build from source
(see `README.md`).
- **Legacy pass manager (`opt -load`, `-enable-new-pm=0`) removed.** All
passes — including `InstructionDuplication` — now use the new pass manager
exclusively. Any external scripts calling `opt` directly must be updated to
use `-load-pass-plugin` and `--passes=<PassName>`.
- **`InstructionDuplication` pass renamed** to `InstructionDuplicationPass` in
the plugin registry to match the new PM convention.

---

### Added

#### New passes and tests
- `InstructionDuplication` migrated to the new pass manager (`PassInfoMixin`);
exposed as `"InstructionDuplicationPass"` in `SEDPasses.so`.
- Two new tests in `test_instruction_duplication.py`:
- `real_model_structural` — applies `InstructionDuplicationPass` to a real
onnx-mlir `model.ll` and verifies `compareFloatValues` calls are inserted.
- `real_model_end_to_end` — runs the baseline and duplicated models through
`lli` and asserts outputs are identical (SKIP when `model.ll` absent).

#### Tooling
- `lint.sh` — unified C++ and Python lint runner; `--fix` auto-formats in-place.
- `.clang-tidy` — project-level tidy config with intentionally disabled checks
documented.
- `.clang-format` — project-level format config (LLVM style, 2-space indent).
- `setup.cfg` — `flake8` and `flake8-bugbear` configuration for Python linting.

#### Documentation
- `architecture.md` — new developer reference covering pass pipeline, selector
class hierarchy, hardware/software/ML fault modes, the runtime library, and
the interface between compile-time and runtime layers.
- `docs/input_yaml_guide.md` — prose guide to writing `input.yaml` files,
covering all keys, `CustomTensorOperator` ML targeting, and complete examples.
- `docs/tutorial_first_experiment.md` — end-to-end walkthrough of the
`factorial` experiment including output file interpretation and outcome
classification (masked / SDC / crash / hang).
- `docs/adding_a_test.md` — step-by-step guide for adding a regression test,
covering program registration, test case structure, custom Python scripts,
and the SKIP convention.
- `CODING_GUIDELINES.md` — expanded with sections on `override`, variable
initialisation, container emptiness (`.empty()` over `.size() == 0`), and
`cast<>` vs. `dyn_cast<>`.
- `CONTRIBUTING.md` — added `Adding a Test Case` section pointing to
`docs/adding_a_test.md`.
- `docs/tutorial_ml_experiment.md` — new end-to-end walkthrough of an ML/ONNX
fault injection experiment covering the full ONNX → LLVM IR compilation
pipeline, `CustomTensorOperator` layer targeting, multi-fault injection
options, per-layer profiling output, and `CompareLayerOutputs.py`.

---

### Changed

#### LLVM 20 API compatibility

| File | Change |
|------|--------|
| `llvm_passes/core/FaultInjectionPass.cpp` | 3 sites: `new AllocaInst/StoreInst/LoadInst` constructors updated to LLVM 17+ API |
| `llvm_passes/core/InstTracePass.cpp` | 6 sites: same; `getFirstNonPHIOrDbgOrLifetime()` now returns `BasicBlock::iterator` |
| `llvm_passes/core/Utils.cpp` | `M.getGlobalList().push_back()` → `new GlobalVariable(M, ...)` (removed in LLVM 17) |
| All selector `.cpp` files | `getNumArgOperands()` → `arg_size()` (removed in LLVM 15); `#include "llvm/Support/CFG.h"` → `"llvm/IR/CFG.h"` |
| `llvm_passes/instruction_duplication/InstructionDuplication.cpp` | `getNextNonDebugInstruction()` return type updated to `BasicBlock::iterator` |

#### Code quality (C++ — found by clang-tidy and code review)

| Category | Details |
|----------|---------|
| Bug fixes | Double-free in `Controller.cpp` destructor; file stream leak in `LLFIDotGraphPass.cpp`; unchecked `fopen` null in `GenLLFIIndexPass.cpp`; uninitialized `isChainDuplication` field |
| Null safety | `getCalledFunction()` null checks in `ProfilingPass.cpp`, `InstructionDuplication.cpp`, `CustomTensorOperatorInstSelector.cpp` |
| LLVM idioms | `dyn_cast<>` after `isa<>` → `cast<>` (asserting) across `Utils.cpp`, `ProfilingPass.cpp`; `NULL` → `nullptr` throughout |
| Override safety | `virtual` on override methods → `override` keyword across all selector classes; `virtual ~Base() = default` added to abstract base classes |
| Style | `.empty()` over `.size() == 0`; `const auto&` in range-for; `strncpy`/`strncat` over unbounded `strcpy`/`strcat`; `cl::opt<T>::getValue()` to avoid slicing |
| Dead code | Removed unreachable `return false` after exhaustive if/else in `InstructionDuplication.cpp:runOnMainGraph()` |
| Copies | `for (auto insVector : arithInst)` → `for (const auto& insVector : ...)` to avoid copying inner vectors |

#### Code quality (Python — found by flake8/bugbear)

- `except:` → `except Exception:` throughout `bin/`, `tools/`, `test_suite/SCRIPTS/`
- Bare `open()` → `with open(...) as f:` in multiple scripts
- `subprocess(..., shell=True)` removed; replaced with list-form calls
- `yaml.load()` → `yaml.safe_load()` everywhere
- `exit()` → `sys.exit()` in scripts
- `%-format` strings → f-strings in new code

#### Docker

- `docker/Dockerfile` — LLVM source checkout updated from a pinned LLVM 15
commit hash (`9778ec057cf4`) to the `llvmorg-20.1.0` tag; `pyyaml===5.4.1`
corrected to `pyyaml==5.4.1` (non-standard triple-equals syntax).

#### Documentation updates

- `README.md` — restructured to eliminate overlap with `architecture.md`;
added `docs/` section listing all user guides; added pointer to
`architecture.md` for internal design.
- `caveats.txt` — LLVM version references updated 15 → 20; duplicate item
number fixed.
- `llvm_passes/instruction_duplication/README.md` — `opt -always-inline`
(legacy PM) → `opt --passes=always-inline` (new PM).
- `llvm_passes/instruction_duplication/shared_lib/build.sh` and
`compile_shrd_lib.sh` — hardcoded `clang`/`clang++` → `LLVM_GXX_BIN_DIR`
pattern, fixing builds on Ubuntu where apt installs `clang-20` only.
- `architecture.md` — corrected several inaccuracies found during code review:
`preFunc` return type (`bool` not `int`) and parameter types (`unsigned`
throughout); `injectFunc` register parameter types; `doProfiling` parameter
type (`int` not `unsigned`); `printInstTracer` signature (second param is
`char *opcode`, not `unsigned`; last param is `int`, not `long`);
`lltfiMLLayer` parameter types (`int64_t`); removed non-existent `random`
and `data_corruption` `fi_type` entries; corrected claim that

---

### Pending before merge (human tasks)

- **H-2** — Human review of IRBuilder insertion-point correctness in
`FaultInjectionPass.cpp` and `InstTracePass.cpp`. The `AllocaInst` calls
were migrated to `BasicBlock*` insertAtEnd form and `BasicBlock::iterator`
form respectively; both compile and all 21 tests pass, but a developer
familiar with the pass semantics should verify the insertion points are
logically correct before merging to main.
- **H-3** — onnx-mlir real-model validation. Requires installing onnx-mlir and
running `sample_programs/ml_sample_programs/vision_models/mnist/compile.sh`
to produce `model.ll`. The two new `test_instruction_duplication.py` tests
will then run instead of skipping. Not a blocker — all other tests pass.

---

## [Previous] — LLVM 15 baseline (`master`)

The `master` branch represents LLTFI as it existed targeting LLVM 15, with
the following improvements over the original LLFI fork:

- ML fault injection support (TensorFlow, PyTorch via ONNX-MLIR)
- `CustomTensorOperator` instruction selector for layer-level ML targeting
- `InstructionDuplication` pass (`SEDPasses.so`) for soft-error detection
- Batch fault injection scripts (`batchInstrument.py`, `batchProfile.py`,
`batchInjectfault.py`)
- Trace analysis tools (`tracediff.py`, `traceontograph.py`, `traceunion.py`,
`tracetodot.py`)
- Makefile generation tool (`GenerateMakefile`)
- Initial `CODING_GUIDELINES.md` and `CONTRIBUTING.md`
- Migration plan document (`migration.md`) for the LLVM 15 → 20 upgrade
Loading
Loading