1; RUN: llc -verify-machineinstrs < %s | FileCheck %s 2; RUN: llc -filetype=obj %s -o - | llvm-dwarfdump - | FileCheck %s --check-prefix DWARF 3 4; Input C code: 5 6; int i = input(); // Nested case 7; int j = input(); // Trivial def-use. 8; output(i, j); 9 10; The ll below generates 330 lines of .S, so relevant parts that the 11; WebAssemblyDebugFixup pass affects: 12 13; CHECK: call input 14; CHECK: .Ltmp0: 15; CHECK: call input 16; CHECK: .Ltmp1: 17; CHECK: call output 18; CHECK: .Ltmp2: 19 20; This defines variable "i" which is live on the stack between Ltmp0 and Ltmp2, 21; 2 = TI_OPERAND_STACK and 0 = stack offset. 22 23; CHECK: .section .debug_loc,"",@ 24; CHECK: .Ldebug_loc0: 25; CHECK: .int32 .Ltmp0-.Lfunc_begin0 26; CHECK: .int32 .Ltmp2-.Lfunc_begin0 27; CHECK: .int16 4 # Loc expr size 28; CHECK: .int8 237 # DW_OP_WASM_location 29; CHECK: .int8 2 # 2 30; CHECK: .int8 0 # 0 31; CHECK: .int8 159 # DW_OP_stack_value 32 33; This defines variable "j" which is live on the stack between Ltmp1 and Ltmp2, 34; 2 = TI_OPERAND_STACK and 1 = stack offset. 35 36; CHECK: .Ldebug_loc1: 37; CHECK: .int32 .Ltmp1-.Lfunc_begin0 38; CHECK: .int32 .Ltmp2-.Lfunc_begin0 39; CHECK: .int16 4 # Loc expr size 40; CHECK: .int8 237 # DW_OP_WASM_location 41; CHECK: .int8 2 # 2 42; CHECK: .int8 1 # 1 43; CHECK: .int8 159 # DW_OP_stack_value 44 45 46source_filename = "stackified.c" 47target triple = "wasm32-unknown-unknown" 48 49define void @foo() !dbg !12 { 50entry: 51 %call = call i32 @input(), !dbg !18 52 call void @llvm.dbg.value(metadata i32 %call, metadata !16, metadata !DIExpression()), !dbg !19 53 %call1 = call i32 @input(), !dbg !20 54 call void @llvm.dbg.value(metadata i32 %call1, metadata !17, metadata !DIExpression()), !dbg !19 55 call void @output(i32 %call, i32 %call1), !dbg !21 56 ret void, !dbg !22 57} 58 59; DebugFixup pass should not add a DBG_VALUE after the BR_IF instruction at the 60; end of the 'entry' BB, because it is not allowed to have more instructions 61; after a terminator and debug ranges are terminated at the end of a BB anyway. 62; If this passes 'llc -verify-machineinstrs', that means the DBG_VALUE 63; instruction is correctly omitted. 64 65; DWARF-LABEL: DW_AT_name ("no_dbg_value_after_terminator") 66; DWARF: DW_TAG_variable 67; DWARF-NEXT: DW_AT_location 68; DWARF-NEXT: [ 69; DWARF-NEXT: DW_AT_name ("myvar") 70define void @no_dbg_value_after_terminator(i32 %a, i32 %b) !dbg !23 { 71entry: 72 %cmp = icmp ne i32 %a, %b, !dbg !25 73 call void @llvm.dbg.value(metadata i1 %cmp, metadata !27, metadata !DIExpression(DW_OP_LLVM_convert, 1, DW_ATE_unsigned, DW_OP_LLVM_convert, 8, DW_ATE_unsigned, DW_OP_stack_value)), !dbg !25 74 br i1 %cmp, label %bb.1, label %bb.0, !dbg !25 75 76bb.0: ; preds = %entry 77 unreachable 78 79bb.1: ; preds = %entry 80 ret void 81} 82 83declare i32 @input() 84declare !dbg !4 void @output(i32, i32) 85declare void @llvm.dbg.value(metadata, metadata, metadata) 86 87!llvm.dbg.cu = !{!0} 88!llvm.module.flags = !{!8, !9, !10} 89!llvm.ident = !{!11} 90 91!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 11.0.0 (https://github.com/llvm/llvm-project.git ed7aaf832444411ce93aa0443425ce401f5c7a8e)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3, nameTableKind: None) 92!1 = !DIFile(filename: "stackified.c", directory: "C:\\stuff\\llvm-project") 93!2 = !{} 94!3 = !{!4} 95!4 = !DISubprogram(name: "output", scope: !1, file: !1, line: 2, type: !5, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2) 96!5 = !DISubroutineType(types: !6) 97!6 = !{null, !7, !7} 98!7 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) 99!8 = !{i32 7, !"Dwarf Version", i32 4} 100!9 = !{i32 2, !"Debug Info Version", i32 3} 101!10 = !{i32 1, !"wchar_size", i32 4} 102!11 = !{!"clang version 11.0.0 (https://github.com/llvm/llvm-project.git ed7aaf832444411ce93aa0443425ce401f5c7a8e)"} 103!12 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 3, type: !13, scopeLine: 3, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !15) 104!13 = !DISubroutineType(types: !14) 105!14 = !{null} 106!15 = !{!16, !17} 107!16 = !DILocalVariable(name: "i", scope: !12, file: !1, line: 4, type: !7) 108!17 = !DILocalVariable(name: "j", scope: !12, file: !1, line: 5, type: !7) 109!18 = !DILocation(line: 4, column: 11, scope: !12) 110!19 = !DILocation(line: 0, scope: !12) 111!20 = !DILocation(line: 5, column: 11, scope: !12) 112!21 = !DILocation(line: 6, column: 3, scope: !12) 113!22 = !DILocation(line: 7, column: 1, scope: !12) 114!23 = distinct !DISubprogram(name: "no_dbg_value_after_terminator", scope: null, type: !24, spFlags: DISPFlagDefinition, unit: !0) 115!24 = !DISubroutineType(types: !2) 116!25 = !DILocation(line: 0, scope: !26) 117!26 = distinct !DILexicalBlock(scope: !23) 118!27 = !DILocalVariable(name: "myvar", scope: !26, type: !28) 119!28 = !DIBasicType(name: "bool", size: 8, encoding: DW_ATE_boolean) 120