Fix warnings in K/Native code

This commit is contained in:
Dmitriy Novozhilov
2021-07-20 16:42:23 +03:00
committed by Space
parent 0a5991d6e7
commit ca9cbf7eb7
8 changed files with 75 additions and 52 deletions

View File

@@ -175,6 +175,8 @@ abstract class StructDef(val size: Long, val align: Int) {
when (it) {
is Field -> add(it)
is AnonymousInnerRecord -> addAll(it.def.fields)
is BitField,
is IncompleteField -> {}
}
}
}
@@ -185,6 +187,8 @@ abstract class StructDef(val size: Long, val align: Int) {
when (it) {
is BitField -> add(it)
is AnonymousInnerRecord -> addAll(it.def.bitFields)
is Field,
is IncompleteField -> {}
}
}
}

View File

@@ -241,6 +241,8 @@ fun StructDef.fieldsHaveDefaultAlignment(): Boolean {
offset = it.offset / 8 + it.typeSize
}
is BitField -> return false
is AnonymousInnerRecord,
is IncompleteField -> {}
}
}

View File

@@ -156,6 +156,7 @@ class StubIrBridgeBuilder(
val getAddressExpression = getGlobalAddressExpression(extra.cGlobalName, propertyAccessor)
propertyAccessorBridgeBodies[propertyAccessor] = typeInfo.argFromBridged(getAddressExpression, kotlinFile, nativeBacked = propertyAccessor) + "!!"
}
else -> {}
}
}
@@ -187,6 +188,7 @@ class StubIrBridgeBuilder(
}
propertyAccessorBridgeBodies[propertyAccessor] = setter
}
else -> {}
}
is PropertyAccessor.Setter.WriteBits -> {
@@ -223,6 +225,11 @@ class StubIrBridgeBuilder(
simpleBridgeGenerator.insertNativeBridge(propertyAccessor, emptyList(), wrapper.lines)
}
}
is PropertyAccessor.Getter.ArrayMemberAt,
is PropertyAccessor.Getter.GetConstructorParameter,
is PropertyAccessor.Getter.GetEnumEntry,
is PropertyAccessor.Getter.MemberAt,
is PropertyAccessor.Setter.MemberAt -> {}
}
}

View File

@@ -179,6 +179,7 @@ internal fun produceOutput(context: Context) {
context.bitcodeFileName = output
LLVMWriteBitcodeToFile(context.llvmModule!!, output)
}
null -> {}
}
}

View File

@@ -126,5 +126,5 @@ internal class FileInitializersLowering(val context: Context) : FileLoweringPass
}
private val IrField.hasNonConstInitializer: Boolean
get() = initializer.let { it != null && it !is IrConst<*> }
get() = initializer?.expression.let { it != null && it !is IrConst<*> }
}

View File

@@ -758,67 +758,64 @@ internal class ModuleDFGBuilder(val context: Context, val irModule: IrModuleFrag
else
it
}
if (callee is IrConstructor) {
error("Constructor call should be done with IrConstructorCall")
} else {
if (value.isVirtualCall) {
val owner = callee.parentAsClass
val actualReceiverType = value.dispatchReceiver!!.type
val actualReceiverClassifier = actualReceiverType.classifierOrFail
val receiverType =
if (actualReceiverClassifier is IrTypeParameterSymbol
|| !callee.isReal /* Could be a bridge. */)
symbolTable.mapClassReferenceType(owner)
else {
val actualClassAtCallsite =
(actualReceiverClassifier as IrClassSymbol).descriptor
if (value.isVirtualCall) {
val owner = callee.parentAsClass
val actualReceiverType = value.dispatchReceiver!!.type
val actualReceiverClassifier = actualReceiverType.classifierOrFail
val receiverType =
if (actualReceiverClassifier is IrTypeParameterSymbol
|| !callee.isReal /* Could be a bridge. */)
symbolTable.mapClassReferenceType(owner)
else {
val actualClassAtCallsite =
(actualReceiverClassifier as IrClassSymbol).descriptor
// assert (DescriptorUtils.isSubclass(actualClassAtCallsite, owner.descriptor)) {
// "Expected an inheritor of ${owner.descriptor}, but was $actualClassAtCallsite"
// }
if (DescriptorUtils.isSubclass(actualClassAtCallsite, owner.descriptor)) {
symbolTable.mapClassReferenceType(actualReceiverClassifier.owner) // Box if inline class.
} else {
symbolTable.mapClassReferenceType(owner)
}
if (DescriptorUtils.isSubclass(actualClassAtCallsite, owner.descriptor)) {
symbolTable.mapClassReferenceType(actualReceiverClassifier.owner) // Box if inline class.
} else {
symbolTable.mapClassReferenceType(owner)
}
}
val isAnyMethod = callee.target.parentAsClass.isAny()
if (owner.isInterface && !isAnyMethod) {
val itablePlace = context.getLayoutBuilder(owner).itablePlace(callee)
DataFlowIR.Node.ItableCall(
symbolTable.mapFunction(callee.target),
receiverType,
itablePlace.interfaceId,
itablePlace.methodIndex,
arguments,
mapReturnType(value.type, callee.target.returnType),
value
)
} else {
val vtableIndex = if (isAnyMethod)
context.getLayoutBuilder(context.irBuiltIns.anyClass.owner).vtableIndex(callee.target)
else
context.getLayoutBuilder(owner).vtableIndex(callee)
DataFlowIR.Node.VtableCall(
symbolTable.mapFunction(callee.target),
receiverType,
vtableIndex,
arguments,
mapReturnType(value.type, callee.target.returnType),
value
)
}
} else {
val actualCallee = value.actualCallee
DataFlowIR.Node.StaticCall(
symbolTable.mapFunction(actualCallee),
val isAnyMethod = callee.target.parentAsClass.isAny()
if (owner.isInterface && !isAnyMethod) {
val itablePlace = context.getLayoutBuilder(owner).itablePlace(callee)
DataFlowIR.Node.ItableCall(
symbolTable.mapFunction(callee.target),
receiverType,
itablePlace.interfaceId,
itablePlace.methodIndex,
arguments,
actualCallee.dispatchReceiverParameter?.let { symbolTable.mapType(it.type) },
mapReturnType(value.type, actualCallee.returnType),
mapReturnType(value.type, callee.target.returnType),
value
)
} else {
val vtableIndex = if (isAnyMethod)
context.getLayoutBuilder(context.irBuiltIns.anyClass.owner).vtableIndex(callee.target)
else
context.getLayoutBuilder(owner).vtableIndex(callee)
DataFlowIR.Node.VtableCall(
symbolTable.mapFunction(callee.target),
receiverType,
vtableIndex,
arguments,
mapReturnType(value.type, callee.target.returnType),
value
)
}
} else {
val actualCallee = value.actualCallee
DataFlowIR.Node.StaticCall(
symbolTable.mapFunction(actualCallee),
arguments,
actualCallee.dispatchReceiverParameter?.let { symbolTable.mapType(it.type) },
mapReturnType(value.type, actualCallee.returnType),
value
)
}
}
}

View File

@@ -231,6 +231,13 @@ internal object EscapeAnalysis {
for (value in node.values)
assignRole(node, Role.ASSIGNED, RoleInfoEntry(value.node, null))
}
is DataFlowIR.Node.AllocInstance,
is DataFlowIR.Node.Call,
is DataFlowIR.Node.Const,
is DataFlowIR.Node.FunctionReference,
is DataFlowIR.Node.Null,
is DataFlowIR.Node.Parameter,
is DataFlowIR.Node.Scope -> {}
}
}
FunctionAnalysisResult(function, nodesRoles)

View File

@@ -136,6 +136,11 @@ internal object LocalEscapeAnalysis {
is DataFlowIR.Node.Parameter -> {
node.escapeState = EscapeState.ARG_ESCAPE
}
is DataFlowIR.Node.AllocInstance,
is DataFlowIR.Node.Const,
is DataFlowIR.Node.FunctionReference,
is DataFlowIR.Node.Null,
is DataFlowIR.Node.Scope -> {}
}
}