blob: 48b21164b3b17373842990a51fc16ee9060694f6 [file] [log] [blame]
Dominic Chena8a63822016-08-17 23:42:27 +00001; RUN: llc < %s -verify-machineinstrs -mtriple=wasm32-unknown-unknown | FileCheck %s
2; RUN: llc < %s -verify-machineinstrs -mtriple=wasm32-unknown-unknown -fast-isel | FileCheck --check-prefix=CHECK-FAST %s
3; CHECK: #DEBUG_VALUE: decode:i <- [%vreg
4; CHECK: #DEBUG_VALUE: decode:v <- [%vreg
5; CHECK: DW_TAG_variable
6; CHECK-FAST: DW_TAG_variable
7
8; Test that llvm.dbg.declare() instrinsics do not crash the backend
9
10target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
11target triple = "wasm32-unknown-unknown"
12
13%0 = type opaque
14
15@key = external global [15 x i8], align 1
16
17; Function Attrs: nounwind
18define internal zeroext i8 @0(i32, i8 zeroext) !dbg !14 !type !19 {
19 %3 = alloca i32, align 4
20 %4 = alloca i8, align 1
21 store i32 %0, i32* %3, align 4
22 call void @llvm.dbg.declare(metadata i32* %3, metadata !20, metadata !21), !dbg !22
23 store i8 %1, i8* %4, align 1
24 call void @llvm.dbg.declare(metadata i8* %4, metadata !23, metadata !21), !dbg !24
25 %5 = load i8, i8* %4, align 1, !dbg !25
26 %6 = zext i8 %5 to i32, !dbg !25
27 %7 = load i32, i32* %3, align 4, !dbg !26
28 %8 = urem i32 %7, 15, !dbg !27
29 %9 = getelementptr inbounds [15 x i8], [15 x i8]* @key, i32 0, i32 %8, !dbg !28
30 %10 = load i8, i8* %9, align 1, !dbg !28
31 %11 = zext i8 %10 to i32, !dbg !28
32 %12 = xor i32 %6, %11, !dbg !29
33 %13 = trunc i32 %12 to i8, !dbg !30
34 ret i8 %13, !dbg !31
35}
36
37; Function Attrs: nounwind readnone
38declare void @llvm.dbg.declare(metadata, metadata, metadata)
39
40!llvm.dbg.cu = !{!0}
41!llvm.module.flags = !{!11, !12}
42!llvm.ident = !{!13}
43
44!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.9.0 (trunk 273884) (llvm/trunk 273897)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !3)
45!1 = !DIFile(filename: "crash.c", directory: "wasm/tests")
46!2 = !{}
47!3 = !{!4}
48!4 = distinct !DIGlobalVariable(name: "key", scope: !0, file: !1, line: 7, type: !5, isLocal: false, isDefinition: true, variable: [15 x i8]* @key)
49!5 = !DICompositeType(tag: DW_TAG_array_type, baseType: !6, size: 120, align: 8, elements: !9)
50!6 = !DIDerivedType(tag: DW_TAG_typedef, name: "uint8_t", file: !7, line: 185, baseType: !8)
51!7 = !DIFile(filename: "wasm/emscripten/system/include/libc/bits/alltypes.h", directory: "wasm/tests")
52!8 = !DIBasicType(name: "unsigned char", size: 8, align: 8, encoding: DW_ATE_unsigned_char)
53!9 = !{!10}
54!10 = !DISubrange(count: 15)
55!11 = !{i32 2, !"Dwarf Version", i32 4}
56!12 = !{i32 2, !"Debug Info Version", i32 3}
57!13 = !{!"clang version 3.9.0 (trunk 273884) (llvm/trunk 273897)"}
58!14 = distinct !DISubprogram(name: "decode", scope: !1, file: !1, line: 11, type: !15, isLocal: false, isDefinition: true, scopeLine: 11, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
59!15 = !DISubroutineType(types: !16)
60!16 = !{!6, !17, !6}
61!17 = !DIDerivedType(tag: DW_TAG_typedef, name: "size_t", file: !7, line: 124, baseType: !18)
62!18 = !DIBasicType(name: "long unsigned int", size: 32, align: 32, encoding: DW_ATE_unsigned)
63!19 = !{i64 0, !"_ZTSFhmhE"}
64!20 = !DILocalVariable(name: "i", arg: 1, scope: !14, file: !1, line: 11, type: !17)
65!21 = !DIExpression()
66!22 = !DILocation(line: 11, column: 23, scope: !14)
67!23 = !DILocalVariable(name: "v", arg: 2, scope: !14, file: !1, line: 11, type: !6)
68!24 = !DILocation(line: 11, column: 34, scope: !14)
69!25 = !DILocation(line: 12, column: 11, scope: !14)
70!26 = !DILocation(line: 12, column: 19, scope: !14)
71!27 = !DILocation(line: 12, column: 21, scope: !14)
72!28 = !DILocation(line: 12, column: 15, scope: !14)
73!29 = !DILocation(line: 12, column: 13, scope: !14)
74!30 = !DILocation(line: 12, column: 10, scope: !14)
75!31 = !DILocation(line: 12, column: 3, scope: !14)