Hi Devang,
You recently mentioned that the pass manager now allows a ModulePass
to require a FunctionPass. I just tried it but ran into errors. Could
you please take a look to see if I did anything wrong? Thanks!
Basically I changed the HelloWorld sample pass to be a ModulePass and
tried to use the LoopInfo pass inside the runOnModule routine.
See below for the source code and error messages.
BTW, I am playing with the LLVM TOT.
//=========Modified HelloWorld Pass===============//
struct Hello3 : public ModulePass {
virtual bool runOnModule(Module &M) {
HelloCounter++;
for (Module::iterator i = M.begin(), e = M.end(); i != e; ++i) {
LoopInfo &LI = getAnalysis<LoopInfo>(*i);
std::string fname = i->getName();
EscapeString(fname);
cerr << "Hello: " << fname <<
"\n";
}
return false;
}
// We don't modify the program, so we preserve all analyses
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.setPreservesAll();
AU.addRequired<LoopInfo>();
};
};
RegisterPass<Hello3> Z("hello3",
"Hello World Pass (ModulePass requires
FunctionPass)");
//=========== Error message ================//
opt -load Hello.so old.bc -hello3 -o new.bc
opt((anonymous namespace)::PrintStackTrace()+0x1a)[0x86423ca]
opt((anonymous namespace)::SignalHandler(int)+0x110)[0x86426f2]
/lib/tls/libc.so.6[0x683898]
opt(std::vector<llvm::Pass*,
std::allocator<llvm::Pass*>>::begin()+0x19)[0x84e3bb7]
opt(llvm::PMTopLevelManager::findAnalysisPass(llvm::PassInfo
const*)+0x26)[0x85cc88a]
opt(llvm::PMDataManager::findAnalysisPass(llvm::PassInfo const*,
bool)+0xb7)[0x85cc827]
opt(llvm::PMDataManager::initializeAnalysisImpl(llvm::Pass*)+0x96)[0x85cd39e]
opt(llvm::FPPassManager::runOnFunction(llvm::Function&)+0xff)[0x85ce667]
opt(llvm::MPPassManager::getOnTheFlyPass(llvm::Pass*, llvm::PassInfo
const*, llvm::Function&)+0x62)[0x85ce85e]
opt(llvm::AnalysisResolver::findImplPass(llvm::Pass*, llvm::PassInfo
const*, llvm::Function&)+0x33)[0x85cbc39]
/home/zhiruz/AutoESL/AutoPilot/trunk/build/obj-Linux-x86-g++/Debug/lib/libLLVMHello.so(llvm::LoopInfo&
llvm::Pass::getAnalysisID<llvm::LoopInfo>(llvm::PassInfo const*,
llvm::Function&)+0x99)[0x12efc7]
/home/zhiruz/AutoESL/AutoPilot/trunk/build/obj-Linux-x86-g++/Debug/lib/libLLVMHello.so(llvm::LoopInfo&
llvm::Pass::getAnalysis<llvm::LoopInfo>(llvm::Function&)+0x63)[0x12f0dd]
/home/zhiruz/AutoESL/AutoPilot/trunk/build/obj-Linux-x86-g++/Debug/lib/libLLVMHello.so((anonymous
namespace)::Hello3::runOnModule(llvm::Module&)+0x7e)[0x12f162]
opt(llvm::MPPassManager::runOnModule(llvm::Module&)+0x11d)[0x85ce341]
opt(llvm::PassManagerImpl::run(llvm::Module&)+0x6e)[0x85ce50e]
opt(llvm::PassManager::run(llvm::Module&)+0x1a)[0x85ce562]
opt(main+0x975)[0x8371791]
/lib/tls/libc.so.6(__libc_start_main+0xd3)[0x670de3]
opt(__gxx_personality_v0+0x14d)[0x8364041]
Segmentation fault