blob: d6337092b281180b673cf3bc62ac2e1505275019 [file] [log] [blame]
Sam Clegga5908002018-05-10 17:49:11 +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
Reid Kleckner29c67522017-08-01 19:45:09 +00003
Dominic Chena8a63822016-08-17 23:42:27 +00004; CHECK: DW_TAG_variable
5; CHECK-FAST: DW_TAG_variable
6
7; Test that llvm.dbg.declare() instrinsics do not crash the backend
8
Adrian Prantl1eadba12016-12-22 00:45:21 +00009source_filename = "test/DebugInfo/WebAssembly/dbg-declare.ll"
Dominic Chena8a63822016-08-17 23:42:27 +000010target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
Sam Clegga5908002018-05-10 17:49:11 +000011target triple = "wasm32-unknown-unknown"
Dominic Chena8a63822016-08-17 23:42:27 +000012
Dominic Chena8a63822016-08-17 23:42:27 +000013@key = external global [15 x i8], align 1
14
Adrian Prantl1eadba12016-12-22 00:45:21 +000015define internal zeroext i8 @0(i32, i8 zeroext) !dbg !15 !type !20 {
Dominic Chena8a63822016-08-17 23:42:27 +000016 %3 = alloca i32, align 4
17 %4 = alloca i8, align 1
18 store i32 %0, i32* %3, align 4
Adrian Prantl1eadba12016-12-22 00:45:21 +000019 call void @llvm.dbg.declare(metadata i32* %3, metadata !21, metadata !22), !dbg !23
Dominic Chena8a63822016-08-17 23:42:27 +000020 store i8 %1, i8* %4, align 1
Adrian Prantl1eadba12016-12-22 00:45:21 +000021 call void @llvm.dbg.declare(metadata i8* %4, metadata !24, metadata !22), !dbg !25
22 %5 = load i8, i8* %4, align 1, !dbg !26
23 %6 = zext i8 %5 to i32, !dbg !26
24 %7 = load i32, i32* %3, align 4, !dbg !27
25 %8 = urem i32 %7, 15, !dbg !28
26 %9 = getelementptr inbounds [15 x i8], [15 x i8]* @key, i32 0, i32 %8, !dbg !29
27 %10 = load i8, i8* %9, align 1, !dbg !29
28 %11 = zext i8 %10 to i32, !dbg !29
29 %12 = xor i32 %6, %11, !dbg !30
30 %13 = trunc i32 %12 to i8, !dbg !31
31 ret i8 %13, !dbg !32
Dominic Chena8a63822016-08-17 23:42:27 +000032}
33
34; Function Attrs: nounwind readnone
Adrian Prantl1eadba12016-12-22 00:45:21 +000035
36declare void @llvm.dbg.declare(metadata, metadata, metadata) #0
37
38attributes #0 = { nounwind readnone }
Dominic Chena8a63822016-08-17 23:42:27 +000039
40!llvm.dbg.cu = !{!0}
Adrian Prantl1eadba12016-12-22 00:45:21 +000041!llvm.module.flags = !{!12, !13}
42!llvm.ident = !{!14}
Dominic Chena8a63822016-08-17 23:42:27 +000043
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}
Derek Schuffbd484b42017-08-30 19:54:08 +000048!4 = distinct !DIGlobalVariableExpression(var: !5, expr: !DIExpression())
Adrian Prantl1eadba12016-12-22 00:45:21 +000049!5 = !DIGlobalVariable(name: "key", scope: !0, file: !1, line: 7, type: !6, isLocal: false, isDefinition: true)
50!6 = !DICompositeType(tag: DW_TAG_array_type, baseType: !7, size: 120, align: 8, elements: !10)
51!7 = !DIDerivedType(tag: DW_TAG_typedef, name: "uint8_t", file: !8, line: 185, baseType: !9)
52!8 = !DIFile(filename: "wasm/emscripten/system/include/libc/bits/alltypes.h", directory: "wasm/tests")
53!9 = !DIBasicType(name: "unsigned char", size: 8, align: 8, encoding: DW_ATE_unsigned_char)
54!10 = !{!11}
55!11 = !DISubrange(count: 15)
56!12 = !{i32 2, !"Dwarf Version", i32 4}
57!13 = !{i32 2, !"Debug Info Version", i32 3}
58!14 = !{!"clang version 3.9.0 (trunk 273884) (llvm/trunk 273897)"}
Shiva Chen2c864552018-05-09 02:40:45 +000059!15 = distinct !DISubprogram(name: "decode", scope: !1, file: !1, line: 11, type: !16, isLocal: false, isDefinition: true, scopeLine: 11, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)
Adrian Prantl1eadba12016-12-22 00:45:21 +000060!16 = !DISubroutineType(types: !17)
61!17 = !{!7, !18, !7}
62!18 = !DIDerivedType(tag: DW_TAG_typedef, name: "size_t", file: !8, line: 124, baseType: !19)
63!19 = !DIBasicType(name: "long unsigned int", size: 32, align: 32, encoding: DW_ATE_unsigned)
64!20 = !{i64 0, !"_ZTSFhmhE"}
65!21 = !DILocalVariable(name: "i", arg: 1, scope: !15, file: !1, line: 11, type: !18)
66!22 = !DIExpression()
67!23 = !DILocation(line: 11, column: 23, scope: !15)
68!24 = !DILocalVariable(name: "v", arg: 2, scope: !15, file: !1, line: 11, type: !7)
69!25 = !DILocation(line: 11, column: 34, scope: !15)
70!26 = !DILocation(line: 12, column: 11, scope: !15)
71!27 = !DILocation(line: 12, column: 19, scope: !15)
72!28 = !DILocation(line: 12, column: 21, scope: !15)
73!29 = !DILocation(line: 12, column: 15, scope: !15)
74!30 = !DILocation(line: 12, column: 13, scope: !15)
75!31 = !DILocation(line: 12, column: 10, scope: !15)
76!32 = !DILocation(line: 12, column: 3, scope: !15)
77