Skip to content

Commit 7ab6ce6

Browse files
committed
[IRGenDebugInfo] Allow multiple dbg.declare on an alloca
This is unnecessarily dropping debug info, as there is currently no assertion in LLVM. The sharing of stack slot can happen because of AllocStackHoisting, which is run at -Onone too. (cherry picked from commit 2726d83)
1 parent 8c230de commit 7ab6ce6

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

lib/IRGen/IRGenDebugInfo.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3401,11 +3401,6 @@ void IRGenDebugInfoImpl::emitDbgIntrinsic(
34013401
auto DL =
34023402
llvm::DILocation::get(IGM.getLLVMContext(), Line, Col, Scope, InlinedAt);
34033403

3404-
// An alloca may only be described by exactly one dbg.declare.
3405-
if (isa<llvm::AllocaInst>(Storage) &&
3406-
!llvm::FindDbgDeclareUses(Storage).empty())
3407-
return;
3408-
34093404
// Fragment DIExpression cannot cover the whole variable
34103405
// or going out-of-bound.
34113406
if (auto Fragment = Expr->getFragmentInfo()) {

test/DebugInfo/inlined-generics-basic.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public class C<R> {
5252
// SIL: function_ref {{.*}}use{{.*}} scope [[F1G3H]]
5353
// IR: dbg.value(metadata ptr %[[ARG_S]], metadata ![[MD_1_0:[0-9]+]]
5454
// IR: %[[RS_PAIR:.*]] = alloca i8, i{{.*}} %
55+
// IR: dbg.declare(metadata ptr %[[RS_PAIR]], metadata ![[GRS_U:[0-9]+]],
5556
// IR: dbg.declare(metadata ptr %[[RS_PAIR]], metadata ![[GRS_T:[0-9]+]],
5657
// IR: dbg.value(metadata ptr %[[ARG_0]], metadata ![[S:[0-9]+]]
5758
// IR: dbg.value(metadata ptr %[[ARG_0]], metadata ![[GS_T:[0-9]+]]
@@ -100,6 +101,8 @@ public class C<R> {
100101
// IR-DAG: ![[MD_1_0]] = !DILocalVariable(name: "$\CF\84_1_0"
101102
// IR-DAG: ![[GRS_T]] = !DILocalVariable(name: "t", {{.*}} scope: ![[SP_GRS_T:[0-9]+]], {{.*}}type: ![[LET_TUPLE:[0-9]+]]
102103
// IR-DAG: ![[SP_GRS_T]] = {{.*}}linkageName: "$s1A1gyyxlFx_qd__t_Ti5"
104+
// IR-DAG: ![[GRS_U]] = !DILocalVariable(name: "u", {{.*}} scope: ![[SP_GRS_U:[0-9]+]], {{.*}}type: ![[LET_TUPLE:[0-9]+]]
105+
// IR-DAG: ![[SP_GRS_U]] = {{.*}}linkageName: "$s1A1hyyxlFx_qd__t_Ti5"
103106
// IR-DAG: ![[LET_TUPLE]] = !DIDerivedType(tag: DW_TAG_const_type, baseType: ![[TUPLE:[0-9]+]])
104107
// IR-DAG: ![[TUPLE]] = {{.*}}DW_TAG_structure_type, name: "$sx_qd__tD"
105108
// IR-DAG: ![[S]] = !DILocalVariable(name: "s", {{.*}} type: ![[LET_TAU_1_0:[0-9]+]]

0 commit comments

Comments
 (0)