Skip to content

Commit 796554f

Browse files
committed
[embedded] Respect ownership in SimplifyKeyPath, emit destroy_value instructions for keypath operands
1 parent b642d77 commit 796554f

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

SwiftCompilerSources/Sources/Optimizer/InstructionSimplification/SimplifyKeyPath.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ import SIL
1515
extension KeyPathInst : OnoneSimplifyable {
1616
func simplify(_ context: SimplifyContext) {
1717
if allUsesRemovable(instruction: self) {
18+
if parentFunction.hasOwnership {
19+
let builder = Builder(after: self, context)
20+
for operand in self.operands {
21+
if !operand.value.type.isTrivial(in: parentFunction) {
22+
builder.createDestroyValue(operand: operand.value)
23+
}
24+
}
25+
}
1826
context.erase(instructionIncludingAllUsers: self)
1927
}
2028
}

0 commit comments

Comments
 (0)