mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-23 13:02:52 +02:00
fcd1037fbe
For the following motivating example bool c(); void f(); bool start() { bool result = c(); if (!c()) { result = false; goto exit; } f(); result = true; exit: return result; } we would previously generate a single DW_AT_const_value(1) because only the DBG_VALUE in the second-to-last basic block survived codegen. This patch improves the heuristic used to determine when a DBG_VALUE is available at the beginning of its variable's enclosing lexical scope: - Stop giving singular constants blanket permission to take over the entire scope. There is still a special case for constants in the function prologue that we also miight want to retire later. - Use the lexical scope information to determine available-at-entry instead of proximity to the function prologue. After this patch we generate a location list with a more accurate narrower availability for the constant true value. As a pleasant side effect, we also generate inline locations instead of location lists where a loacation covers the entire range of the enclosing lexical scope. Measured on compiling llc with four targets this doesn't have an effect on compile time and reduces the size of the debug info for llc by ~600K. rdar://problem/30286912 llvm-svn: 305599
77 lines
3.3 KiB
LLVM
77 lines
3.3 KiB
LLVM
; RUN: llc -filetype=obj -o %t.o %s
|
|
; RUN: llvm-dwarfdump %t.o | FileCheck %s
|
|
|
|
; Testcase generated using 'clang -g -O2 -S -emit-llvm' from the following:
|
|
;; void sink(void);
|
|
;; static __attribute__((always_inline)) void bar(int a) { sink(); }
|
|
;; void foo(void) {
|
|
;; bar(0);
|
|
;; bar(0);
|
|
;; }
|
|
|
|
; Check that we have formal parameters for 'a' in both inlined subroutines.
|
|
; CHECK: .debug_info
|
|
; CHECK: DW_TAG_inlined_subroutine
|
|
; CHECK-NEXT: DW_AT_abstract_origin {{.*}} "bar"
|
|
; CHECK: DW_TAG_formal_parameter
|
|
; CHECK-NEXT: DW_AT_const_value
|
|
; CHECK-NEXT: DW_AT_abstract_origin {{.*}} "a"
|
|
; CHECK: DW_TAG_inlined_subroutine
|
|
; CHECK-NEXT: DW_AT_abstract_origin {{.*}} "bar"
|
|
; CHECK: DW_TAG_formal_parameter
|
|
; CHECK-NEXT: DW_AT_location [DW_FORM_data4] (0x00000000)
|
|
; CHECK-NEXT: DW_AT_abstract_origin {{.*}} "a"
|
|
;
|
|
; CHECK: .debug_loc
|
|
; CHECK: Location description: 11 00
|
|
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
|
|
target triple = "x86_64-apple-darwin"
|
|
|
|
; Function Attrs: nounwind ssp uwtable
|
|
define void @foo() #0 !dbg !4 {
|
|
entry:
|
|
tail call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !12, metadata !17) #3, !dbg !18
|
|
tail call void @sink() #3, !dbg !20
|
|
tail call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !12, metadata !17) #3, !dbg !21
|
|
tail call void @sink() #3, !dbg !23
|
|
ret void, !dbg !24
|
|
}
|
|
|
|
declare void @sink()
|
|
|
|
; Function Attrs: nounwind readnone
|
|
declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #2
|
|
|
|
attributes #0 = { nounwind ssp uwtable }
|
|
attributes #2 = { nounwind readnone }
|
|
attributes #3 = { nounwind }
|
|
|
|
!llvm.dbg.cu = !{!0}
|
|
!llvm.module.flags = !{!13, !14, !15}
|
|
!llvm.ident = !{!16}
|
|
|
|
!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.7.0 (trunk 235110) (llvm/trunk 235108)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !2, globals: !2, imports: !2)
|
|
!1 = !DIFile(filename: "t.c", directory: "/path/to/dir")
|
|
!2 = !{}
|
|
!4 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 3, type: !5, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: true, unit: !0, variables: !2)
|
|
!5 = !DISubroutineType(types: !6)
|
|
!6 = !{null}
|
|
!7 = distinct !DISubprogram(name: "bar", scope: !1, file: !1, line: 2, type: !8, isLocal: true, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: true, unit: !0, variables: !11)
|
|
!8 = !DISubroutineType(types: !9)
|
|
!9 = !{null, !10}
|
|
!10 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
|
|
!11 = !{!12}
|
|
!12 = !DILocalVariable(name: "a", arg: 1, scope: !7, file: !1, line: 2, type: !10)
|
|
!13 = !{i32 2, !"Dwarf Version", i32 2}
|
|
!14 = !{i32 2, !"Debug Info Version", i32 3}
|
|
!15 = !{i32 1, !"PIC Level", i32 2}
|
|
!16 = !{!"clang version 3.7.0 (trunk 235110) (llvm/trunk 235108)"}
|
|
!17 = !DIExpression()
|
|
!18 = !DILocation(line: 2, column: 52, scope: !7, inlinedAt: !19)
|
|
!19 = distinct !DILocation(line: 4, column: 3, scope: !4)
|
|
!20 = !DILocation(line: 2, column: 57, scope: !7, inlinedAt: !19)
|
|
!21 = !DILocation(line: 2, column: 52, scope: !7, inlinedAt: !22)
|
|
!22 = distinct !DILocation(line: 5, column: 3, scope: !4)
|
|
!23 = !DILocation(line: 2, column: 57, scope: !7, inlinedAt: !22)
|
|
!24 = !DILocation(line: 6, column: 1, scope: !4)
|