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