LLVM pass error

Hi,

I wrote a sample program to iterate through each function and just print a ‘hello’ for every basic blocks. There were no errors while running a ‘make’ command. But the program returns some errors in my system. When I check the same program in my friend’s system it works fine.

My program:

virtual bool runOnFunction(Function &F) {
for (Function::iterator b = F.begin(), be = F.end(); b != be; ++b) //Thorws error when I add this loop
{

errs()<<“hello”<<"\t";
}

return false;
}

Command : $ opt -load ~/LLVM/bulid/Debug+Asserts/lib/CSE.so -CSE < hell.ll > /dev/null

Error while running the pass :

hello hello 0 opt 0x00000000014a1b92 llvm::sys::PrintStackTrace(_IO_FILE*) + 34
1 opt 0x00000000014a0f79
2 libpthread.so.0 0x00007f2c1a4a7340
3 CSE.so 0x00007f2c192826cc
4 CSE.so 0x00007f2c192826ac
5 CSE.so 0x00007f2c1928267f
6 CSE.so 0x00007f2c19282564
7 opt 0x000000000142f4df llvm::FPPassManager::runOnFunction(llvm::Function&) + 607
8 opt 0x000000000142f54b llvm::FPPassManager::runOnModule(llvm::Module&) + 43
9 opt 0x000000000142f09f llvm::legacy::PassManagerImpl::run(llvm::Module&) + 927
10 opt 0x000000000059f768 main + 4888
11 libc.so.6 0x00007f2c194a6ec5 __libc_start_main + 245
12 opt 0x00000000005bae91
Stack dump:
0. Program arguments: opt -load /home/mtech2/LLVM/bulid/Debug+Asserts/lib/CSE.so -CSE

  1. Running pass ‘Function Pass Manager’ on module ‘’.
  2. Running pass ‘Print Instructions’ on function ‘@main
    Segmentation fault (core dumped)

Any help regarding the error.

Regards,

Rakesh R Nair

Most likely this is picking up opt from somewhere in $PATH, which only
has a middling chance of being compatible with what you've just built
even if it was based on exactly the same source. If it's an official
release and you're compiling trunk then it's doomed.

So try running ~/LLVM/build/Debug+Asserts/bin/opt instead (or wherever
autotools puts opt, I'm afraid I am guessing).

Cheers.

Tim.