【发布时间】:2015-04-27 18:33:44
【问题描述】:
我想请教一下将自己的 c++ 函数调用/绑定到 LLVM 中的正确方法。
我编写了简单的函数:
void writeSomething() {
std::cout << "Awesome" << std::endl;
}
在 LLVM 中,我正在尝试注册该函数。我已经创建了到它的外部链接。
// Void type
llvm::FunctionType* fccType =
llvm::FunctionType::get(
llvm::Type::getVoidTy(getGlobalContext()), false
);
// External - c++
Function *fcc = (Function*) module->getOrInsertFunction("writeSomething",
fccType
);
// Call
std::vector<Value*> emptyArgs;
CallInst::Create(fcc, makeArrayRef(emptyArgs));
仅调用此函数的 LLVM 输出为 ( // cmets 是我的输入,我如何理解输出)
// External linkage
declare void @writeSomething()
define internal void @main() {
entry:
// Call my function
call void @writeSomething()
ret void
}
程序以消息结束:LLVM ERROR: Program used external function 'writeSomething' which could not be resolved!
【问题讨论】:
标签: c++ compiler-construction llvm