2015-03-11 09:08:32 +08:00
; RUN: llc -mtriple i686-pc-cygwin -O2 %s -o - | FileCheck %s
; Check struct X for dead variable xyz from inlined function foo.
; CHECK: Lsection_info
; CHECK: DW_TAG_structure_type
; CHECK-NEXT: info_string
2016-12-22 08:45:21 +08:00
source_filename = "test/DebugInfo/X86/InlinedFnLocalVar.ll"
2015-03-11 09:08:32 +08:00
2016-12-22 08:45:21 +08:00
@i = common global i32 0 , !dbg !0
2015-03-11 09:08:32 +08:00
2016-12-22 08:45:21 +08:00
; Function Attrs: nounwind readnone
declare void @llvm.dbg.declare ( metadata , metadata , metadata ) #0
2015-03-11 09:08:32 +08:00
2016-12-22 08:45:21 +08:00
; Function Attrs: nounwind readnone
2017-07-29 04:21:02 +08:00
declare void @llvm.dbg.value ( metadata , metadata , metadata ) #0
2016-12-22 08:45:21 +08:00
; Function Attrs: nounwind ssp
define i32 @bar ( ) #1 !dbg !8 {
2015-03-11 09:08:32 +08:00
entry:
2016-12-22 08:45:21 +08:00
%0 = load i32 , i32 * @i , align 4 , !dbg !11
2017-07-29 04:21:02 +08:00
tail call void @llvm.dbg.value ( metadata i32 %0 , metadata !13 , metadata !24 ) , !dbg !25
2016-12-22 08:45:21 +08:00
tail call void @llvm.dbg.declare ( metadata !5 , metadata !18 , metadata !24 ) , !dbg !26
%1 = mul nsw i32 %0 , %0 , !dbg !27
store i32 %1 , i32 * @i , align 4 , !dbg !11
ret i32 %1 , !dbg !28
2015-03-11 09:08:32 +08:00
}
2016-12-22 08:45:21 +08:00
attributes #0 = { nounwind readnone }
attributes #1 = { nounwind ssp }
!llvm.dbg.cu = ! { !4 }
!llvm.module.flags = ! { !7 }
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: "i" , scope: !2 , file: !2 , line: 5 , type: !3 , isLocal: false , isDefinition: true )
!2 = !DIFile ( filename: "bar.c" , directory: "/tmp/" )
!3 = !DIBasicType ( name: "int" , size: 32 , align: 32 , encoding: D W _ A T E _ s i g n e d )
!4 = distinct !DICompileUnit ( language: D W _ L A N G _ C 89 , file: !2 , producer: "4.2.1 (Based on Apple Inc. build 5658) (LLVM build)" , isOptimized: true , runtimeVersion: 0 , emissionKind: F u l l D e b u g , enums: !5 , retainedTypes: !5 , globals: !6 , imports: !5 )
!5 = ! { }
!6 = ! { !0 }
!7 = ! { i32 1 , !"Debug Info Version" , i32 3 }
!8 = distinct !DISubprogram ( name: "bar" , linkageName: "bar" , scope: !2 , file: !2 , line: 14 , type: !9 , isLocal: false , isDefinition: true , virtualIndex: 6 , isOptimized: true , unit: !4 )
!9 = !DISubroutineType ( types: !10 )
!10 = ! { !3 }
!11 = !DILocation ( line: 15 , scope: !12 )
!12 = distinct !DILexicalBlock ( scope: !8 , file: !2 , line: 14 )
!13 = !DILocalVariable ( name: "j" , arg: 1 , scope: !14 , file: !2 , line: 9 , type: !3 )
[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
!14 = distinct !DISubprogram ( name: "foo" , scope: !2 , file: !2 , line: 9 , type: !15 , isLocal: true , isDefinition: true , scopeLine: 9 , virtualIndex: 6 , isOptimized: true , unit: !4 , retainedNodes: !17 )
2016-12-22 08:45:21 +08:00
!15 = !DISubroutineType ( types: !16 )
!16 = ! { !3 , !3 }
!17 = ! { !13 , !18 }
!18 = !DILocalVariable ( name: "xyz" , scope: !19 , file: !2 , line: 10 , type: !20 )
!19 = distinct !DILexicalBlock ( scope: !14 , file: !2 , line: 9 )
!20 = !DICompositeType ( tag: D W _ T A G _ s t r u c t u r e _ type , name: "X" , scope: !14 , file: !2 , line: 10 , size: 64 , align: 32 , elements: !21 )
!21 = ! { !22 , !23 }
!22 = !DIDerivedType ( tag: D W _ T A G _ m e m b e r , name: "a" , scope: !20 , file: !2 , line: 10 , baseType: !3 , size: 32 , align: 32 )
!23 = !DIDerivedType ( tag: D W _ T A G _ m e m b e r , name: "b" , scope: !20 , file: !2 , line: 10 , baseType: !3 , size: 32 , align: 32 , offset: 32 )
!24 = !DIExpression ( )
!25 = !DILocation ( line: 9 , scope: !14 , inlinedAt: !11 )
!26 = !DILocation ( line: 9 , scope: !19 , inlinedAt: !11 )
!27 = !DILocation ( line: 11 , scope: !19 , inlinedAt: !11 )
!28 = !DILocation ( line: 16 , scope: !12 )