mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 20:32:21 +00:00
Add DWARF discriminator support to DILexicalBlocks.
This adds support for emitting discriminators from DILexicalBlocks. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202736 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
98b5aaeebb
commit
6f8c0c0613
@ -319,6 +319,7 @@ Block descriptors
|
||||
metadata,;; Reference to context descriptor
|
||||
i32, ;; Line number
|
||||
i32, ;; Column number
|
||||
i32, ;; DWARF path discriminator value
|
||||
i32 ;; Unique ID to identify blocks from a template function
|
||||
}
|
||||
|
||||
@ -724,7 +725,8 @@ Compiled to LLVM, this function would be represented like this:
|
||||
!15 = metadata !{i32 786688, metadata !16, metadata !"Z", metadata !5, i32 5,
|
||||
metadata !11, i32 0, i32 0} ; [ DW_TAG_auto_variable ] [Z] \
|
||||
[line 5]
|
||||
!16 = metadata !{i32 786443, metadata !1, metadata !4, i32 4, i32 0, i32 0} \
|
||||
!16 = metadata !{i32 786443, metadata !1, metadata !4, i32 4, i32 0, i32 0,
|
||||
i32 0} \
|
||||
; [ DW_TAG_lexical_block ] [/private/tmp/t.c]
|
||||
!17 = metadata !{i32 5, i32 0, metadata !16, null}
|
||||
!18 = metadata !{i32 6, i32 0, metadata !16, null}
|
||||
@ -776,7 +778,8 @@ scope information for the variable ``Z``.
|
||||
|
||||
.. code-block:: llvm
|
||||
|
||||
!16 = metadata !{i32 786443, metadata !1, metadata !4, i32 4, i32 0, i32 0}
|
||||
!16 = metadata !{i32 786443, metadata !1, metadata !4, i32 4, i32 0, i32 0,
|
||||
i32 0}
|
||||
; [ DW_TAG_lexical_block ] [/private/tmp/t.c]
|
||||
!17 = metadata !{i32 5, i32 0, metadata !16, null}
|
||||
|
||||
|
@ -633,12 +633,14 @@ namespace llvm {
|
||||
|
||||
/// createLexicalBlock - This creates a descriptor for a lexical block
|
||||
/// with the specified parent context.
|
||||
/// @param Scope Parent lexical scope.
|
||||
/// @param File Source file
|
||||
/// @param Line Line number
|
||||
/// @param Col Column number
|
||||
/// @param Scope Parent lexical scope.
|
||||
/// @param File Source file.
|
||||
/// @param Line Line number.
|
||||
/// @param Col Column number.
|
||||
/// @param Discriminator DWARF path discriminator value.
|
||||
DILexicalBlock createLexicalBlock(DIDescriptor Scope, DIFile File,
|
||||
unsigned Line, unsigned Col);
|
||||
unsigned Line, unsigned Col,
|
||||
unsigned Discriminator);
|
||||
|
||||
/// \brief Create a descriptor for an imported module.
|
||||
/// @param Context The scope this module is imported into
|
||||
|
@ -522,6 +522,7 @@ public:
|
||||
DIScope getContext() const { return getFieldAs<DIScope>(2); }
|
||||
unsigned getLineNumber() const { return getUnsignedField(3); }
|
||||
unsigned getColumnNumber() const { return getUnsignedField(4); }
|
||||
unsigned getDiscriminator() const { return getUnsignedField(5); }
|
||||
bool Verify() const;
|
||||
};
|
||||
|
||||
|
@ -1825,6 +1825,7 @@ void DwarfDebug::recordSourceLine(unsigned Line, unsigned Col, const MDNode *S,
|
||||
StringRef Fn;
|
||||
StringRef Dir;
|
||||
unsigned Src = 1;
|
||||
unsigned Discriminator = 0;
|
||||
if (S) {
|
||||
DIDescriptor Scope(S);
|
||||
|
||||
@ -1848,13 +1849,15 @@ void DwarfDebug::recordSourceLine(unsigned Line, unsigned Col, const MDNode *S,
|
||||
DILexicalBlock DB(S);
|
||||
Fn = DB.getFilename();
|
||||
Dir = DB.getDirectory();
|
||||
Discriminator = DB.getDiscriminator();
|
||||
} else
|
||||
llvm_unreachable("Unexpected scope info");
|
||||
|
||||
Src = getOrCreateSourceID(
|
||||
Fn, Dir, Asm->OutStreamer.getContext().getDwarfCompileUnitID());
|
||||
}
|
||||
Asm->OutStreamer.EmitDwarfLocDirective(Src, Line, Col, Flags, 0, 0, Fn);
|
||||
Asm->OutStreamer.EmitDwarfLocDirective(Src, Line, Col, Flags, 0,
|
||||
Discriminator, Fn);
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -1186,7 +1186,8 @@ DILexicalBlockFile DIBuilder::createLexicalBlockFile(DIDescriptor Scope,
|
||||
}
|
||||
|
||||
DILexicalBlock DIBuilder::createLexicalBlock(DIDescriptor Scope, DIFile File,
|
||||
unsigned Line, unsigned Col) {
|
||||
unsigned Line, unsigned Col,
|
||||
unsigned Discriminator) {
|
||||
// Defeat MDNode uniquing for lexical blocks by using unique id.
|
||||
static unsigned int unique_id = 0;
|
||||
Value *Elts[] = {
|
||||
@ -1195,6 +1196,7 @@ DILexicalBlock DIBuilder::createLexicalBlock(DIDescriptor Scope, DIFile File,
|
||||
getNonCompileUnitScope(Scope),
|
||||
ConstantInt::get(Type::getInt32Ty(VMContext), Line),
|
||||
ConstantInt::get(Type::getInt32Ty(VMContext), Col),
|
||||
ConstantInt::get(Type::getInt32Ty(VMContext), Discriminator),
|
||||
ConstantInt::get(Type::getInt32Ty(VMContext), unique_id++)
|
||||
};
|
||||
DILexicalBlock R(MDNode::get(VMContext, Elts));
|
||||
|
@ -600,7 +600,7 @@ bool DISubrange::Verify() const {
|
||||
|
||||
/// \brief Verify that the lexical block descriptor is well formed.
|
||||
bool DILexicalBlock::Verify() const {
|
||||
return isLexicalBlock() && DbgNode->getNumOperands() == 6;
|
||||
return isLexicalBlock() && DbgNode->getNumOperands() == 7;
|
||||
}
|
||||
|
||||
/// \brief Verify that the file-scoped lexical block descriptor is well formed.
|
||||
|
63
test/DebugInfo/X86/discriminator.ll
Normal file
63
test/DebugInfo/X86/discriminator.ll
Normal file
@ -0,0 +1,63 @@
|
||||
; RUN: llc -mtriple=i386-unknown-unknown %s -o %t -filetype=obj
|
||||
; RUN: llvm-dwarfdump -debug-dump=line %t | FileCheck %s
|
||||
;
|
||||
; Generated from:
|
||||
;
|
||||
; int foo(int i) {
|
||||
; if (i < 10) return i - 1;
|
||||
; return 0;
|
||||
; }
|
||||
;
|
||||
; Manually generated debug nodes !14 and !15 to incorporate an
|
||||
; arbitrary discriminator with value 42.
|
||||
|
||||
define i32 @foo(i32 %i) #0 {
|
||||
entry:
|
||||
%retval = alloca i32, align 4
|
||||
%i.addr = alloca i32, align 4
|
||||
store i32 %i, i32* %i.addr, align 4
|
||||
%0 = load i32* %i.addr, align 4, !dbg !10
|
||||
%cmp = icmp slt i32 %0, 10, !dbg !10
|
||||
br i1 %cmp, label %if.then, label %if.end, !dbg !10
|
||||
|
||||
if.then: ; preds = %entry
|
||||
%1 = load i32* %i.addr, align 4, !dbg !14
|
||||
%sub = sub nsw i32 %1, 1, !dbg !14
|
||||
store i32 %sub, i32* %retval, !dbg !14
|
||||
br label %return, !dbg !14
|
||||
|
||||
if.end: ; preds = %entry
|
||||
store i32 0, i32* %retval, !dbg !12
|
||||
br label %return, !dbg !12
|
||||
|
||||
return: ; preds = %if.end, %if.then
|
||||
%2 = load i32* %retval, !dbg !13
|
||||
ret i32 %2, !dbg !13
|
||||
}
|
||||
|
||||
attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
|
||||
|
||||
!llvm.dbg.cu = !{!0}
|
||||
!llvm.module.flags = !{!7, !8}
|
||||
!llvm.ident = !{!9}
|
||||
|
||||
!0 = metadata !{i32 786449, metadata !1, i32 12, metadata !"clang version 3.5 ", i1 false, metadata !"", i32 0, metadata !2, metadata !2, metadata !3, metadata !2, metadata !2, metadata !""} ; [ DW_TAG_compile_unit ] [./discriminator.c] [DW_LANG_C99]
|
||||
!1 = metadata !{metadata !"discriminator.c", metadata !"."}
|
||||
!2 = metadata !{}
|
||||
!3 = metadata !{metadata !4}
|
||||
!4 = metadata !{i32 786478, metadata !1, metadata !5, metadata !"foo", metadata !"foo", metadata !"", i32 1, metadata !6, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, i32 (i32)* @foo, null, null, metadata !2, i32 1} ; [ DW_TAG_subprogram ] [line 1] [def] [foo]
|
||||
!5 = metadata !{i32 786473, metadata !1} ; [ DW_TAG_file_type ] [./discriminator.c]
|
||||
!6 = metadata !{i32 786453, i32 0, null, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !2, i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
|
||||
!7 = metadata !{i32 2, metadata !"Dwarf Version", i32 4}
|
||||
!8 = metadata !{i32 1, metadata !"Debug Info Version", i32 1}
|
||||
!9 = metadata !{metadata !"clang version 3.5 "}
|
||||
!10 = metadata !{i32 2, i32 0, metadata !11, null}
|
||||
!11 = metadata !{i32 786443, metadata !1, metadata !4, i32 2, i32 0, i32 0, i32 0} ; [ DW_TAG_lexical_block ] [./discriminator.c]
|
||||
!12 = metadata !{i32 3, i32 0, metadata !4, null}
|
||||
!13 = metadata !{i32 4, i32 0, metadata !4, null}
|
||||
!14 = metadata !{i32 2, i32 0, metadata !15, null}
|
||||
!15 = metadata !{i32 786443, metadata !1, metadata !4, i32 2, i32 0, i32 42, i32 1} ; [ DW_TAG_lexical_block ] [./discriminator.c]
|
||||
|
||||
; CHECK: Address Line Column File ISA Discriminator Flags
|
||||
; CHECK: ------------------ ------ ------ ------ --- ------------- -------------
|
||||
; CHECK: 0x0000000000000011 2 0 1 0 42 is_stmt
|
Loading…
Reference in New Issue
Block a user