1; RUN: opt %s -S -passes=instcombine | FileCheck %s 2; RUN: opt --try-experimental-debuginfo-iterators %s -S -passes=instcombine | FileCheck %s 3 4;; Check that instcombine merges the DIAssignID metadata when merging two 5;; stores into a successor. Filecheck directives inline. 6;; 7;; Generated from the following source: 8;; int c; 9;; void esc(int*); 10;; int get(); 11;; void fun() { 12;; int local; 13;; if (c) { 14;; get(); 15;; local = 2; 16;; } else { 17;; local = 2; 18;; } 19;; esc(&local); 20;; } 21 22; CHECK: if.then: 23; CHECK-NEXT: %call = call 24; CHECK-NEXT: #dbg_assign(i32 2, ![[LOCAL:[0-9]+]], !DIExpression(), ![[MERGED_ID:[0-9]+]], ptr %local, !DIExpression(), 25 26; CHECK: if.else: 27; CHECK-NEXT: #dbg_assign(i32 2, ![[LOCAL]], !DIExpression(), ![[MERGED_ID]], ptr %local, !DIExpression(), 28 29; CHECK: if.end: 30; CHECK-NEXT: store i32 2, ptr %local{{.*}}!DIAssignID ![[MERGED_ID]] 31 32; CHECK: ![[LOCAL]] = !DILocalVariable(name: "local", 33 34@c = dso_local local_unnamed_addr global i32 0, align 4, !dbg !0 35 36; Function Attrs: uwtable mustprogress 37define dso_local void @_Z3funv() local_unnamed_addr !dbg !11 { 38entry: 39 %local = alloca i32, align 4 40 %0 = bitcast ptr %local to ptr, !dbg !16 41 call void @llvm.lifetime.start.p0(i64 4, ptr %0), !dbg !16 42 %1 = load i32, ptr @c, align 4, !dbg !17 43 %tobool = icmp ne i32 %1, 0, !dbg !17 44 br i1 %tobool, label %if.then, label %if.else, !dbg !23 45 46if.then: ; preds = %entry 47 %call = call i32 @_Z3getv(), !dbg !24 48 store i32 2, ptr %local, align 4, !dbg !26, !DIAssignID !27 49 call void @llvm.dbg.assign(metadata i32 2, metadata !15, metadata !DIExpression(), metadata !27, metadata ptr %local, metadata !DIExpression()), !dbg !26 50 br label %if.end, !dbg !28 51 52if.else: ; preds = %entry 53 store i32 2, ptr %local, align 4, !dbg !29, !DIAssignID !31 54 call void @llvm.dbg.assign(metadata i32 2, metadata !15, metadata !DIExpression(), metadata !31, metadata ptr %local, metadata !DIExpression()), !dbg !29 55 br label %if.end 56 57if.end: ; preds = %if.else, %if.then 58 call void @_Z3escPi(ptr %local), !dbg !32 59 call void @llvm.lifetime.end.p0(i64 4, ptr %0), !dbg !33 60 ret void, !dbg !33 61} 62 63declare !dbg !34 dso_local i32 @_Z3getv() local_unnamed_addr 64declare !dbg !37 dso_local void @_Z3escPi(ptr) local_unnamed_addr 65declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) 66declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) 67declare void @llvm.dbg.assign(metadata, metadata, metadata, metadata, metadata, metadata) 68 69!llvm.dbg.cu = !{!2} 70!llvm.module.flags = !{!7, !8, !9, !1000} 71!llvm.ident = !{!10} 72 73!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) 74!1 = distinct !DIGlobalVariable(name: "c", scope: !2, file: !3, line: 1, type: !6, isLocal: false, isDefinition: true) 75!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !3, producer: "clang version 12.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, splitDebugInlining: false, nameTableKind: None) 76!3 = !DIFile(filename: "test.cpp", directory: "/") 77!4 = !{} 78!5 = !{!0} 79!6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) 80!7 = !{i32 7, !"Dwarf Version", i32 4} 81!8 = !{i32 2, !"Debug Info Version", i32 3} 82!9 = !{i32 1, !"wchar_size", i32 4} 83!10 = !{!"clang version 12.0.0"} 84!11 = distinct !DISubprogram(name: "fun", linkageName: "_Z3funv", scope: !3, file: !3, line: 4, type: !12, scopeLine: 4, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !14) 85!12 = !DISubroutineType(types: !13) 86!13 = !{null} 87!14 = !{!15} 88!15 = !DILocalVariable(name: "local", scope: !11, file: !3, line: 5, type: !6) 89!16 = !DILocation(line: 5, column: 3, scope: !11) 90!17 = !DILocation(line: 6, column: 7, scope: !18) 91!18 = distinct !DILexicalBlock(scope: !11, file: !3, line: 6, column: 7) 92!23 = !DILocation(line: 6, column: 7, scope: !11) 93!24 = !DILocation(line: 7, column: 5, scope: !25) 94!25 = distinct !DILexicalBlock(scope: !18, file: !3, line: 6, column: 10) 95!26 = !DILocation(line: 8, column: 11, scope: !25) 96!27 = distinct !DIAssignID() 97!28 = !DILocation(line: 9, column: 3, scope: !25) 98!29 = !DILocation(line: 10, column: 11, scope: !30) 99!30 = distinct !DILexicalBlock(scope: !18, file: !3, line: 9, column: 10) 100!31 = distinct !DIAssignID() 101!32 = !DILocation(line: 12, column: 3, scope: !11) 102!33 = !DILocation(line: 13, column: 1, scope: !11) 103!34 = !DISubprogram(name: "get", linkageName: "_Z3getv", scope: !3, file: !3, line: 3, type: !35, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !4) 104!35 = !DISubroutineType(types: !36) 105!36 = !{!6} 106!37 = !DISubprogram(name: "esc", linkageName: "_Z3escPi", scope: !3, file: !3, line: 2, type: !38, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !4) 107!38 = !DISubroutineType(types: !39) 108!39 = !{null, !40} 109!40 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !6, size: 64) 110!1000 = !{i32 7, !"debug-info-assignment-tracking", i1 true} 111