ci: add support for LLVM 15

This commit switches to LLVM 15 everywhere by default, while still
keeping LLVM 14 support.
This commit is contained in:
Ayke van Laethem
2022-09-22 13:39:51 +02:00
committed by Ron Evans
parent 08a51535d4
commit 2b7f562202
40 changed files with 895 additions and 881 deletions
+3 -1
View File
@@ -305,7 +305,9 @@ func (p *lowerInterfacesPass) addTypeMethods(t *typeInfo, methodSet llvm.Value)
// no methods or methods already read
return
}
methodSet = methodSet.Operand(0) // get global from GEP
if !methodSet.IsAConstantExpr().IsNil() && methodSet.Opcode() == llvm.GetElementPtr {
methodSet = methodSet.Operand(0) // get global from GEP, for LLVM 14 (non-opaque pointers)
}
// This type has methods, collect all methods of this type.
t.methodSet = methodSet
+1 -2
View File
@@ -36,9 +36,8 @@ func LowerInterrupts(mod llvm.Module) []error {
handleMap := map[int64][]llvm.Value{}
handleType := mod.GetTypeByName("runtime/interrupt.handle")
if !handleType.IsNil() {
handlePtrType := llvm.PointerType(handleType, 0)
for global := mod.FirstGlobal(); !global.IsNil(); global = llvm.NextGlobal(global) {
if global.Type() != handlePtrType {
if global.GlobalValueType() != handleType {
continue
}
+6
View File
@@ -80,6 +80,12 @@ func replaceGlobalIntWithArray(mod llvm.Module, name string, buf interface{}) ll
// stripPointerCasts strips instruction pointer casts (getelementptr and
// bitcast) and returns the original value without the casts.
func stripPointerCasts(value llvm.Value) llvm.Value {
if !value.IsAConstantExpr().IsNil() {
switch value.Opcode() {
case llvm.GetElementPtr, llvm.BitCast:
return stripPointerCasts(value.Operand(0))
}
}
if !value.IsAInstruction().IsNil() {
switch value.InstructionOpcode() {
case llvm.GetElementPtr, llvm.BitCast:
+7 -4
View File
@@ -251,7 +251,10 @@ func LowerReflect(mod llvm.Module) {
// a pointer to a runtime.structField array and therefore a
// bitcast. This global should be erased separately, otherwise
// typecode objects cannot be erased.
structFields := references.Operand(0)
structFields := references
if !structFields.IsAConstantExpr().IsNil() && structFields.Opcode() == llvm.BitCast {
structFields = structFields.Operand(0) // get global from bitcast, for LLVM 14 compatibility (non-opaque pointers)
}
structFields.EraseFromParentAsGlobal()
}
}
@@ -460,7 +463,7 @@ func (state *typeCodeAssignmentState) getStructTypeNum(typecode llvm.Value) int
// Get the fields this struct type contains.
// The struct number will be the start index of
structTypeGlobal := state.builder.CreateExtractValue(typecode.Initializer(), 0, "").Operand(0).Initializer()
structTypeGlobal := stripPointerCasts(state.builder.CreateExtractValue(typecode.Initializer(), 0, "")).Initializer()
numFields := structTypeGlobal.Type().ArrayLength()
// The first data that is stored in the struct sidetable is the number of
@@ -483,7 +486,7 @@ func (state *typeCodeAssignmentState) getStructTypeNum(typecode llvm.Value) int
if nameGlobal == llvm.ConstPointerNull(nameGlobal.Type()) {
panic("compiler: no name for this struct field")
}
fieldNameBytes := getGlobalBytes(nameGlobal.Operand(0), state.builder)
fieldNameBytes := getGlobalBytes(stripPointerCasts(nameGlobal), state.builder)
fieldNameNumber := state.getStructNameNumber(fieldNameBytes)
// See whether this struct field has an associated tag, and if so,
@@ -493,7 +496,7 @@ func (state *typeCodeAssignmentState) getStructTypeNum(typecode llvm.Value) int
tagNumber := 0
if tagGlobal != llvm.ConstPointerNull(tagGlobal.Type()) {
hasTag = true
tagBytes := getGlobalBytes(tagGlobal.Operand(0), state.builder)
tagBytes := getGlobalBytes(stripPointerCasts(tagGlobal), state.builder)
tagNumber = state.getStructNameNumber(tagBytes)
}
+2 -3
View File
@@ -139,14 +139,13 @@ func OptimizeReflectImplements(mod llvm.Module) {
if call.IsACallInst().IsNil() {
continue
}
interfaceTypeBitCast := call.Operand(2)
if interfaceTypeBitCast.IsAConstantExpr().IsNil() || interfaceTypeBitCast.Opcode() != llvm.BitCast {
interfaceType := stripPointerCasts(call.Operand(2))
if interfaceType.IsAGlobalVariable().IsNil() {
// The asserted interface is not constant, so can't optimize this
// code.
continue
}
interfaceType := interfaceTypeBitCast.Operand(0)
if strings.HasPrefix(interfaceType.Name(), "reflect/types.type:named:") {
// Get the underlying type.
interfaceType = builder.CreateExtractValue(interfaceType.Initializer(), 0, "")