1; RUN: llc < %s -print-machineinstrs 2>&1 | FileCheck %s 2 3; CHECK: After WebAssembly Register Stackify: 4; CHECK: bb.2.for.body: 5; CHECK: [[REG:%[0-9]+]]:i32 = TEE_I32 {{.*}} fib2.c:6:7 6; CHECK-NEXT: DBG_VALUE [[REG]]:i32, $noreg, !"a", {{.*}} fib2.c:2:13 7; CHECK: After WebAssembly Register Coloring: 8 9; ModuleID = 'fib2.bc' 10; The test generated via: clang --target=wasm32-unknown-unknown-wasm fib2.c -g -O2 11; All non-"!dbg !18" llvm.dbg.value calls and attributes were removed. 12source_filename = "fib2.c" 13; int fib(int n) { 14; int i, t, a = 0, b = 1; 15; for (i = 0; i < n; i++) { 16; t = a; 17; a = b; 18; b += t; 19; } 20; return b; 21; } 22target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128" 23target triple = "wasm32-unknown-unknown-wasm" 24 25; Function Attrs: nounwind readnone 26define hidden i32 @fib(i32 %n) local_unnamed_addr #0 !dbg !7 { 27entry: 28 call void @llvm.dbg.value(metadata i32 0, metadata !15, metadata !DIExpression()), !dbg !18 29 %cmp8 = icmp sgt i32 %n, 0, !dbg !21 30 br i1 %cmp8, label %for.body, label %for.end, !dbg !24 31 32for.body: ; preds = %entry, %for.body 33 %b.011 = phi i32 [ %add, %for.body ], [ 1, %entry ] 34 %a.010 = phi i32 [ %b.011, %for.body ], [ 0, %entry ] 35 %i.09 = phi i32 [ %inc, %for.body ], [ 0, %entry ] 36 call void @llvm.dbg.value(metadata i32 %a.010, metadata !15, metadata !DIExpression()), !dbg !18 37 %add = add nsw i32 %b.011, %a.010, !dbg !26 38 %inc = add nuw nsw i32 %i.09, 1, !dbg !28 39 call void @llvm.dbg.value(metadata i32 %b.011, metadata !15, metadata !DIExpression()), !dbg !18 40 %exitcond = icmp eq i32 %inc, %n, !dbg !21 41 br i1 %exitcond, label %for.end, label %for.body, !dbg !24, !llvm.loop !29 42 43for.end: ; preds = %for.body, %entry 44 %b.0.lcssa = phi i32 [ 1, %entry ], [ %add, %for.body ] 45 ret i32 %b.0.lcssa, !dbg !31 46} 47 48; Function Attrs: nounwind readnone speculatable 49declare void @llvm.dbg.value(metadata, metadata, metadata) #1 50 51!llvm.dbg.cu = !{!0} 52!llvm.module.flags = !{!3, !4, !5} 53!llvm.ident = !{!6} 54 55!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 7.0.0 (trunk 337180)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2) 56!1 = !DIFile(filename: "fib2.c", directory: "/d/y/llvmwasm") 57!2 = !{} 58!3 = !{i32 2, !"Dwarf Version", i32 4} 59!4 = !{i32 2, !"Debug Info Version", i32 3} 60!5 = !{i32 1, !"wchar_size", i32 4} 61!6 = !{!"clang version 7.0.0 (trunk 337180)"} 62!7 = distinct !DISubprogram(name: "fib", scope: !1, file: !1, line: 1, type: !8, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !11) 63!8 = !DISubroutineType(types: !9) 64!9 = !{!10, !10} 65!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) 66!11 = !{!15} 67!15 = !DILocalVariable(name: "a", scope: !7, file: !1, line: 2, type: !10) 68!17 = !DILocation(line: 1, column: 13, scope: !7) 69!18 = !DILocation(line: 2, column: 13, scope: !7) 70!19 = !DILocation(line: 2, column: 20, scope: !7) 71!20 = !DILocation(line: 2, column: 7, scope: !7) 72!21 = !DILocation(line: 3, column: 17, scope: !22) 73!22 = distinct !DILexicalBlock(scope: !23, file: !1, line: 3, column: 3) 74!23 = distinct !DILexicalBlock(scope: !7, file: !1, line: 3, column: 3) 75!24 = !DILocation(line: 3, column: 3, scope: !23) 76!25 = !DILocation(line: 2, column: 10, scope: !7) 77!26 = !DILocation(line: 6, column: 7, scope: !27) 78!27 = distinct !DILexicalBlock(scope: !22, file: !1, line: 3, column: 27) 79!28 = !DILocation(line: 3, column: 23, scope: !22) 80!29 = distinct !{!29, !24, !30} 81!30 = !DILocation(line: 7, column: 3, scope: !23) 82!31 = !DILocation(line: 8, column: 3, scope: !7) 83