Open
Conversation
Added a new method to repair basic blocks using cloned instructions and unordered_set.
Reworked the EDDI pass to move duplicated instructions toward a coarse-grain layout inspired by REPAIR, instead of keeping the original fine-grain interleaving. Added basic-block repair logic to collect duplicated instructions and place them near the end of the block before the terminator, while preserving the original duplication pipeline and operand remapping. This change aims to reduce origin/shadow adjacency and better expose the control-flow fault-detection behavior expected from REPAIR.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Title
Add REPAIR-style coarse-grain duplicate scheduling to EDDI
PR Description
Problem
The original
EDDIimplementation (EDDI_v1) duplicates eligible instructions by inserting each clone immediately after its original instruction. This produces a fine-grain layout such as:While this preserves the original EDDI duplication flow, it keeps each master instruction and its shadow counterpart very close in the basic block. In this configuration, a transient fault may affect both copies within the same short vulnerability window, reducing the effectiveness of mismatch-based detection. Moreover, the capacity of detecting an illegal branch in the middle of the code is not optimal. These are exactly the kind of limitations that motivated the project goal of integrating a REPAIR-style coarse-grain duplication strategy into ASPIS
Solution
This PR updates the pass by introducing REPAIR in
EDDI_v2.Instead of leaving duplicates interleaved with their originals, the pass now moves cloned instructions toward the end of each basic block, before the terminator, producing a coarse-grain layout of the form:
The goal is to increase the temporal/spatial separation between original and duplicate instructions, reducing the probability that a single transient fault corrupts both copies before consistency checks can expose the mismatch. This is consistent with the REPAIR idea described in the project material and with the broader EDDI discussion on how instruction ordering affects detection behavior
Main changes
1. Tracking duplicated instructions
EDDI_v2introduces a dedicated container to keep track of cloned instructions:static std::unordered_set<Instruction *> ClonedInstructions;This set is populated inside
cloneInstr()whenever a duplicated non-alloca instruction is emitted into a basic block. This provides an explicit way to distinguish duplicate instructions from original ones during the subsequent repair/reordering phaseIn
EDDI_v1, duplicated instructions are inserted but not explicitly tracked for later relocation2. New basic-block repair phase
EDDI_v2adds a new function:This function scans each basic block, collects duplicated instructions in their original relative order, and moves them before the block terminator.
The implementation explicitly avoids moving:
PHINodes, because LLVM requires them to stay at the top of the block,AllocaInsts,Keeping duplicates in their original relative order is important to avoid unnecessarily perturbing the shadow computation stream
This function is not present in
EDDI_v13. Reordering is applied after the standard duplication pipeline
After the pass finishes duplicating instructions in a function,
EDDI_v2runs the repair phase on every basic block:This means the new workflow is:
By contrast,
EDDI_v1ends after duplication and does not perform any post-processing reorder of the duplicated stream4. Clone-tracking state reset
Before transforming functions,
EDDI_v2clears the tracking set:This prevents stale clone metadata from previous transformations from affecting later blocks/functions within the same pass execution
What remains unchanged
This PR does not redesign the full EDDI pass. It intentionally keeps the existing infrastructure intact, including:
So the key behavioral difference between
EDDI_v1andEDDI_v2is not what gets duplicated, but how duplicated instructions are placed in the basic block once they have been generatedSummary
EDDI_v2extends the originalEDDI_v1by adding a REPAIR reordering phase that: