Loading include/core/functionBundle.hpp +22 −1 Original line number Diff line number Diff line Loading @@ -5,11 +5,31 @@ #include "blockReachabilityInfo.hpp" #include "llvm/IR/Function.h" #include "llvm/IR/IRBuilder.h" #include "llvm/IR/Dominators.h" #include <unordered_map> #include <vector> #include <optional> namespace llvm { struct DomTreeWrapper { std::optional<DominatorTree> DT; DomTreeWrapper(Function& F) : DT() { if (!F.isDeclaration()) { DT = DominatorTree(F); } } bool dominates(BasicBlock* BB1, BasicBlock* BB2) { if (DT.has_value()) { return DT.value().dominates(BB1, BB2); } return false; } }; struct FunctionBundle { Function* origFunction; Function* revFunction; Loading @@ -21,7 +41,8 @@ struct FunctionBundle { DenseMap<Instruction*, Instruction*> directAsserts; // calls to assert in the original function DenseMap<Instruction*, Instruction*> calledAsserts; // calls to functions with assert inside DenseMap<BasicBlock*, bool> BBscontainAssert; // BBs from orig program BlockReachabilityInfo reachableBlocks; // BlockReachabilityInfo reachableBlocks; DomTreeWrapper origDT; FunctionBundle(Function* origFunction, Function* reversedFunction, Module& origModule, HelperFunctionsBuilder& functionsBuilder); Loading src/core/functionBundle.cpp +2 −4 Original line number Diff line number Diff line Loading @@ -12,7 +12,7 @@ FunctionBundle::FunctionBundle(Function* origFunction, Function* reversedFunctio : origFunction(origFunction), revFunction(reversedFunction), instBuilder(functionsBuilder, *this, origFunction->size() + 2), reachableBlocks(origFunction) origDT(*origFunction) { for (auto& BB : *origFunction) { BBscontainAssert[&BB] = false; Loading @@ -30,7 +30,7 @@ FunctionBundle::FunctionBundle(FunctionBundle&& other) noexcept directAsserts(std::move(other.directAsserts)), calledAsserts(std::move(other.calledAsserts)), BBscontainAssert(std::move(other.BBscontainAssert)), reachableBlocks(other.origFunction) origDT(std::move(other.origDT)) { other.origFunction = nullptr; other.revFunction = nullptr; Loading Loading @@ -101,7 +101,5 @@ FunctionBundle FunctionBundle::duplicate() copyFBundle.BBscontainAssert = BBscontainAssert; copyFBundle.reachableBlocks = reachableBlocks; return copyFBundle; } No newline at end of file src/core/instructionBuilder.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -633,7 +633,7 @@ bool ValueBuilder::isValueNeededInRevBlock(Value* origVal, BasicBlock* origBB, B } if (auto* I = dyn_cast<Instruction>(origVal)) { return _fBundle.reachableBlocks.isReachable(I->getParent(), origBB); return I->getParent() == origBB || _fBundle.origDT.dominates(I->getParent(), origBB); } return false; Loading Loading
include/core/functionBundle.hpp +22 −1 Original line number Diff line number Diff line Loading @@ -5,11 +5,31 @@ #include "blockReachabilityInfo.hpp" #include "llvm/IR/Function.h" #include "llvm/IR/IRBuilder.h" #include "llvm/IR/Dominators.h" #include <unordered_map> #include <vector> #include <optional> namespace llvm { struct DomTreeWrapper { std::optional<DominatorTree> DT; DomTreeWrapper(Function& F) : DT() { if (!F.isDeclaration()) { DT = DominatorTree(F); } } bool dominates(BasicBlock* BB1, BasicBlock* BB2) { if (DT.has_value()) { return DT.value().dominates(BB1, BB2); } return false; } }; struct FunctionBundle { Function* origFunction; Function* revFunction; Loading @@ -21,7 +41,8 @@ struct FunctionBundle { DenseMap<Instruction*, Instruction*> directAsserts; // calls to assert in the original function DenseMap<Instruction*, Instruction*> calledAsserts; // calls to functions with assert inside DenseMap<BasicBlock*, bool> BBscontainAssert; // BBs from orig program BlockReachabilityInfo reachableBlocks; // BlockReachabilityInfo reachableBlocks; DomTreeWrapper origDT; FunctionBundle(Function* origFunction, Function* reversedFunction, Module& origModule, HelperFunctionsBuilder& functionsBuilder); Loading
src/core/functionBundle.cpp +2 −4 Original line number Diff line number Diff line Loading @@ -12,7 +12,7 @@ FunctionBundle::FunctionBundle(Function* origFunction, Function* reversedFunctio : origFunction(origFunction), revFunction(reversedFunction), instBuilder(functionsBuilder, *this, origFunction->size() + 2), reachableBlocks(origFunction) origDT(*origFunction) { for (auto& BB : *origFunction) { BBscontainAssert[&BB] = false; Loading @@ -30,7 +30,7 @@ FunctionBundle::FunctionBundle(FunctionBundle&& other) noexcept directAsserts(std::move(other.directAsserts)), calledAsserts(std::move(other.calledAsserts)), BBscontainAssert(std::move(other.BBscontainAssert)), reachableBlocks(other.origFunction) origDT(std::move(other.origDT)) { other.origFunction = nullptr; other.revFunction = nullptr; Loading Loading @@ -101,7 +101,5 @@ FunctionBundle FunctionBundle::duplicate() copyFBundle.BBscontainAssert = BBscontainAssert; copyFBundle.reachableBlocks = reachableBlocks; return copyFBundle; } No newline at end of file
src/core/instructionBuilder.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -633,7 +633,7 @@ bool ValueBuilder::isValueNeededInRevBlock(Value* origVal, BasicBlock* origBB, B } if (auto* I = dyn_cast<Instruction>(origVal)) { return _fBundle.reachableBlocks.isReachable(I->getParent(), origBB); return I->getParent() == origBB || _fBundle.origDT.dominates(I->getParent(), origBB); } return false; Loading