Dan Gohman | 7d7409e | 2017-02-28 23:37:04 +0000 | [diff] [blame^] | 1 | ; RUN: llc < %s -verify-machineinstrs -mtriple=wasm32-unknown-unknown-wasm | FileCheck %s |
| 2 | ; RUN: llc < %s -verify-machineinstrs -mtriple=wasm32-unknown-unknown-wasm -fast-isel | FileCheck --check-prefix=CHECK-FAST %s |
Dominic Chen | a8a6382 | 2016-08-17 23:42:27 +0000 | [diff] [blame] | 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 | |
Adrian Prantl | 1eadba1 | 2016-12-22 00:45:21 +0000 | [diff] [blame] | 10 | source_filename = "test/DebugInfo/WebAssembly/dbg-declare.ll" |
Dominic Chen | a8a6382 | 2016-08-17 23:42:27 +0000 | [diff] [blame] | 11 | target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128" |
Dan Gohman | 7d7409e | 2017-02-28 23:37:04 +0000 | [diff] [blame^] | 12 | target triple = "wasm32-unknown-unknown-wasm" |
Dominic Chen | a8a6382 | 2016-08-17 23:42:27 +0000 | [diff] [blame] | 13 | |
Dominic Chen | a8a6382 | 2016-08-17 23:42:27 +0000 | [diff] [blame] | 14 | @key = external global [15 x i8], align 1 |
| 15 | |
Adrian Prantl | 1eadba1 | 2016-12-22 00:45:21 +0000 | [diff] [blame] | 16 | define internal zeroext i8 @0(i32, i8 zeroext) !dbg !15 !type !20 { |
Dominic Chen | a8a6382 | 2016-08-17 23:42:27 +0000 | [diff] [blame] | 17 | %3 = alloca i32, align 4 |
| 18 | %4 = alloca i8, align 1 |
| 19 | store i32 %0, i32* %3, align 4 |
Adrian Prantl | 1eadba1 | 2016-12-22 00:45:21 +0000 | [diff] [blame] | 20 | call void @llvm.dbg.declare(metadata i32* %3, metadata !21, metadata !22), !dbg !23 |
Dominic Chen | a8a6382 | 2016-08-17 23:42:27 +0000 | [diff] [blame] | 21 | store i8 %1, i8* %4, align 1 |
Adrian Prantl | 1eadba1 | 2016-12-22 00:45:21 +0000 | [diff] [blame] | 22 | call void @llvm.dbg.declare(metadata i8* %4, metadata !24, metadata !22), !dbg !25 |
| 23 | %5 = load i8, i8* %4, align 1, !dbg !26 |
| 24 | %6 = zext i8 %5 to i32, !dbg !26 |
| 25 | %7 = load i32, i32* %3, align 4, !dbg !27 |
| 26 | %8 = urem i32 %7, 15, !dbg !28 |
| 27 | %9 = getelementptr inbounds [15 x i8], [15 x i8]* @key, i32 0, i32 %8, !dbg !29 |
| 28 | %10 = load i8, i8* %9, align 1, !dbg !29 |
| 29 | %11 = zext i8 %10 to i32, !dbg !29 |
| 30 | %12 = xor i32 %6, %11, !dbg !30 |
| 31 | %13 = trunc i32 %12 to i8, !dbg !31 |
| 32 | ret i8 %13, !dbg !32 |
Dominic Chen | a8a6382 | 2016-08-17 23:42:27 +0000 | [diff] [blame] | 33 | } |
| 34 | |
| 35 | ; Function Attrs: nounwind readnone |
Adrian Prantl | 1eadba1 | 2016-12-22 00:45:21 +0000 | [diff] [blame] | 36 | |
| 37 | declare void @llvm.dbg.declare(metadata, metadata, metadata) #0 |
| 38 | |
| 39 | attributes #0 = { nounwind readnone } |
Dominic Chen | a8a6382 | 2016-08-17 23:42:27 +0000 | [diff] [blame] | 40 | |
| 41 | !llvm.dbg.cu = !{!0} |
Adrian Prantl | 1eadba1 | 2016-12-22 00:45:21 +0000 | [diff] [blame] | 42 | !llvm.module.flags = !{!12, !13} |
| 43 | !llvm.ident = !{!14} |
Dominic Chen | a8a6382 | 2016-08-17 23:42:27 +0000 | [diff] [blame] | 44 | |
| 45 | !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) |
| 46 | !1 = !DIFile(filename: "crash.c", directory: "wasm/tests") |
| 47 | !2 = !{} |
| 48 | !3 = !{!4} |
Adrian Prantl | 1eadba1 | 2016-12-22 00:45:21 +0000 | [diff] [blame] | 49 | !4 = distinct !DIGlobalVariableExpression(var: !5) |
| 50 | !5 = !DIGlobalVariable(name: "key", scope: !0, file: !1, line: 7, type: !6, isLocal: false, isDefinition: true) |
| 51 | !6 = !DICompositeType(tag: DW_TAG_array_type, baseType: !7, size: 120, align: 8, elements: !10) |
| 52 | !7 = !DIDerivedType(tag: DW_TAG_typedef, name: "uint8_t", file: !8, line: 185, baseType: !9) |
| 53 | !8 = !DIFile(filename: "wasm/emscripten/system/include/libc/bits/alltypes.h", directory: "wasm/tests") |
| 54 | !9 = !DIBasicType(name: "unsigned char", size: 8, align: 8, encoding: DW_ATE_unsigned_char) |
| 55 | !10 = !{!11} |
| 56 | !11 = !DISubrange(count: 15) |
| 57 | !12 = !{i32 2, !"Dwarf Version", i32 4} |
| 58 | !13 = !{i32 2, !"Debug Info Version", i32 3} |
| 59 | !14 = !{!"clang version 3.9.0 (trunk 273884) (llvm/trunk 273897)"} |
| 60 | !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, variables: !2) |
| 61 | !16 = !DISubroutineType(types: !17) |
| 62 | !17 = !{!7, !18, !7} |
| 63 | !18 = !DIDerivedType(tag: DW_TAG_typedef, name: "size_t", file: !8, line: 124, baseType: !19) |
| 64 | !19 = !DIBasicType(name: "long unsigned int", size: 32, align: 32, encoding: DW_ATE_unsigned) |
| 65 | !20 = !{i64 0, !"_ZTSFhmhE"} |
| 66 | !21 = !DILocalVariable(name: "i", arg: 1, scope: !15, file: !1, line: 11, type: !18) |
| 67 | !22 = !DIExpression() |
| 68 | !23 = !DILocation(line: 11, column: 23, scope: !15) |
| 69 | !24 = !DILocalVariable(name: "v", arg: 2, scope: !15, file: !1, line: 11, type: !7) |
| 70 | !25 = !DILocation(line: 11, column: 34, scope: !15) |
| 71 | !26 = !DILocation(line: 12, column: 11, scope: !15) |
| 72 | !27 = !DILocation(line: 12, column: 19, scope: !15) |
| 73 | !28 = !DILocation(line: 12, column: 21, scope: !15) |
| 74 | !29 = !DILocation(line: 12, column: 15, scope: !15) |
| 75 | !30 = !DILocation(line: 12, column: 13, scope: !15) |
| 76 | !31 = !DILocation(line: 12, column: 10, scope: !15) |
| 77 | !32 = !DILocation(line: 12, column: 3, scope: !15) |
| 78 | |