【发布时间】:2015-12-19 00:27:04
【问题描述】:
我是 LLVM 新手。我正在使用 clang c++ API 将多个存根文件(在 c 中)编译为 IR,然后使用 IR 构建器(链接它们之后)将它们粘在一起,最终通过 JIT 运行。
这一切都很好,除非我在优化中添加 functionInlining 传递,此时在 IR 构建器中进行的这些函数调用之一将在传递管理器运行时触发以下异常:
Assertion failed: (New->getType() == getType() && "replaceAllUses of value with new value of different type!"), function replaceAllUsesWith, file /Users/mike/Development/llvm/llvm/lib/IR/Value.cpp, line 356.
这就是我制作呼叫指令的方式(非常简单):
Function *kernelFunc = mModule->getFunction( (kernel->Name() + StringRef("_") + StringRef(funcName)).str());
if (kernelFunc){
CallInst* newInst = builder.CreateCall(kernelFunc, args);
}
后期模块优化:
legacy::PassManager passMan;
PassManagerBuilder Builder;
Builder.OptLevel = 3;
//Builder.Inliner = llvm::createFunctionInliningPass(); //commenting this back in trigger the exception
Builder.populateModulePassManager(passMan);
passMan.run( *mModule ); //exception occurs before this call returns
有什么想法吗?
【问题讨论】:
标签: llvm llvm-ir llvm-c++-api