Skip to content

Commit 57d3bd6

Browse files
author
git apple-llvm automerger
committed
Merge commit 'b4274c3bc8ee' from llvm.org/release/21.x into stable/21.x
2 parents b9b9344 + b4274c3 commit 57d3bd6

File tree

4 files changed

+69
-16
lines changed

4 files changed

+69
-16
lines changed

clang/lib/CodeGen/CGCall.cpp

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4796,19 +4796,6 @@ struct DestroyUnpassedArg final : EHScopeStack::Cleanup {
47964796
}
47974797
};
47984798

4799-
struct DisableDebugLocationUpdates {
4800-
CodeGenFunction &CGF;
4801-
bool disabledDebugInfo;
4802-
DisableDebugLocationUpdates(CodeGenFunction &CGF, const Expr *E) : CGF(CGF) {
4803-
if ((disabledDebugInfo = isa<CXXDefaultArgExpr>(E) && CGF.getDebugInfo()))
4804-
CGF.disableDebugInfo();
4805-
}
4806-
~DisableDebugLocationUpdates() {
4807-
if (disabledDebugInfo)
4808-
CGF.enableDebugInfo();
4809-
}
4810-
};
4811-
48124799
} // end anonymous namespace
48134800

48144801
RValue CallArg::getRValue(CodeGenFunction &CGF) const {
@@ -4845,7 +4832,9 @@ void CodeGenFunction::EmitWritebacks(const CallArgList &args) {
48454832

48464833
void CodeGenFunction::EmitCallArg(CallArgList &args, const Expr *E,
48474834
QualType type) {
4848-
DisableDebugLocationUpdates Dis(*this, E);
4835+
std::optional<DisableDebugLocationUpdates> Dis;
4836+
if (isa<CXXDefaultArgExpr>(E))
4837+
Dis.emplace(*this);
48494838
if (const ObjCIndirectCopyRestoreExpr *CRE =
48504839
dyn_cast<ObjCIndirectCopyRestoreExpr>(E)) {
48514840
assert(getLangOpts().ObjCAutoRefCount);
@@ -6238,3 +6227,12 @@ RValue CodeGenFunction::EmitVAArg(VAArgExpr *VE, Address &VAListAddr,
62386227
return CGM.getABIInfo().EmitMSVAArg(*this, VAListAddr, Ty, Slot);
62396228
return CGM.getABIInfo().EmitVAArg(*this, VAListAddr, Ty, Slot);
62406229
}
6230+
6231+
DisableDebugLocationUpdates::DisableDebugLocationUpdates(CodeGenFunction &CGF)
6232+
: CGF(CGF) {
6233+
CGF.disableDebugInfo();
6234+
}
6235+
6236+
DisableDebugLocationUpdates::~DisableDebugLocationUpdates() {
6237+
CGF.enableDebugInfo();
6238+
}

clang/lib/CodeGen/CGCall.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,12 @@ inline FnInfoOpts &operator&=(FnInfoOpts &A, FnInfoOpts B) {
456456
return A;
457457
}
458458

459+
struct DisableDebugLocationUpdates {
460+
CodeGenFunction &CGF;
461+
DisableDebugLocationUpdates(CodeGenFunction &CGF);
462+
~DisableDebugLocationUpdates();
463+
};
464+
459465
} // end namespace CodeGen
460466
} // end namespace clang
461467

clang/lib/CodeGen/CGExpr.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3810,7 +3810,14 @@ LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) {
38103810
auto *FD = LambdaCaptureFields.lookup(BD);
38113811
return EmitCapturedFieldLValue(*this, FD, CXXABIThisValue);
38123812
}
3813-
return EmitLValue(BD->getBinding());
3813+
// Suppress debug location updates when visiting the binding, since the
3814+
// binding may emit instructions that would otherwise be associated with the
3815+
// binding itself, rather than the expression referencing the binding. (this
3816+
// leads to jumpy debug stepping behavior where the location/debugger jump
3817+
// back to the binding declaration, then back to the expression referencing
3818+
// the binding)
3819+
DisableDebugLocationUpdates D(*this);
3820+
return EmitLValue(BD->getBinding(), NotKnownNonNull);
38143821
}
38153822

38163823
// We can form DeclRefExprs naming GUID declarations when reconstituting

clang/test/CodeGenCXX/debug-info-structured-binding.cpp

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
// CHECK: #dbg_declare(ptr %{{[0-9]+}}, ![[VAR_4:[0-9]+]], !DIExpression(DW_OP_deref, DW_OP_plus_uconst, 4),
88
// CHECK: #dbg_declare(ptr %z1, ![[VAR_5:[0-9]+]], !DIExpression()
99
// CHECK: #dbg_declare(ptr %z2, ![[VAR_6:[0-9]+]], !DIExpression()
10+
// CHECK: getelementptr inbounds nuw %struct.A, ptr {{.*}}, i32 0, i32 1, !dbg ![[Y1_DEBUG_LOC:[0-9]+]]
11+
// CHECK: getelementptr inbounds nuw %struct.A, ptr {{.*}}, i32 0, i32 1, !dbg ![[Y2_DEBUG_LOC:[0-9]+]]
12+
// CHECK: load ptr, ptr %z2, {{.*}}!dbg ![[Z2_DEBUG_LOC:[0-9]+]]
13+
// CHECK: getelementptr inbounds [2 x i32], ptr {{.*}}, i64 0, i64 1, !dbg ![[A2_DEBUG_LOC:[0-9]+]]
14+
// CHECK: getelementptr inbounds nuw { i32, i32 }, ptr {{.*}}, i32 0, i32 1, !dbg ![[C2_DEBUG_LOC:[0-9]+]]
15+
// CHECK: extractelement <2 x i32> {{.*}}, i32 1, !dbg ![[V2_DEBUG_LOC:[0-9]+]]
1016
// CHECK: ![[VAR_0]] = !DILocalVariable(name: "a"
1117
// CHECK: ![[VAR_1]] = !DILocalVariable(name: "x1", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}})
1218
// CHECK: ![[VAR_2]] = !DILocalVariable(name: "y1", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}})
@@ -46,5 +52,41 @@ int f() {
4652
auto [x1, y1] = a;
4753
auto &[x2, y2] = a;
4854
auto [z1, z2] = B{1, 2};
49-
return x1 + y1 + x2 + y2 + z1 + z2;
55+
int array[2] = {3, 4};
56+
auto &[a1, a2] = array;
57+
_Complex int cmplx = {1, 2};
58+
auto &[c1, c2] = cmplx;
59+
int vctr __attribute__ ((vector_size (sizeof(int)*2)))= {1, 2};
60+
auto &[v1, v2] = vctr;
61+
return //
62+
x1 //
63+
+ //
64+
// CHECK: ![[Y1_DEBUG_LOC]] = !DILocation(line: [[@LINE+1]]
65+
y1 //
66+
+ //
67+
x2 //
68+
+ //
69+
// CHECK: ![[Y2_DEBUG_LOC]] = !DILocation(line: [[@LINE+1]]
70+
y2 //
71+
+ //
72+
z1 //
73+
+ //
74+
// CHECK: ![[Z2_DEBUG_LOC]] = !DILocation(line: [[@LINE+1]]
75+
z2 //
76+
+ //
77+
a1 //
78+
+ //
79+
// CHECK: ![[A2_DEBUG_LOC]] = !DILocation(line: [[@LINE+1]]
80+
a2 //
81+
+ //
82+
c1 //
83+
+ //
84+
// CHECK: ![[C2_DEBUG_LOC]] = !DILocation(line: [[@LINE+1]]
85+
c2 //
86+
+ //
87+
v1 //
88+
+ //
89+
// CHECK: ![[V2_DEBUG_LOC]] = !DILocation(line: [[@LINE+1]]
90+
v2 //
91+
;
5092
}

0 commit comments

Comments
 (0)