Skip to content

Commit d658d41

Browse files
authored
Add called_type (#341)
1 parent 35be970 commit d658d41

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/core/instructions.jl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ const CallBase = Union{CallBrInst, CallInst, InvokeInst}
148148

149149
export callconv, callconv!,
150150
istailcall, tailcall!,
151-
called_value, arguments,
151+
called_value, arguments, called_type,
152152
OperandBundleUse, OperandBundleDef, operand_bundles
153153

154154
callconv(inst::CallBase) = API.LLVMGetInstructionCallConv(inst)
@@ -160,6 +160,14 @@ tailcall!(inst::CallBase, bool) = API.LLVMSetTailCall(inst, convert(Bool, bool))
160160

161161
called_value(inst::CallBase) = Value(API.LLVMGetCalledValue(inst))
162162

163+
function called_type(inst::CallBase)
164+
@static if version() >= v"11"
165+
LLVMType(API.LLVMGetCalledFunctionType(inst))
166+
else
167+
value_type(called_value(inst))
168+
end
169+
end
170+
163171
function arguments(inst::CallBase)
164172
nargs = API.LLVMGetNumArgOperands(inst)
165173
operands(inst)[1:nargs]

test/instructions.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@
321321

322322
@check_ir callinst "call void @llvm.trap()"
323323
@test called_value(callinst) == trap
324+
@test called_type(callinst) == LLVM.FunctionType(LLVM.VoidType(ctx))
324325

325326
neginst = neg!(builder, int1)
326327
@check_ir neginst "sub i32 0, %0"

0 commit comments

Comments
 (0)