1; RUN: opt %s -S -passes=sroa -o - | FileCheck %s 2; RUN: opt --try-experimental-debuginfo-iterators %s -S -passes=sroa -o - | FileCheck %s 3 4;; Ensure that only the value-expression gets fragment info; that the 5;; address-expression remains untouched. 6 7;; $ cat test.cpp 8;; class a { 9;; float b[4]; 10;; }; 11;; class c { 12;; a m_fn1() const; 13;; void d() const; 14;; }; 15;; void c::d() const { a e = m_fn1(); } 16;; 17;; Generated by grabbing IR before sroa in: 18;; $ clang++ -O2 -g -c test.cpp -Xclang -fexperimental-assignment-tracking 19 20; CHECK: %call = call 21; CHECK-NEXT: %0 = extractvalue { <2 x float>, <2 x float> } %call, 0 22; CHECK-NEXT: #dbg_value(<2 x float> %0, ![[var:[0-9]+]], !DIExpression(DW_OP_LLVM_fragment, 0, 64), 23; CHECK-NEXT: %1 = extractvalue { <2 x float>, <2 x float> } %call, 1 24; CHECK-NEXT: #dbg_value(<2 x float> %1, ![[var]], !DIExpression(DW_OP_LLVM_fragment, 64, 64), 25 26%class.c = type { i8 } 27%class.a = type { [4 x float] } 28 29; Function Attrs: uwtable 30define dso_local void @_ZNK1c1dEv(ptr %this) #0 align 2 !dbg !7 { 31entry: 32 %this.addr = alloca ptr, align 8, !DIAssignID !29 33 call void @llvm.dbg.assign(metadata i1 undef, metadata !26, metadata !DIExpression(), metadata !29, metadata ptr %this.addr, metadata !DIExpression()), !dbg !30 34 %e = alloca %class.a, align 4, !DIAssignID !31 35 call void @llvm.dbg.assign(metadata i1 undef, metadata !28, metadata !DIExpression(), metadata !31, metadata ptr %e, metadata !DIExpression()), !dbg !30 36 store ptr %this, ptr %this.addr, align 8, !DIAssignID !36 37 call void @llvm.dbg.assign(metadata ptr %this, metadata !26, metadata !DIExpression(), metadata !36, metadata ptr %this.addr, metadata !DIExpression()), !dbg !30 38 %this1 = load ptr, ptr %this.addr, align 8 39 %0 = bitcast ptr %e to ptr, !dbg !37 40 %call = call { <2 x float>, <2 x float> } @_ZNK1c5m_fn1Ev(ptr %this1), !dbg !38 41 %coerce.dive = getelementptr inbounds %class.a, ptr %e, i32 0, i32 0, !dbg !38 42 %1 = bitcast ptr %coerce.dive to ptr, !dbg !38 43 %2 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %1, i32 0, i32 0, !dbg !38 44 %3 = extractvalue { <2 x float>, <2 x float> } %call, 0, !dbg !38 45 store <2 x float> %3, ptr %2, align 4, !dbg !38, !DIAssignID !39 46 call void @llvm.dbg.assign(metadata <2 x float> %3, metadata !28, metadata !DIExpression(DW_OP_LLVM_fragment, 0, 64), metadata !39, metadata ptr %2, metadata !DIExpression()), !dbg !30 47 %4 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %1, i32 0, i32 1, !dbg !38 48 %5 = extractvalue { <2 x float>, <2 x float> } %call, 1, !dbg !38 49 store <2 x float> %5, ptr %4, align 4, !dbg !38, !DIAssignID !40 50 call void @llvm.dbg.assign(metadata <2 x float> %5, metadata !28, metadata !DIExpression(DW_OP_LLVM_fragment, 64, 64), metadata !40, metadata ptr %4, metadata !DIExpression()), !dbg !30 51 %6 = bitcast ptr %e to ptr, !dbg !41 52 ret void, !dbg !41 53} 54 55declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 56declare dso_local { <2 x float>, <2 x float> } @_ZNK1c5m_fn1Ev(ptr) #3 57declare void @llvm.dbg.assign(metadata, metadata, metadata, metadata, metadata, metadata) #1 58 59 60!llvm.dbg.cu = !{!0} 61!llvm.module.flags = !{!3, !4, !5, !1000} 62!llvm.ident = !{!6} 63 64!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 12.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None) 65!1 = !DIFile(filename: "test.cpp", directory: "/") 66!2 = !{} 67!3 = !{i32 7, !"Dwarf Version", i32 4} 68!4 = !{i32 2, !"Debug Info Version", i32 3} 69!5 = !{i32 1, !"wchar_size", i32 4} 70!6 = !{!"clang version 12.0.0"} 71!7 = distinct !DISubprogram(name: "d", linkageName: "_ZNK1c1dEv", scope: !8, file: !1, line: 8, type: !23, scopeLine: 8, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, declaration: !22, retainedNodes: !25) 72!8 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "c", file: !1, line: 4, size: 8, flags: DIFlagTypePassByValue, elements: !9, identifier: "_ZTS1c") 73!9 = !{!10, !22} 74!10 = !DISubprogram(name: "m_fn1", linkageName: "_ZNK1c5m_fn1Ev", scope: !8, file: !1, line: 5, type: !11, scopeLine: 5, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized) 75!11 = !DISubroutineType(types: !12) 76!12 = !{!13, !20} 77!13 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "a", file: !1, line: 1, size: 128, flags: DIFlagTypePassByValue, elements: !14, identifier: "_ZTS1a") 78!14 = !{!15} 79!15 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !13, file: !1, line: 2, baseType: !16, size: 128) 80!16 = !DICompositeType(tag: DW_TAG_array_type, baseType: !17, size: 128, elements: !18) 81!17 = !DIBasicType(name: "float", size: 32, encoding: DW_ATE_float) 82!18 = !{!19} 83!19 = !DISubrange(count: 4) 84!20 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !21, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer) 85!21 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !8) 86!22 = !DISubprogram(name: "d", linkageName: "_ZNK1c1dEv", scope: !8, file: !1, line: 6, type: !23, scopeLine: 6, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized) 87!23 = !DISubroutineType(types: !24) 88!24 = !{null, !20} 89!25 = !{!26, !28} 90!26 = !DILocalVariable(name: "this", arg: 1, scope: !7, type: !27, flags: DIFlagArtificial | DIFlagObjectPointer) 91!27 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !21, size: 64) 92!28 = !DILocalVariable(name: "e", scope: !7, file: !1, line: 8, type: !13) 93!29 = distinct !DIAssignID() 94!30 = !DILocation(line: 0, scope: !7) 95!31 = distinct !DIAssignID() 96!36 = distinct !DIAssignID() 97!37 = !DILocation(line: 8, column: 21, scope: !7) 98!38 = !DILocation(line: 8, column: 27, scope: !7) 99!39 = distinct !DIAssignID() 100!40 = distinct !DIAssignID() 101!41 = !DILocation(line: 8, column: 36, scope: !7) 102!1000 = !{i32 7, !"debug-info-assignment-tracking", i1 true} 103