diff options
author | Ayke van Laethem <[email protected]> | 2022-09-21 13:55:32 +0200 |
---|---|---|
committer | Ron Evans <[email protected]> | 2022-10-19 22:23:19 +0200 |
commit | 7b6a9fab4206bde1a11c3a8d79631a0e8ac71a82 (patch) | |
tree | edacd9c30e7f6d6aec8e4d084e800c964aaa12b6 /transform | |
parent | 6bc6de8f829786e84e01b97d1f452505a83047b1 (diff) | |
download | tinygo-7b6a9fab4206bde1a11c3a8d79631a0e8ac71a82.tar.gz tinygo-7b6a9fab4206bde1a11c3a8d79631a0e8ac71a82.zip |
all: add type parameter to CreateLoad
This is needed for LLVM 15.
Diffstat (limited to 'transform')
-rw-r--r-- | transform/gc.go | 2 | ||||
-rw-r--r-- | transform/stacksize.go | 13 | ||||
-rw-r--r-- | transform/wasm-abi.go | 4 |
3 files changed, 12 insertions, 7 deletions
diff --git a/transform/gc.go b/transform/gc.go index 87dc6e88a..7a4e99aca 100644 --- a/transform/gc.go +++ b/transform/gc.go @@ -222,7 +222,7 @@ func MakeGCStackSlots(mod llvm.Module) bool { builder.CreateStore(initialStackObject, stackObject) // Update stack start. - parent := builder.CreateLoad(stackChainStart, "") + parent := builder.CreateLoad(stackChainStartType, stackChainStart, "") gep := builder.CreateGEP(stackObject, []llvm.Value{ llvm.ConstInt(ctx.Int32Type(), 0, false), llvm.ConstInt(ctx.Int32Type(), 0, false), diff --git a/transform/stacksize.go b/transform/stacksize.go index 7be49238f..f1a3c93d7 100644 --- a/transform/stacksize.go +++ b/transform/stacksize.go @@ -34,6 +34,11 @@ func CreateStackSizeLoads(mod llvm.Module, config *compileopts.Config) []string return nil } + ctx := mod.Context() + targetData := llvm.NewTargetData(mod.DataLayout()) + defer targetData.Dispose() + uintptrType := ctx.IntType(targetData.PointerSize() * 8) + // Create the new global with stack sizes, that will be put in a new section // just for itself. stackSizesGlobalType := llvm.ArrayType(functions[0].Type(), len(functions)) @@ -50,16 +55,16 @@ func CreateStackSizeLoads(mod llvm.Module, config *compileopts.Config) []string appendToUsedGlobals(mod, append([]llvm.Value{stackSizesGlobal}, functionValues...)...) // Replace the calls with loads from the new global with stack sizes. - irbuilder := mod.Context().NewBuilder() + irbuilder := ctx.NewBuilder() defer irbuilder.Dispose() for i, function := range functions { for _, use := range functionMap[function] { ptr := llvm.ConstGEP(stackSizesGlobal, []llvm.Value{ - llvm.ConstInt(mod.Context().Int32Type(), 0, false), - llvm.ConstInt(mod.Context().Int32Type(), uint64(i), false), + llvm.ConstInt(ctx.Int32Type(), 0, false), + llvm.ConstInt(ctx.Int32Type(), uint64(i), false), }) irbuilder.SetInsertPointBefore(use) - stacksize := irbuilder.CreateLoad(ptr, "stacksize") + stacksize := irbuilder.CreateLoad(uintptrType, ptr, "stacksize") use.ReplaceAllUsesWith(stacksize) use.EraseFromParentAsInstruction() } diff --git a/transform/wasm-abi.go b/transform/wasm-abi.go index aedad71d0..064e38f4b 100644 --- a/transform/wasm-abi.go +++ b/transform/wasm-abi.go @@ -125,7 +125,7 @@ func ExternalInt64AsPtr(mod llvm.Module, config *compileopts.Config) error { // where the return value should be stored, instead of using // the regular return value. builder.CreateCall(externalFnType, externalFn, callParams, callName) - returnValue := builder.CreateLoad(retvalAlloca, "retval") + returnValue := builder.CreateLoad(int64Type, retvalAlloca, "retval") call.ReplaceAllUsesWith(returnValue) call.EraseFromParentAsInstruction() } else { @@ -152,7 +152,7 @@ func ExternalInt64AsPtr(mod llvm.Module, config *compileopts.Config) error { for i, origParam := range fn.Params() { paramValue := externalFn.Param(i) if origParam.Type() == int64Type { - paramValue = builder.CreateLoad(paramValue, "i64") + paramValue = builder.CreateLoad(int64Type, paramValue, "i64") } callParams = append(callParams, paramValue) } |