2013-07-24 23:55:41 +08:00
|
|
|
; RUN: llc -O2 < %s | FileCheck %s
|
|
|
|
; RUN: llc -O2 -regalloc=basic < %s | FileCheck %s
|
2010-06-02 03:59:01 +08:00
|
|
|
; Test to check that unused argument 'this' is not undefined in debug info.
|
2010-06-17 03:39:45 +08:00
|
|
|
|
|
|
|
target triple = "x86_64-apple-darwin10.2"
|
2010-06-02 03:59:01 +08:00
|
|
|
%struct.foo = type { i32 }
|
|
|
|
|
|
|
|
@llvm.used = appending global [1 x i8*] [i8* bitcast (i32 (%struct.foo*, i32)* @_ZN3foo3bazEi to i8*)], section "llvm.metadata" ; <[1 x i8*]*> [#uses=0]
|
|
|
|
|
|
|
|
define i32 @_ZN3foo3bazEi(%struct.foo* nocapture %this, i32 %x) nounwind readnone optsize noinline ssp align 2 {
|
2013-06-16 00:02:44 +08:00
|
|
|
;CHECK: DEBUG_VALUE: baz:this <- RDI{{$}}
|
2010-06-02 03:59:01 +08:00
|
|
|
entry:
|
|
|
|
tail call void @llvm.dbg.value(metadata !{%struct.foo* %this}, i64 0, metadata !15)
|
|
|
|
tail call void @llvm.dbg.value(metadata !{i32 %x}, i64 0, metadata !16)
|
|
|
|
%0 = mul nsw i32 %x, 7, !dbg !29 ; <i32> [#uses=1]
|
|
|
|
%1 = add nsw i32 %0, 1, !dbg !29 ; <i32> [#uses=1]
|
|
|
|
ret i32 %1, !dbg !29
|
|
|
|
}
|
|
|
|
|
|
|
|
declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone
|
|
|
|
|
2013-07-30 02:12:58 +08:00
|
|
|
!llvm.dbg.cu = !{!4}
|
2013-11-23 05:49:45 +08:00
|
|
|
!llvm.module.flags = !{!34}
|
2010-06-02 03:59:01 +08:00
|
|
|
!llvm.dbg.lv = !{!0, !14, !15, !16, !17, !24, !25, !28}
|
|
|
|
|
2013-03-12 06:37:40 +08:00
|
|
|
!0 = metadata !{i32 786689, metadata !1, metadata !"this", metadata !3, i32 11, metadata !12, i32 0, null} ; [ DW_TAG_arg_variable ]
|
Recommit r212203: Don't try to construct debug LexicalScopes hierarchy for functions that do not have top level debug information.
Reverted by Eric Christopher (Thanks!) in r212203 after Bob Wilson
reported LTO issues. Duncan Exon Smith and Aditya Nandakumar helped
provide a reduced reproduction, though the failure wasn't too hard to
guess, and even easier with the example to confirm.
The assertion that the subprogram metadata associated with an
llvm::Function matches the scope data referenced by the DbgLocs on the
instructions in that function is not valid under LTO. In LTO, a C++
inline function might exist in multiple CUs and the subprogram metadata
nodes will refer to the same llvm::Function. In this case, depending on
the order of the CUs, the first intance of the subprogram metadata may
not be the one referenced by the instructions in that function and the
assertion will fail.
A test case (test/DebugInfo/cross-cu-linkonce-distinct.ll) is added, the
assertion removed and a comment added to explain this situation.
This was then reverted again in r213581 as it caused PR20367. The root
cause of this was the early exit in LiveDebugVariables meant that
spurious DBG_VALUE intrinsics that referenced dead variables were not
removed, causing an assertion/crash later on. The fix is to have
LiveDebugVariables strip all DBG_VALUE intrinsics in functions without
debug info as they're not needed anyway. Test case added to cover this
situation (that occurs when a debug-having function is inlined into a
nodebug function) in test/DebugInfo/X86/nodebug_with_debug_loc.ll
Original commit message:
If a function isn't actually in a CU's subprogram list in the debug info
metadata, ignore all the DebugLocs and don't try to build scopes, track
variables, etc.
While this is possibly a minor optimization, it's also a correctness fix
for an incoming patch that will add assertions to LexicalScopes and the
debug info verifier to ensure that all scope chains lead to debug info
for the current function.
Fix up a few test cases that had broken/incomplete debug info that could
violate this constraint.
Add a test case where this occurs by design (inlining a
debug-info-having function in an attribute nodebug function - we want
this to work because /if/ the nodebug function is then inlined into a
debug-info-having function, it should be fine (and will work fine - we
just stitch the scopes up as usual), but should the inlining not happen
we need to not assert fail either).
llvm-svn: 213952
2014-07-26 00:10:16 +08:00
|
|
|
!1 = metadata !{i32 786478, metadata !31, metadata !2, metadata !"bar", metadata !"bar", metadata !"_ZN3foo3barEi", i32 11, metadata !9, i1 false, i1 true, i32 0, i32 0, null, i32 0, i1 true, i32 (%struct.foo*, i32)* null, null, null, null, i32 11} ; [ DW_TAG_subprogram ]
|
2013-08-27 06:39:55 +08:00
|
|
|
!2 = metadata !{i32 786451, metadata !31, metadata !3, metadata !"foo", i32 3, i64 32, i64 32, i64 0, i32 0, null, metadata !5, i32 0, null, null, null} ; [ DW_TAG_structure_type ] [foo] [line 3, size 32, align 32, offset 0] [def] [from ]
|
2013-03-28 10:44:59 +08:00
|
|
|
!3 = metadata !{i32 786473, metadata !31} ; [ DW_TAG_file_type ]
|
2013-07-30 02:12:58 +08:00
|
|
|
!4 = metadata !{i32 786449, metadata !31, i32 4, metadata !"4.2.1 LLVM build", i1 true, metadata !"", i32 0, metadata !32, metadata !32, metadata !33, null, null, metadata !""} ; [ DW_TAG_compile_unit ]
|
2010-06-02 03:59:01 +08:00
|
|
|
!5 = metadata !{metadata !6, metadata !1, metadata !8}
|
2013-07-24 23:55:41 +08:00
|
|
|
!6 = metadata !{i32 786445, metadata !31, metadata !2, metadata !"y", i32 8, i64 32, i64 32, i64 0, i32 0, metadata !7} ; [ DW_TAG_member ]
|
|
|
|
!7 = metadata !{i32 786468, metadata !31, metadata !3, metadata !"int", i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ]
|
2013-07-30 02:12:58 +08:00
|
|
|
!8 = metadata !{i32 786478, metadata !31, metadata !2, metadata !"baz", metadata !"baz", metadata !"_ZN3foo3bazEi", i32 15, metadata !9, i1 false, i1 true, i32 0, i32 0, null, i32 0, i1 true, i32 (%struct.foo*, i32)* @_ZN3foo3bazEi, null, null, null, i32 15} ; [ DW_TAG_subprogram ]
|
2013-08-27 06:39:55 +08:00
|
|
|
!9 = metadata !{i32 786453, metadata !31, metadata !3, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !10, i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
|
2010-06-02 03:59:01 +08:00
|
|
|
!10 = metadata !{metadata !7, metadata !11, metadata !7}
|
2013-07-24 23:55:41 +08:00
|
|
|
!11 = metadata !{i32 786447, metadata !31, metadata !3, metadata !"", i32 0, i64 64, i64 64, i64 0, i32 64, metadata !2} ; [ DW_TAG_pointer_type ]
|
|
|
|
!12 = metadata !{i32 786470, metadata !31, metadata !3, metadata !"", i32 0, i64 64, i64 64, i64 0, i32 64, metadata !13} ; [ DW_TAG_const_type ]
|
|
|
|
!13 = metadata !{i32 786447, metadata !31, metadata !3, metadata !"", i32 0, i64 64, i64 64, i64 0, i32 0, metadata !2} ; [ DW_TAG_pointer_type ]
|
2013-03-12 06:37:40 +08:00
|
|
|
!14 = metadata !{i32 786689, metadata !1, metadata !"x", metadata !3, i32 11, metadata !7, i32 0, null} ; [ DW_TAG_arg_variable ]
|
|
|
|
!15 = metadata !{i32 786689, metadata !8, metadata !"this", metadata !3, i32 15, metadata !12, i32 0, null} ; [ DW_TAG_arg_variable ]
|
|
|
|
!16 = metadata !{i32 786689, metadata !8, metadata !"x", metadata !3, i32 15, metadata !7, i32 0, null} ; [ DW_TAG_arg_variable ]
|
|
|
|
!17 = metadata !{i32 786689, metadata !18, metadata !"argc", metadata !3, i32 19, metadata !7, i32 0, null} ; [ DW_TAG_arg_variable ]
|
2013-07-30 02:12:58 +08:00
|
|
|
!18 = metadata !{i32 786478, metadata !31, metadata !3, metadata !"main", metadata !"main", metadata !"main", i32 19, metadata !19, i1 false, i1 true, i32 0, i32 0, null, i32 0, i1 true, null, null, null, null, i32 19} ; [ DW_TAG_subprogram ]
|
2013-08-27 06:39:55 +08:00
|
|
|
!19 = metadata !{i32 786453, metadata !31, metadata !3, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !20, i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
|
2010-06-02 03:59:01 +08:00
|
|
|
!20 = metadata !{metadata !7, metadata !7, metadata !21}
|
2013-07-24 23:55:41 +08:00
|
|
|
!21 = metadata !{i32 786447, metadata !31, metadata !3, metadata !"", i32 0, i64 64, i64 64, i64 0, i32 0, metadata !22} ; [ DW_TAG_pointer_type ]
|
|
|
|
!22 = metadata !{i32 786447, metadata !31, metadata !3, metadata !"", i32 0, i64 64, i64 64, i64 0, i32 0, metadata !23} ; [ DW_TAG_pointer_type ]
|
|
|
|
!23 = metadata !{i32 786468, metadata !31, metadata !3, metadata !"char", i32 0, i64 8, i64 8, i64 0, i32 0, i32 6} ; [ DW_TAG_base_type ]
|
2013-03-12 06:37:40 +08:00
|
|
|
!24 = metadata !{i32 786689, metadata !18, metadata !"argv", metadata !3, i32 19, metadata !21, i32 0, null} ; [ DW_TAG_arg_variable ]
|
|
|
|
!25 = metadata !{i32 786688, metadata !26, metadata !"a", metadata !3, i32 20, metadata !2, i32 0, null} ; [ DW_TAG_auto_variable ]
|
2013-07-30 02:12:58 +08:00
|
|
|
!26 = metadata !{i32 786443, metadata !31, metadata !27, i32 19, i32 0, i32 0} ; [ DW_TAG_lexical_block ]
|
|
|
|
!27 = metadata !{i32 786443, metadata !31, metadata !18, i32 19, i32 0, i32 0} ; [ DW_TAG_lexical_block ]
|
2013-03-12 06:37:40 +08:00
|
|
|
!28 = metadata !{i32 786688, metadata !26, metadata !"b", metadata !3, i32 21, metadata !7, i32 0, null} ; [ DW_TAG_auto_variable ]
|
2010-06-02 03:59:01 +08:00
|
|
|
!29 = metadata !{i32 16, i32 0, metadata !30, null}
|
2013-08-07 03:38:43 +08:00
|
|
|
!30 = metadata !{i32 786443, metadata !31, metadata !8, i32 15, i32 0, i32 0} ; [ DW_TAG_lexical_block ]
|
2013-03-18 05:13:55 +08:00
|
|
|
!31 = metadata !{metadata !"foo.cp", metadata !"/tmp/"}
|
2013-07-30 02:12:58 +08:00
|
|
|
!32 = metadata !{i32 0}
|
2013-08-07 03:38:43 +08:00
|
|
|
!33 = metadata !{metadata !1, metadata !8, metadata !18}
|
2013-11-23 05:49:45 +08:00
|
|
|
!34 = metadata !{i32 1, metadata !"Debug Info Version", i32 1}
|