为什么打给我
jit->lookup("test");
命中失败的断言:“正在解决此职责范围之外的符号”?
当我以以下方式创建函数时会执行此操作:
define double @test() {
begin:
ret double 1.343000e+01
}
但是当我将函数创建为]时,它可以正常工作(即,在没有断言的情况下找到它)>
define void @test() { begin: ret void }
这不是找不到函数“ test”的情况,如果我查找不存在的名称,它会有不同的行为。
这是命中断言的代码:
ThreadSafeModule Create_M() { auto pCtx = make_unique<LLVMContext>(); LLVMContext& ctx = *pCtx; auto pM = make_unique<Module>("myModule", ctx); Module& M = *pM; IRBuilder<> builder(ctx); FunctionType* FT = FunctionType::get(Type::getDoubleTy(ctx),false); Function* testFn = Function::Create(FT, GlobalValue::LinkageTypes::ExternalLinkage, "test", M); auto BB = BasicBlock::Create(ctx,"begin",testFn); builder.SetInsertPoint(BB); builder.CreateRet(ConstantFP::get(ctx,APFloat(13.43))); outs() << M; // For debugging return ThreadSafeModule(std::move(pM), std::move(pCtx)); } int main() { InitializeNativeTarget(); InitializeNativeTargetAsmPrinter(); // Create an LLJIT instance. auto jit = ExitOnErr(LLJITBuilder().create()); auto M1 = Create_M(); ExitOnErr(jit->addIRModule(std::move(M1))); auto testSym = ExitOnErr(jit->lookup("test")); }
用这些行替换函数创建,它没有问题:
FunctionType* FT = FunctionType::get(Type::getVoidTy(ctx),false); Function* testFn = Function::Create(FT, GlobalValue::LinkageTypes::ExternalLinkage, "test", M); auto BB = BasicBlock::Create(ctx,"begin",testFn); builder.SetInsertPoint(BB); builder.CreateRetVoid();
我想了解断言的含义,为什么它在一种情况下而不在另一种情况下断言,以及我需要为(* double)()情况做些什么才能使其起作用。我做了很多搜索有关LLVM责任集的文档,但几乎没有发现。在https://llvm.org/docs/ORCv2.html处有人提及,但不足以让我解释该断言告诉我的内容。
我正在使用截至2019年8月20日的SVN存储库版本的LLVM,基于Visual Studio 2017 15.9.6。
为什么我要调用jit-> lookup(“ test”);命中一个失败的断言:“正在解决此职责范围之外的符号”?当我创建函数时,它会执行以下操作:define double @test(){begin:...
这确实是Windows平台上ORC LLJIT中的错误。