xref: /llvm-project/llvm/test/DebugInfo/WebAssembly/dbgvalue.ll (revision 5a288fa32e0c91b211e39f3e370255916902f898)
1; RUN: llc < %s -O0 -verify-machineinstrs | FileCheck %s
2
3; CHECK: %bb.0
4; CHECK: #DEBUG_VALUE: usage:self <- !target-index(0,0)
5; CHECK: %bb.1
6; CHECK: DW_TAG_variable
7source_filename = "test/CodeGen/WebAssembly/dbgvalue.ll"
8target triple = "wasm32-unknown-unknown"
9
10@key = external local_unnamed_addr global [15 x i8], align 1
11@.str = external unnamed_addr constant [33 x i8], align 1
12
13define internal i32 @0(ptr) local_unnamed_addr !dbg !15 !type !23 {
14  tail call void @llvm.dbg.value(metadata ptr %0, i64 0, metadata !22, metadata !24), !dbg !25
15  %2 = tail call i32 (ptr, ...) @printf(ptr @.str, ptr %0), !dbg !26
16  br i1 true, label %a, label %b
17
18a:                                                ; preds = %1
19  %3 = add i32 %2, %2
20  br label %c
21
22b:                                                ; preds = %1
23  %4 = sub i32 %2, %2
24  br label %c
25
26c:                                                ; preds = %b, %a
27  %5 = phi i32 [ %3, %a ], [ %4, %b ]
28  %6 = add i32 ptrtoint (ptr @0 to i32), %5
29  ret i32 %6, !dbg !27
30}
31
32declare i32 @printf(ptr nocapture readonly, ...) local_unnamed_addr
33
34; Function Attrs: nounwind readnone
35declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #0
36
37attributes #0 = { nounwind readnone }
38
39!llvm.dbg.cu = !{!0}
40!llvm.module.flags = !{!12, !13}
41!llvm.ident = !{!14}
42
43!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.9.0 (trunk 273884) (llvm/trunk 273897)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !3)
44!1 = !DIFile(filename: "crash.c", directory: "wasm/tests")
45!2 = !{}
46!3 = !{!4}
47!4 = !DIGlobalVariableExpression(var: !5, expr: !DIExpression())
48!5 = !DIGlobalVariable(name: "key", scope: !0, file: !1, line: 7, type: !6, isLocal: false, isDefinition: true)
49!6 = !DICompositeType(tag: DW_TAG_array_type, baseType: !7, size: 120, align: 8, elements: !10)
50!7 = !DIDerivedType(tag: DW_TAG_typedef, name: "uint8_t", file: !8, line: 185, baseType: !9)
51!8 = !DIFile(filename: "wasm/emscripten/system/include/libc/bits/alltypes.h", directory: "wasm/tests")
52!9 = !DIBasicType(name: "unsigned char", size: 8, align: 8, encoding: DW_ATE_unsigned_char)
53!10 = !{!11}
54!11 = !DISubrange(count: 15)
55!12 = !{i32 2, !"Dwarf Version", i32 4}
56!13 = !{i32 2, !"Debug Info Version", i32 3}
57!14 = !{!"clang version 3.9.0 (trunk 273884) (llvm/trunk 273897)"}
58!15 = distinct !DISubprogram(name: "usage", scope: !1, file: !1, line: 15, type: !16, isLocal: false, isDefinition: true, scopeLine: 15, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !21)
59!16 = !DISubroutineType(types: !17)
60!17 = !{!18, !19}
61!18 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
62!19 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !20, size: 32, align: 32)
63!20 = !DIBasicType(name: "char", size: 8, align: 8, encoding: DW_ATE_signed_char)
64!21 = !{!22}
65!22 = !DILocalVariable(name: "self", arg: 1, scope: !15, file: !1, line: 15, type: !19)
66!23 = !{i64 0, !"_ZTSFiPcE"}
67!24 = !DIExpression()
68!25 = !DILocation(line: 15, column: 17, scope: !15)
69!26 = !DILocation(line: 16, column: 3, scope: !15)
70!27 = !DILocation(line: 17, column: 3, scope: !15)
71