Skip to content

Commit b67aaef

Browse files
author
Greg Parker
authored
Merge pull request #12484 from shajrawi/relax_verify
Relax the open_existential_addr immutable_access verifier further after sil-combine bail-out
2 parents 23b519a + b9c93bd commit b67aaef

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

lib/SIL/SILVerifier.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2412,6 +2412,7 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
24122412
if (!isConsumingOrMutatingApplyUse(use))
24132413
return true;
24142414
break;
2415+
case SILInstructionKind::StructElementAddrInst:
24152416
case SILInstructionKind::LoadInst:
24162417
case SILInstructionKind::DebugValueAddrInst:
24172418
if (I->hasOneUse())

test/SILOptimizer/sil_combine1.swift

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// RUN: %target-swift-frontend %s -O -emit-sil | %FileCheck %s
2+
3+
func curry<T1, T2, T3, T4>(_ f: @escaping (T1, T2, T3) -> T4) -> (T1) -> (T2) -> (T3) -> T4 {
4+
return { x in { y in { z in f(x, y, z) } } }
5+
}
6+
7+
public protocol P {
8+
func val() -> Int32
9+
}
10+
11+
struct CP: P {
12+
let v: Int32
13+
14+
func val() -> Int32 {
15+
return v
16+
}
17+
18+
init(_ v: Int32) {
19+
self.v = v
20+
}
21+
}
22+
23+
func compose(_ x: P, _ y: P, _ z: P) -> Int32 {
24+
return x.val() + y.val() + z.val()
25+
}
26+
27+
//CHECK-LABEL: sil [noinline] @_T012sil_combine120test_compose_closures5Int32VyF : $@convention(thin) () -> Int32 {
28+
//CHECK: [[OEADDR:%.*]] = open_existential_addr immutable_access {{%.*}} : $*P to $*@opened
29+
//CHECK: [[ADDRCAST:%.*]] = unchecked_addr_cast [[OEADDR]] : $*@opened
30+
//CHECK: struct_element_addr [[ADDRCAST]] : $*CP, #CP.v
31+
@inline(never)
32+
public func test_compose_closure() -> Int32 {
33+
let insult = curry(compose)(CP(1))(CP(2))
34+
let gs = insult(CP(3))
35+
return gs
36+
}
37+

0 commit comments

Comments
 (0)