[LLVMdev] A few beginner level questions..
Abhijit Ray
abhijit.ray at gmail.com
Wed Nov 17 23:19:35 PST 2004
1. If we run a few passes in a sequence ..is the bytecode file
transformed after each pass in sequence i.e
if we have
a) opt -pass1 -pass2 -pass3 < in.bc > out.bc
b)opt -pass1 -pass2 < in.bc > tmp.bc
opt -pass3 < tmp.bc > out.bc
are the above two equivalent ?
what I basically want is to run my pass on an optimised bytecode , so
should i optimize it and get a new bytecode file first or I can just
put my pass at the end of all the other optimization passes ?
2. For an application , for every instruction if its a call
instruction I try to print out the called function as below ..
void pass01a::instruct_show(Instruction* I){
if ( isa<CallInst>(*I) ){
const CallInst *CI = cast<CallInst>(I);
const Function *Func = CI->getCalledFunction() ;
std::cerr<<":calledFunction:"<<Func->getName();
}
}
Now it works fine for some application but for one of the benchmark in
MIBENCH , i am getting the following error ..
++++++++++++++++++++++++
:calledFunction:opt((anonymous namespace)::PrintStackTrace()+0x1a)[0x86b74e6]
opt((anonymous namespace)::SignalHandler(int)+0xcb)[0x86b7759]
/lib/libc.so.6[0x401532b8]
/home/ary/work/llvm/lib/Debug/libpass01.so((anonymous
namespace)::pass01a::instruct_show(llvm::Instruction*)+0x281)[0x4001a425]
/home/ary/work/llvm/lib/Debug/libpass01.so((anonymous
namespace)::pass01a::runOnFunction(llvm::Function&)+0x18c)[0x4001b57c]
opt(llvm::PassManagerTraits<llvm::Function>::runPass(llvm::FunctionPass*,
llvm::Function*)+0x1f)[0x8679cbf]
opt(llvm::PassManagerT<llvm::Function>::runOnUnit(llvm::Function*)+0x5d3)[0x8675117]
opt(llvm::PassManagerTraits<llvm::Function>::runOnFunction(llvm::Function&)+0x1f)[0x8672f1d]
opt(llvm::FunctionPass::runOnModule(llvm::Module&)+0xa7)[0x862234b]
opt(llvm::PassManagerTraits<llvm::Module>::runPass(llvm::ModulePass*,
llvm::Module*)+0x1f)[0x8679d55]
opt(llvm::PassManagerT<llvm::Module>::runOnUnit(llvm::Module*)+0x5d3)[0x8673653]
opt(llvm::PassManagerTraits<llvm::Module>::runOnModule(llvm::Module&)+0x1f)[0x8672ce1]
opt(llvm::PassManager::run(llvm::Module&)+0x23)[0x862174d]
opt(main+0x913)[0x83c0bab]
/lib/libc.so.6(__libc_start_main+0xcb)[0x4013f90b]
opt(dlopen+0x41)[0x83c0201]
Segmentation fault
+++++++++++++++++++++++++++
Is there something wrong with my coding or llvm itself .? Is there any
simpler way to extract the function names?
Thanks,
Abhijit
More information about the llvm-dev
mailing list