Skip to content

Commit 778d39d

Browse files
authored
Merge pull request #71566 from meg-gupta/fixhash
Fix Lifetime dependence function type hash
2 parents 2875980 + 0b4cba9 commit 778d39d

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

lib/Sema/LifetimeDependence.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,15 @@ std::string LifetimeDependenceInfo::getString() const {
4949

5050
void LifetimeDependenceInfo::Profile(llvm::FoldingSetNodeID &ID) const {
5151
if (inheritLifetimeParamIndices) {
52+
// Copy and Consume are the same, can be unified if we converge on dependsOn
53+
// syntax
54+
ID.AddInteger((uint8_t)LifetimeDependenceKind::Copy);
5255
inheritLifetimeParamIndices->Profile(ID);
5356
}
5457
if (scopeLifetimeParamIndices) {
58+
// Borrow and Mutate are the same, can be unified if we converge on
59+
// dependsOn syntax
60+
ID.AddInteger((uint8_t)LifetimeDependenceKind::Borrow);
5561
scopeLifetimeParamIndices->Profile(ID);
5662
}
5763
}

test/SIL/explicit_lifetime_dependence_specifiers.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,21 @@ struct Wrapper : ~Escapable {
102102
return view
103103
}
104104
}
105+
106+
struct Container {
107+
let ptr: UnsafeRawBufferPointer
108+
init(_ ptr: UnsafeRawBufferPointer) {
109+
self.ptr = ptr
110+
}
111+
}
112+
113+
// CHECK-LABEL: sil hidden @$s39explicit_lifetime_dependence_specifiers16getConsumingViewyAA06BufferG0VAA9ContainerVnF : $@convention(thin) (Container) -> _inherit(1) @owned BufferView {
114+
func getConsumingView(_ x: consuming Container) -> _consume(x) BufferView {
115+
return BufferView(x.ptr)
116+
}
117+
118+
// CHECK: sil hidden @$s39explicit_lifetime_dependence_specifiers16getBorrowingViewyAA06BufferG0VAA9ContainerVF : $@convention(thin) (Container) -> _scope(1) @owned BufferView {
119+
func getBorrowingView(_ x: borrowing Container) -> _borrow(x) BufferView {
120+
return BufferView(x.ptr)
121+
}
122+

test/SILOptimizer/lifetime_dependence_diagnostics.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func bv_copy(_ bv: borrowing BV) -> _copy(bv) BV {
2020

2121
// Diagnostics resolves mark_dependence [nonescaping].
2222
//
23-
// CHECK-LABEL: sil hidden @$s4test14bv_borrow_copy0B0AA2BVVAE_tF : $@convention(thin) (@guaranteed BV) -> _inherit(1) @owned BV {
23+
// CHECK-LABEL: sil hidden @$s4test14bv_borrow_copy0B0AA2BVVAE_tF : $@convention(thin) (@guaranteed BV) -> _scope(1) @owned BV {
2424
// CHECK: bb0(%0 : @noImplicitCopy $BV):
2525
// CHECK: [[R:%.*]] = apply %{{.*}}(%0) : $@convention(thin) (@guaranteed BV) -> _inherit(1) @owned BV
2626
// CHECK: [[MD:%.*]] = mark_dependence [nonescaping] [[R]] : $BV on %0 : $BV

0 commit comments

Comments
 (0)