all: replace llvm.Const* calls with builder.Create* calls

A number of llvm.Const* functions (in particular extractvalue and
insertvalue) were removed in LLVM 15, so we have to use a builder
instead. This builder will create the same constant values, it simply
uses a different API.
This commit is contained in:
Ayke van Laethem
2022-09-20 23:26:49 +02:00
committed by Ron Evans
parent f57cffce2d
commit 09ec846c9f
13 changed files with 86 additions and 65 deletions
+2 -2
View File
@@ -149,7 +149,7 @@ func OptimizeReflectImplements(mod llvm.Module) {
interfaceType := interfaceTypeBitCast.Operand(0)
if strings.HasPrefix(interfaceType.Name(), "reflect/types.type:named:") {
// Get the underlying type.
interfaceType = llvm.ConstExtractValue(interfaceType.Initializer(), []uint32{0})
interfaceType = builder.CreateExtractValue(interfaceType.Initializer(), 0, "")
}
if !strings.HasPrefix(interfaceType.Name(), "reflect/types.type:interface:") {
// This is an error. The Type passed to Implements should be of
@@ -161,7 +161,7 @@ func OptimizeReflectImplements(mod llvm.Module) {
// Interface is unknown at compile time. This can't be optimized.
continue
}
typeAssertFunction := llvm.ConstExtractValue(interfaceType.Initializer(), []uint32{4}).Operand(0)
typeAssertFunction := builder.CreateExtractValue(interfaceType.Initializer(), 4, "").Operand(0)
// Replace Implements call with the type assert call.
builder.SetInsertPointBefore(call)