Skip to content

Commit 2113752

Browse files
authored
Merge pull request #82678 from eeckstein/fix-bridged-debug-var
SILBridging: remove OptionalBridgedSILDebugVariable
2 parents dc88058 + 1343dc5 commit 2113752

File tree

3 files changed

+23
-20
lines changed

3 files changed

+23
-20
lines changed

SwiftCompilerSources/Sources/SIL/Builder.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,15 @@ public struct Builder {
127127
hasDynamicLifetime: Bool = false,
128128
isLexical: Bool = false, isFromVarDecl: Bool = false,
129129
usesMoveableValueDebugInfo: Bool = false) -> AllocStackInst {
130-
let bridgedDebugVar: OptionalBridgedSILDebugVariable
130+
let allocStack: BridgedInstruction
131131
if let debugVariable = debugVariable {
132-
bridgedDebugVar = OptionalBridgedSILDebugVariable(debugVariable)
132+
allocStack = bridged.createAllocStack(type.bridged, debugVariable, hasDynamicLifetime, isLexical,
133+
isFromVarDecl, usesMoveableValueDebugInfo)
133134
} else {
134-
bridgedDebugVar = OptionalBridgedSILDebugVariable()
135+
allocStack = bridged.createAllocStack(type.bridged, hasDynamicLifetime, isLexical,
136+
isFromVarDecl, usesMoveableValueDebugInfo)
135137
}
136-
let dr = bridged.createAllocStack(type.bridged, bridgedDebugVar, hasDynamicLifetime, isLexical,
137-
isFromVarDecl, usesMoveableValueDebugInfo)
138-
return notifyNew(dr.getAs(AllocStackInst.self))
138+
return notifyNew(allocStack.getAs(AllocStackInst.self))
139139
}
140140

141141
@discardableResult

include/swift/SIL/SILBridging.h

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -636,14 +636,6 @@ struct BridgedSILDebugVariable {
636636
BRIDGED_INLINE swift::SILDebugVariable unbridge() const;
637637
};
638638

639-
struct OptionalBridgedSILDebugVariable {
640-
BridgedSILDebugVariable debugVar;
641-
bool hasDebugVar = false;
642-
643-
OptionalBridgedSILDebugVariable() {}
644-
OptionalBridgedSILDebugVariable(BridgedSILDebugVariable d) : debugVar(d), hasDebugVar(true) {}
645-
};
646-
647639
struct BridgedInstruction {
648640
SwiftObject obj;
649641

@@ -1170,8 +1162,10 @@ struct BridgedBuilder{
11701162
BridgedSILTypeArray elementTypes, BridgedValueArray elementCountOperands) const;
11711163

11721164
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedInstruction
1173-
createAllocStack(BridgedType type, OptionalBridgedSILDebugVariable debugVar,
1165+
createAllocStack(BridgedType type, BridgedSILDebugVariable debugVar,
11741166
bool hasDynamicLifetime, bool isLexical, bool isFromVarDecl, bool wasMoved) const;
1167+
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedInstruction
1168+
createAllocStack(BridgedType type, bool hasDynamicLifetime, bool isLexical, bool isFromVarDecl, bool wasMoved) const;
11751169
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedInstruction createAllocVector(BridgedValue capacity,
11761170
BridgedType type) const;
11771171
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedInstruction createDeallocStack(BridgedValue operand) const;

include/swift/SIL/SILBridgingImpl.h

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2184,16 +2184,25 @@ BridgedInstruction BridgedBuilder::createAllocRef(BridgedType type,
21842184
}
21852185

21862186
BridgedInstruction BridgedBuilder::createAllocStack(BridgedType type,
2187-
OptionalBridgedSILDebugVariable debugVar,
2187+
BridgedSILDebugVariable debugVar,
21882188
bool hasDynamicLifetime,
21892189
bool isLexical,
21902190
bool isFromVarDecl,
21912191
bool wasMoved) const {
2192-
std::optional<swift::SILDebugVariable> var = std::nullopt;
2193-
if (debugVar.hasDebugVar)
2194-
var = debugVar.debugVar.unbridge();
21952192
return {unbridged().createAllocStack(
2196-
regularLoc(), type.unbridged(), var,
2193+
regularLoc(), type.unbridged(), debugVar.unbridge(),
2194+
swift::HasDynamicLifetime_t(hasDynamicLifetime),
2195+
swift::IsLexical_t(isLexical), swift::IsFromVarDecl_t(isFromVarDecl),
2196+
swift::UsesMoveableValueDebugInfo_t(wasMoved), /*skipVarDeclAssert=*/ true)};
2197+
}
2198+
2199+
BridgedInstruction BridgedBuilder::createAllocStack(BridgedType type,
2200+
bool hasDynamicLifetime,
2201+
bool isLexical,
2202+
bool isFromVarDecl,
2203+
bool wasMoved) const {
2204+
return {unbridged().createAllocStack(
2205+
regularLoc(), type.unbridged(), std::nullopt,
21972206
swift::HasDynamicLifetime_t(hasDynamicLifetime),
21982207
swift::IsLexical_t(isLexical), swift::IsFromVarDecl_t(isFromVarDecl),
21992208
swift::UsesMoveableValueDebugInfo_t(wasMoved), /*skipVarDeclAssert=*/ true)};

0 commit comments

Comments
 (0)