diff options
author | Ayke van Laethem <[email protected]> | 2022-09-21 00:37:01 +0200 |
---|---|---|
committer | Ron Evans <[email protected]> | 2022-10-19 22:23:19 +0200 |
commit | 6bc6de8f829786e84e01b97d1f452505a83047b1 (patch) | |
tree | bf90f4942d2aa881521b77734a07acaf0b8b411d /transform | |
parent | b79bf29c110191140b2f9ac0b1085127d66c36c7 (diff) | |
download | tinygo-6bc6de8f829786e84e01b97d1f452505a83047b1.tar.gz tinygo-6bc6de8f829786e84e01b97d1f452505a83047b1.zip |
all: add type parameter to CreateCall
This uses LLVMBuildCall2 in the background, which is the replacement for
the deprecated LLVMBuildCall function.
Diffstat (limited to 'transform')
-rw-r--r-- | transform/interface-lowering.go | 7 | ||||
-rw-r--r-- | transform/interrupt.go | 2 | ||||
-rw-r--r-- | transform/panic.go | 2 | ||||
-rw-r--r-- | transform/rtcalls.go | 2 | ||||
-rw-r--r-- | transform/wasm-abi.go | 6 |
5 files changed, 10 insertions, 9 deletions
diff --git a/transform/interface-lowering.go b/transform/interface-lowering.go index 7a01c2ea7..f5b29e301 100644 --- a/transform/interface-lowering.go +++ b/transform/interface-lowering.go @@ -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() diff --git a/transform/interrupt.go b/transform/interrupt.go index 3ffe7048c..2c301be01 100644 --- a/transform/interrupt.go +++ b/transform/interrupt.go @@ -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, }, "") diff --git a/transform/panic.go b/transform/panic.go index e8e9a1fe9..dee3bae06 100644 --- a/transform/panic.go +++ b/transform/panic.go @@ -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, "") } } } diff --git a/transform/rtcalls.go b/transform/rtcalls.go index 2edfd6554..2f17f815b 100644 --- a/transform/rtcalls.go +++ b/transform/rtcalls.go @@ -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) diff --git a/transform/wasm-abi.go b/transform/wasm-abi.go index aeba713d9..aedad71d0 100644 --- a/transform/wasm-abi.go +++ b/transform/wasm-abi.go @@ -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 { |