1; RUN: opt %s -passes=verify \ 2; RUN: | opt -passes=verify -S \ 3; RUN: | FileCheck %s 4; RUN: opt --try-experimental-debuginfo-iterators %s -passes=verify \ 5; RUN: | opt -passes=verify -S \ 6; RUN: | FileCheck %s 7 8;; Roundtrip test (text -> bitcode -> text) for DIAssignID metadata and 9;; llvm.dbg.assign intrinsics. 10 11;; DIAssignID attachment only. 12; CHECK-LABEL: @fun() 13; CHECK: %local = alloca i32, align 4, !DIAssignID ![[ID1:[0-9]+]] 14define dso_local void @fun() !dbg !7 { 15entry: 16 %local = alloca i32, align 4, !DIAssignID !14 17 ret void, !dbg !13 18} 19 20;; Unlinked llvm.dbg.assign. 21; CHECK-DAG: @fun2() 22; CHECK: #dbg_assign(i32 undef, ![[VAR2:[0-9]+]], !DIExpression(), ![[ID2:[0-9]+]], i32 undef, !DIExpression(), ![[DBG2:[0-9]+]] 23define dso_local void @fun2() !dbg !15 { 24entry: 25 %local = alloca i32, align 4 26 call void @llvm.dbg.assign(metadata i32 undef, metadata !16, metadata !DIExpression(), metadata !18, metadata i32 undef, metadata !DIExpression()), !dbg !17 27 ret void, !dbg !17 28} 29 30;; An llvm.dbg.assign linked to an alloca. 31; CHECK-LABEL: @fun3() 32; CHECK: %local = alloca i32, align 4, !DIAssignID ![[ID3:[0-9]+]] 33; CHECK-NEXT: #dbg_assign(i32 undef, ![[VAR3:[0-9]+]], !DIExpression(), ![[ID3]], i32 undef, !DIExpression(), ![[DBG3:[0-9]+]] 34define dso_local void @fun3() !dbg !19 { 35entry: 36 %local = alloca i32, align 4, !DIAssignID !22 37 call void @llvm.dbg.assign(metadata i32 undef, metadata !20, metadata !DIExpression(), metadata !22, metadata i32 undef, metadata !DIExpression()), !dbg !21 38 ret void, !dbg !21 39} 40 41;; Check that using a DIAssignID as an operand before using it as an attachment 42;; works (the order of the alloca and dbg.assign has been swapped). 43; CHECK-LABEL: @fun4() 44; CHECK: #dbg_assign(i32 undef, ![[VAR4:[0-9]+]], !DIExpression(), ![[ID4:[0-9]+]], i32 undef, !DIExpression(), ![[DBG4:[0-9]+]] 45; CHECK-NEXT: %local = alloca i32, align 4, !DIAssignID ![[ID4]] 46define dso_local void @fun4() !dbg !23 { 47entry: 48 call void @llvm.dbg.assign(metadata i32 undef, metadata !24, metadata !DIExpression(), metadata !26, metadata i32 undef, metadata !DIExpression()), !dbg !25 49 %local = alloca i32, align 4, !DIAssignID !26 50 ret void, !dbg !25 51} 52 53;; Check that the value and address operands print correctly. 54;; There are currently no plans to support DIArgLists for the address component. 55; CHECK-LABEL: @fun5 56; CHECK: %local = alloca i32, align 4, !DIAssignID ![[ID5:[0-9]+]] 57; CHECK-NEXT: #dbg_assign(i32 %v, ![[VAR5:[0-9]+]], !DIExpression(), ![[ID5]], ptr %local, !DIExpression(), ![[DBG5:[0-9]+]] 58; CHECK-NEXT: #dbg_assign(!DIArgList(i32 %v, i32 1), ![[VAR5]], !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_minus, DW_OP_stack_value), ![[ID5]], ptr %local, !DIExpression(), ![[DBG5]] 59define dso_local void @fun5(i32 %v) !dbg !27 { 60entry: 61 %local = alloca i32, align 4, !DIAssignID !30 62 call void @llvm.dbg.assign(metadata i32 %v, metadata !28, metadata !DIExpression(), metadata !30, metadata ptr %local, metadata !DIExpression()), !dbg !29 63 call void @llvm.dbg.assign(metadata !DIArgList(i32 %v, i32 1), metadata !28, metadata !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_minus, DW_OP_stack_value), metadata !30, metadata ptr %local, metadata !DIExpression()), !dbg !29 64 ret void 65} 66 67; CHECK-DAG: ![[ID1]] = distinct !DIAssignID() 68; CHECK-DAG: ![[ID2]] = distinct !DIAssignID() 69; CHECK-DAG: ![[VAR2]] = !DILocalVariable(name: "local2", 70; CHECK-DAG: ![[DBG2]] = !DILocation(line: 2 71; CHECK-DAG: ![[ID3]] = distinct !DIAssignID() 72; CHECK-DAG: ![[VAR3]] = !DILocalVariable(name: "local3", 73; CHECK-DAG: ![[DBG3]] = !DILocation(line: 3, 74; CHECK-DAG: ![[ID4]] = distinct !DIAssignID() 75; CHECK-DAG: ![[VAR4]] = !DILocalVariable(name: "local4", 76; CHECK-DAG: ![[DBG4]] = !DILocation(line: 4, 77; CHECK-DAG: ![[ID5]] = distinct !DIAssignID() 78; CHECK-DAG: ![[VAR5]] = !DILocalVariable(name: "local5", 79; CHECK-DAG: ![[DBG5]] = !DILocation(line: 5, 80 81declare void @llvm.dbg.assign(metadata, metadata, metadata, metadata, metadata, metadata) 82 83!llvm.dbg.cu = !{!0} 84!llvm.module.flags = !{!3, !4, !5, !1000} 85!llvm.ident = !{!6} 86 87!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 14.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None) 88!1 = !DIFile(filename: "test.c", directory: "/") 89!2 = !{} 90!3 = !{i32 7, !"Dwarf Version", i32 4} 91!4 = !{i32 2, !"Debug Info Version", i32 3} 92!5 = !{i32 1, !"wchar_size", i32 4} 93!6 = !{!"clang version 14.0.0"} 94!7 = distinct !DISubprogram(name: "fun", scope: !1, file: !1, line: 1, type: !8, scopeLine: 1, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2) 95!8 = !DISubroutineType(types: !9) 96!9 = !{null} 97!10 = !DILocalVariable(name: "local", scope: !7, file: !1, line: 2, type: !11) 98!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) 99!13 = !DILocation(line: 1, column: 1, scope: !7) 100!14 = distinct !DIAssignID() 101!15 = distinct !DISubprogram(name: "fun2", scope: !1, file: !1, line: 1, type: !8, scopeLine: 1, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2) 102!16 = !DILocalVariable(name: "local2", scope: !15, file: !1, line: 2, type: !11) 103!17 = !DILocation(line: 2, column: 1, scope: !15) 104!18 = distinct !DIAssignID() 105!19 = distinct !DISubprogram(name: "fun3", scope: !1, file: !1, line: 1, type: !8, scopeLine: 1, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2) 106!20 = !DILocalVariable(name: "local3", scope: !19, file: !1, line: 2, type: !11) 107!21 = !DILocation(line: 3, column: 1, scope: !19) 108!22 = distinct !DIAssignID() 109!23 = distinct !DISubprogram(name: "fun4", scope: !1, file: !1, line: 1, type: !8, scopeLine: 1, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2) 110!24 = !DILocalVariable(name: "local4", scope: !23, file: !1, line: 2, type: !11) 111!25 = !DILocation(line: 4, column: 1, scope: !23) 112!26 = distinct !DIAssignID() 113!27 = distinct !DISubprogram(name: "fun5", scope: !1, file: !1, line: 1, type: !31, scopeLine: 1, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2) 114!28 = !DILocalVariable(name: "local5", scope: !27, file: !1, line: 2, type: !11) 115!29 = !DILocation(line: 5, column: 1, scope: !27) 116!30 = distinct !DIAssignID() 117!31 = !DISubroutineType(types: !32) 118!32 = !{null, !11} 119!1000 = !{i32 7, !"debug-info-assignment-tracking", i1 true} 120