@@ -298,17 +298,22 @@ void IR2Vec_FA::topoOrder(std::vector<int> &visitStack, int size) {
298298void IR2Vec_FA::TransitiveReads (SmallVector<Instruction *, 16 > &Killlist,
299299 Instruction *Inst, BasicBlock *ParentBB) {
300300 assert (Inst != nullptr );
301- unsigned operandNum;
302- bool isMemAccess = isMemOp (Inst->getOpcodeName (), operandNum, memAccessOp);
301+ Instruction *parentI;
302+ while (true ) {
303+ unsigned operandNum;
304+ bool isMemAccess = isMemOp (Inst->getOpcodeName (), operandNum, memAccessOp);
305+ if (!isMemAccess)
306+ break ;
303307
304- if (!isMemAccess)
305- return ;
306- auto parentI = dyn_cast<Instruction>(Inst->getOperand (operandNum));
307- if (parentI == nullptr )
308- return ;
309- if (ParentBB == parentI->getParent ())
310- Killlist.push_back (parentI);
311- TransitiveReads (Killlist, parentI, ParentBB);
308+ parentI = dyn_cast<Instruction>(Inst->getOperand (operandNum));
309+ if (parentI == nullptr )
310+ break ;
311+
312+ if (ParentBB == parentI->getParent ())
313+ Killlist.push_back (parentI);
314+
315+ Inst = parentI; // Move to the next instruction (parent)
316+ }
312317}
313318
314319void IR2Vec_FA::createKilllist (SmallVector<Instruction *, 16 > &KillList,
@@ -1363,13 +1368,10 @@ void IR2Vec_FA::traverseRD(
13631368 llvm::SmallVector<const llvm::Instruction *, 10 > &timeStack) {
13641369
13651370 auto RDit = instReachingDefsMap.find (inst);
1366-
13671371 Visited[inst] = true ;
13681372
13691373 if (RDit != instReachingDefsMap.end ()) {
1370-
13711374 auto RD = RDit->second ;
1372-
13731375 for (auto defs : RD ) {
13741376 if (Visited.find (defs) == Visited.end ())
13751377 traverseRD (defs, Visited, timeStack);
@@ -1379,22 +1381,6 @@ void IR2Vec_FA::traverseRD(
13791381 timeStack.push_back (inst);
13801382}
13811383
1382- // void IR2Vec_FA::DFSUtil(
1383- // const llvm::Instruction *inst,
1384- // std::unordered_map<const llvm::Instruction *, bool> &Visited,
1385- // llvm::SmallVector<const llvm::Instruction *, 10> &nodeList) {
1386-
1387- // nodeList.push_back(inst);
1388- // Visited[inst] = true;
1389- // auto RD = reverseReachingDefsMap[inst];
1390-
1391- // for (auto defs : RD) {
1392- // if (Visited.find(defs) == Visited.end()) {
1393- // DFSUtil(defs, Visited, nodeList);
1394- // }
1395- // }
1396- // }
1397-
13981384void IR2Vec_FA::DFSUtil (
13991385 const llvm::Instruction *inst,
14001386 std::unordered_map<const llvm::Instruction *, bool > &Visited,
0 commit comments