all: add type parameter to *GEP calls

This is necessary for LLVM 15.
This commit is contained in:
Ayke van Laethem
2022-09-21 17:00:09 +02:00
committed by Ron Evans
parent 7b6a9fab42
commit f57cffce2d
13 changed files with 69 additions and 60 deletions
+2 -2
View File
@@ -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),
}, "")
+5 -5
View File
@@ -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),
})
+1 -1
View File
@@ -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),
})