llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Carlos Alberto Enciso (CarlosAlbertoEnciso) <details> <summary>Changes</summary> Do not emit call to llvm.dbg.declare when the variable declaration is a DecompositionDecl as its instance class is always unnamed. The emitted debug declare looks like: ``` call void @<!-- -->llvm.dbg.declare(metadata ..., metadata !xx, metadata ...) !xx = !DILocalVariable(scope: !..., file: !..., line: ..., type: !...) ``` --- Full diff: https://github.com/llvm/llvm-project/pull/69681.diff 4 Files Affected: - (modified) clang/lib/CodeGen/CGDebugInfo.cpp (+5-1) - (modified) clang/test/CodeGenCXX/debug-info-structured-binding-bitfield.cpp (-3) - (added) clang/test/CodeGenCXX/debug-info-structured-binding-field.cpp (+20) - (modified) clang/test/CodeGenCXX/debug-info-structured-binding.cpp (-2) ``````````diff diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index c430713b0d77d79..b2646cd1d2a0f53 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -4879,11 +4879,15 @@ CGDebugInfo::EmitDeclareOfAutoVariable(const VarDecl *VD, llvm::Value *Storage, const bool UsePointerValue) { assert(CGM.getCodeGenOpts().hasReducedDebugInfo()); - if (auto *DD = dyn_cast<DecompositionDecl>(VD)) + if (auto *DD = dyn_cast<DecompositionDecl>(VD)) { for (auto *B : DD->bindings()) { EmitDeclare(B, Storage, std::nullopt, Builder, VD->getType()->isReferenceType()); } + // Don't emit an llvm.dbg.declare for the composite storage as it doesn't + // correspond to a user variable. + return nullptr; + } return EmitDeclare(VD, Storage, std::nullopt, Builder, UsePointerValue); } diff --git a/clang/test/CodeGenCXX/debug-info-structured-binding-bitfield.cpp b/clang/test/CodeGenCXX/debug-info-structured-binding-bitfield.cpp index b5ee96224565d3a..0234e41009f6225 100644 --- a/clang/test/CodeGenCXX/debug-info-structured-binding-bitfield.cpp +++ b/clang/test/CodeGenCXX/debug-info-structured-binding-bitfield.cpp @@ -189,7 +189,6 @@ struct S11 { // CHECK-LABEL: define dso_local void @_Z4fS11v // CHECK: alloca %struct.S11, align 4 // CHECK-NEXT: [[TMP0:%.*]] = alloca %struct.S11, align 4 -// CHECK: call void @llvm.dbg.declare(metadata ptr [[TMP0]] // CHECK-NOT: call void @llvm.dbg.declare(metadata ptr [[TMP0]] // void fS11() { @@ -206,7 +205,6 @@ struct S12 { // CHECK: alloca %struct.S12, align 4 // CHECK-NEXT: [[TMP0:%.*]] = alloca %struct.S12, align 4 // CHECK: call void @llvm.dbg.declare(metadata ptr [[TMP0]], metadata [[S12_A:![0-9]+]], metadata !DIExpression()) -// CHECK: call void @llvm.dbg.declare(metadata ptr [[TMP0]] // CHECK-NOT: call void @llvm.dbg.declare(metadata ptr [[TMP0]] // void fS12() { @@ -222,7 +220,6 @@ struct __attribute__((packed)) S13 { // CHECK-LABEL: define dso_local void @_Z4fS13v // CHECK: alloca %struct.S13, align 1 // CHECK-NEXT: [[TMP0:%.*]] = alloca %struct.S13, align 1 -// CHECK: call void @llvm.dbg.declare(metadata ptr [[TMP0]], metadata {{.*}}, metadata !DIExpression()) // CHECK-NOT: call void @llvm.dbg.declare(metadata ptr [[TMP0]] // void fS13() { diff --git a/clang/test/CodeGenCXX/debug-info-structured-binding-field.cpp b/clang/test/CodeGenCXX/debug-info-structured-binding-field.cpp new file mode 100644 index 000000000000000..928d22776d21093 --- /dev/null +++ b/clang/test/CodeGenCXX/debug-info-structured-binding-field.cpp @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 -emit-llvm -debug-info-kind=standalone %s -o - | FileCheck %s + +struct Tuple { + int Fld_1; + int Fld_2; +}; +__attribute__((optnone)) Tuple get() { return {10, 20}; } + +// CHECK-LABEL: define dso_local noundef i32 @main +// CHECK: %retval = alloca i32, align 4 +// CHECK-NEXT: [[T0:%.*]] = alloca %struct.Tuple, align 4 +// CHECK: call void @llvm.dbg.declare(metadata ptr [[T0]], metadata {{.*}}, metadata !DIExpression()) +// CHECK: call void @llvm.dbg.declare(metadata ptr [[T0]], metadata {{.*}}, metadata !DIExpression(DW_OP_plus_uconst, {{[0-9]+}})) +// CHECK-NOT: call void @llvm.dbg.declare(metadata ptr [[T0]], metadata {{.*}}, metadata !DIExpression()) +// +int main() { + auto [Var_1, Var_2] = get(); + + return Var_1 + Var_2; +} diff --git a/clang/test/CodeGenCXX/debug-info-structured-binding.cpp b/clang/test/CodeGenCXX/debug-info-structured-binding.cpp index 8d4ae0aaf32636b..163c152efa19d0b 100644 --- a/clang/test/CodeGenCXX/debug-info-structured-binding.cpp +++ b/clang/test/CodeGenCXX/debug-info-structured-binding.cpp @@ -2,10 +2,8 @@ // CHECK: call void @llvm.dbg.declare(metadata ptr %{{[0-9]+}}, metadata !{{[0-9]+}}, metadata !DIExpression()) // CHECK: call void @llvm.dbg.declare(metadata ptr %{{[0-9]+}}, metadata !{{[0-9]+}}, metadata !DIExpression(DW_OP_plus_uconst, {{[0-9]+}})) -// CHECK: call void @llvm.dbg.declare(metadata ptr %{{[0-9]+}}, metadata !{{[0-9]+}}, metadata !DIExpression()) // CHECK: call void @llvm.dbg.declare(metadata ptr %{{[0-9]+}}, metadata !{{[0-9]+}}, metadata !DIExpression(DW_OP_deref)) // CHECK: call void @llvm.dbg.declare(metadata ptr %{{[0-9]+}}, metadata !{{[0-9]+}}, metadata !DIExpression(DW_OP_deref, DW_OP_plus_uconst, {{[0-9]+}})) -// CHECK: call void @llvm.dbg.declare(metadata ptr %{{[0-9]+}}, metadata !{{[0-9]+}}, metadata !DIExpression()) struct A { int x; int y; `````````` </details> https://github.com/llvm/llvm-project/pull/69681 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits