Running grep with LLI

Hi everyone,

I compiled grep with llvm-3.4(because consumer tool uses llvm3.4 bit code)
and generate bit-code for this.

When I am running with lli output is

pseudo instructions should be removed before code emission
UNREACHABLE executed at
/home/awanish/llvm/llvm-3.4.2/lib/Target/X86/X86CodeEmitter.cpp:1176!
0 libLLVM-3.4.so 0x00007f1250f655d5
llvm::sys::PrintStackTrace(_IO_FILE*) + 37
1 libLLVM-3.4.so 0x00007f1250f65a23
2 libpthread.so.0 0x00007f124fffd330
3 libc.so.6 0x00007f124f011c37 gsignal + 55
4 libc.so.6 0x00007f124f015028 abort + 328
5 libLLVM-3.4.so 0x00007f1250f5218c llvm::llvm_unreachable_internal(char
const*, char const*, unsigned int) + 444
6 libLLVM-3.4.so 0x00007f12510624f2
7 libLLVM-3.4.so 0x00007f125105f3a2
8 libLLVM-3.4.so 0x00007f125087b6ec
llvm::MachineFunctionPass::runOnFunction(llvm::Function&) + 124
9 libLLVM-3.4.so 0x00007f1250a46d9a
llvm::FPPassManager::runOnFunction(llvm::Function&) + 362
10 libLLVM-3.4.so 0x00007f1250a464fe
llvm::legacy::FunctionPassManagerImpl::run(llvm::Function&) + 238
11 libLLVM-3.4.so 0x00007f1250a4639d
llvm::legacy::FunctionPassManager::run(llvm::Function&) + 93
12 libLLVM-3.4.so 0x00007f1250bca1dd
llvm::JIT::runJITOnFunctionUnlocked(llvm::Function*, llvm::MutexGuard
const&) + 45
13 libLLVM-3.4.so 0x00007f1250bca435
llvm::JIT::getPointerToFunction(llvm::Function*) + 261
14 lli 0x0000000000409f95 main + 4437
15 libc.so.6 0x00007f124effcf45 __libc_start_main + 245
16 lli 0x00000000004069bd
Stack dump:
0. Program arguments: lli kleegrep.bc
1. Running pass 'X86 Machine Code Emitter' on function '@main'
Aborted (core dumped)

Can anyone help me in debugging this. I am doing wrong in bit-code
generation phase or in execution.

This error looks like an internal LLVM bug. I don’t think there is much you can do about it other than:

1) upgrading to a more recent LLVM
2) find when the bug was fixed and backport the fix on your 3.4 version (this is non-trivial and likely quite involved).

As a starter, can you compile the code with llc instead of using lli (in case lli does not setup something correctly)?