xref: /llvm-project/llvm/test/CodeGen/X86/machine-outliner-debuginfo.ll (revision 2f448bf509432c1a19ec46ab8cbc7353c03c6280)
1; RUN: llc -enable-machine-outliner -mtriple=x86_64-apple-darwin < %s | FileCheck %s
2
3@x = global i32 0, align 4, !dbg !0
4
5define i32 @main() #0 !dbg !11 {
6  ; CHECK-LABEL: _main:
7  %1 = alloca i32, align 4
8  %2 = alloca i32, align 4
9  %3 = alloca i32, align 4
10  %4 = alloca i32, align 4
11  %5 = alloca i32, align 4
12  ; There is a debug value in the middle of this section, make sure debug values are ignored.
13  ; CHECK: callq
14  ; CHECK-SAME: OUTLINED_FUNCTION_0
15  store i32 1, ptr %2, align 4
16  store i32 2, ptr %3, align 4
17  store i32 3, ptr %4, align 4
18  call void @llvm.dbg.value(metadata i32 10, i64 0, metadata !15, metadata !16), !dbg !17
19  store i32 4, ptr %5, align 4
20  store i32 0, ptr @x, align 4, !dbg !24
21  call void asm sideeffect "", "~{memory},~{dirflag},~{fpsr},~{flags}"()
22  ; This is the same sequence of instructions without a debug value. It should be outlined
23  ; in the same way.
24  ; CHECK: callq
25  ; CHECK-SAME: OUTLINED_FUNCTION_0
26  store i32 1, ptr %2, align 4
27  store i32 2, ptr %3, align 4
28  store i32 3, ptr %4, align 4
29  store i32 4, ptr %5, align 4
30  store i32 1, ptr @x, align 4, !dbg !14
31  ret i32 0, !dbg !25
32}
33
34; CHECK: OUTLINED_FUNCTION_0:
35; CHECK-NOT:  .loc  {{[0-9]+}} {{[0-9]+}} {{[0-9]+}} {{^(is_stmt)}}
36; CHECK-NOT:  ##DEBUG_VALUE: main:{{[a-z]}} <- {{[0-9]+}}
37; CHECK:      movl  $1, -{{[0-9]+}}(%rbp)
38; CHECK-NEXT: movl  $2, -{{[0-9]+}}(%rbp)
39; CHECK-NEXT: movl  $3, -{{[0-9]+}}(%rbp)
40; CHECK-NEXT: movl  $4, -{{[0-9]+}}(%rbp)
41; CHECK-NEXT: retq
42
43declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
44
45declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #1
46
47attributes #0 = { noredzone nounwind ssp uwtable "frame-pointer"="all" }
48
49!llvm.dbg.cu = !{!2}
50!llvm.module.flags = !{!7, !8, !9}
51!llvm.ident = !{!10}
52
53!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
54!1 = distinct !DIGlobalVariable(name: "x", scope: !2, file: !3, line: 2, type: !6, isLocal: false, isDefinition: true)
55!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 5.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5)
56!3 = !DIFile(filename: "debug-test.c", directory: "dir")
57!4 = !{}
58!5 = !{!0}
59!6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
60!7 = !{i32 2, !"Dwarf Version", i32 4}
61!8 = !{i32 2, !"Debug Info Version", i32 3}
62!9 = !{i32 1, !"PIC Level", i32 2}
63!10 = !{!"clang version 5.0.0"}
64!11 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 4, type: !12, isLocal: false, isDefinition: true, scopeLine: 4, flags: DIFlagPrototyped, isOptimized: false, unit: !2, retainedNodes: !4)
65!12 = !DISubroutineType(types: !13)
66!13 = !{!6}
67!14 = !DILocation(line: 7, column: 4, scope: !11)
68!15 = !DILocalVariable(name: "a", scope: !11, file: !3, line: 5, type: !6)
69!16 = !DIExpression()
70!17 = !DILocation(line: 5, column: 6, scope: !11)
71!18 = !DILocalVariable(name: "b", scope: !11, file: !3, line: 5, type: !6)
72!19 = !DILocation(line: 5, column: 9, scope: !11)
73!20 = !DILocalVariable(name: "c", scope: !11, file: !3, line: 5, type: !6)
74!21 = !DILocation(line: 5, column: 12, scope: !11)
75!22 = !DILocalVariable(name: "d", scope: !11, file: !3, line: 5, type: !6)
76!23 = !DILocation(line: 5, column: 15, scope: !11)
77!24 = !DILocation(line: 14, column: 4, scope: !11)
78!25 = !DILocation(line: 21, column: 2, scope: !11)
79