blob: fce0664c0dcc18b079b863084fd8e045e35574e4 [file] [log] [blame]
Vedant Kumar195dfd12017-12-08 21:57:28 +00001; RUN: opt -debugify -S -o - < %s | FileCheck %s
2
3; RUN: opt -debugify -debugify -S -o - < %s 2>&1 | \
4; RUN: FileCheck %s -check-prefix=CHECK-REPEAT
5
6; RUN: opt -debugify -check-debugify -S -o - < %s | \
7; RUN: FileCheck %s -implicit-check-not="CheckDebugify: FAIL"
8
9; RUN: opt -debugify -strip -check-debugify -S -o - < %s | \
10; RUN: FileCheck %s -check-prefix=CHECK-FAIL
11
12; CHECK-LABEL: define void @foo
13define void @foo() {
14; CHECK: ret void, !dbg ![[RET1:.*]]
15 ret void
16}
17
18; CHECK-LABEL: define i32 @bar
19define i32 @bar() {
20; CHECK: call void @foo(), !dbg ![[CALL1:.*]]
21 call void @foo()
22
23; CHECK: add i32 0, 1, !dbg ![[ADD1:.*]]
24 %sum = add i32 0, 1
25
26; CHECK: ret i32 0, !dbg ![[RET2:.*]]
27 ret i32 0
28}
29
30; CHECK-DAG: !llvm.dbg.cu = !{![[CU:.*]]}
31; CHECK-DAG: !llvm.debugify = !{![[NUM_INSTS:.*]], ![[NUM_VARS:.*]]}
32
33; CHECK-DAG: ![[CU]] = distinct !DICompileUnit(language: DW_LANG_C, file: {{.*}}, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: {{.*}})
34; CHECK-DAG: !DIFile(filename: "<stdin>", directory: "/")
35; CHECK-DAG: distinct !DISubprogram(name: "foo", linkageName: "foo", scope: null, file: {{.*}}, line: 1, type: {{.*}}, isLocal: false, isDefinition: true, scopeLine: 1, isOptimized: true, unit: {{.*}}, variables: {{.*}})
36; CHECK-DAG: distinct !DISubprogram(name: "bar", linkageName: "bar", scope: null, file: {{.*}}, line: 2, type: {{.*}}, isLocal: false, isDefinition: true, scopeLine: 2, isOptimized: true, unit: {{.*}}, variables: {{.*}})
37
38; --- DILocations
39; CHECK-DAG: ![[RET1]] = !DILocation(line: 1, column: 1
40; CHECK-DAG: ![[CALL1]] = !DILocation(line: 2, column: 1
41; CHECK-DAG: ![[ADD1]] = !DILocation(line: 3, column: 1
42; CHECK-DAG: ![[RET2]] = !DILocation(line: 4, column: 1
43
44; --- DILocalVariables
45; CHECK-DAG: ![[TY32:.*]] = !DIBasicType(name: "ty32", size: 32, encoding: DW_ATE_unsigned)
46; CHECK-DAG: !DILocalVariable(name: "1", scope: {{.*}}, file: {{.*}}, line: 3, type: ![[TY32]])
47
48; --- Metadata counts
49; CHECK-DAG: ![[NUM_INSTS]] = !{i32 4}
50; CHECK-DAG: ![[NUM_VARS]] = !{i32 1}
51
52; --- Repeat case
53; CHECK-REPEAT: Debugify: Skipping module with debug info
54
55; --- Failure case
56; CHECK-FAIL: ERROR: Instruction with empty DebugLoc -- ret void
57; CHECK-FAIL: ERROR: Instruction with empty DebugLoc -- call void @foo()
58; CHECK-FAIL: ERROR: Instruction with empty DebugLoc -- {{.*}} add i32 0, 1
59; CHECK-FAIL: ERROR: Instruction with empty DebugLoc -- ret i32 0
60; CHECK-FAIL: WARNING: Missing line 1
61; CHECK-FAIL: WARNING: Missing line 2
62; CHECK-FAIL: WARNING: Missing line 3
63; CHECK-FAIL: WARNING: Missing line 4
64; CHECK-FAIL: ERROR: Missing variable 1
65; CHECK-FAIL: CheckDebugify: FAIL