1; RUN: opt %s -S -passes=instcombine -o - \ 2; RUN: | FileCheck %s 3; RUN: opt --try-experimental-debuginfo-iterators %s -S -passes=instcombine -o - \ 4; RUN: | FileCheck %s 5 6;; $ cat test.cpp 7;; void esc(int*); 8;; void fun() { 9;; int local[5]; 10;; __builtin_memset(local, 8, 4 * 4); 11;; __builtin_memset(local, 0, 2 * 4); 12;; esc(local); 13;; } 14;; IR grabbed before instcombine in: 15;; clang++ -O2 -g -Xclang -fexperimental-assignment-tracking 16 17;; Instcombine is going to turn the second memset into a store. Check that it 18;; inherits the DIAssignID from the memset and that the dbg.assign's value 19;; component is correct. 20 21; CHECK: store i64 0, ptr %local, align 16{{.*}}, !DIAssignID ![[ID:[0-9]+]] 22; CHECK-NEXT: #dbg_assign(i64 0, !{{.*}}, !DIExpression(DW_OP_LLVM_fragment, 0, 64), ![[ID]], ptr %local, !DIExpression(), 23 24define dso_local void @_Z3funv() local_unnamed_addr #0 !dbg !7 { 25entry: 26 %local = alloca [5 x i32], align 16, !DIAssignID !16 27 call void @llvm.dbg.assign(metadata i1 undef, metadata !11, metadata !DIExpression(), metadata !16, metadata ptr %local, metadata !DIExpression()), !dbg !17 28 %0 = bitcast ptr %local to ptr, !dbg !18 29 call void @llvm.lifetime.start.p0(i64 20, ptr %0) #5, !dbg !18 30 %arraydecay = getelementptr inbounds [5 x i32], ptr %local, i64 0, i64 0, !dbg !19 31 %1 = bitcast ptr %arraydecay to ptr, !dbg !19 32 call void @llvm.memset.p0.i64(ptr align 16 %1, i8 8, i64 16, i1 false), !dbg !19, !DIAssignID !20 33 call void @llvm.dbg.assign(metadata i8 8, metadata !11, metadata !DIExpression(DW_OP_LLVM_fragment, 0, 128), metadata !20, metadata ptr %1, metadata !DIExpression()), !dbg !17 34 call void @llvm.memset.p0.i64(ptr align 16 %1, i8 0, i64 8, i1 false), !dbg !21, !DIAssignID !22 35 call void @llvm.dbg.assign(metadata i8 0, metadata !11, metadata !DIExpression(DW_OP_LLVM_fragment, 0, 64), metadata !22, metadata ptr %1, metadata !DIExpression()), !dbg !17 36 call void @_Z3escPi(ptr noundef %arraydecay), !dbg !23 37 call void @llvm.lifetime.end.p0(i64 20, ptr %0) #5, !dbg !24 38 ret void, !dbg !24 39} 40 41declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) 42declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) 43declare !dbg !25 dso_local void @_Z3escPi(ptr noundef) local_unnamed_addr 44declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) 45declare void @llvm.dbg.assign(metadata, metadata, metadata, metadata, metadata, metadata) 46 47!llvm.dbg.cu = !{!0} 48!llvm.module.flags = !{!2, !3, !4, !5, !1000} 49!llvm.ident = !{!6} 50 51!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 14.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None) 52!1 = !DIFile(filename: "test.cpp", directory: "/") 53!2 = !{i32 7, !"Dwarf Version", i32 5} 54!3 = !{i32 2, !"Debug Info Version", i32 3} 55!4 = !{i32 1, !"wchar_size", i32 4} 56!5 = !{i32 7, !"uwtable", i32 1} 57!6 = !{!"clang version 14.0.0"} 58!7 = distinct !DISubprogram(name: "fun", linkageName: "_Z3funv", scope: !1, file: !1, line: 2, type: !8, scopeLine: 2, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !10) 59!8 = !DISubroutineType(types: !9) 60!9 = !{null} 61!10 = !{!11} 62!11 = !DILocalVariable(name: "local", scope: !7, file: !1, line: 3, type: !12) 63!12 = !DICompositeType(tag: DW_TAG_array_type, baseType: !13, size: 160, elements: !14) 64!13 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) 65!14 = !{!15} 66!15 = !DISubrange(count: 5) 67!16 = distinct !DIAssignID() 68!17 = !DILocation(line: 0, scope: !7) 69!18 = !DILocation(line: 3, column: 3, scope: !7) 70!19 = !DILocation(line: 4, column: 3, scope: !7) 71!20 = distinct !DIAssignID() 72!21 = !DILocation(line: 5, column: 3, scope: !7) 73!22 = distinct !DIAssignID() 74!23 = !DILocation(line: 6, column: 3, scope: !7) 75!24 = !DILocation(line: 7, column: 1, scope: !7) 76!25 = !DISubprogram(name: "esc", linkageName: "_Z3escPi", scope: !1, file: !1, line: 1, type: !26, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !29) 77!26 = !DISubroutineType(types: !27) 78!27 = !{null, !28} 79!28 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !13, size: 64) 80!29 = !{} 81!1000 = !{i32 7, !"debug-info-assignment-tracking", i1 true} 82