我在运行程序时遇到以下问题:
pseudo instructions should be removed before code emission
UNREACHABLE executed at /home/leonor/llvm/llvm/lib/Target/X86/X86CodeEmitter.cpp:1164!
Stack dump:
0. Running pass 'X86 Machine Code Emitter' on function '@main'
./build/Release+Asserts/bin/llvm-dis: Bitcode stream must be at least 16 bytes in length
我的程序将 .bc 文件作为输入,然后加载该文件并显示它。我的疑问是:为什么只有当 C 程序包含条件语句(如果,for ..)时才会发生此错误。怎么解决??
我的代码:
int main(int argc, char **argv) {
InitializeNativeTarget();
LLVMContext &Context = getGlobalContext();
std::string Err;
const std::string InputFile = "teste_f1.bc";
OwningPtr<MemoryBuffer> result;
error_code ec = MemoryBuffer::getFile(InputFile, result);
MemoryBuffer *buffer = result.take();
Module * Mod = ParseBitcodeFile(buffer, Context);
ExecutionEngine* EE = 0;
EngineBuilder builder(Mod);
builder.setErrorStr(&Err);
builder.setEngineKind(EngineKind::JIT);
EE = builder.create();
Function * func = Mod->getFunction("main");
std::vector <std::string> params;
params.push_back(Mod->getModuleIdentifier());
EE->runStaticConstructorsDestructors(false);
int Result = EE->runFunctionAsMain(func, params, NULL);
EE->runStaticConstructorsDestructors(true);
WriteBitcodeToFile(Mod, outs());
delete Mod;
return 0;
}