Commit 6f61b616 authored by guruhegde's avatar guruhegde

[LoopSplitter] step 2: Find Var use locations

parent 41b3e747
......@@ -18,9 +18,15 @@ namespace tas {
bool LoopSplitter::run() {
SmallVector<Value *, 4> AnnotatedVars;
detectExpPtrVars(F, AnnotatedVars);
errs() << "No of annotated variables = " << AnnotatedVars.size() << "\n";
auto FU = findFirstUseOfValueInInstType<LoadInst>(AnnotatedVars.front());
SmallVector<const LoadInst *, 4> VarUsePoints;
for_each(AnnotatedVars, [&]
(const auto & Var) {
auto FU = findFirstUseOfValueInInstType<LoadInst>(Var);
if (FU) VarUsePoints.push_back(FU);
});
stat = Stats(AnnotatedVars.size(), VarUsePoints.size());
return true;
}
......
......@@ -19,15 +19,29 @@ namespace tas {
class TASForLoop;
llvm::AllocaInst * getLoopIndexVar(llvm::Loop * L);
struct Stats {
unsigned AnnotatedVarsSize;
unsigned VarUsePointsSize;
Stats() = default;
Stats(unsigned A, unsigned V) :
AnnotatedVarsSize(A), VarUsePointsSize(V) {}
Stats(const Stats & o) = default;
};
class LoopSplitter {
llvm::Function * F;
llvm::LoopInfo * LI;
Stats stat;
// Statistics
public:
LoopSplitter(llvm::Function * F_, llvm::LoopInfo * LI_)
: F(F_), LI(LI_) {}
bool run();
Stats & getStats() { return stat; }
};
} // tas namespace
......
......@@ -63,4 +63,8 @@ TEST_CASE("fn with single loop") {
LoopSplitter LS(F, &LI);
LS.run();
auto Stats = LS.getStats();
REQUIRE(Stats.AnnotatedVarsSize == 1);
REQUIRE(Stats.VarUsePointsSize == 1);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment