CallInst::Create() 在 LLVM 中返回什么
What does CallInst::Create() return in LLVM?
正在考虑
static CallInst *Create(Value *Func,
ArrayRef<Value *> Args,
const Twine &NameStr = "",
Instruction *InsertBefore = 0)
这个函数,我想知道这个函数的返回值是什么意思。
例如,在下面的代码中,
int foo(int a);
...
Function *foo_ptr = ~~;//say, foo is refered through getOrInsertFunction()
CallInst *ptr = CallInst::Create(foo_ptr, .../* properly set */);
CallInst *ptr 是返回值。抽象地说,ptr是否意味着
- 由 int foo(int( 返回的整数值;
- 或呼叫指令
我以为数字 2 是答案,但看着一些代码开始感到困惑。
1 和 2 都是"true"。它返回调用指令,当我们执行代码时,其"值"将是函数的返回值。
为了说明这一点,请以这个小的Pascal程序为例:
program p;
function f: integer;
begin
f := 42;
end; { f }
begin
writeln(f);
end.
这转化为这个LLVM-IR:
; ModuleID = 'TheModule'
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
%text = type { i32, i8*, i32, i32 }
@input = global %text zeroinitializer, align 8
@output = global %text zeroinitializer, align 8
@UnitIniList = constant [1 x i8*] zeroinitializer
define i32 @P.f() #0 {
entry:
%f = alloca i32, align 4
store i32 42, i32* %f
%0 = load i32, i32* %f
ret i32 %0
}
define void @__PascalMain() #0 {
entry:
%calltmp = call i32 @P.f()
call void @__write_int(%text* @output, i32 %calltmp, i32 0)
call void @__write_nl(%text* @output)
ret void
}
declare void @__write_int(%text*, i32, i32)
declare void @__write_nl(%text*)
attributes #0 = { "no-frame-pointer-elim"="true" }
call i32 @P.f()
由以下人员生成:
inst = builder.CreateCall(calleF, argsV, "calltmp");
inst
的内容是%calltmp = call i32 @P.f()
的——这是一个CallInst
"价值"。
并且inst
返回到表达式的计算中,以便参数writeln
。
相关文章:
- 查找不存在的键时,unordered_map返回什么
- 如果我在 const 函数上使用指针,我可以返回什么?
- 使用枚举作为条件,if 条件将返回什么,真或假?
- 我应该返回什么而不是标准::shared_ptr<>&?
- 当你只使用 return 时,函数返回什么类型;在 c++ 中
- 在C++中,运算符 sizeof 返回什么数据类型?
- ActorItr 迭代器变量中有什么,* ActorItr 返回什么?
- mxGetPr 返回什么?
- 重载运算符返回什么类型的值(对于用户定义的类型):右值还是左值?
- 代码是否有效.如果我想显示第一个元素?如果不是,那么 s.begin() 会返回什么?
- 范围分辨率运算符在类型:: var的情况下返回什么
- fork_rv返回什么
- int* foo(int a)在C 中返回什么
- 当找不到请求的注册表值时,ReggetValue会返回什么
- 我们应该在带有 char *func(char *string) 的函数中返回什么?需要简要说明这与 c 中的 char
- 重载的 QAbstractItemModel::flags 应该为无效的 QModelIndex 返回什么
- 试图在每次输出后使用一个函数摆脱'0',但不确定我可以返回什么
- 查找函数在失败结果中应该返回什么
- 当c 中的矢量容器过载[]运算符时,我对未定义的索引返回什么
- 新运营商在组装中返回什么