140 lines · plain
1# RUN: llc -mtriple=x86_64 -run-pass none -o - %s | FileCheck %s2# This test ensures that the MIR parser parses the machine instruction's3# debug location metadata correctly.4 5--- |6 7 define i32 @test(i32 %x) #0 !dbg !4 {8 entry:9 %x.addr = alloca i32, align 410 store i32 %x, ptr %x.addr, align 411 call void @llvm.dbg.declare(metadata ptr %x.addr, metadata !12, metadata !DIExpression()), !dbg !1312 %0 = load i32, ptr %x.addr, align 4, !dbg !1413 ret i32 %0, !dbg !1414 }15 16 define i32 @test_typed_immediates(i32 %x) #0 {17 entry:18 %x.addr = alloca i32, align 419 store i32 %x, ptr %x.addr, align 420 call void @llvm.dbg.declare(metadata ptr %x.addr, metadata !12, metadata !DIExpression()), !dbg !1321 %0 = load i32, ptr %x.addr, align 4, !dbg !1422 ret i32 %0, !dbg !1423 }24 25 define i32 @test_mir_created(i32 %x) #0 !dbg !15 {26 entry:27 %x.addr = alloca i32, align 428 store i32 %x, ptr %x.addr, align 429 %0 = load i32, ptr %x.addr, align 430 %1 = load i32, ptr %x.addr, align 431 %2 = load i32, ptr %x.addr, align 432 %3 = load i32, ptr %x.addr, align 433 ret i32 %0, !dbg !1634 }35 36 declare void @llvm.dbg.declare(metadata, metadata, metadata) #137 38 attributes #0 = { nounwind "frame-pointer"="none" }39 attributes #1 = { nounwind readnone }40 41 !llvm.dbg.cu = !{!0}42 !llvm.module.flags = !{!9, !10}43 !llvm.ident = !{!11}44 45 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.7.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !2, globals: !2, imports: !2)46 !1 = !DIFile(filename: "test.ll", directory: "")47 !2 = !{}48 !4 = distinct !DISubprogram(name: "test", scope: !5, file: !5, line: 4, type: !6, isLocal: false, isDefinition: true, scopeLine: 4, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)49 !5 = !DIFile(filename: "test.c", directory: "")50 !6 = !DISubroutineType(types: !7)51 !7 = !{!8, !8}52 !8 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)53 !9 = !{i32 2, !"Dwarf Version", i32 4}54 !10 = !{i32 2, !"Debug Info Version", i32 3}55 !11 = !{!"clang version 3.7.0"}56 !12 = !DILocalVariable(name: "x", arg: 1, scope: !4, file: !5, line: 4, type: !8)57 !13 = !DILocation(line: 4, scope: !4)58 !14 = !DILocation(line: 8, scope: !4)59 !15 = distinct !DISubprogram(name: "test_mir_created", scope: !5, file: !5, line: 10, type: !6, isLocal: false, isDefinition: true, scopeLine: 10, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)60 !16 = !DILocation(line: 20, scope: !15)61 62...63---64name: test65tracksRegLiveness: true66registers:67 - { id: 0, class: gr32 }68frameInfo:69 maxAlignment: 470stack:71 - { id: 0, name: x.addr, size: 4, alignment: 4 }72body: |73 bb.0.entry:74 liveins: $edi75 ; CHECK: DBG_VALUE $noreg, 0, !11, !DIExpression(), debug-location !1276 ; CHECK: DBG_VALUE $noreg, 0, !11, !DIExpression(), debug-location !1277 ; CHECK: $eax = COPY %0, debug-location !1378 ; CHECK: RET64 $eax, debug-location !1379 %0 = COPY $edi80 DBG_VALUE _, 0, !12, !DIExpression(), debug-location !1381 ; Test whether debug-use is still recognized for compatibility with old82 ; files.83 DBG_VALUE debug-use _, 0, !12, !DIExpression(), debug-location !1384 MOV32mr %stack.0.x.addr, 1, _, 0, _, %085 $eax = COPY %0, debug-location !1486 RET64 $eax, debug-location !1487...88---89name: test_typed_immediates90tracksRegLiveness: true91registers:92 - { id: 0, class: gr32 }93frameInfo:94 maxAlignment: 495stack:96 - { id: 0, name: x.addr, size: 4, alignment: 4 }97body: |98 bb.0.entry:99 liveins: $edi100 101 %0 = COPY $edi102 ; CHECK: DBG_VALUE $noreg, i32 0, !11, !DIExpression()103 ; CHECK-NEXT: DBG_VALUE $noreg, i64 -22, !11, !DIExpression()104 ; CHECK-NEXT: DBG_VALUE $noreg, i128 123492148938512984928424384934328985928, !11, !DIExpression()105 DBG_VALUE _, i32 0, !12, !DIExpression(), debug-location !13106 DBG_VALUE _, i64 -22, !12, !DIExpression(), debug-location !13107 DBG_VALUE _, i128 123492148938512984928424384934328985928, !12, !DIExpression(), debug-location !13108 MOV32mr %stack.0.x.addr, 1, _, 0, _, %0109 $eax = COPY %0110 RET64 $eax111...112---113name: test_mir_created114tracksRegLiveness: true115registers:116 - { id: 0, class: gr32 }117frameInfo:118 maxAlignment: 4119stack:120 - { id: 0, name: x.addr, size: 4, alignment: 4 }121body: |122 bb.0.entry:123 liveins: $edi124 125 %0 = COPY $edi126 ; CHECK-LABEL: name: test_mir_created127 ; CHECK: MOV32mr %stack.0.x.addr, 1, $noreg, 0, $noreg, %0, debug-location !DILocation(line: 1, scope: !14)128 ; CHECK: MOV32mr %stack.0.x.addr, 1, $noreg, 0, $noreg, %0, debug-location !DILocation(line: 2, column: 2, scope: !14)129 ; CHECK: MOV32mr %stack.0.x.addr, 1, $noreg, 0, $noreg, %0, debug-location !DILocation(line: 3, column: 2, scope: !14, isImplicitCode: true)130 ; CHECK: MOV32mr %stack.0.x.addr, 1, $noreg, 0, $noreg, %0, debug-location !DILocation(line: 4, scope: !14, inlinedAt: !15)131 ; CHECK: MOV32mr %stack.0.x.addr, 1, $noreg, 0, $noreg, %0, debug-location !DILocation(line: 5, scope: !14, inlinedAt: !DILocation(line: 4, scope: !14))132 MOV32mr %stack.0.x.addr, 1, _, 0, _, %0, debug-location !DILocation(line: 1, scope: !15)133 MOV32mr %stack.0.x.addr, 1, _, 0, _, %0, debug-location !DILocation(line: 2, column: 2, scope: !15)134 MOV32mr %stack.0.x.addr, 1, _, 0, _, %0, debug-location !DILocation(line: 3, column: 2, scope: !15, isImplicitCode: true)135 MOV32mr %stack.0.x.addr, 1, _, 0, _, %0, debug-location !DILocation(line: 4, scope: !15, inlinedAt: !16)136 MOV32mr %stack.0.x.addr, 1, _, 0, _, %0, debug-location !DILocation(line: 5, scope: !15, inlinedAt: !DILocation(line: 4, scope: !15))137 $eax = COPY %0138 RET64 $eax139...140