2017-12-09 05:57:28 +08:00
|
|
|
; RUN: opt -debugify -S -o - < %s | FileCheck %s
|
2018-02-16 05:14:36 +08:00
|
|
|
; RUN: opt -passes=debugify -S -o - < %s | FileCheck %s
|
2017-12-09 05:57:28 +08:00
|
|
|
|
|
|
|
; RUN: opt -debugify -debugify -S -o - < %s 2>&1 | \
|
|
|
|
; RUN: FileCheck %s -check-prefix=CHECK-REPEAT
|
2018-02-16 05:14:36 +08:00
|
|
|
; RUN: opt -passes=debugify,debugify -S -o - < %s 2>&1 | \
|
|
|
|
; RUN: FileCheck %s -check-prefix=CHECK-REPEAT
|
2017-12-09 05:57:28 +08:00
|
|
|
|
|
|
|
; RUN: opt -debugify -check-debugify -S -o - < %s | \
|
2018-05-15 08:29:27 +08:00
|
|
|
; RUN: FileCheck %s -implicit-check-not="CheckModuleDebugify: FAIL"
|
2018-02-16 05:14:36 +08:00
|
|
|
; RUN: opt -passes=debugify,check-debugify -S -o - < %s | \
|
2018-05-15 08:29:27 +08:00
|
|
|
; RUN: FileCheck %s -implicit-check-not="CheckModuleDebugify: FAIL"
|
2018-02-16 05:14:36 +08:00
|
|
|
; RUN: opt -enable-debugify -passes=verify -S -o - < %s | \
|
2018-05-15 08:29:27 +08:00
|
|
|
; RUN: FileCheck %s -implicit-check-not="CheckModuleDebugify: FAIL"
|
2017-12-09 05:57:28 +08:00
|
|
|
|
2018-05-18 02:19:58 +08:00
|
|
|
; RUN: opt -debugify -strip -check-debugify -S -o - < %s 2>&1 | \
|
2017-12-09 05:57:28 +08:00
|
|
|
; RUN: FileCheck %s -check-prefix=CHECK-FAIL
|
|
|
|
|
2018-05-18 02:19:58 +08:00
|
|
|
; RUN: opt -enable-debugify -strip -S -o - < %s 2>&1 | \
|
2018-01-24 04:43:50 +08:00
|
|
|
; RUN: FileCheck %s -check-prefix=CHECK-FAIL
|
|
|
|
|
2018-05-18 02:19:58 +08:00
|
|
|
; RUN: opt -enable-debugify -S -o - < %s 2>&1 | FileCheck %s -check-prefix=PASS
|
|
|
|
|
|
|
|
; Verify that debugify can be safely used with piping
|
|
|
|
; RUN: opt -enable-debugify -O1 < %s | opt -O2 -o /dev/null
|
|
|
|
; RUN: opt -debugify -mem2reg -check-debugify < %s | opt -O2 -o /dev/null
|
2018-02-16 05:28:38 +08:00
|
|
|
|
2017-12-09 05:57:28 +08:00
|
|
|
; CHECK-LABEL: define void @foo
|
|
|
|
define void @foo() {
|
|
|
|
; CHECK: ret void, !dbg ![[RET1:.*]]
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK-LABEL: define i32 @bar
|
|
|
|
define i32 @bar() {
|
|
|
|
; CHECK: call void @foo(), !dbg ![[CALL1:.*]]
|
|
|
|
call void @foo()
|
|
|
|
|
|
|
|
; CHECK: add i32 0, 1, !dbg ![[ADD1:.*]]
|
|
|
|
%sum = add i32 0, 1
|
|
|
|
|
|
|
|
; CHECK: ret i32 0, !dbg ![[RET2:.*]]
|
|
|
|
ret i32 0
|
|
|
|
}
|
|
|
|
|
2018-02-14 02:15:27 +08:00
|
|
|
; CHECK-LABEL: define weak_odr zeroext i1 @baz
|
|
|
|
define weak_odr zeroext i1 @baz() {
|
|
|
|
; CHECK-NOT: !dbg
|
|
|
|
ret i1 false
|
|
|
|
}
|
|
|
|
|
2018-06-04 06:50:22 +08:00
|
|
|
; CHECK-LABEL: define i32 @boom
|
|
|
|
define i32 @boom() {
|
|
|
|
; CHECK: [[result:%.*]] = musttail call i32 @bar(), !dbg ![[musttail:.*]]
|
|
|
|
%retval = musttail call i32 @bar()
|
|
|
|
; CHECK-NEXT: ret i32 [[result]], !dbg ![[musttailRes:.*]]
|
|
|
|
ret i32 %retval
|
|
|
|
}
|
|
|
|
|
2017-12-09 05:57:28 +08:00
|
|
|
; CHECK-DAG: !llvm.dbg.cu = !{![[CU:.*]]}
|
|
|
|
; CHECK-DAG: !llvm.debugify = !{![[NUM_INSTS:.*]], ![[NUM_VARS:.*]]}
|
2018-05-25 07:00:23 +08:00
|
|
|
; CHECK-DAG: "Debug Info Version"
|
2017-12-09 05:57:28 +08:00
|
|
|
|
|
|
|
; CHECK-DAG: ![[CU]] = distinct !DICompileUnit(language: DW_LANG_C, file: {{.*}}, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: {{.*}})
|
|
|
|
; CHECK-DAG: !DIFile(filename: "<stdin>", directory: "/")
|
[DebugInfo] Add DILabel metadata and intrinsic llvm.dbg.label.
In order to set breakpoints on labels and list source code around
labels, we need collect debug information for labels, i.e., label
name, the function label belong, line number in the file, and the
address label located. In order to keep these information in LLVM
IR and to allow backend to generate debug information correctly.
We create a new kind of metadata for labels, DILabel. The format
of DILabel is
!DILabel(scope: !1, name: "foo", file: !2, line: 3)
We hope to keep debug information as much as possible even the
code is optimized. So, we create a new kind of intrinsic for label
metadata to avoid the metadata is eliminated with basic block.
The intrinsic will keep existing if we keep it from optimized out.
The format of the intrinsic is
llvm.dbg.label(metadata !1)
It has only one argument, that is the DILabel metadata. The
intrinsic will follow the label immediately. Backend could get the
label metadata through the intrinsic's parameter.
We also create DIBuilder API for labels to be used by Frontend.
Frontend could use createLabel() to allocate DILabel objects, and use
insertLabel() to insert llvm.dbg.label intrinsic in LLVM IR.
Differential Revision: https://reviews.llvm.org/D45024
Patch by Hsiangkai Wang.
llvm-svn: 331841
2018-05-09 10:40:45 +08:00
|
|
|
; CHECK-DAG: distinct !DISubprogram(name: "foo", linkageName: "foo", scope: null, file: {{.*}}, line: 1, type: {{.*}}, isLocal: false, isDefinition: true, scopeLine: 1, isOptimized: true, unit: {{.*}}, retainedNodes: {{.*}})
|
|
|
|
; CHECK-DAG: distinct !DISubprogram(name: "bar", linkageName: "bar", scope: null, file: {{.*}}, line: 2, type: {{.*}}, isLocal: false, isDefinition: true, scopeLine: 2, isOptimized: true, unit: {{.*}}, retainedNodes: {{.*}})
|
2017-12-09 05:57:28 +08:00
|
|
|
|
|
|
|
; --- DILocations
|
|
|
|
; CHECK-DAG: ![[RET1]] = !DILocation(line: 1, column: 1
|
|
|
|
; CHECK-DAG: ![[CALL1]] = !DILocation(line: 2, column: 1
|
|
|
|
; CHECK-DAG: ![[ADD1]] = !DILocation(line: 3, column: 1
|
|
|
|
; CHECK-DAG: ![[RET2]] = !DILocation(line: 4, column: 1
|
2018-06-04 06:50:22 +08:00
|
|
|
; CHECK-DAG: ![[musttail]] = !DILocation(line: 5, column: 1
|
|
|
|
; CHECK-DAG: ![[musttailRes]] = !DILocation(line: 6, column: 1
|
2017-12-09 05:57:28 +08:00
|
|
|
|
|
|
|
; --- DILocalVariables
|
|
|
|
; CHECK-DAG: ![[TY32:.*]] = !DIBasicType(name: "ty32", size: 32, encoding: DW_ATE_unsigned)
|
|
|
|
; CHECK-DAG: !DILocalVariable(name: "1", scope: {{.*}}, file: {{.*}}, line: 3, type: ![[TY32]])
|
|
|
|
|
|
|
|
; --- Metadata counts
|
2018-06-04 06:50:22 +08:00
|
|
|
; CHECK-DAG: ![[NUM_INSTS]] = !{i32 6}
|
2017-12-09 05:57:28 +08:00
|
|
|
; CHECK-DAG: ![[NUM_VARS]] = !{i32 1}
|
|
|
|
|
|
|
|
; --- Repeat case
|
2018-05-15 08:29:27 +08:00
|
|
|
; CHECK-REPEAT: ModuleDebugify: Skipping module with debug info
|
2017-12-09 05:57:28 +08:00
|
|
|
|
|
|
|
; --- Failure case
|
2018-05-15 08:29:27 +08:00
|
|
|
; CHECK-FAIL: ERROR: Instruction with empty DebugLoc in function foo -- ret void
|
|
|
|
; CHECK-FAIL: ERROR: Instruction with empty DebugLoc in function bar -- call void @foo()
|
|
|
|
; CHECK-FAIL: ERROR: Instruction with empty DebugLoc in function bar -- {{.*}} add i32 0, 1
|
|
|
|
; CHECK-FAIL: ERROR: Instruction with empty DebugLoc in function bar -- ret i32 0
|
2017-12-09 05:57:28 +08:00
|
|
|
; CHECK-FAIL: WARNING: Missing line 1
|
|
|
|
; CHECK-FAIL: WARNING: Missing line 2
|
|
|
|
; CHECK-FAIL: WARNING: Missing line 3
|
|
|
|
; CHECK-FAIL: WARNING: Missing line 4
|
2018-06-27 02:54:10 +08:00
|
|
|
; CHECK-FAIL: WARNING: Missing variable 1
|
2018-05-25 07:00:22 +08:00
|
|
|
; CHECK-FAIL: CheckModuleDebugify: FAIL
|
2018-02-16 05:28:38 +08:00
|
|
|
|
2018-05-25 07:00:22 +08:00
|
|
|
; PASS: CheckModuleDebugify: PASS
|