compiler: move GC passes to the transform package

This commit is contained in:
Ayke van Laethem
2019-11-17 20:37:45 +01:00
committed by Ron Evans
parent 3d3e48179e
commit f0bb3c092d
9 changed files with 611 additions and 359 deletions
+24
View File
@@ -65,3 +65,27 @@ func replaceGlobalIntWithArray(mod llvm.Module, name string, buf interface{}) ll
global.SetName(name)
return global
}
// typeHasPointers returns whether this type is a pointer or contains pointers.
// If the type is an aggregate type, it will check whether there is a pointer
// inside.
func typeHasPointers(t llvm.Type) bool {
switch t.TypeKind() {
case llvm.PointerTypeKind:
return true
case llvm.StructTypeKind:
for _, subType := range t.StructElementTypes() {
if typeHasPointers(subType) {
return true
}
}
return false
case llvm.ArrayTypeKind:
if typeHasPointers(t.ElementType()) {
return true
}
return false
default:
return false
}
}