1; RUN: opt -passes=declare-to-assign -S %s -o - | FileCheck %s 2; RUN: opt --try-experimental-debuginfo-iterators -passes=declare-to-assign -S %s -o - | FileCheck %s 3 4;; Check assignment tracking debug info for structured bindings. FIXME only 5;; variables at offset 0 in the backing alloca are currently tracked with the 6;; feature. 7 8;; struct two { int a, b; }; 9;; two get(); 10;; int fun() { 11;; auto [a,b] = get(); 12;; return a * b; 13;; } 14 15; CHECK: %0 = alloca %struct.two, align 4, !DIAssignID ![[ID1:[0-9]+]] 16; CHECK-NEXT: #dbg_assign(i1 undef, ![[AGGR:[0-9]+]], !DIExpression(), ![[ID1]], ptr %0, !DIExpression(), 17; CHECK-NEXT: #dbg_assign(i1 undef, ![[A:[0-9]+]], !DIExpression(), ![[ID1]], ptr %0, !DIExpression(), 18; CHECK-NEXT: #dbg_declare(ptr %0, ![[B:[0-9]+]], !DIExpression(DW_OP_plus_uconst, 4), 19 20; CHECK: store i64 %call, ptr %0, align 4,{{.*}}, !DIAssignID ![[ID2:[0-9]+]] 21; CHECK-NEXT: #dbg_assign(i64 %call, ![[AGGR]], !DIExpression(), ![[ID2]], ptr %0, !DIExpression(), 22; CHECK-NEXT: #dbg_assign(i64 %call, ![[A]], !DIExpression(), ![[ID2]], ptr %0, !DIExpression(), 23 24; CHECK: ![[AGGR]] = !DILocalVariable(scope: 25; CHECK: ![[A]] = !DILocalVariable(name: "a", scope: 26; CHECK: ![[B]] = !DILocalVariable(name: "b", scope: 27 28%struct.two = type { i32, i32 } 29 30define dso_local noundef i32 @_Z3funv() #0 !dbg !10 { 31entry: 32 %0 = alloca %struct.two, align 4 33 call void @llvm.dbg.declare(metadata ptr %0, metadata !15, metadata !DIExpression()), !dbg !16 34 call void @llvm.dbg.declare(metadata ptr %0, metadata !17, metadata !DIExpression(DW_OP_plus_uconst, 4)), !dbg !18 35 call void @llvm.dbg.declare(metadata ptr %0, metadata !19, metadata !DIExpression()), !dbg !24 36 %call = call i64 @_Z3getv(), !dbg !25 37 store i64 %call, ptr %0, align 4, !dbg !25 38 %a = getelementptr inbounds %struct.two, ptr %0, i32 0, i32 0, !dbg !16 39 %1 = load i32, ptr %a, align 4, !dbg !26 40 %b = getelementptr inbounds %struct.two, ptr %0, i32 0, i32 1, !dbg !18 41 %2 = load i32, ptr %b, align 4, !dbg !27 42 %mul = mul nsw i32 %1, %2, !dbg !28 43 ret i32 %mul, !dbg !29 44} 45 46declare void @llvm.dbg.declare(metadata, metadata, metadata) 47declare i64 @_Z3getv() 48 49!llvm.dbg.cu = !{!0} 50!llvm.module.flags = !{!2, !3, !4, !5, !6, !7, !8} 51!llvm.ident = !{!9} 52 53!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 17.0.0)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None) 54!1 = !DIFile(filename: "test.cpp", directory: "/") 55!2 = !{i32 7, !"Dwarf Version", i32 5} 56!3 = !{i32 2, !"Debug Info Version", i32 3} 57!4 = !{i32 1, !"wchar_size", i32 4} 58!5 = !{i32 8, !"PIC Level", i32 2} 59!6 = !{i32 7, !"PIE Level", i32 2} 60!7 = !{i32 7, !"uwtable", i32 2} 61!8 = !{i32 7, !"frame-pointer", i32 2} 62!9 = !{!"clang version 17.0.0)"} 63!10 = distinct !DISubprogram(name: "fun", linkageName: "_Z3funv", scope: !1, file: !1, line: 3, type: !11, scopeLine: 3, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !14) 64!11 = !DISubroutineType(types: !12) 65!12 = !{!13} 66!13 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) 67!14 = !{} 68!15 = !DILocalVariable(name: "a", scope: !10, file: !1, line: 4, type: !13) 69!16 = !DILocation(line: 4, column: 9, scope: !10) 70!17 = !DILocalVariable(name: "b", scope: !10, file: !1, line: 4, type: !13) 71!18 = !DILocation(line: 4, column: 11, scope: !10) 72!19 = !DILocalVariable(scope: !10, file: !1, line: 4, type: !20) 73!20 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "two", file: !1, line: 1, size: 64, flags: DIFlagTypePassByValue, elements: !21, identifier: "_ZTS3two") 74!21 = !{!22, !23} 75!22 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !20, file: !1, line: 1, baseType: !13, size: 32) 76!23 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !20, file: !1, line: 1, baseType: !13, size: 32, offset: 32) 77!24 = !DILocation(line: 4, column: 8, scope: !10) 78!25 = !DILocation(line: 4, column: 16, scope: !10) 79!26 = !DILocation(line: 5, column: 10, scope: !10) 80!27 = !DILocation(line: 5, column: 14, scope: !10) 81!28 = !DILocation(line: 5, column: 12, scope: !10) 82!29 = !DILocation(line: 5, column: 3, scope: !10) 83