DebugInfo: Fix r309526, ensure resetting base address selection entries are used

Missed the resetting base address selections when going from a base
address version to zero base address for non-base-addressed entries.

llvm-svn: 309529
This commit is contained in:
David Blaikie 2017-07-31 00:18:24 +00:00
parent ae3625ad1d
commit cf261b51d7
2 changed files with 55 additions and 22 deletions

View File

@ -1873,6 +1873,7 @@ void DwarfDebug::emitDebugRanges() {
}
auto *CUBase = TheCU->getBaseAddress();
bool BaseIsSet = false;
for (const auto &P : MV) {
// Don't bother with a base address entry if there's only one range in
// this section in this range list - for example ranges for a CU will
@ -1882,11 +1883,16 @@ void DwarfDebug::emitDebugRanges() {
// contrubutions.
auto *Base = CUBase;
if (!Base && P.second.size() > 1) {
BaseIsSet = true;
// FIXME/use care: This may not be a useful base address if it's not
// the lowest address/range in this object.
Base = P.second.front()->getStart();
Asm->OutStreamer->EmitIntValue(-1, Size);
Asm->OutStreamer->EmitSymbolValue(Base, Size);
} else if (BaseIsSet) {
BaseIsSet = false;
Asm->OutStreamer->EmitIntValue(-1, Size);
Asm->OutStreamer->EmitIntValue(0, Size);
}
for (const auto *RS : P.second) {

View File

@ -14,54 +14,81 @@
; smaller (the growth of debug_ranges itself would be more significant).
; CHECK: {{^.Ldebug_ranges0}}
; CHECK: .quad -1
; CHECK: .quad .Lfunc_begin0
; CHECK: .quad .Lfunc_begin0-.Lfunc_begin0
; CHECK: .quad .Lfunc_end0-.Lfunc_begin0
; CHECK: .quad .Lfunc_begin2-.Lfunc_begin0
; CHECK: .quad .Lfunc_end2-.Lfunc_begin0
; CHECK: .quad .Lfunc_begin1
; CHECK: .quad .Lfunc_end1
; CHECK: .quad 0
; CHECK: .quad 0
; CHECK-NEXT: .quad .Lfunc_begin0
; CHECK-NEXT: .quad .Lfunc_end0
; CHECK-NEXT: .quad -1
; CHECK-NEXT: .quad .Lfunc_begin1
; CHECK-NEXT: .quad .Lfunc_begin1-.Lfunc_begin1
; CHECK-NEXT: .quad .Lfunc_end1-.Lfunc_begin1
; CHECK-NEXT: .quad .Lfunc_begin3-.Lfunc_begin1
; CHECK-NEXT: .quad .Lfunc_end3-.Lfunc_begin1
; CHECK-NEXT: .quad -1
; CHECK-NEXT: .quad 0
; CHECK-NEXT: .quad .Lfunc_begin4
; CHECK-NEXT: .quad .Lfunc_end4
; CHECK-NEXT: .quad .Lfunc_begin5
; CHECK-NEXT: .quad .Lfunc_end5
; CHECK-NEXT: .quad 0
; CHECK-NEXT: .quad 0
; Function Attrs: noinline nounwind optnone uwtable
define void @_Z2f1v() #0 !dbg !7 {
define void @_Z2f1v() #0 section "a" !dbg !7 {
entry:
ret void, !dbg !10
}
; Function Attrs: noinline nounwind optnone uwtable
define void @_Z2f2v() #0 section "narf" !dbg !11 {
define void @_Z2f2v() #0 section "b" !dbg !11 {
entry:
ret void, !dbg !12
}
; Function Attrs: noinline nounwind optnone uwtable
define void @_Z2f3v() #0 !dbg !13 {
define void @_Z2f3v() #0 section "b" {
entry:
ret void
}
; Function Attrs: noinline nounwind optnone uwtable
define void @_Z2f4v() #0 section "b" !dbg !13 {
entry:
ret void, !dbg !14
}
; Function Attrs: noinline nounwind optnone uwtable
define void @_Z2f5v() #0 section "e" !dbg !15 {
entry:
ret void, !dbg !16
}
; Function Attrs: noinline nounwind optnone uwtable
define void @_Z2f6v() #0 section "f" !dbg !17 {
entry:
ret void, !dbg !18
}
attributes #0 = { noinline nounwind optnone uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
!llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!3, !4, !5}
!llvm.ident = !{!6}
!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 6.0.0 (trunk 309510) (llvm/trunk 309516)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
!1 = !DIFile(filename: "range.cpp", directory: "/usr/local/google/home/blaikie/dev/scratch")
!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 6.0.0 (trunk 309523) (llvm/trunk 309526)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
!1 = !DIFile(filename: "funcs.cpp", directory: "/usr/local/google/home/blaikie/dev/scratch")
!2 = !{}
!3 = !{i32 2, !"Dwarf Version", i32 4}
!4 = !{i32 2, !"Debug Info Version", i32 3}
!5 = !{i32 1, !"wchar_size", i32 4}
!6 = !{!"clang version 6.0.0 (trunk 309510) (llvm/trunk 309516)"}
!6 = !{!"clang version 6.0.0 (trunk 309523) (llvm/trunk 309526)"}
!7 = distinct !DISubprogram(name: "f1", linkageName: "_Z2f1v", scope: !1, file: !1, line: 1, type: !8, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
!8 = !DISubroutineType(types: !9)
!9 = !{null}
!10 = !DILocation(line: 2, column: 1, scope: !7)
!11 = distinct !DISubprogram(name: "f2", linkageName: "_Z2f2v", scope: !1, file: !1, line: 3, type: !8, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
!12 = !DILocation(line: 4, column: 1, scope: !11)
!13 = distinct !DISubprogram(name: "f3", linkageName: "_Z2f3v", scope: !1, file: !1, line: 5, type: !8, isLocal: false, isDefinition: true, scopeLine: 5, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
!14 = !DILocation(line: 6, column: 1, scope: !13)
!10 = !DILocation(line: 1, column: 42, scope: !7)
!11 = distinct !DISubprogram(name: "f2", linkageName: "_Z2f2v", scope: !1, file: !1, line: 2, type: !8, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
!12 = !DILocation(line: 2, column: 42, scope: !11)
!13 = distinct !DISubprogram(name: "f4", linkageName: "_Z2f4v", scope: !1, file: !1, line: 4, type: !8, isLocal: false, isDefinition: true, scopeLine: 4, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
!14 = !DILocation(line: 4, column: 42, scope: !13)
!15 = distinct !DISubprogram(name: "f5", linkageName: "_Z2f5v", scope: !1, file: !1, line: 5, type: !8, isLocal: false, isDefinition: true, scopeLine: 5, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
!16 = !DILocation(line: 5, column: 42, scope: !15)
!17 = distinct !DISubprogram(name: "f6", linkageName: "_Z2f6v", scope: !1, file: !1, line: 6, type: !8, isLocal: false, isDefinition: true, scopeLine: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
!18 = !DILocation(line: 6, column: 42, scope: !17)