【问题标题】:LLVM: run-time error in creating a function of empty input and outputLLVM:创建空输入和输出函数时出现运行时错误
【发布时间】:2015-04-22 12:08:02
【问题描述】:

我想在 LLVM IR 中创建一个空函数

void foo(){
}

我用

LLVMContext Context;
std::unique_ptr<Module> Owner(new Module("test", Context));
Module *M = Owner.get();    
Function *foo =
cast<Function>(M->getOrInsertFunction("foo", Type::getVoidTy(Context),
                                      Type::getVoidTy(Context),
                                      (Type *)0));

编译但给我这个错误在运行时

llvm-3.7.src/lib/IR/Type.cpp:350: llvm::FunctionType::FunctionType(llvm::Type*, llvm::ArrayRef, bool): 断言`isValidArgumentType(Params[i]) &&“不是函数参数的有效类型!”'失败。 * 崩溃并返回代码:0 *

关于我们如何在 LLVM 中执行 void foo(){} 函数有任何想法吗?

【问题讨论】:

    标签: llvm llvm-ir


    【解决方案1】:

    Void 不是有效的参数类型。仅对返回类型使用 void,然后传入 null 以创建一个空参数列表。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-09-11
      • 1970-01-01
      • 2020-04-04
      • 2022-01-05
      • 2017-03-21
      • 1970-01-01
      • 2022-12-18
      • 1970-01-01
      相关资源
      最近更新 更多