Skip to content

Merge pull request #12484 from shajrawi/relax_verify #12526

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/SIL/SILVerifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2405,6 +2405,7 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
if (!isConsumingOrMutatingApplyUse(use))
return true;
break;
case ValueKind::StructElementAddrInst:
case ValueKind::LoadInst:
case ValueKind::DebugValueAddrInst:
if (I->hasOneUse())
Expand Down
37 changes: 37 additions & 0 deletions test/SILOptimizer/sil_combine1.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// RUN: %target-swift-frontend %s -O -emit-sil | %FileCheck %s

func curry<T1, T2, T3, T4>(_ f: @escaping (T1, T2, T3) -> T4) -> (T1) -> (T2) -> (T3) -> T4 {
return { x in { y in { z in f(x, y, z) } } }
}

public protocol P {
func val() -> Int32
}

struct CP: P {
let v: Int32

func val() -> Int32 {
return v
}

init(_ v: Int32) {
self.v = v
}
}

func compose(_ x: P, _ y: P, _ z: P) -> Int32 {
return x.val() + y.val() + z.val()
}

//CHECK-LABEL: sil [noinline] @_T012sil_combine120test_compose_closures5Int32VyF : $@convention(thin) () -> Int32 {
//CHECK: [[OEADDR:%.*]] = open_existential_addr immutable_access {{%.*}} : $*P to $*@opened
//CHECK: [[ADDRCAST:%.*]] = unchecked_addr_cast [[OEADDR]] : $*@opened
//CHECK: struct_element_addr [[ADDRCAST]] : $*CP, #CP.v
@inline(never)
public func test_compose_closure() -> Int32 {
let insult = curry(compose)(CP(1))(CP(2))
let gs = insult(CP(3))
return gs
}