1 ; RUN: llc < %s -print-machineinstrs 2>&1 | FileCheck %s
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:
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.
12 source_filename = "fib2.c"
14 ; int i, t, a = 0, b = 1;
15 ; for (i = 0; i < n; i++) {
22 target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
23 target triple = "wasm32-unknown-unknown-wasm"
25 ; Function Attrs: nounwind readnone
26 define hidden i32 @fib(i32 %n) local_unnamed_addr #0 !dbg !7 {
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
32 for.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
43 for.end: ; preds = %for.body, %entry
44 %b.0.lcssa = phi i32 [ 1, %entry ], [ %add, %for.body ]
45 ret i32 %b.0.lcssa, !dbg !31
48 ; Function Attrs: nounwind readnone speculatable
49 declare void @llvm.dbg.value(metadata, metadata, metadata) #1
52 !llvm.module.flags = !{!3, !4, !5}
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")
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)
65 !10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
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)