mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-10 22:13:39 +00:00
all: add type parameter to CreateCall
This uses LLVMBuildCall2 in the background, which is the replacement for the deprecated LLVMBuildCall function.
This commit is contained in:
committed by
Ron Evans
parent
b79bf29c11
commit
6bc6de8f82
@@ -493,12 +493,13 @@ func (p *lowerInterfacesPass) defineInterfaceMethodFunc(fn llvm.Value, itf *inte
|
||||
paramTypes = append(paramTypes, param.Type())
|
||||
}
|
||||
calledFunctionType := function.Type()
|
||||
sig := llvm.PointerType(llvm.FunctionType(returnType, paramTypes, false), calledFunctionType.PointerAddressSpace())
|
||||
functionType := llvm.FunctionType(returnType, paramTypes, false)
|
||||
sig := llvm.PointerType(functionType, calledFunctionType.PointerAddressSpace())
|
||||
if sig != function.Type() {
|
||||
function = p.builder.CreateBitCast(function, sig, "")
|
||||
}
|
||||
|
||||
retval := p.builder.CreateCall(function, append([]llvm.Value{receiver}, params...), "")
|
||||
retval := p.builder.CreateCall(functionType, function, append([]llvm.Value{receiver}, params...), "")
|
||||
if retval.Type().TypeKind() == llvm.VoidTypeKind {
|
||||
p.builder.CreateRetVoid()
|
||||
} else {
|
||||
@@ -518,7 +519,7 @@ func (p *lowerInterfacesPass) defineInterfaceMethodFunc(fn llvm.Value, itf *inte
|
||||
// importantly, it avoids undefined behavior when accidentally calling a
|
||||
// method on a nil interface.
|
||||
nilPanic := p.mod.NamedFunction("runtime.nilPanic")
|
||||
p.builder.CreateCall(nilPanic, []llvm.Value{
|
||||
p.builder.CreateCall(nilPanic.GlobalValueType(), nilPanic, []llvm.Value{
|
||||
llvm.Undef(llvm.PointerType(p.ctx.Int8Type(), 0)),
|
||||
}, "")
|
||||
p.builder.CreateUnreachable()
|
||||
|
||||
Reference in New Issue
Block a user