-
Notifications
You must be signed in to change notification settings - Fork 11.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DebugInstrRef] Create DBG_INSTR_REFs in SelectionDAG
When given the -experimental-debug-variable-locations option (via -Xclang or to llc), have SelectionDAG generate DBG_INSTR_REF instructions instead of DBG_VALUE. For now, this only happens in a limited circumstance: when the value referred to is not a PHI and is defined in the current block. Other situations introduce interesting problems, addresed in later patches. Practically, this patch hooks into InstrEmitter and if it can find a defining instruction for a value, gives it an instruction number, and points the DBG_INSTR_REF at that <instr, operand> pair. Differential Revision: https://reviews.llvm.org/D85747
- Loading branch information
Showing
5 changed files
with
132 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
; RUN: llc %s -mtriple=x86_64-unknown-unknown -o - -stop-before=finalize-isel \ | ||
; RUN: | FileCheck %s --check-prefix=NORMAL \ | ||
; RUN: --implicit-check-not=debug-instr-number \ | ||
; RUN: --implicit-check-not=DBG_INSTR_REF | ||
; RUN: llc %s -mtriple=x86_64-unknown-unknown -o - -stop-before=finalize-isel \ | ||
; RUN: -experimental-debug-variable-locations -verify-machineinstrs \ | ||
; RUN: | FileCheck %s --check-prefix=INSTRREF \ | ||
; RUN: --implicit-check-not=DBG_VALUE | ||
|
||
; Test that SelectionDAG produces DBG_VALUEs normally, but DBG_INSTR_REFs when | ||
; asked. | ||
|
||
; NORMAL: %[[REG0:[0-9]+]]:gr32 = ADD32rr | ||
; NORMAL-NEXT: DBG_VALUE %[[REG0]] | ||
; NORMAL-NEXT: %[[REG1:[0-9]+]]:gr32 = ADD32rr | ||
; NORMAL-NEXT: DBG_VALUE %[[REG1]] | ||
|
||
; Note that I'm baking in an assumption of one-based ordering here. We could | ||
; capture and check for the instruction numbers, we'd rely on machine verifier | ||
; ensuring there were no duplicates. | ||
|
||
; INSTRREF: ADD32rr | ||
; INSTRREF-SAME: debug-instr-number 1 | ||
; INSTRREF-NEXT: DBG_INSTR_REF 1, 0 | ||
; INSTRREF-NEXT: ADD32rr | ||
; INSTRREF-SAME: debug-instr-number 2 | ||
; INSTRREF-NEXT: DBG_INSTR_REF 2, 0 | ||
|
||
declare void @llvm.dbg.value(metadata, metadata, metadata) | ||
|
||
define i32 @foo(i32 %bar, i32 %baz, i32 %qux) !dbg !7 { | ||
entry: | ||
%0 = add i32 %bar, %baz, !dbg !14 | ||
call void @llvm.dbg.value(metadata i32 %0, metadata !13, metadata !DIExpression()), !dbg !14 | ||
%1 = add i32 %0, %qux | ||
call void @llvm.dbg.value(metadata i32 %1, metadata !13, metadata !DIExpression()), !dbg !14 | ||
ret i32 %1, !dbg !14 | ||
} | ||
|
||
!llvm.dbg.cu = !{!0} | ||
!llvm.module.flags = !{!3, !4} | ||
|
||
!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None) | ||
!1 = !DIFile(filename: "exprconflict.c", directory: "/home/jmorse") | ||
!2 = !{} | ||
!3 = !{i32 2, !"Dwarf Version", i32 4} | ||
!4 = !{i32 2, !"Debug Info Version", i32 3} | ||
!7 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 5, type: !8, scopeLine: 5, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !11) | ||
!8 = !DISubroutineType(types: !9) | ||
!9 = !{!10, !10} | ||
!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) | ||
!11 = !{!13} | ||
!13 = !DILocalVariable(name: "baz", scope: !7, file: !1, line: 6, type: !10) | ||
!14 = !DILocation(line: 1, scope: !7) |