1 ; RUN: llc -enable-machine-outliner -mtriple=x86_64-apple-darwin < %s | FileCheck %s
3 @x = global i32 0, align 4, !dbg !0
5 define i32 @main() #0 !dbg !11 {
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.
14 ; CHECK-SAME: OUTLINED_FUNCTION_0
15 store i32 1, i32* %2, align 4
16 store i32 2, i32* %3, align 4
17 store i32 3, i32* %4, align 4
18 call void @llvm.dbg.value(metadata i32 10, i64 0, metadata !15, metadata !16), !dbg !17
19 store i32 4, i32* %5, align 4
20 store i32 0, i32* @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
25 ; CHECK-SAME: OUTLINED_FUNCTION_0
26 store i32 1, i32* %2, align 4
27 store i32 2, i32* %3, align 4
28 store i32 3, i32* %4, align 4
29 store i32 4, i32* %5, align 4
30 store i32 1, i32* @x, align 4, !dbg !14
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)
43 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
45 declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #1
47 attributes #0 = { noredzone nounwind ssp uwtable "no-frame-pointer-elim"="true" }
50 !llvm.module.flags = !{!7, !8, !9}
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")
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)
67 !14 = !DILocation(line: 7, column: 4, scope: !11)
68 !15 = !DILocalVariable(name: "a", scope: !11, file: !3, line: 5, type: !6)
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)