diff options
author | Ayke van Laethem <[email protected]> | 2022-09-21 17:00:09 +0200 |
---|---|---|
committer | Ron Evans <[email protected]> | 2022-10-19 22:23:19 +0200 |
commit | f57cffce2d47f7c2b3c9ec1ddd1f077f0830d435 (patch) | |
tree | 316ab792c0442635e3f7cb0facfdee3d9d8bcf9b /transform | |
parent | 7b6a9fab4206bde1a11c3a8d79631a0e8ac71a82 (diff) | |
download | tinygo-f57cffce2d47f7c2b3c9ec1ddd1f077f0830d435.tar.gz tinygo-f57cffce2d47f7c2b3c9ec1ddd1f077f0830d435.zip |
all: add type parameter to *GEP calls
This is necessary for LLVM 15.
Diffstat (limited to 'transform')
-rw-r--r-- | transform/gc.go | 4 | ||||
-rw-r--r-- | transform/llvm.go | 10 | ||||
-rw-r--r-- | transform/stacksize.go | 2 |
3 files changed, 8 insertions, 8 deletions
diff --git a/transform/gc.go b/transform/gc.go index 7a4e99aca..3870a6b60 100644 --- a/transform/gc.go +++ b/transform/gc.go @@ -223,7 +223,7 @@ func MakeGCStackSlots(mod llvm.Module) bool { // Update stack start. parent := builder.CreateLoad(stackChainStartType, stackChainStart, "") - gep := builder.CreateGEP(stackObject, []llvm.Value{ + gep := builder.CreateGEP(stackObjectType, stackObject, []llvm.Value{ llvm.ConstInt(ctx.Int32Type(), 0, false), llvm.ConstInt(ctx.Int32Type(), 0, false), }, "") @@ -244,7 +244,7 @@ func MakeGCStackSlots(mod llvm.Module) bool { builder.SetInsertPointBefore(insertionPoint) // Extract a pointer to the appropriate section of the stack object. - gep := builder.CreateGEP(stackObject, []llvm.Value{ + gep := builder.CreateGEP(stackObjectType, stackObject, []llvm.Value{ llvm.ConstInt(ctx.Int32Type(), 0, false), llvm.ConstInt(ctx.Int32Type(), uint64(2+i), false), }, "") diff --git a/transform/llvm.go b/transform/llvm.go index 32ee95604..6716dd633 100644 --- a/transform/llvm.go +++ b/transform/llvm.go @@ -31,10 +31,10 @@ func hasUses(value llvm.Value) bool { } // makeGlobalArray creates a new LLVM global with the given name and integers as -// contents, and returns the global. +// contents, and returns the global and initializer type. // Note that it is left with the default linkage etc., you should set // linkage/constant/etc properties yourself. -func makeGlobalArray(mod llvm.Module, bufItf interface{}, name string, elementType llvm.Type) llvm.Value { +func makeGlobalArray(mod llvm.Module, bufItf interface{}, name string, elementType llvm.Type) (llvm.Type, llvm.Value) { buf := reflect.ValueOf(bufItf) globalType := llvm.ArrayType(elementType, buf.Len()) global := llvm.AddGlobal(mod, globalType, name) @@ -44,7 +44,7 @@ func makeGlobalArray(mod llvm.Module, bufItf interface{}, name string, elementTy value = llvm.ConstInsertValue(value, llvm.ConstInt(elementType, ch, false), []uint32{uint32(i)}) } global.SetInitializer(value) - return global + return globalType, global } // getGlobalBytes returns the slice contained in the array of the provided @@ -64,8 +64,8 @@ func getGlobalBytes(global llvm.Value) []byte { // function used for creating reflection sidetables, for example. func replaceGlobalIntWithArray(mod llvm.Module, name string, buf interface{}) llvm.Value { oldGlobal := mod.NamedGlobal(name) - global := makeGlobalArray(mod, buf, name+".tmp", oldGlobal.Type().ElementType()) - gep := llvm.ConstGEP(global, []llvm.Value{ + globalType, global := makeGlobalArray(mod, buf, name+".tmp", oldGlobal.Type().ElementType()) + gep := llvm.ConstGEP(globalType, global, []llvm.Value{ llvm.ConstInt(mod.Context().Int32Type(), 0, false), llvm.ConstInt(mod.Context().Int32Type(), 0, false), }) diff --git a/transform/stacksize.go b/transform/stacksize.go index f1a3c93d7..169f1454c 100644 --- a/transform/stacksize.go +++ b/transform/stacksize.go @@ -59,7 +59,7 @@ func CreateStackSizeLoads(mod llvm.Module, config *compileopts.Config) []string defer irbuilder.Dispose() for i, function := range functions { for _, use := range functionMap[function] { - ptr := llvm.ConstGEP(stackSizesGlobal, []llvm.Value{ + ptr := llvm.ConstGEP(stackSizesGlobalType, stackSizesGlobal, []llvm.Value{ llvm.ConstInt(ctx.Int32Type(), 0, false), llvm.ConstInt(ctx.Int32Type(), uint64(i), false), }) |