2014-08-08 06:22:49 +08:00
; REQUIRES: object-emission
2017-09-12 07:05:20 +08:00
; RUN: %llc_dwarf -filetype=obj -O0 < %s | llvm-dwarfdump -v -debug-info - | FileCheck %s
2014-08-08 06:22:49 +08:00
; This isn't a very pretty test case - I imagine there might be other ways to
; tickle the optimizers into producing the desired code, but I haven't found
; them.
; The issue is when a function is inlined into itself, the inlined argument
; accidentally overwrote the concrete argument and was lost.
; IR generated from the following source compiled with clang -g:
; void fn1(void *);
; void fn2(int, int, int, int);
; void fn3();
; void fn8();
; struct C {
; int b;
; void m_fn2() {
; fn8();
; if (b) fn2(0, 0, 0, 0);
; fn3();
; }
; };
; C *x;
; inline void fn7() {}
; void fn6() {
; fn8();
; x->m_fn2();
; fn7();
; }
; void fn3() { fn6(); }
; void fn4() { x->m_fn2(); }
; void fn5() { x->m_fn2(); }
; The definition of C and declaration of C::m_fn2
; CHECK: DW_TAG_structure_type
; CHECK-NOT: {{DW_TAG|NULL}}
; CHECK: DW_TAG_member
; CHECK-NOT: {{DW_TAG|NULL}}
2015-08-12 05:36:45 +08:00
; CHECK: [[M_FN2_DECL:.*]]: DW_TAG_subprogram
2014-08-08 06:22:49 +08:00
; CHECK-NOT: DW_TAG
; CHECK: DW_AT_name {{.*}} "m_fn2"
; CHECK-NOT: {{DW_TAG|NULL}}
2015-08-12 05:36:45 +08:00
; CHECK: DW_TAG_formal_parameter
2014-08-08 06:22:49 +08:00
; The abstract definition of C::m_fn2
; CHECK: [[M_FN2_ABS_DEF:.*]]: DW_TAG_subprogram
; CHECK-NOT: DW_TAG
2015-08-12 05:36:45 +08:00
; CHECK: DW_AT_specification {{.*}} {[[M_FN2_DECL]]}
2014-08-08 06:22:49 +08:00
; CHECK-NOT: DW_TAG
; CHECK: DW_AT_inline
; CHECK-NOT: {{DW_TAG|NULL}}
; CHECK: [[M_FN2_THIS_ABS_DEF:.*]]: DW_TAG_formal_parameter
; CHECK-NOT: DW_TAG
; CHECK: DW_AT_name {{.*}} "this"
; Skip some other functions
; CHECK: DW_TAG_subprogram
; CHECK: DW_TAG_subprogram
; CHECK: DW_TAG_subprogram
; The concrete definition of C::m_fn2
; CHECK: DW_TAG_subprogram
; CHECK-NOT: DW_TAG
2015-08-12 05:36:45 +08:00
; CHECK: DW_AT_abstract_origin {{.*}} {[[M_FN2_ABS_DEF]]}
2014-08-08 06:22:49 +08:00
; CHECK-NOT: {{DW_TAG|NULL}}
; CHECK: DW_TAG_formal_parameter
; CHECK-NOT: DW_TAG
; CHECK: DW_AT_abstract_origin {{.*}} {[[M_FN2_THIS_ABS_DEF]]}
; CHECK-NOT: {{DW_TAG|NULL}}
; Inlined fn3:
; CHECK: DW_TAG_inlined_subroutine
; CHECK-NOT: {{DW_TAG|NULL}}
; Inlined fn6:
; CHECK: DW_TAG_inlined_subroutine
; CHECK-NOT: {{DW_TAG|NULL}}
; Inlined C::m_fn2:
; CHECK: DW_TAG_inlined_subroutine
; CHECK-NOT: DW_TAG
2015-08-12 05:36:45 +08:00
; CHECK: DW_AT_abstract_origin {{.*}} {[[M_FN2_ABS_DEF]]}
2014-08-08 06:22:49 +08:00
; CHECK-NOT: {{DW_TAG|NULL}}
; CHECK: DW_TAG_formal_parameter
; CHECK-NOT: DW_TAG
; CHECK: DW_AT_abstract_origin {{.*}} {[[M_FN2_THIS_ABS_DEF]]}
2016-12-22 08:45:21 +08:00
source_filename = "test/DebugInfo/Generic/recursive_inlining.ll"
2014-08-08 06:22:49 +08:00
%struct.C = type { i32 }
2016-12-22 08:45:21 +08:00
@x = global %struct.C * null , align 8 , !dbg !0
2014-08-08 06:22:49 +08:00
; Function Attrs: nounwind
2016-12-22 08:45:21 +08:00
define void @_Z3fn6v ( ) #0 !dbg !20 {
2014-08-08 06:22:49 +08:00
entry:
2016-12-22 08:45:21 +08:00
tail call void @_Z3fn8v ( ) #3 , !dbg !23
%0 = load %struct.C * , %struct.C * * @x , align 8 , !dbg !24 , !tbaa !25
2017-07-29 04:21:02 +08:00
tail call void @llvm.dbg.value ( metadata %struct.C * %0 , metadata !29 , metadata !32 ) #3 , !dbg !33
2016-12-22 08:45:21 +08:00
tail call void @_Z3fn8v ( ) #3 , !dbg !34
%b.i = getelementptr inbounds %struct.C , %struct.C * %0 , i64 0 , i32 0 , !dbg !35
%1 = load i32 , i32 * %b.i , align 4 , !dbg !35 , !tbaa !37
%tobool.i = icmp eq i32 %1 , 0 , !dbg !35
br i1 %tobool.i , label %_ZN1C5m_fn2Ev.exit , label %if.then.i , !dbg !35
2014-08-08 06:22:49 +08:00
if.then.i: ; preds = %entry
2016-12-22 08:45:21 +08:00
tail call void @_Z3fn2iiii ( i32 0 , i32 0 , i32 0 , i32 0 ) #3 , !dbg !40
br label %_ZN1C5m_fn2Ev.exit , !dbg !40
2014-08-08 06:22:49 +08:00
2016-12-22 08:45:21 +08:00
_ZN1C5m_fn2Ev.exit: ; preds = %if.then.i, %entry
tail call void @_Z3fn3v ( ) #3 , !dbg !42
ret void , !dbg !43
2014-08-08 06:22:49 +08:00
}
declare void @_Z3fn8v ( ) #1
; Function Attrs: nounwind
2016-12-22 08:45:21 +08:00
define linkonce_odr void @_ZN1C5m_fn2Ev ( %struct.C * nocapture readonly %this ) #0 align 2 !dbg !30 {
2014-08-08 06:22:49 +08:00
entry:
2017-07-29 04:21:02 +08:00
tail call void @llvm.dbg.value ( metadata %struct.C * %this , metadata !29 , metadata !32 ) , !dbg !44
2016-12-22 08:45:21 +08:00
tail call void @_Z3fn8v ( ) #3 , !dbg !45
%b = getelementptr inbounds %struct.C , %struct.C * %this , i64 0 , i32 0 , !dbg !46
%0 = load i32 , i32 * %b , align 4 , !dbg !46 , !tbaa !37
%tobool = icmp eq i32 %0 , 0 , !dbg !46
br i1 %tobool , label %if.end , label %if.then , !dbg !46
2014-08-08 06:22:49 +08:00
if.then: ; preds = %entry
2016-12-22 08:45:21 +08:00
tail call void @_Z3fn2iiii ( i32 0 , i32 0 , i32 0 , i32 0 ) #3 , !dbg !47
br label %if.end , !dbg !47
if.end: ; preds = %if.then, %entry
tail call void @_Z3fn8v ( ) #3 , !dbg !48
%1 = load %struct.C * , %struct.C * * @x , align 8 , !dbg !52 , !tbaa !25
2017-07-29 04:21:02 +08:00
tail call void @llvm.dbg.value ( metadata %struct.C * %1 , metadata !29 , metadata !32 ) #3 , !dbg !53
2016-12-22 08:45:21 +08:00
tail call void @_Z3fn8v ( ) #3 , !dbg !54
%b.i.i = getelementptr inbounds %struct.C , %struct.C * %1 , i64 0 , i32 0 , !dbg !55
%2 = load i32 , i32 * %b.i.i , align 4 , !dbg !55 , !tbaa !37
%tobool.i.i = icmp eq i32 %2 , 0 , !dbg !55
br i1 %tobool.i.i , label %_Z3fn6v.exit , label %if.then.i.i , !dbg !55
2014-08-08 06:22:49 +08:00
if.then.i.i: ; preds = %if.end
2016-12-22 08:45:21 +08:00
tail call void @_Z3fn2iiii ( i32 0 , i32 0 , i32 0 , i32 0 ) #3 , !dbg !56
br label %_Z3fn6v.exit , !dbg !56
_Z3fn6v.exit: ; preds = %if.then.i.i, %if.end
tail call void @_Z3fn3v ( ) #3 , !dbg !57
ret void , !dbg !58
2014-08-08 06:22:49 +08:00
}
; Function Attrs: nounwind
2016-12-22 08:45:21 +08:00
define void @_Z3fn3v ( ) #0 !dbg !50 {
2014-08-08 06:22:49 +08:00
entry:
br label %tailrecurse
tailrecurse: ; preds = %tailrecurse.backedge, %entry
2016-12-22 08:45:21 +08:00
tail call void @_Z3fn8v ( ) #3 , !dbg !59
%0 = load %struct.C * , %struct.C * * @x , align 8 , !dbg !61 , !tbaa !25
2017-07-29 04:21:02 +08:00
tail call void @llvm.dbg.value ( metadata %struct.C * %0 , metadata !29 , metadata !32 ) #3 , !dbg !62
2016-12-22 08:45:21 +08:00
tail call void @_Z3fn8v ( ) #3 , !dbg !63
%b.i.i = getelementptr inbounds %struct.C , %struct.C * %0 , i64 0 , i32 0 , !dbg !64
%1 = load i32 , i32 * %b.i.i , align 4 , !dbg !64 , !tbaa !37
%tobool.i.i = icmp eq i32 %1 , 0 , !dbg !64
br i1 %tobool.i.i , label %tailrecurse.backedge , label %if.then.i.i , !dbg !64
tailrecurse.backedge: ; preds = %if.then.i.i, %tailrecurse
2014-08-08 06:22:49 +08:00
br label %tailrecurse
if.then.i.i: ; preds = %tailrecurse
2016-12-22 08:45:21 +08:00
tail call void @_Z3fn2iiii ( i32 0 , i32 0 , i32 0 , i32 0 ) #3 , !dbg !65
br label %tailrecurse.backedge , !dbg !65
2014-08-08 06:22:49 +08:00
}
; Function Attrs: nounwind
2016-12-22 08:45:21 +08:00
define void @_Z3fn4v ( ) #0 !dbg !66 {
2014-08-08 06:22:49 +08:00
entry:
2016-12-22 08:45:21 +08:00
%0 = load %struct.C * , %struct.C * * @x , align 8 , !dbg !67 , !tbaa !25
tail call void @_ZN1C5m_fn2Ev ( %struct.C * %0 ) , !dbg !67
ret void , !dbg !67
2014-08-08 06:22:49 +08:00
}
; Function Attrs: nounwind
2016-12-22 08:45:21 +08:00
define void @_Z3fn5v ( ) #0 !dbg !68 {
2014-08-08 06:22:49 +08:00
entry:
2016-12-22 08:45:21 +08:00
%0 = load %struct.C * , %struct.C * * @x , align 8 , !dbg !69 , !tbaa !25
tail call void @_ZN1C5m_fn2Ev ( %struct.C * %0 ) , !dbg !69
ret void , !dbg !69
2014-08-08 06:22:49 +08:00
}
declare void @_Z3fn2iiii ( i32 , i32 , i32 , i32 ) #1
; Function Attrs: nounwind readnone
2017-07-29 04:21:02 +08:00
declare void @llvm.dbg.value ( metadata , metadata , metadata ) #2
2014-08-08 06:22:49 +08:00
2019-12-25 08:11:33 +08:00
attributes #0 = { nounwind "less-precise-fpmad" = "false" "frame-pointer" = "none" "no-infs-fp-math" = "false" "no-nans-fp-math" = "false" "no-realign-stack" "stack-protector-buffer-size" = "8" "unsafe-fp-math" = "false" "use-soft-float" = "false" }
attributes #1 = { "less-precise-fpmad" = "false" "frame-pointer" = "none" "no-infs-fp-math" = "false" "no-nans-fp-math" = "false" "no-realign-stack" "stack-protector-buffer-size" = "8" "unsafe-fp-math" = "false" "use-soft-float" = "false" }
2014-08-08 06:22:49 +08:00
attributes #2 = { nounwind readnone }
attributes #3 = { nounwind }
2016-12-22 08:45:21 +08:00
!llvm.dbg.cu = ! { !12 }
!llvm.module.flags = ! { !17 , !18 }
!llvm.ident = ! { !19 }
2017-08-31 02:06:51 +08:00
!0 = !DIGlobalVariableExpression ( var: !1 , expr: !DIExpression ( ) )
2016-12-22 08:45:21 +08:00
!1 = !DIGlobalVariable ( name: "x" , scope: null , file: !2 , line: 13 , type: !3 , isLocal: false , isDefinition: true )
!2 = !DIFile ( filename: "recursive_inlining.cpp" , directory: "/usr/local/google/home/blaikie/dev/scratch/missing_concrete_variable_on_darwin/reduce" )
!3 = !DIDerivedType ( tag: D W _ T A G _ p o i n t e r _ type , baseType: !4 , size: 64 , align: 64 )
!4 = !DICompositeType ( tag: D W _ T A G _ s t r u c t u r e _ type , name: "C" , file: !2 , line: 5 , size: 32 , align: 32 , elements: !5 , identifier: "_ZTS1C" )
!5 = ! { !6 , !8 }
!6 = !DIDerivedType ( tag: D W _ T A G _ m e m b e r , name: "b" , scope: !4 , file: !2 , line: 6 , baseType: !7 , size: 32 , align: 32 )
!7 = !DIBasicType ( name: "int" , size: 32 , align: 32 , encoding: D W _ A T E _ s i g n e d )
!8 = !DISubprogram ( name: "m_fn2" , linkageName: "_ZN1C5m_fn2Ev" , scope: !4 , file: !2 , line: 7 , type: !9 , isLocal: false , isDefinition: false , scopeLine: 7 , virtualIndex: 6 , flags: D I F l a g P r o t o t y p e d , isOptimized: true )
!9 = !DISubroutineType ( types: !10 )
!10 = ! { null , !11 }
!11 = !DIDerivedType ( tag: D W _ T A G _ p o i n t e r _ type , baseType: !4 , size: 64 , align: 64 , flags: D I F l a g A r t i f i c i a l | D I F l a g O b j e c t P o i n t e r )
!12 = distinct !DICompileUnit ( language: D W _ L A N G _ C _ p l u s _ p l u s , file: !13 , producer: "clang version 3.6.0 " , isOptimized: true , runtimeVersion: 0 , emissionKind: F u l l D e b u g , enums: !14 , retainedTypes: !15 , globals: !16 , imports: !14 )
!13 = !DIFile ( filename: "<stdin>" , directory: "/usr/local/google/home/blaikie/dev/scratch/missing_concrete_variable_on_darwin/reduce" )
!14 = ! { }
!15 = ! { !4 }
!16 = ! { !0 }
!17 = ! { i32 2 , !"Dwarf Version" , i32 4 }
!18 = ! { i32 2 , !"Debug Info Version" , i32 3 }
!19 = ! { !"clang version 3.6.0 " }
[DebugInfo] Add DILabel metadata and intrinsic llvm.dbg.label.
In order to set breakpoints on labels and list source code around
labels, we need collect debug information for labels, i.e., label
name, the function label belong, line number in the file, and the
address label located. In order to keep these information in LLVM
IR and to allow backend to generate debug information correctly.
We create a new kind of metadata for labels, DILabel. The format
of DILabel is
!DILabel(scope: !1, name: "foo", file: !2, line: 3)
We hope to keep debug information as much as possible even the
code is optimized. So, we create a new kind of intrinsic for label
metadata to avoid the metadata is eliminated with basic block.
The intrinsic will keep existing if we keep it from optimized out.
The format of the intrinsic is
llvm.dbg.label(metadata !1)
It has only one argument, that is the DILabel metadata. The
intrinsic will follow the label immediately. Backend could get the
label metadata through the intrinsic's parameter.
We also create DIBuilder API for labels to be used by Frontend.
Frontend could use createLabel() to allocate DILabel objects, and use
insertLabel() to insert llvm.dbg.label intrinsic in LLVM IR.
Differential Revision: https://reviews.llvm.org/D45024
Patch by Hsiangkai Wang.
llvm-svn: 331841
2018-05-09 10:40:45 +08:00
!20 = distinct !DISubprogram ( name: "fn6" , linkageName: "_Z3fn6v" , scope: !2 , file: !2 , line: 15 , type: !21 , isLocal: false , isDefinition: true , scopeLine: 15 , virtualIndex: 6 , flags: D I F l a g P r o t o t y p e d , isOptimized: true , unit: !12 , retainedNodes: !14 )
2016-12-22 08:45:21 +08:00
!21 = !DISubroutineType ( types: !22 )
!22 = ! { null }
!23 = !DILocation ( line: 16 , scope: !20 )
!24 = !DILocation ( line: 17 , scope: !20 )
!25 = ! { !26 , !26 , i64 0 }
!26 = ! { !"any pointer" , !27 , i64 0 }
!27 = ! { !"omnipotent char" , !28 , i64 0 }
!28 = ! { !"Simple C/C++ TBAA" }
!29 = !DILocalVariable ( name: "this" , arg: 1 , scope: !30 , type: !3 , flags: D I F l a g A r t i f i c i a l | D I F l a g O b j e c t P o i n t e r )
[DebugInfo] Add DILabel metadata and intrinsic llvm.dbg.label.
In order to set breakpoints on labels and list source code around
labels, we need collect debug information for labels, i.e., label
name, the function label belong, line number in the file, and the
address label located. In order to keep these information in LLVM
IR and to allow backend to generate debug information correctly.
We create a new kind of metadata for labels, DILabel. The format
of DILabel is
!DILabel(scope: !1, name: "foo", file: !2, line: 3)
We hope to keep debug information as much as possible even the
code is optimized. So, we create a new kind of intrinsic for label
metadata to avoid the metadata is eliminated with basic block.
The intrinsic will keep existing if we keep it from optimized out.
The format of the intrinsic is
llvm.dbg.label(metadata !1)
It has only one argument, that is the DILabel metadata. The
intrinsic will follow the label immediately. Backend could get the
label metadata through the intrinsic's parameter.
We also create DIBuilder API for labels to be used by Frontend.
Frontend could use createLabel() to allocate DILabel objects, and use
insertLabel() to insert llvm.dbg.label intrinsic in LLVM IR.
Differential Revision: https://reviews.llvm.org/D45024
Patch by Hsiangkai Wang.
llvm-svn: 331841
2018-05-09 10:40:45 +08:00
!30 = distinct !DISubprogram ( name: "m_fn2" , linkageName: "_ZN1C5m_fn2Ev" , scope: !4 , file: !2 , line: 7 , type: !9 , isLocal: false , isDefinition: true , scopeLine: 7 , virtualIndex: 6 , flags: D I F l a g P r o t o t y p e d , isOptimized: true , unit: !12 , declaration: !8 , retainedNodes: !31 )
2016-12-22 08:45:21 +08:00
!31 = ! { !29 }
!32 = !DIExpression ( )
!33 = !DILocation ( line: 0 , scope: !30 , inlinedAt: !24 )
!34 = !DILocation ( line: 8 , scope: !30 , inlinedAt: !24 )
!35 = !DILocation ( line: 9 , scope: !36 , inlinedAt: !24 )
!36 = distinct !DILexicalBlock ( scope: !30 , file: !2 , line: 9 )
!37 = ! { !38 , !39 , i64 0 }
2016-12-29 23:47:05 +08:00
!38 = ! { !"struct" , !39 , i64 0 }
2016-12-22 08:45:21 +08:00
!39 = ! { !"int" , !27 , i64 0 }
!40 = !DILocation ( line: 9 , scope: !41 , inlinedAt: !24 )
!41 = distinct !DILexicalBlock ( scope: !36 , file: !2 , line: 9 )
!42 = !DILocation ( line: 10 , scope: !30 , inlinedAt: !24 )
!43 = !DILocation ( line: 19 , scope: !20 )
!44 = !DILocation ( line: 0 , scope: !30 )
!45 = !DILocation ( line: 8 , scope: !30 )
!46 = !DILocation ( line: 9 , scope: !36 )
!47 = !DILocation ( line: 9 , scope: !41 )
!48 = !DILocation ( line: 16 , scope: !20 , inlinedAt: !49 )
!49 = !DILocation ( line: 20 , scope: !50 , inlinedAt: !51 )
[DebugInfo] Add DILabel metadata and intrinsic llvm.dbg.label.
In order to set breakpoints on labels and list source code around
labels, we need collect debug information for labels, i.e., label
name, the function label belong, line number in the file, and the
address label located. In order to keep these information in LLVM
IR and to allow backend to generate debug information correctly.
We create a new kind of metadata for labels, DILabel. The format
of DILabel is
!DILabel(scope: !1, name: "foo", file: !2, line: 3)
We hope to keep debug information as much as possible even the
code is optimized. So, we create a new kind of intrinsic for label
metadata to avoid the metadata is eliminated with basic block.
The intrinsic will keep existing if we keep it from optimized out.
The format of the intrinsic is
llvm.dbg.label(metadata !1)
It has only one argument, that is the DILabel metadata. The
intrinsic will follow the label immediately. Backend could get the
label metadata through the intrinsic's parameter.
We also create DIBuilder API for labels to be used by Frontend.
Frontend could use createLabel() to allocate DILabel objects, and use
insertLabel() to insert llvm.dbg.label intrinsic in LLVM IR.
Differential Revision: https://reviews.llvm.org/D45024
Patch by Hsiangkai Wang.
llvm-svn: 331841
2018-05-09 10:40:45 +08:00
!50 = distinct !DISubprogram ( name: "fn3" , linkageName: "_Z3fn3v" , scope: !2 , file: !2 , line: 20 , type: !21 , isLocal: false , isDefinition: true , scopeLine: 20 , virtualIndex: 6 , flags: D I F l a g P r o t o t y p e d , isOptimized: true , unit: !12 , retainedNodes: !14 )
2016-12-22 08:45:21 +08:00
!51 = !DILocation ( line: 10 , scope: !30 )
!52 = !DILocation ( line: 17 , scope: !20 , inlinedAt: !49 )
!53 = !DILocation ( line: 0 , scope: !30 , inlinedAt: !52 )
!54 = !DILocation ( line: 8 , scope: !30 , inlinedAt: !52 )
!55 = !DILocation ( line: 9 , scope: !36 , inlinedAt: !52 )
!56 = !DILocation ( line: 9 , scope: !41 , inlinedAt: !52 )
!57 = !DILocation ( line: 10 , scope: !30 , inlinedAt: !52 )
!58 = !DILocation ( line: 11 , scope: !30 )
!59 = !DILocation ( line: 16 , scope: !20 , inlinedAt: !60 )
!60 = !DILocation ( line: 20 , scope: !50 )
!61 = !DILocation ( line: 17 , scope: !20 , inlinedAt: !60 )
!62 = !DILocation ( line: 0 , scope: !30 , inlinedAt: !61 )
!63 = !DILocation ( line: 8 , scope: !30 , inlinedAt: !61 )
!64 = !DILocation ( line: 9 , scope: !36 , inlinedAt: !61 )
!65 = !DILocation ( line: 9 , scope: !41 , inlinedAt: !61 )
[DebugInfo] Add DILabel metadata and intrinsic llvm.dbg.label.
In order to set breakpoints on labels and list source code around
labels, we need collect debug information for labels, i.e., label
name, the function label belong, line number in the file, and the
address label located. In order to keep these information in LLVM
IR and to allow backend to generate debug information correctly.
We create a new kind of metadata for labels, DILabel. The format
of DILabel is
!DILabel(scope: !1, name: "foo", file: !2, line: 3)
We hope to keep debug information as much as possible even the
code is optimized. So, we create a new kind of intrinsic for label
metadata to avoid the metadata is eliminated with basic block.
The intrinsic will keep existing if we keep it from optimized out.
The format of the intrinsic is
llvm.dbg.label(metadata !1)
It has only one argument, that is the DILabel metadata. The
intrinsic will follow the label immediately. Backend could get the
label metadata through the intrinsic's parameter.
We also create DIBuilder API for labels to be used by Frontend.
Frontend could use createLabel() to allocate DILabel objects, and use
insertLabel() to insert llvm.dbg.label intrinsic in LLVM IR.
Differential Revision: https://reviews.llvm.org/D45024
Patch by Hsiangkai Wang.
llvm-svn: 331841
2018-05-09 10:40:45 +08:00
!66 = distinct !DISubprogram ( name: "fn4" , linkageName: "_Z3fn4v" , scope: !2 , file: !2 , line: 21 , type: !21 , isLocal: false , isDefinition: true , scopeLine: 21 , virtualIndex: 6 , flags: D I F l a g P r o t o t y p e d , isOptimized: true , unit: !12 , retainedNodes: !14 )
2016-12-22 08:45:21 +08:00
!67 = !DILocation ( line: 21 , scope: !66 )
[DebugInfo] Add DILabel metadata and intrinsic llvm.dbg.label.
In order to set breakpoints on labels and list source code around
labels, we need collect debug information for labels, i.e., label
name, the function label belong, line number in the file, and the
address label located. In order to keep these information in LLVM
IR and to allow backend to generate debug information correctly.
We create a new kind of metadata for labels, DILabel. The format
of DILabel is
!DILabel(scope: !1, name: "foo", file: !2, line: 3)
We hope to keep debug information as much as possible even the
code is optimized. So, we create a new kind of intrinsic for label
metadata to avoid the metadata is eliminated with basic block.
The intrinsic will keep existing if we keep it from optimized out.
The format of the intrinsic is
llvm.dbg.label(metadata !1)
It has only one argument, that is the DILabel metadata. The
intrinsic will follow the label immediately. Backend could get the
label metadata through the intrinsic's parameter.
We also create DIBuilder API for labels to be used by Frontend.
Frontend could use createLabel() to allocate DILabel objects, and use
insertLabel() to insert llvm.dbg.label intrinsic in LLVM IR.
Differential Revision: https://reviews.llvm.org/D45024
Patch by Hsiangkai Wang.
llvm-svn: 331841
2018-05-09 10:40:45 +08:00
!68 = distinct !DISubprogram ( name: "fn5" , linkageName: "_Z3fn5v" , scope: !2 , file: !2 , line: 22 , type: !21 , isLocal: false , isDefinition: true , scopeLine: 22 , virtualIndex: 6 , flags: D I F l a g P r o t o t y p e d , isOptimized: true , unit: !12 , retainedNodes: !14 )
2016-12-22 08:45:21 +08:00
!69 = !DILocation ( line: 22 , scope: !68 )