Skip to content

Commit b1774aa

Browse files
authored
Merge pull request #84945 from eeckstein/fix-debugvar-verification
SILVerifier: relax the check for debug vars with different types
2 parents 4c33e75 + 395db88 commit b1774aa

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

lib/SIL/Verifier/SILVerifier.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1657,7 +1657,11 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
16571657

16581658
require(lhs == rhs ||
16591659
(lhs.isAddress() && lhs.getObjectType() == rhs) ||
1660-
(DebugVarTy.isAddress() && lhs == rhs.getObjectType()),
1660+
(DebugVarTy.isAddress() && lhs == rhs.getObjectType()) ||
1661+
1662+
// When cloning SIL (e.g. in LoopUnroll) local archetypes are uniqued
1663+
// and therefore distinct in cloned instructions.
1664+
(lhs.hasLocalArchetype() && rhs.hasLocalArchetype()),
16611665
"Two variables with different type but same scope!");
16621666
}
16631667

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// RUN: %target-sil-opt %s
2+
3+
sil_stage canonical
4+
5+
import Builtin
6+
import Swift
7+
import SwiftShims
8+
9+
protocol P {}
10+
11+
sil_scope 2 { loc "test.swift":1:6 parent @testit : $@convention(thin) (@in_guaranteed any P) -> () }
12+
sil_scope 3 { loc "test.swift":2:7 parent 2 }
13+
14+
// Check that the verifier does not complain about two alloc_stacks with the same variable but different existential archetypes.
15+
16+
sil @testit : $@convention(thin) (@in_guaranteed any P) -> () {
17+
bb0(%0 : $*any P):
18+
%1 = open_existential_addr immutable_access %0 to $*@opened("2A0E9166-A9AC-11F0-A5A7-0EA13E3AABAF", any P) Self
19+
%2 = alloc_stack [lexical] $@opened("2A0E9166-A9AC-11F0-A5A7-0EA13E3AABAF", any P) Self, var, name "x", loc "test.swift":2:7, scope 3
20+
dealloc_stack %2
21+
%4 = open_existential_addr immutable_access %0 to $*@opened("3A0E9166-A9AC-11F0-A5A7-0EA13E3AABAF", any P) Self
22+
%5 = alloc_stack [lexical] $@opened("3A0E9166-A9AC-11F0-A5A7-0EA13E3AABAF", any P) Self, var, name "x", loc "test.swift":2:7, scope 3
23+
dealloc_stack %5
24+
%r = tuple ()
25+
return %r
26+
}
27+

0 commit comments

Comments
 (0)