1 # RUN: llc -march=x86-64 -run-pass none -o - %s | FileCheck %s
2 # This test ensures that the MIR parser parses the machine instruction's
3 # debug location metadata correctly.
7 define i32 @test(i32 %x) #0 !dbg !4 {
9 %x.addr = alloca i32, align 4
10 store i32 %x, i32* %x.addr, align 4
11 call void @llvm.dbg.declare(metadata i32* %x.addr, metadata !12, metadata !DIExpression()), !dbg !13
12 %0 = load i32, i32* %x.addr, align 4, !dbg !14
16 define i32 @test_typed_immediates(i32 %x) #0 {
18 %x.addr = alloca i32, align 4
19 store i32 %x, i32* %x.addr, align 4
20 call void @llvm.dbg.declare(metadata i32* %x.addr, metadata !12, metadata !DIExpression()), !dbg !13
21 %0 = load i32, i32* %x.addr, align 4, !dbg !14
25 define i32 @test_mir_created(i32 %x) #0 !dbg !15 {
27 %x.addr = alloca i32, align 4
28 store i32 %x, i32* %x.addr, align 4
29 %0 = load i32, i32* %x.addr, align 4
30 %1 = load i32, i32* %x.addr, align 4
31 %2 = load i32, i32* %x.addr, align 4
32 %3 = load i32, i32* %x.addr, align 4
36 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
38 attributes #0 = { nounwind "no-frame-pointer-elim"="false" }
39 attributes #1 = { nounwind readnone }
42 !llvm.module.flags = !{!9, !10}
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: "")
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)
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)
65 tracksRegLiveness: true
67 - { id: 0, class: gr32 }
71 - { id: 0, name: x.addr, size: 4, alignment: 4 }
75 ; CHECK: DBG_VALUE $noreg, 0, !11, !DIExpression(), debug-location !12
76 ; CHECK: DBG_VALUE $noreg, 0, !11, !DIExpression(), debug-location !12
77 ; CHECK: $eax = COPY %0, debug-location !13
78 ; CHECK: RETQ $eax, debug-location !13
80 DBG_VALUE _, 0, !12, !DIExpression(), debug-location !13
81 ; Test whether debug-use is still recognized for compatibility with old
83 DBG_VALUE debug-use _, 0, !12, !DIExpression(), debug-location !13
84 MOV32mr %stack.0.x.addr, 1, _, 0, _, %0
85 $eax = COPY %0, debug-location !14
86 RETQ $eax, debug-location !14
89 name: test_typed_immediates
90 tracksRegLiveness: true
92 - { id: 0, class: gr32 }
96 - { id: 0, name: x.addr, size: 4, alignment: 4 }
102 ; CHECK: DBG_VALUE $noreg, i32 0, !DIExpression(), !12
103 ; CHECK-NEXT: DBG_VALUE $noreg, i64 -22, !DIExpression(), !12
104 ; CHECK-NEXT: DBG_VALUE $noreg, i128 123492148938512984928424384934328985928, !DIExpression(), !12
105 DBG_VALUE _, i32 0, !DIExpression(), !13
106 DBG_VALUE _, i64 -22, !DIExpression(), !13
107 DBG_VALUE _, i128 123492148938512984928424384934328985928, !DIExpression(), !13
108 MOV32mr %stack.0.x.addr, 1, _, 0, _, %0
113 name: test_mir_created
114 tracksRegLiveness: true
116 - { id: 0, class: gr32 }
120 - { id: 0, name: x.addr, size: 4, alignment: 4 }
126 ; CHECK-LABEL: name: test_mir_created
127 ; 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))