Skip to content

Commit

Permalink
opt checkpoint. changed transitiveReads from recursive to iterative
Browse files Browse the repository at this point in the history
  • Loading branch information
nishant-sachdeva committed Aug 13, 2024
1 parent 0737211 commit 5865c34
Showing 1 changed file with 15 additions and 29 deletions.
44 changes: 15 additions & 29 deletions src/FlowAware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,17 +298,22 @@ void IR2Vec_FA::topoOrder(std::vector<int> &visitStack, int size) {
void IR2Vec_FA::TransitiveReads(SmallVector<Instruction *, 16> &Killlist,
Instruction *Inst, BasicBlock *ParentBB) {
assert(Inst != nullptr);
unsigned operandNum;
bool isMemAccess = isMemOp(Inst->getOpcodeName(), operandNum, memAccessOp);
Instruction *parentI;
while (true) {
unsigned operandNum;
bool isMemAccess = isMemOp(Inst->getOpcodeName(), operandNum, memAccessOp);
if (!isMemAccess)
break;

if (!isMemAccess)
return;
auto parentI = dyn_cast<Instruction>(Inst->getOperand(operandNum));
if (parentI == nullptr)
return;
if (ParentBB == parentI->getParent())
Killlist.push_back(parentI);
TransitiveReads(Killlist, parentI, ParentBB);
parentI = dyn_cast<Instruction>(Inst->getOperand(operandNum));
if (parentI == nullptr)
break;

if (ParentBB == parentI->getParent())
Killlist.push_back(parentI);

Inst = parentI; // Move to the next instruction (parent)
}
}

void IR2Vec_FA::createKilllist(SmallVector<Instruction *, 16> &KillList,
Expand Down Expand Up @@ -1363,13 +1368,10 @@ void IR2Vec_FA::traverseRD(
llvm::SmallVector<const llvm::Instruction *, 10> &timeStack) {

auto RDit = instReachingDefsMap.find(inst);

Visited[inst] = true;

if (RDit != instReachingDefsMap.end()) {

auto RD = RDit->second;

for (auto defs : RD) {
if (Visited.find(defs) == Visited.end())
traverseRD(defs, Visited, timeStack);
Expand All @@ -1379,22 +1381,6 @@ void IR2Vec_FA::traverseRD(
timeStack.push_back(inst);
}

// void IR2Vec_FA::DFSUtil(
// const llvm::Instruction *inst,
// std::unordered_map<const llvm::Instruction *, bool> &Visited,
// llvm::SmallVector<const llvm::Instruction *, 10> &nodeList) {

// nodeList.push_back(inst);
// Visited[inst] = true;
// auto RD = reverseReachingDefsMap[inst];

// for (auto defs : RD) {
// if (Visited.find(defs) == Visited.end()) {
// DFSUtil(defs, Visited, nodeList);
// }
// }
// }

void IR2Vec_FA::DFSUtil(
const llvm::Instruction *inst,
std::unordered_map<const llvm::Instruction *, bool> &Visited,
Expand Down

0 comments on commit 5865c34

Please sign in to comment.