Skip to content

Commit 04ab380

Browse files
committedMar 20, 2024
[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.

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed
 

‎lib/SILGen/SILGenPattern.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -2867,7 +2867,12 @@ void PatternMatchEmission::emitAddressOnlyAllocations() {
28672867
if (!ty.isAddressOnly(SGF.F))
28682868
continue;
28692869
assert(!Temporaries[vd]);
2870-
Temporaries[vd] = SGF.emitTemporaryAllocation(vd, ty);
2870+
// Don't generate debug info for the temporary, as another debug_value
2871+
// will be created in the body, with the same scope and a different type
2872+
// Not sure if this is the best way to avoid that?
2873+
Temporaries[vd] = SGF.emitTemporaryAllocation(
2874+
vd, ty, DoesNotHaveDynamicLifetime, IsNotLexical, IsNotFromVarDecl,
2875+
/* generateDebugInfo = */ false);
28712876
}
28722877
}
28732878

‎test/SILGen/switch.swift

+3-3
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)
Please sign in to comment.