Skip to content

Commit 51c6a60

Browse files
committed
SIL Verifier: check that an instruction with a guaranteed result is either a BeginBorrowValue or a ForwardingInstruction
1 parent c5b14c2 commit 51c6a60

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

SwiftCompilerSources/Sources/Optimizer/Utilities/Verifier.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ extension Function {
3535
for inst in block.instructions {
3636

3737
inst.checkForwardingConformance()
38+
inst.checkGuaranteedResults()
3839

3940
if let verifiableInst = inst as? VerifiableInstruction {
4041
verifiableInst.verify(context)
@@ -52,6 +53,13 @@ private extension Instruction {
5253
require(!(self is ForwardingInstruction), "instruction \(self)\nshould not conform to ForwardingInstruction")
5354
}
5455
}
56+
57+
func checkGuaranteedResults() {
58+
for result in results where result.ownership == .guaranteed {
59+
require(BeginBorrowValue(result) != nil || self is ForwardingInstruction,
60+
"\(result) must either be a BeginBorrowValue or a ForwardingInstruction")
61+
}
62+
}
5563
}
5664

5765
private extension Argument {

0 commit comments

Comments
 (0)