diff --git a/SwiftCompilerSources/Sources/SIL/Builder.swift b/SwiftCompilerSources/Sources/SIL/Builder.swift index a9c824fb16f9e..79989878c32a6 100644 --- a/SwiftCompilerSources/Sources/SIL/Builder.swift +++ b/SwiftCompilerSources/Sources/SIL/Builder.swift @@ -127,15 +127,15 @@ public struct Builder { hasDynamicLifetime: Bool = false, isLexical: Bool = false, isFromVarDecl: Bool = false, usesMoveableValueDebugInfo: Bool = false) -> AllocStackInst { - let bridgedDebugVar: OptionalBridgedSILDebugVariable + let allocStack: BridgedInstruction if let debugVariable = debugVariable { - bridgedDebugVar = OptionalBridgedSILDebugVariable(debugVariable) + allocStack = bridged.createAllocStack(type.bridged, debugVariable, hasDynamicLifetime, isLexical, + isFromVarDecl, usesMoveableValueDebugInfo) } else { - bridgedDebugVar = OptionalBridgedSILDebugVariable() + allocStack = bridged.createAllocStack(type.bridged, hasDynamicLifetime, isLexical, + isFromVarDecl, usesMoveableValueDebugInfo) } - let dr = bridged.createAllocStack(type.bridged, bridgedDebugVar, hasDynamicLifetime, isLexical, - isFromVarDecl, usesMoveableValueDebugInfo) - return notifyNew(dr.getAs(AllocStackInst.self)) + return notifyNew(allocStack.getAs(AllocStackInst.self)) } @discardableResult diff --git a/include/swift/SIL/SILBridging.h b/include/swift/SIL/SILBridging.h index 4789e15a34c34..d81e1f62775bf 100644 --- a/include/swift/SIL/SILBridging.h +++ b/include/swift/SIL/SILBridging.h @@ -636,14 +636,6 @@ struct BridgedSILDebugVariable { BRIDGED_INLINE swift::SILDebugVariable unbridge() const; }; -struct OptionalBridgedSILDebugVariable { - BridgedSILDebugVariable debugVar; - bool hasDebugVar = false; - - OptionalBridgedSILDebugVariable() {} - OptionalBridgedSILDebugVariable(BridgedSILDebugVariable d) : debugVar(d), hasDebugVar(true) {} -}; - struct BridgedInstruction { SwiftObject obj; @@ -1170,8 +1162,10 @@ struct BridgedBuilder{ BridgedSILTypeArray elementTypes, BridgedValueArray elementCountOperands) const; SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedInstruction - createAllocStack(BridgedType type, OptionalBridgedSILDebugVariable debugVar, + createAllocStack(BridgedType type, BridgedSILDebugVariable debugVar, bool hasDynamicLifetime, bool isLexical, bool isFromVarDecl, bool wasMoved) const; + SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedInstruction + createAllocStack(BridgedType type, bool hasDynamicLifetime, bool isLexical, bool isFromVarDecl, bool wasMoved) const; SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedInstruction createAllocVector(BridgedValue capacity, BridgedType type) const; SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedInstruction createDeallocStack(BridgedValue operand) const; diff --git a/include/swift/SIL/SILBridgingImpl.h b/include/swift/SIL/SILBridgingImpl.h index 6b597c72c4bce..d5dca81fbcc13 100644 --- a/include/swift/SIL/SILBridgingImpl.h +++ b/include/swift/SIL/SILBridgingImpl.h @@ -2184,16 +2184,25 @@ BridgedInstruction BridgedBuilder::createAllocRef(BridgedType type, } BridgedInstruction BridgedBuilder::createAllocStack(BridgedType type, - OptionalBridgedSILDebugVariable debugVar, + BridgedSILDebugVariable debugVar, bool hasDynamicLifetime, bool isLexical, bool isFromVarDecl, bool wasMoved) const { - std::optional var = std::nullopt; - if (debugVar.hasDebugVar) - var = debugVar.debugVar.unbridge(); return {unbridged().createAllocStack( - regularLoc(), type.unbridged(), var, + regularLoc(), type.unbridged(), debugVar.unbridge(), + swift::HasDynamicLifetime_t(hasDynamicLifetime), + swift::IsLexical_t(isLexical), swift::IsFromVarDecl_t(isFromVarDecl), + swift::UsesMoveableValueDebugInfo_t(wasMoved), /*skipVarDeclAssert=*/ true)}; +} + +BridgedInstruction BridgedBuilder::createAllocStack(BridgedType type, + bool hasDynamicLifetime, + bool isLexical, + bool isFromVarDecl, + bool wasMoved) const { + return {unbridged().createAllocStack( + regularLoc(), type.unbridged(), std::nullopt, swift::HasDynamicLifetime_t(hasDynamicLifetime), swift::IsLexical_t(isLexical), swift::IsFromVarDecl_t(isFromVarDecl), swift::UsesMoveableValueDebugInfo_t(wasMoved), /*skipVarDeclAssert=*/ true)};