Skip to content
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
6 changes: 5 additions & 1 deletion lib/SIL/Verifier/SILVerifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1657,7 +1657,11 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {

require(lhs == rhs ||
(lhs.isAddress() && lhs.getObjectType() == rhs) ||
(DebugVarTy.isAddress() && lhs == rhs.getObjectType()),
(DebugVarTy.isAddress() && lhs == rhs.getObjectType()) ||

// When cloning SIL (e.g. in LoopUnroll) local archetypes are uniqued
// and therefore distinct in cloned instructions.
(lhs.hasLocalArchetype() && rhs.hasLocalArchetype()),
"Two variables with different type but same scope!");
}

Expand Down
27 changes: 27 additions & 0 deletions test/SIL/verifier-archetype-debugvars.sil
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// RUN: %target-sil-opt %s

sil_stage canonical

import Builtin
import Swift
import SwiftShims

protocol P {}

sil_scope 2 { loc "test.swift":1:6 parent @testit : $@convention(thin) (@in_guaranteed any P) -> () }
sil_scope 3 { loc "test.swift":2:7 parent 2 }

// Check that the verifier does not complain about two alloc_stacks with the same variable but different existential archetypes.

sil @testit : $@convention(thin) (@in_guaranteed any P) -> () {
bb0(%0 : $*any P):
%1 = open_existential_addr immutable_access %0 to $*@opened("2A0E9166-A9AC-11F0-A5A7-0EA13E3AABAF", any P) Self
%2 = alloc_stack [lexical] $@opened("2A0E9166-A9AC-11F0-A5A7-0EA13E3AABAF", any P) Self, var, name "x", loc "test.swift":2:7, scope 3
dealloc_stack %2
%4 = open_existential_addr immutable_access %0 to $*@opened("3A0E9166-A9AC-11F0-A5A7-0EA13E3AABAF", any P) Self
%5 = alloc_stack [lexical] $@opened("3A0E9166-A9AC-11F0-A5A7-0EA13E3AABAF", any P) Self, var, name "x", loc "test.swift":2:7, scope 3
dealloc_stack %5
%r = tuple ()
return %r
}