mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-09 05:23:40 +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()
|
||||
|
||||
@@ -91,7 +91,7 @@ func LowerInterrupts(mod llvm.Module) []error {
|
||||
initializer := handler.Initializer()
|
||||
context := llvm.ConstExtractValue(initializer, []uint32{0})
|
||||
funcPtr := llvm.ConstExtractValue(initializer, []uint32{1}).Operand(0)
|
||||
builder.CreateCall(funcPtr, []llvm.Value{
|
||||
builder.CreateCall(funcPtr.GlobalValueType(), funcPtr, []llvm.Value{
|
||||
num,
|
||||
context,
|
||||
}, "")
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ func ReplacePanicsWithTrap(mod llvm.Module) {
|
||||
panic("expected use of a panic function to be a call")
|
||||
}
|
||||
builder.SetInsertPointBefore(use)
|
||||
builder.CreateCall(trap, nil, "")
|
||||
builder.CreateCall(trap.GlobalValueType(), trap, nil, "")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ func OptimizeReflectImplements(mod llvm.Module) {
|
||||
|
||||
// Replace Implements call with the type assert call.
|
||||
builder.SetInsertPointBefore(call)
|
||||
implements := builder.CreateCall(typeAssertFunction, []llvm.Value{
|
||||
implements := builder.CreateCall(typeAssertFunction.GlobalValueType(), typeAssertFunction, []llvm.Value{
|
||||
builder.CreatePtrToInt(call.Operand(0), uintptrType, ""), // typecode to check
|
||||
}, "")
|
||||
call.ReplaceAllUsesWith(implements)
|
||||
|
||||
@@ -124,12 +124,12 @@ func ExternalInt64AsPtr(mod llvm.Module, config *compileopts.Config) error {
|
||||
// Pass a stack-allocated pointer as the first parameter
|
||||
// where the return value should be stored, instead of using
|
||||
// the regular return value.
|
||||
builder.CreateCall(externalFn, callParams, callName)
|
||||
builder.CreateCall(externalFnType, externalFn, callParams, callName)
|
||||
returnValue := builder.CreateLoad(retvalAlloca, "retval")
|
||||
call.ReplaceAllUsesWith(returnValue)
|
||||
call.EraseFromParentAsInstruction()
|
||||
} else {
|
||||
newCall := builder.CreateCall(externalFn, callParams, callName)
|
||||
newCall := builder.CreateCall(externalFnType, externalFn, callParams, callName)
|
||||
call.ReplaceAllUsesWith(newCall)
|
||||
call.EraseFromParentAsInstruction()
|
||||
}
|
||||
@@ -156,7 +156,7 @@ func ExternalInt64AsPtr(mod llvm.Module, config *compileopts.Config) error {
|
||||
}
|
||||
callParams = append(callParams, paramValue)
|
||||
}
|
||||
retval := builder.CreateCall(fn, callParams, "")
|
||||
retval := builder.CreateCall(fn.GlobalValueType(), fn, callParams, "")
|
||||
if retval.Type().TypeKind() == llvm.VoidTypeKind {
|
||||
builder.CreateRetVoid()
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user