[llvm-dev] correct way to pass data structures between passes?
Buse Yilmaz via llvm-dev
llvm-dev at lists.llvm.org
Sat Aug 25 14:22:01 PDT 2018
Hi all,
I have a function pass which does some analysis and populates
A a;
where
typedef std::map< std::string, B* > A;
class B {
typedef std::vector< C* > D;
D d;
}
class C {
// some class packing information about basic blocks;
}
Hence I have a map of vectors traversed by string.
I wrote associated destructors for these classes. This pass works
successfully on its own.
I have another function pass needing this structure of type A to make some
transformations. I used
bool secondPass::doInitialization(Module &M) {
errs() << "now running secondPass\n";
a = getAnalysis<firstPass>().getA();
return false;
}
void secondPass::getAnalysisUsage(AnalysisUsage &AU) const {
AU.addRequired<firstPass>();
AU.setPreservesAll();
}
the whole code compiles fine. But I get seg. fault when printing this
structure at the end of my first pass *if I call my second pass since B* is
null.*
How should I wrap this data structure and pass it to the second pass
without issues?
Thanks in advance.
--
Buse
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180825/75d90b2b/attachment.html>
More information about the llvm-dev
mailing list