diff --git a/COVERAGE.md b/COVERAGE.md index 6d763860..54045744 100644 --- a/COVERAGE.md +++ b/COVERAGE.md @@ -653,7 +653,7 @@ Function parameters: - [ ] LLVMGetCallSiteStringAttribute - [ ] LLVMRemoveCallSiteEnumAttribute - [ ] LLVMRemoveCallSiteStringAttribute -- [ ] LLVMGetCalledValue +- [x] LLVMGetCalledValue - [x] LLVMIsTailCall - [x] LLVMSetTailCall diff --git a/src/core/instructions.jl b/src/core/instructions.jl index 5ffd935f..d684672c 100644 --- a/src/core/instructions.jl +++ b/src/core/instructions.jl @@ -80,7 +80,8 @@ end ## call sites and invocations export callconv, callconv!, - istailcall, tailcall! + istailcall, tailcall!, + called_value callconv(inst::Instruction) = API.LLVMGetInstructionCallConv(ref(inst)) callconv!(inst::Instruction, cc) = @@ -89,6 +90,8 @@ callconv!(inst::Instruction, cc) = istailcall(inst::Instruction) = convert(Core.Bool, API.LLVMIsTailCall(ref(inst))) tailcall!(inst::Instruction, bool) = API.LLVMSetTailCall(ref(inst), convert(Bool, bool)) +called_value(inst::Instruction) = Value(API.LLVMGetCalledValue(ref( inst))) + ## terminators diff --git a/test/irbuilder.jl b/test/irbuilder.jl index d73c1f9f..55cabb49 100644 --- a/test/irbuilder.jl +++ b/test/irbuilder.jl @@ -249,6 +249,7 @@ LLVM.Module("SomeModule", ctx) do mod trap = LLVM.Function(mod, "llvm.trap", LLVM.FunctionType(LLVM.VoidType(ctx))) callinst = call!(builder, trap) @check_ir callinst "call void @llvm.trap()" + @test called_value(callinst) == trap neginst = neg!(builder, int1) @check_ir neginst "sub i32 0, %0"