Skip to content

Commit d5b4a17

Browse files
authored
Merge pull request #74992 from atrick/markdep-opers
Assert that mark_dependence operands are distinct.
2 parents e61f514 + ad2e58e commit d5b4a17

File tree

2 files changed

+3
-15
lines changed

2 files changed

+3
-15
lines changed

SwiftCompilerSources/Sources/Optimizer/Utilities/LifetimeDependenceUtils.swift

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -101,21 +101,7 @@ func gatherVariableIntroducers(for value: Value, _ context: Context)
101101
/// bb0(%dependent : NonEscapableThing):
102102
///
103103
/// A lifetime dependence identifies its parent value, the kind of
104-
/// scope that the parent value represents, and a dependent value. A
105-
/// self-dependence has the same parent and dependent value:
106-
///
107-
/// %dependent = mark_dependence [nonescaping] %value on %value
108-
///
109-
/// Self-dependence is useful to ensure that derived values, including
110-
/// copies, do not escape the lifetime of the original
111-
/// value. Non-escapable function arguments are implicitly
112-
/// self-dependent, meaning that the argument's value does not escape
113-
/// the function body. Note that we do not insert a 'mark_dependence
114-
/// [nonescaping]' for function arguments because the caller must
115-
/// already represent the argument's dependence on some parent
116-
/// value. That parent value may not be the value directly passed to
117-
/// the argument. After inlining, an additional self-dependence on
118-
/// argument value would be overly strict.
104+
/// scope that the parent value represents, and a dependent value.
119105
struct LifetimeDependence : CustomStringConvertible {
120106
enum Scope : CustomStringConvertible {
121107
/// A guaranteed or inout argument whose scope is provided by the caller

lib/SIL/Verifier/SILVerifier.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2147,6 +2147,8 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
21472147
}
21482148

21492149
void checkMarkDependencInst(MarkDependenceInst *MDI) {
2150+
require(isa<SILUndef>(MDI->getValue()) || MDI->getValue() != MDI->getBase(),
2151+
"mark_dependence operands must be distinct");
21502152
if (MDI->isNonEscaping()) {
21512153
require(F.hasOwnership(), "mark_dependence [nonescaping] requires OSSA");
21522154
require(MDI->getOwnershipKind() == OwnershipKind::Owned,

0 commit comments

Comments
 (0)