Skip to content

Commit 910d63e

Browse files
committed
[DebugInfo] Remove conflicting debug info in switch
For address-only types, a temporary was emitted with the same debug variable and same scope as the instruction it is moved to after entering a shared case, but it would have a different type, which would create a conflict. The better way to fix this would probably to use a different scope for both, but the variable is moved immediately anyway. (cherry picked from commit 04ab380)
1 parent a88b4e4 commit 910d63e

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

lib/SILGen/SILGenPattern.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2870,7 +2870,12 @@ void PatternMatchEmission::emitAddressOnlyAllocations() {
28702870
if (!ty.isAddressOnly(SGF.F))
28712871
continue;
28722872
assert(!Temporaries[vd]);
2873-
Temporaries[vd] = SGF.emitTemporaryAllocation(vd, ty);
2873+
// Don't generate debug info for the temporary, as another debug_value
2874+
// will be created in the body, with the same scope and a different type
2875+
// Not sure if this is the best way to avoid that?
2876+
Temporaries[vd] = SGF.emitTemporaryAllocation(
2877+
vd, ty, DoesNotHaveDynamicLifetime, IsNotLexical, IsNotFromVarDecl,
2878+
/* generateDebugInfo = */ false);
28742879
}
28752880
}
28762881

test/SILGen/switch.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,9 +1461,9 @@ func testVoidType() {
14611461

14621462
// CHECK-LABEL: sil hidden [ossa] @$s6switch28addressOnlyFallthroughCalleeyyAA015MultipleAddressC8CaseEnumOyxGSzRzlF : $@convention(thin) <T where T : BinaryInteger> (@in_guaranteed MultipleAddressOnlyCaseEnum<T>) -> () {
14631463
// CHECK: bb0([[ARG:%.*]] :
1464-
// CHECK: [[AB_PHI:%.*]] = alloc_stack $T, let, name "x"
1465-
// CHECK: [[ABB_PHI:%.*]] = alloc_stack $T, let, name "x"
1466-
// CHECK: [[ABBC_PHI:%.*]] = alloc_stack $T, let, name "x"
1464+
// CHECK: [[AB_PHI:%.*]] = alloc_stack $T
1465+
// CHECK: [[ABB_PHI:%.*]] = alloc_stack $T
1466+
// CHECK: [[ABBC_PHI:%.*]] = alloc_stack $T
14671467
// CHECK: [[SWITCH_ENUM_ARG:%.*]] = alloc_stack $MultipleAddressOnlyCaseEnum<T>
14681468
// CHECK: copy_addr [[ARG]] to [init] [[SWITCH_ENUM_ARG]]
14691469
// CHECK: switch_enum_addr [[SWITCH_ENUM_ARG]] : $*MultipleAddressOnlyCaseEnum<T>, case #MultipleAddressOnlyCaseEnum.a!enumelt: [[BB_A:bb[0-9]+]], case #MultipleAddressOnlyCaseEnum.b!enumelt: [[BB_B:bb[0-9]+]], case #MultipleAddressOnlyCaseEnum.c!enumelt: [[BB_C:bb[0-9]+]]

0 commit comments

Comments
 (0)