Polly Dependency Analysis in MyPass

Hello,

I need to analyze dependencies in my llvm ir by using polly. i created a new pass called mypass there i added polly dependency analysis pass but when i execute this pass in gdb i get no data.

Why is that so?

My code is follows;

namespace {
struct mypass : public FunctionPass {
static char ID;

mypass() : FunctionPass(ID) {
}
virtual bool runOnFunction(Function &F)
{

polly::DependenceInfoWrapperPass dp;

auto &SI = *getAnalysispolly::ScopInfoWrapperPass().getSI();

for (auto &It : SI) {
assert(It.second && “Invalid SCoP object!”);
dp.recomputeDependences(It.second.get(), polly::Dependences::AL_Access); }

virtual void getAnalysisUsage(AnalysisUsage &AU) const
{

AU.addRequiredTransitivepolly::ScopInfoWrapperPass();

AU.setPreservesAll();
}
};
}
char mypass::ID = 0;
static RegisterPass X(“mypass”, “mypass World Pass”, false, false);

please help. i have been trying a lot.

I have modified the code as follows; now i am using both scopdetection and scopinformation before dependency check but i think link is missing…

virtual bool runOnFunction(Function &F)
{

std::unique_ptr Result;
std::unique_ptr Result2;
//polly::ScopDetection pl;

auto &LI = getAnalysis().getLoopInfo();
auto &RI = getAnalysis().getRegionInfo();
auto &AA = getAnalysis().getAAResults();
auto &SE = getAnalysis().getSE();
auto &DT = getAnalysis().getDomTree();
Result2.reset(new ScopDetection(F, DT, SE, LI, RI, AA));

auto &SD2 = getAnalysispolly::ScopDetectionWrapperPass().getSD();

auto &SE2 = getAnalysis().getSE();
auto &LI2 = getAnalysis().getLoopInfo();
auto &AA2 = getAnalysis().getAAResults();
auto const &DL2 = F.getParent()->getDataLayout();
auto &DT2 = getAnalysis().getDomTree();
auto &AC2 = getAnalysis().getAssumptionCache(F);

Result.reset(new ScopInfo{DL2, SD2, SE2, LI2, AA2, DT2, AC2});

polly::DependenceInfoWrapperPass dp;

auto &SI = *getAnalysispolly::ScopInfoWrapperPass().getSI();

for (auto &It : SI) {
assert(It.second && “Invalid SCoP object!”);
dp.recomputeDependences(It.second.get(), polly::Dependences::AL_Access);

}

return false;
}

what to do? please help…

HI Hameeza,

what do mean by link is still missing?

Currently it is not possible to use polyhedral information from within in-tree LLVM passes. This is because Polly is not currently part of the LLVM tree, and is only linked into the tools as an external project. I.e., you can’t depend on Polly passes in an in-tree pass. What you can do, though, is use Polly from an out-of-tree context. If you build your pass as a loadable library, you’re free to link against Polly and include its headers.

Cheers,
Philip

i donot know how to do the method you said. can you please explain…

when i was running my written code in the debug mode i didnot get the input IR values in variables…

How do you compile the code? Within the Polly subdirectory using CMake?
How do you run your pass. Using "opt -mypass inputfile.ll"?

Michael

Hello,

I need to analyze dependencies in my llvm ir by using polly. i created a new
pass called mypass there i added polly dependency analysis pass but when i
execute this pass in gdb i get no data.

Why is that so?

Are you sure there is a SCoP detected in your input file? "opt mypass
-debug" may give you some information.

Thank You.

Actually i pass polly canonaclize IR to my new created polly pass called “mypass”. Mypass should first detect scops then find depedndencies as the mechanism conventional approach.

Now i know how to write llvm pass here i am writing pass as loadable module first afterwards i will integrate it with opt in the end.

I tried writing following code. Could you please help me on this? What to modify here?

namespace {
struct mypass : public FunctionPass {
static char ID;

mypass() : FunctionPass(ID) {
}

virtual bool runOnFunction(Function &F)
{

std::unique_ptr Result;
std::unique_ptr Result2;

auto &LI = getAnalysis().getLoopInfo();
auto &RI = getAnalysis().getRegionInfo();
auto &AA = getAnalysis().getAAResults();
auto &SE = getAnalysis().getSE();
auto &DT = getAnalysis().getDomTree();
Result2.reset(new ScopDetection(F, DT, SE, LI, RI, AA));

auto &SD2 = getAnalysispolly::ScopDetectionWrapperPass().getSD();
auto &SE2 = getAnalysis().getSE();
auto &LI2 = getAnalysis().getLoopInfo();
auto &AA2 = getAnalysis().getAAResults();
auto const &DL2 = F.getParent()->getDataLayout();
auto &DT2 = getAnalysis().getDomTree();
auto &AC2 = getAnalysis().getAssumptionCache(F);

Result.reset(new ScopInfo{DL2, SD2, SE2, LI2, AA2, DT2, AC2});

polly::DependenceInfoWrapperPass dp;

auto &SI = *getAnalysispolly::ScopInfoWrapperPass().getSI();

for (auto &It : SI) {
assert(It.second && “Invalid SCoP object!”);
dp.recomputeDependences(It.second.get(), polly::Dependences::AL_Access);
}
return false;
}

virtual void getAnalysisUsage(AnalysisUsage &AU) const
{
AU.addRequiredTransitivepolly::ScopInfoWrapperPass();

AU.addRequired();
AU.addRequired();
AU.addRequired();
AU.addRequiredTransitive();
AU.addRequiredTransitivepolly::ScopDetectionWrapperPass();
AU.addRequired();
AU.addRequired();
// We also need AA and RegionInfo when we are verifying analysis.
AU.setPreservesAll();
}
};
}
char mypass::ID = 0;
static RegisterPass X(“mypass”, “mypass World Pass”, false, false);

Please send a script executing the commands that you have been using,
including all required files (eg .cpp, CMakeLists.txt, .ll, patches,
...)

Michael